Skip to content

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
chrs1885 committed Apr 24, 2019
2 parents 615b11b + 344d944 commit ed3846b
Show file tree
Hide file tree
Showing 43 changed files with 1,009 additions and 47 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Version 0.1.0
## Version 0.2.0
### Features
* HSB support

## Version 0.1.0
### Features
* Initial library setup
* RGB support
4 changes: 2 additions & 2 deletions Documentation/Reference/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Reference Documentation
This Reference Documentation has been generated with
[SourceDocs](https://github.com/eneko/SourceDocs).

## Protocols

Expand All @@ -13,6 +11,7 @@ This Reference Documentation has been generated with

## Classes

- [HSBAColor](classes/HSBAColor.md)
- [RGBAColor](classes/RGBAColor.md)

## Enums
Expand All @@ -21,6 +20,7 @@ This Reference Documentation has been generated with

## Extensions

- [HSBAColor](extensions/HSBAColor.md)
- [RGBAColor](extensions/RGBAColor.md)
- [SheetyColorsController](extensions/SheetyColorsController.md)
- [UIColor](extensions/UIColor.md)
52 changes: 52 additions & 0 deletions Documentation/Reference/classes/HSBAColor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
**CLASS**

# `HSBAColor`

```swift
public class HSBAColor: NSObject, NSCopying, Codable
```

> A model class representing HSBA colors. The hue component can hold values between 0.0 and 360.0 while the saturation and brightnes values have a maximum value of 100.0.

## Methods
### `init(hue:saturation:brightness:alpha:)`

```swift
public init(hue: CGFloat, saturation: CGFloat, brightness: CGFloat, alpha: CGFloat)
```

> Creates a HSBAColor instance.
>
> - Parameter:
> - hue: The hue component.
> - saturation: The saturation component.
> - brightness: The brightness component.
> - alpha: The opacity component.

### `copy(with:)`

```swift
public func copy(with _: NSZone? = nil) -> Any
```

> Creates a copy of the HSBAColor instance.
>
> - Returns: A copy of the HSBAColor instance.

### `isEqual(_:)`

```swift
public override func isEqual(_ object: Any?) -> Bool
```

> Compares two HSBAColor instances with each other.
>
> - Parameter object: The HSBAColor to compare with.
>
> - Returns: 'true' if the instance is equal to the other HSBAColor instance, otherwise 'false''.

#### Parameters

| Name | Description |
| ---- | ----------- |
| object | The HSBAColor to compare with. |
8 changes: 8 additions & 0 deletions Documentation/Reference/enums/SheetyColorsType.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ case rgb
```

> The RGB color model.

### `hsb`

```swift
case hsb
```

> The HSB color model.
12 changes: 12 additions & 0 deletions Documentation/Reference/extensions/HSBAColor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
**EXTENSION**

# `HSBAColor`

## Properties
### `uiColor`

```swift
public var uiColor: UIColor
```

> The UIColor representation of the HSBAColor.
8 changes: 8 additions & 0 deletions Documentation/Reference/extensions/UIColor.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
# `UIColor`

## Properties
### `hsbaColor`

```swift
var hsbaColor: HSBAColor
```

> The HSBAColor representation of the UIColor instance.
### `rgbaColor`

```swift
Expand Down
Binary file added Documentation/sheetycolors.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Documentation/sheetycolors_demo.gif
Binary file not shown.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PODS:
- Capable/Colors (0.9.0)
- Nimble (8.0.1)
- Quick (2.0.0)
- SheetyColors (0.1.0):
- SheetyColors (0.2.0):
- Capable/Colors (~> 0.9.0)
- SnapshotTesting (1.5.0)

Expand All @@ -27,7 +27,7 @@ SPEC CHECKSUMS:
Capable: 3f2cbbd61326df7304ff97ca4b954c2de2e3ff43
Nimble: 45f786ae66faa9a709624227fae502db55a8bdd0
Quick: ce1276c7c27ba2da3cb2fd0cde053c3648b3b22d
SheetyColors: 256f907e54648c5d08b52bdacaef6b795242ad59
SheetyColors: 483d95d270f01dde725b68217b63704f1efc984b
SnapshotTesting: 9ca1d80f6322509a035856170c11d0571b1f7171

PODFILE CHECKSUM: 5b2abbedbad9c9292a41e99328101b079df5f152
Expand Down
40 changes: 40 additions & 0 deletions Example/SheetyColors.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
831FCF0022591DFE003C48A4 /* UIAlertController+customViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 831FCEFF22591DFE003C48A4 /* UIAlertController+customViewTests.swift */; };
831FCF02225E62F8003C48A4 /* SheetyColorsViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 831FCF01225E62F8003C48A4 /* SheetyColorsViewTests.swift */; };
83205EE52256815500D62BB8 /* UIView+findLabelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83205EE42256815500D62BB8 /* UIView+findLabelTests.swift */; };
832DCEFF226E4D7C00DAF3EF /* HSBViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 832DCEFE226E4D7B00DAF3EF /* HSBViewModelTests.swift */; };
832DCF03226F92E100DAF3EF /* UIColor+hsbaColorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 832DCF02226F92E100DAF3EF /* UIColor+hsbaColorTests.swift */; };
834A36DC224686C500DECD37 /* RGBAColors+NSItemProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 834A36DB224686C500DECD37 /* RGBAColors+NSItemProvider.swift */; };
834A36E022496F8A00DECD37 /* SheetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 834A36DF22496F8A00DECD37 /* SheetType.swift */; };
834A36E2224971F700DECD37 /* SheetyColorsViewFactoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 834A36E1224971F700DECD37 /* SheetyColorsViewFactoryTests.swift */; };
Expand Down Expand Up @@ -64,6 +66,8 @@
831FCEFF22591DFE003C48A4 /* UIAlertController+customViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIAlertController+customViewTests.swift"; sourceTree = "<group>"; };
831FCF01225E62F8003C48A4 /* SheetyColorsViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetyColorsViewTests.swift; sourceTree = "<group>"; };
83205EE42256815500D62BB8 /* UIView+findLabelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+findLabelTests.swift"; sourceTree = "<group>"; };
832DCEFE226E4D7B00DAF3EF /* HSBViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HSBViewModelTests.swift; sourceTree = "<group>"; };
832DCF02226F92E100DAF3EF /* UIColor+hsbaColorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+hsbaColorTests.swift"; sourceTree = "<group>"; };
834A36DB224686C500DECD37 /* RGBAColors+NSItemProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RGBAColors+NSItemProvider.swift"; sourceTree = "<group>"; };
834A36DF22496F8A00DECD37 /* SheetType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetType.swift; sourceTree = "<group>"; };
834A36E1224971F700DECD37 /* SheetyColorsViewFactoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetyColorsViewFactoryTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -176,6 +180,7 @@
607FACE81AFB9204008FA782 /* Tests */ = {
isa = PBXGroup;
children = (
832DCEFC226E4D5900DAF3EF /* HSB */,
834A36EA224E893B00DECD37 /* Common */,
834A36EB224E894900DECD37 /* RGB */,
834A36E32249823800DECD37 /* Mocks */,
Expand Down Expand Up @@ -221,6 +226,39 @@
name = Extensions;
sourceTree = "<group>";
};
832DCEFC226E4D5900DAF3EF /* HSB */ = {
isa = PBXGroup;
children = (
832DCF00226F92BE00DAF3EF /* Models */,
832DCEFD226E4D6200DAF3EF /* ViewModels */,
);
name = HSB;
sourceTree = "<group>";
};
832DCEFD226E4D6200DAF3EF /* ViewModels */ = {
isa = PBXGroup;
children = (
832DCEFE226E4D7B00DAF3EF /* HSBViewModelTests.swift */,
);
name = ViewModels;
sourceTree = "<group>";
};
832DCF00226F92BE00DAF3EF /* Models */ = {
isa = PBXGroup;
children = (
832DCF01226F92C600DAF3EF /* Extensions */,
);
name = Models;
sourceTree = "<group>";
};
832DCF01226F92C600DAF3EF /* Extensions */ = {
isa = PBXGroup;
children = (
832DCF02226F92E100DAF3EF /* UIColor+hsbaColorTests.swift */,
);
name = Extensions;
sourceTree = "<group>";
};
834A36E32249823800DECD37 /* Mocks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -557,6 +595,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
832DCEFF226E4D7C00DAF3EF /* HSBViewModelTests.swift in Sources */,
832DCF03226F92E100DAF3EF /* UIColor+hsbaColorTests.swift in Sources */,
834A36E52249829300DECD37 /* SheetyColorsConfigMock.swift in Sources */,
83DDE2212264FD1C005F4CEF /* SheetyColorsConfigTests.swift in Sources */,
83DDE21A225FBCBC005F4CEF /* UIColor+rgbaColorTests.swift in Sources */,
Expand Down
6 changes: 3 additions & 3 deletions Example/SheetyColors/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="UMl-Ee-pwf">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="UMl-Ee-pwf">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -59,7 +59,7 @@
<navigationItem key="navigationItem" title="My SheetyColors" largeTitleDisplayMode="always" id="6Q6-BL-y8l">
<barButtonItem key="rightBarButtonItem" systemItem="add" id="emJ-78-rLo">
<connections>
<action selector="openSheetyColors:" destination="lSR-Jl-jt2" id="yIh-a3-gSG"/>
<action selector="addColor:" destination="lSR-Jl-jt2" id="UIf-mC-5Db"/>
</connections>
</barButtonItem>
</navigationItem>
Expand Down
37 changes: 25 additions & 12 deletions Example/SheetyColors/ColorsCollectionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,38 @@ class ColorsCollectionViewController: UICollectionViewController {
collectionView.dragInteractionEnabled = true
}

@IBAction func openSheetyColors(_: Any) {
openColorsActionSheet(with: .createColor)
@IBAction func addColor(_: Any) {
openColorTypeSelection(forAction: .createColor)
}

func openEditActionSheet(forItemAt item: Int) {
openColorsActionSheet(with: .editColor(item: item))
func editColor(forItemAt item: Int) {
openColorTypeSelection(forAction: .editColor(item: item))
}

func openColorsActionSheet(with type: SheetType) {
func openColorTypeSelection(forAction action: SheetType) {
let colorTypeSelectionSheet = UIAlertController(title: "Color Type", message: "Select a color type to use for your color picker.", preferredStyle: .actionSheet)
colorTypeSelectionSheet.addAction(UIAlertAction(title: "HSB", style: .default, handler: { _ in
self.openColorPicker(withAction: action, colorType: .hsb)
}))
colorTypeSelectionSheet.addAction(UIAlertAction(title: "RGB", style: .default, handler: { _ in
self.openColorPicker(withAction: action, colorType: .rgb)
}))
addCancelAlertAction(for: colorTypeSelectionSheet)

present(colorTypeSelectionSheet, animated: true)
}

func openColorPicker(withAction action: SheetType, colorType: SheetyColorsType) {
var itemIndex: Int?
if case let .editColor(item) = type {
if case let .editColor(item) = action {
itemIndex = item
}

let color = (itemIndex != nil) ? colorItems[itemIndex!].uiColor : UIColor.white
let config = SheetyColorsConfig(alphaEnabled: true, hapticFeedbackEnabled: true, initialColor: color, title: type.title, type: .rgb)
let config = SheetyColorsConfig(alphaEnabled: true, hapticFeedbackEnabled: true, initialColor: color, title: action.title, type: colorType)
let controller = SheetyColorsController(withConfig: config)

addSelectAlertAction(for: controller, withType: type)
addSelectAlertAction(for: controller, withAction: action)
addCancelAlertAction(for: controller)
if let itemIndex = itemIndex {
addDeleteAlertAction(for: controller, item: itemIndex)
Expand All @@ -67,10 +80,10 @@ class ColorsCollectionViewController: UICollectionViewController {
present(controller, animated: true, completion: nil)
}

func addSelectAlertAction(for controller: SheetyColorsController, withType type: SheetType) {
func addSelectAlertAction(for controller: SheetyColorsController, withAction action: SheetType) {
let selectAction = UIAlertAction(title: "Save Color", style: .default, handler: { _ in
self.collectionView.performBatchUpdates({
if case let .editColor(item) = type {
if case let .editColor(item) = action {
self.colorItems[item] = controller.color.rgbaColor
self.collectionView.reloadItems(at: [IndexPath(item: item, section: 0)])
} else {
Expand Down Expand Up @@ -99,7 +112,7 @@ class ColorsCollectionViewController: UICollectionViewController {
controller.addAction(deleteAction)
}

func addCancelAlertAction(for controller: SheetyColorsController) {
func addCancelAlertAction(for controller: UIAlertController) {
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
controller.addAction(cancelAction)
}
Expand Down Expand Up @@ -134,7 +147,7 @@ extension ColorsCollectionViewController {

extension ColorsCollectionViewController {
override func collectionView(_: UICollectionView, didSelectItemAt indexPath: IndexPath) {
openEditActionSheet(forItemAt: indexPath.item)
editColor(forItemAt: indexPath.item)
}
}

Expand Down
Loading

0 comments on commit ed3846b

Please sign in to comment.