NatCounter

public final class NatCounter : UIView, UITextFieldDelegate

Note

This component is available in the following variants:
  • ✅ Standard

With the following attribute status:

  • ✅ Label
  • Disabled:
    • Subtract
    • Add
    • Both
  • Size:
    • Semi
    • Medium
  • Interaction state:
    • Enabled
    • Press

NatCounter is a class that represents the counter component from the design system.

It can be configured with the sizes:

  • Semi (default)
  • Medium

Example of usage:

       let counter = NatCounter()
       let counter = NatCounter(size: .medium)

Requires

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

DesignSystem().configure(with: AvailableTheme)

Inits

Public methods

  • Sets the label of NatCounter component

    Declaration

    Swift

    public func configure(label: String?)

    Parameters

    label

    text always displayed above NatCounter

  • Sets the value of NatCounter component

    Declaration

    Swift

    public func setCount(_ value: Int)

    Parameters

    value

    value for NatCounter

  • Sets the handler to listening value changes

    Example of usage:

    counter.configure { newValue in }
    

    Declaration

    Swift

    public func configure(changeValue: @escaping CounterChangeValueHandler)

    Parameters

    changeValue

    A closure to notify value changes

  • Sets the state of CounterButtons

    Example of usage:

    counter.configure(button: .add, state: .disabled)
    counter.configure(button: .subtract, state: .disabled)
    counter.configure(button: .all, state: .disabled)
    

    Declaration

    Swift

    public func configure(button: CounterButtonType, state: State)

    Parameters

    button

    An option from CounterButtonType enum: subtract, add or all

    state

    An option from State enum: enabled or disabled

  • Undocumented

    Declaration

    Swift

    public func configureKeyboard(state: State)
  • Returns the value of counter

    Declaration

    Swift

    public func getValue() -> Int
  • CounterButtonType represents the buttons type of NatCounter component.

    These are all CounterButtonType allowed :

    • add
    • subtract
    • all
    See more

    Declaration

    Swift

    public enum CounterButtonType
  • Size is a enum that represents size values for NatCounter component.

    These are all sizes allowed for a NatCounter:

    • semi
    • medium

    Requires

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

    DesignSystem().configure(with: AvailableTheme)

    See more

    Declaration

    Swift

    public enum Size : CaseIterable
  • State represents state values for NatCounter component.

    These are all states allowed for a NatCounter:

    • enabled
    • disabled
    See more

    Declaration

    Swift

    public enum State
  • Undocumented

    See more

    Declaration

    Swift

    public enum MinValue