Tweakable

public protocol Tweakable : Storable

A type whose value can be tweaked.

  • primaryViewReuseID Default implementation

    The reuse id of the primary view.

    This is like the reuseIdentifier of UITableViewCell.

    Every Tweakable type must have a primary view. The primary view is used for tweaking the value. For example, Bool uses a switcher as its primary view.

    If this method is not implemented, then the return value is assumed to be the id of blank placeholder primary view.

    For more information about primary view please checkout TweakPrimaryView.

    Default Implementation

    Declaration

    Swift

    static var primaryViewReuseID: String { get }
  • primaryView Default implementation

    The primary view.

    Every Tweakable type must have a primary view. The primary view is used for tweaking the value. For example, Bool uses a switcher as its primary view.

    If this method is not implemented, then the return value is assumed to be a blank placeholder primary view.

    For more information about primary view please checkout TweakPrimaryView.

    Default Implementation

    Declaration

    Swift

    static var primaryView: TweakPrimaryView { get }
  • hasSecondaryView Default implementation

    A flag indicates whether the Tweakable type has a secondary view.

    A Tweakable type can opt-in a secondary view when its primary view has not enough room to display the UI for users to change the value. For example, UIColor uses a secondary view which uses some sliders for adjustment.

    If this method is not implemented, then the return value is assumed to be false.

    Note

    The value of hasSecondaryView should be the same as secondaryView != nil. The reason why we use a separated property is to avoid unnecessary initialization of a secondary. Sometimes we just need to know whether the type has a secondary view.

    For more information about secondary view please checkout TweakSecondaryView.

    Default Implementation

    Declaration

    Swift

    static var hasSecondaryView: Bool { get }
  • secondaryView Default implementation

    The secondary view.

    A Tweakable type can opt-in a secondary view when its primary view has not enough room to display the UI for users to change the value. For example, UIColor uses a secondary view which uses some sliders for adjustment.

    If this method is not implemented, then the return value is assumed to be nil.

    For more information about secondary view please checkout TweakSecondaryView.

    Default Implementation

    Declaration

    Swift

    static var secondaryView: TweakSecondaryView? { get }
  • validateAsDefaultValue() Default implementation

    Validates the receiver can be the default value of the tweak.

    Not every value is a valid default value for a tweak. For example, It’s meaningless to tweak a empty array.

    If this method is not implemented, then the return value is assumed to be true.

    Default Implementation

    Declaration

    Swift

    func validateAsDefaultValue() -> Bool

    Return Value

    True if the receiver can be the default value of the tweak; otherwise, false.