NatSwitch

public class NatSwitch : UIView

NatSwitch is a class that represents the switch component from the design system. The switch colors changes according with the current theme configured in the Design System.

Example of usage:

   natSwitch.configure(state: .normal)
   natSwitch.configure(state: .focused)
   natSwitch.configure(state: .disabled)

   natSwitch.configure(isOn: true)
   natSwitch.configure(isOn: false)

   natSwitch.configure(isOnHandler:  { isOn in
       // Code
   })

Requires

It’s necessary to configure the Design System with a theme or fatalError will be raised.

DesignSystem().configure(with: AvailableTheme)

  • Undocumented

    Declaration

    Swift

    public private(set) var isOn: Bool { get set }
  • Undocumented

    Declaration

    Swift

    public private(set) var state: UIControl.State { get set }
  • Undocumented

    Declaration

    Swift

    public init(theme: AvailableTheme = .none)

Public Methods

  • Sets the state of the component.

    Example of usage:

    natSwitch.configure(state: .normal)
    

    Declaration

    Swift

    public func configure(state: UIControl.State)

    Parameters

    state

    An UIControl.State that changes the state of the component

  • Turns the component on/off.

    Example of usage:

    natSwitch.configure(isOn: true)
    

    Declaration

    Swift

    public func configure(isOn: Bool)

    Parameters

    isOn

    A Bool that turns the component on/off

  • Sets the handler to be executed when isOn value changes

    Example of usage:

    natSwitch.configure { isOn in }
    

    Declaration

    Swift

    public func configure(isOnHandler: @escaping (Bool) -> Void)

    Parameters

    isOnHandler

    A closure to notify value change