Skip to content

Commit

Permalink
Changed public interface to open to allow subclassing
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariusz Cieśla committed Nov 21, 2016
1 parent 869b662 commit 988915d
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions Sources/M13Checkbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import UIKit

/// A customizable checkbox control for iOS.
@IBDesignable
public class M13Checkbox: UIControl {
open class M13Checkbox: UIControl {

//----------------------------
// MARK: - Constants
Expand Down Expand Up @@ -262,20 +262,20 @@ public class M13Checkbox: UIControl {
//----------------------------

/// The object to return from `value` when the checkbox is checked.
public var checkedValue: Any?
open var checkedValue: Any?

/// The object to return from `value` when the checkbox is unchecked.
public var uncheckedValue: Any?
open var uncheckedValue: Any?

/// The object to return from `value` when the checkbox is mixed.
public var mixedValue: Any?
open var mixedValue: Any?

/**
Returns one of the three "value" properties depending on the checkbox state.
- returns: The value coresponding to the checkbox state.
- note: This is a convenience method so that if one has a large group of checkboxes, it is not necessary to write: if (someCheckbox == thatCheckbox) { if (someCheckbox.checkState == ...
*/
public var value: Any? {
open var value: Any? {
switch checkState {
case .unchecked:
return uncheckedValue
Expand All @@ -291,7 +291,7 @@ public class M13Checkbox: UIControl {
//----------------------------

/// The current state of the checkbox.
public var checkState: CheckState {
open var checkState: CheckState {
get {
return controller.state
}
Expand All @@ -305,7 +305,7 @@ public class M13Checkbox: UIControl {
- parameter checkState: The new state of the checkbox.
- parameter animated: Whether or not to animate the change.
*/
public func setCheckState(_ newState: CheckState, animated: Bool) {
open func setCheckState(_ newState: CheckState, animated: Bool) {
if checkState == newState {
return
}
Expand All @@ -329,7 +329,7 @@ public class M13Checkbox: UIControl {
- parameter animated: Whether or not to animate the change. Defaults to false.
- note: If the checkbox is mixed, it will return to the unchecked state.
*/
public func toggleCheckState(_ animated: Bool = false) {
open func toggleCheckState(_ animated: Bool = false) {
switch checkState {
case .checked:
setCheckState(.unchecked, animated: animated)
Expand All @@ -348,7 +348,7 @@ public class M13Checkbox: UIControl {
//----------------------------

/// The duration of the animation that occurs when the checkbox switches states. The default is 0.3 seconds.
@IBInspectable public var animationDuration: TimeInterval {
@IBInspectable open var animationDuration: TimeInterval {
get {
return controller.animationGenerator.animationDuration
}
Expand All @@ -358,7 +358,7 @@ public class M13Checkbox: UIControl {
}

/// The type of animation to preform when changing from the unchecked state to any other state.
public var stateChangeAnimation: Animation = .stroke {
open var stateChangeAnimation: Animation = .stroke {
didSet {

// Remove the sublayers
Expand Down Expand Up @@ -395,7 +395,7 @@ public class M13Checkbox: UIControl {
}

/// Whether or not to enable morphing between states.
@IBInspectable public var enableMorphing: Bool {
@IBInspectable open var enableMorphing: Bool {
get {
return controller.enableMorphing
}
Expand Down Expand Up @@ -425,7 +425,7 @@ public class M13Checkbox: UIControl {
//----------------------------

/// The color of the checkbox's tint color when not in the unselected state. The tint color is is the main color used when not in the unselected state.
@IBInspectable public var secondaryTintColor: UIColor? {
@IBInspectable open var secondaryTintColor: UIColor? {
get {
return controller.secondaryTintColor
}
Expand All @@ -435,7 +435,7 @@ public class M13Checkbox: UIControl {
}

/// The color of the checkmark when it is displayed against a filled background.
@IBInspectable public var secondaryCheckmarkTintColor: UIColor? {
@IBInspectable open var secondaryCheckmarkTintColor: UIColor? {
get {
return controller.secondaryCheckmarkTintColor
}
Expand All @@ -445,7 +445,7 @@ public class M13Checkbox: UIControl {
}

/// The stroke width of the checkmark.
@IBInspectable public var checkmarkLineWidth: CGFloat {
@IBInspectable open var checkmarkLineWidth: CGFloat {
get {
return controller.pathGenerator.checkmarkLineWidth
}
Expand All @@ -456,7 +456,7 @@ public class M13Checkbox: UIControl {
}

/// The type of mark to display.
@IBInspectable public var markType: MarkType {
@IBInspectable open var markType: MarkType {
get {
return controller.markType
}
Expand All @@ -467,12 +467,12 @@ public class M13Checkbox: UIControl {
}

/// Set the mark type with the option of animating the change.
public func setMarkType(markType: MarkType, animated: Bool) {
open func setMarkType(markType: MarkType, animated: Bool) {
controller.setMarkType(type: markType, animated: animated)
}

/// The stroke width of the box.
@IBInspectable public var boxLineWidth: CGFloat {
@IBInspectable open var boxLineWidth: CGFloat {
get {
return controller.pathGenerator.boxLineWidth
}
Expand All @@ -483,7 +483,7 @@ public class M13Checkbox: UIControl {
}

/// The corner radius of the box if the box type is square.
@IBInspectable public var cornerRadius: CGFloat {
@IBInspectable open var cornerRadius: CGFloat {
get {
return controller.pathGenerator.cornerRadius
}
Expand All @@ -494,7 +494,7 @@ public class M13Checkbox: UIControl {
}

/// The shape of the checkbox.
public var boxType: BoxType {
open var boxType: BoxType {
get {
return controller.pathGenerator.boxType
}
Expand All @@ -505,7 +505,7 @@ public class M13Checkbox: UIControl {
}

/// Wether or not to hide the checkbox.
@IBInspectable public var hideBox: Bool {
@IBInspectable open var hideBox: Bool {
get {
return controller.hideBox
}
Expand All @@ -514,7 +514,7 @@ public class M13Checkbox: UIControl {
}
}

public override func tintColorDidChange() {
open override func tintColorDidChange() {
super.tintColorDidChange()
controller.tintColor = tintColor
}
Expand All @@ -523,7 +523,7 @@ public class M13Checkbox: UIControl {
// MARK: - Layout
//----------------------------

public override func layoutSubviews() {
open override func layoutSubviews() {
super.layoutSubviews()
// Update size
controller.pathGenerator.size = min(frame.size.width, frame.size.height)
Expand Down

0 comments on commit 988915d

Please sign in to comment.