Skip to content

Commit

Permalink
fix(Checkbox): Rename CheckBox to Checkbox (#53)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Rename CheckBox to Checkbox
  • Loading branch information
gonzalezreal committed Dec 15, 2020
1 parent f80fe08 commit f66721f
Show file tree
Hide file tree
Showing 24 changed files with 119 additions and 127 deletions.
106 changes: 49 additions & 57 deletions Mistica.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// CheckBoxAssets.swift
// CheckboxAssets.swift
//
// Made with ❤️ by Novum
//
Expand Down
21 changes: 0 additions & 21 deletions Mistica/Source/Components/CheckBox/README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// CheckBox.swift
// Checkbox.swift
//
// Made with ❤️ by Novum
//
Expand All @@ -9,21 +9,21 @@
import CoreGraphics
import UIKit

public class CheckBox: UIControl {
public class Checkbox: UIControl {
private enum Constants {
static let viewWidth = CGFloat(24)
}

private let imageView = UIImageView()

// A Boolean value that determines the off/on state of the CheckBox
// A Boolean value that determines the off/on state of the Checkbox
public var isChecked = false {
didSet {
changeIcon(checked: isChecked)
}
}

// Called when the CheckBox changes its value.
// Called when the Checkbox changes its value.
public var onValueChanged: ((Bool) -> Void)?

public convenience init() {
Expand Down Expand Up @@ -66,7 +66,7 @@ public class CheckBox: UIControl {
}
}

private extension CheckBox {
private extension Checkbox {
func commonInit() {
layoutView()

Expand Down
21 changes: 21 additions & 0 deletions Mistica/Source/Components/Checkbox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Checkbox

The Checkbox offers a binary choice.

## Usage

The **Checkbox** is used as any other view.

The component has two mechanisms for notify when the value changes. You can use the `onValueChanged` close

```swift
checkbox.onValueChanged = { checked in
// do something
}
```

or using the target-action pattern of UIControl. Checkbox only send actions for `UIControl.Event.valueChanged`,

```swift
checkbox.addTarget(self, action: #selector(checkboxTapped), for: .valueChanged)
``
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// CheckBoxTests.swift
// CheckboxTests.swift
//
// Made with ❤️ by Novum
//
Expand All @@ -10,7 +10,7 @@ import Mistica
import SnapshotTesting
import XCTest

final class CheckBoxTests: XCTestCase {
final class CheckboxTests: XCTestCase {
override class func setUp() {
super.setUp()

Expand All @@ -22,14 +22,14 @@ final class CheckBoxTests: XCTestCase {
func testCheckboxDefaultState() {
assertSnapshotForAllBrands(
as: .image,
viewBuilder: makeTemplateWithCheckBoxState(isChecked: false)
viewBuilder: makeTemplateWithCheckboxState(isChecked: false)
)
}

func testCheckboxActiveCheckedState() {
assertSnapshotForAllBrands(
as: .image,
viewBuilder: makeTemplateWithCheckBoxState(isChecked: true)
viewBuilder: makeTemplateWithCheckboxState(isChecked: true)
)
}

Expand All @@ -38,20 +38,20 @@ final class CheckBoxTests: XCTestCase {
func testCheckboxIsChecked() {
MisticaConfig.brandStyle = .o2

let checkBox = CheckBox()
checkBox.isChecked = false
let checkbox = Checkbox()
checkbox.isChecked = false

assertSnapshot(
matching: checkBox,
as: .image(size: checkBox.intrinsicContentSize),
matching: checkbox,
as: .image(size: checkbox.intrinsicContentSize),
named: "assertInitialState"
)

checkBox.isChecked = true
checkbox.isChecked = true

assertSnapshot(
matching: checkBox,
as: .image(size: checkBox.intrinsicContentSize),
matching: checkbox,
as: .image(size: checkbox.intrinsicContentSize),
named: "finalState"
)
}
Expand All @@ -61,7 +61,7 @@ final class CheckBoxTests: XCTestCase {
func testXIBIntegration() {
MisticaConfig.brandStyle = .vivo

let view = CheckBoxXIBIntegration.viewFromNib()
let view = CheckboxXIBIntegration.viewFromNib()

assertSnapshot(
matching: view,
Expand All @@ -72,13 +72,13 @@ final class CheckBoxTests: XCTestCase {

// MARK: - Helpers

private func makeTemplateWithCheckBoxState(isChecked: Bool) -> UIView {
let checkBox = CheckBox(frame: CGRect(origin: .zero, size: CGSize(width: 24, height: 24)))
checkBox.isChecked = isChecked
private func makeTemplateWithCheckboxState(isChecked: Bool) -> UIView {
let checkbox = Checkbox(frame: CGRect(origin: .zero, size: CGSize(width: 24, height: 24)))
checkbox.isChecked = isChecked

let containerView = UIView(frame: CGRect(origin: .zero, size: checkBox.intrinsicContentSize))
let containerView = UIView(frame: CGRect(origin: .zero, size: checkbox.intrinsicContentSize))
containerView.backgroundColor = .white
containerView.addSubview(checkBox)
containerView.addSubview(checkbox)

return containerView
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// CheckBoxXIBIntegration.swift
// CheckboxXIBIntegration.swift
//
// Made with ❤️ by Novum
//
Expand All @@ -9,6 +9,6 @@
import Mistica
import UIKit

class CheckBoxXIBIntegration: UIView {
@IBOutlet var checkBox: CheckBox!
class CheckboxXIBIntegration: UIView {
@IBOutlet var checkbox: Checkbox!
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" userLabel="CheckBoxXIB Integration" customClass="CheckBoxXIBIntegration" customModule="MisticaTests">
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="CheckboxXIBIntegration" customModule="MisticaTests">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gsx-LH-iVS" userLabel="CheckBox" customClass="CheckBox" customModule="Mistica">
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gsx-LH-iVS" customClass="Checkbox" customModule="Mistica">
<rect key="frame" x="184" y="203" width="46" height="46"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
Expand All @@ -31,7 +31,7 @@
<constraint firstItem="gsx-LH-iVS" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="159" id="uiF-Bl-ha8"/>
</constraints>
<connections>
<outlet property="checkBox" destination="gsx-LH-iVS" id="pSl-4L-nYD"/>
<outlet property="checkbox" destination="gsx-LH-iVS" id="pSl-4L-nYD"/>
</connections>
<point key="canvasLocation" x="137.68115942028987" y="134.59821428571428"/>
</view>
Expand Down
8 changes: 4 additions & 4 deletions MisticaCatalog/MisticaCatalog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
B8F9903F2546C98700DFBFE9 /* UICatalogScrollContentIndicatorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F990172546C98600DFBFE9 /* UICatalogScrollContentIndicatorViewController.swift */; };
B8F990402546C98700DFBFE9 /* UICatalogFeedbacksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F990182546C98600DFBFE9 /* UICatalogFeedbacksViewController.swift */; };
B8F990412546C98700DFBFE9 /* UICatalogHighlightedCardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F990192546C98600DFBFE9 /* UICatalogHighlightedCardViewController.swift */; };
B8F990422546C98700DFBFE9 /* UICatalogCheckBoxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F9901A2546C98600DFBFE9 /* UICatalogCheckBoxViewController.swift */; };
B8F990422546C98700DFBFE9 /* UICatalogCheckboxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F9901A2546C98600DFBFE9 /* UICatalogCheckboxViewController.swift */; };
B8F990432546C98700DFBFE9 /* UICatalogButtonsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F9901B2546C98600DFBFE9 /* UICatalogButtonsViewController.swift */; };
B8F990442546C98700DFBFE9 /* UICatalogFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F9901C2546C98600DFBFE9 /* UICatalogFormViewController.swift */; };
B8F990452546C98700DFBFE9 /* UICatalogFontsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F9901D2546C98600DFBFE9 /* UICatalogFontsViewController.swift */; };
Expand Down Expand Up @@ -73,7 +73,7 @@
B8F990172546C98600DFBFE9 /* UICatalogScrollContentIndicatorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICatalogScrollContentIndicatorViewController.swift; sourceTree = "<group>"; };
B8F990182546C98600DFBFE9 /* UICatalogFeedbacksViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICatalogFeedbacksViewController.swift; sourceTree = "<group>"; };
B8F990192546C98600DFBFE9 /* UICatalogHighlightedCardViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICatalogHighlightedCardViewController.swift; sourceTree = "<group>"; };
B8F9901A2546C98600DFBFE9 /* UICatalogCheckBoxViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICatalogCheckBoxViewController.swift; sourceTree = "<group>"; };
B8F9901A2546C98600DFBFE9 /* UICatalogCheckboxViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICatalogCheckboxViewController.swift; sourceTree = "<group>"; };
B8F9901B2546C98600DFBFE9 /* UICatalogButtonsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICatalogButtonsViewController.swift; sourceTree = "<group>"; };
B8F9901C2546C98600DFBFE9 /* UICatalogFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICatalogFormViewController.swift; sourceTree = "<group>"; };
B8F9901D2546C98600DFBFE9 /* UICatalogFontsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICatalogFontsViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -208,7 +208,7 @@
B8F990172546C98600DFBFE9 /* UICatalogScrollContentIndicatorViewController.swift */,
B8F990182546C98600DFBFE9 /* UICatalogFeedbacksViewController.swift */,
B8F990192546C98600DFBFE9 /* UICatalogHighlightedCardViewController.swift */,
B8F9901A2546C98600DFBFE9 /* UICatalogCheckBoxViewController.swift */,
B8F9901A2546C98600DFBFE9 /* UICatalogCheckboxViewController.swift */,
B8F9901B2546C98600DFBFE9 /* UICatalogButtonsViewController.swift */,
B8F9901C2546C98600DFBFE9 /* UICatalogFormViewController.swift */,
B8F9901D2546C98600DFBFE9 /* UICatalogFontsViewController.swift */,
Expand Down Expand Up @@ -339,7 +339,7 @@
B8F990512546C98700DFBFE9 /* UICatalogHeaderViewController.swift in Sources */,
B8F990492546C98700DFBFE9 /* UICatalogSegmentSelectorViewController.swift in Sources */,
B8F990312546C98700DFBFE9 /* NavigationBarStyles.swift in Sources */,
B8F990422546C98700DFBFE9 /* UICatalogCheckBoxViewController.swift in Sources */,
B8F990422546C98700DFBFE9 /* UICatalogCheckboxViewController.swift in Sources */,
B8F9904D2546C98700DFBFE9 /* UICatalogListsViewController.swift in Sources */,
B8F9902D2546C98700DFBFE9 /* CatalogList.swift in Sources */,
B8F9904F2546C98700DFBFE9 /* UICatalogCroutonViewController.swift in Sources */,
Expand Down
12 changes: 6 additions & 6 deletions MisticaCatalog/Source/Catalog/UICatalogViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import UIKit
private enum UICatalogRow: Int, CaseIterable {
case badge
case buttons
case checkBox
case checkbox
case controls
case crouton
case feedbacks
Expand Down Expand Up @@ -172,8 +172,8 @@ extension UICatalogViewController: UITableViewDataSource, UITableViewDelegate {
show(UICatalogControlsViewController(), sender: self)
case .highlightedCard:
show(UICatalogHighlightedCardViewController(), sender: self)
case .checkBox:
show(UICatalogCheckBoxViewController(), sender: self)
case .checkbox:
show(UICatalogCheckboxViewController(), sender: self)
}
}
}
Expand Down Expand Up @@ -234,8 +234,8 @@ private extension UICatalogRow {
return "Buttons"
case .feedbacks:
return "Feedbacks"
case .checkBox:
return "CheckBox"
case .checkbox:
return "Checkbox"
case .crouton:
return "Crouton"
case .segmentSelector:
Expand Down Expand Up @@ -279,7 +279,7 @@ private extension UICatalogRow {
return .feedbacksIcon
case .crouton:
return .croutonIcon
case .checkBox:
case .checkbox:
return .controlsIcon
case .segmentSelector:
return .segmentSelectorIcon
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// UICatalogCheckBoxViewController.swift
// UICatalogCheckboxViewController.swift
//
// Made with ❤️ by Novum
//
Expand All @@ -11,10 +11,10 @@ import UIKit

private enum Section: Int, CaseIterable {
case activated
case disabld
case disabled
}

class UICatalogCheckBoxViewController: UITableViewController {
class UICatalogCheckboxViewController: UITableViewController {
init() {
if #available(iOS 13.0, *) {
super.init(style: .insetGrouped)
Expand All @@ -30,15 +30,15 @@ class UICatalogCheckBoxViewController: UITableViewController {

override func viewDidLoad() {
super.viewDidLoad()
title = "CheckBox"
title = "Checkbox"

tableView.dataSource = self
tableView.delegate = self
tableView.keyboardDismissMode = .interactive
}
}

extension UICatalogCheckBoxViewController {
extension UICatalogCheckboxViewController {
override func numberOfSections(in _: UITableView) -> Int {
Section.allCases.count
}
Expand All @@ -52,7 +52,7 @@ extension UICatalogCheckBoxViewController {
}

override func tableView(_: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let checkBox = CheckBox()
let checkBox = Checkbox()
checkBox.isUserInteractionEnabled = false

if indexPath.section == 0 {
Expand All @@ -66,7 +66,7 @@ extension UICatalogCheckBoxViewController {
}

private class CellView: UITableViewCell {
public init(checkBox: CheckBox, reuseIdentifier: String?) {
public init(checkBox: Checkbox, reuseIdentifier: String?) {
super.init(style: .default, reuseIdentifier: reuseIdentifier)

selectionStyle = .none
Expand All @@ -91,7 +91,7 @@ private extension Section {
switch self {
case .activated:
return "Activated"
case .disabld:
case .disabled:
return "Disabled"
}
}
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let package = Package(
"Components/Badge/README.md",
"Components/Button/docs",
"Components/Button/README.md",
"Components/CheckBox/README.md",
"Components/Checkbox/README.md",
"Components/Controls/README.md",
"Components/Crouton/docs",
"Components/Crouton/README.md",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func scene(_ scene: UIScene, willConnectTo _: UISceneSession, options _: UIScene

* [Badge](./Mistica/Source/Components/Badge/)
* [Button](./Mistica/Source/Components/Button/)
* [CheckBox](./Mistica/Source/Components/CheckBox/)
* [Checkbox](./Mistica/Source/Components/Checkbox/)
* [Controls](./Mistica/Source/Components/Controls/)
* [Crouton](./Mistica/Source/Components/Crouton/)
* [Feedbacks](./Mistica/Source/Components/Feedback/)
Expand Down

0 comments on commit f66721f

Please sign in to comment.