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)
-
Undocumented
Declaration
Swift
public typealias CounterChangeValueHandler = (Int) -> Void -
Undocumented
Declaration
Swift
public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool -
Undocumented
Declaration
Swift
public func textFieldDidEndEditing(_ textField: UITextField)
-
Sets the label of NatCounter component
Declaration
Swift
public func configure(label: String?)Parameters
labeltext always displayed above NatCounter
-
Sets the value of NatCounter component
Declaration
Swift
public func setCount(_ value: Int)Parameters
valuevalue 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
changeValueA 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
buttonAn option from CounterButtonType enum: subtract, add or all
stateAn 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
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
See moreRequires
It’s necessary to configure the Design System with a theme or fatalError will be raised.
DesignSystem().configure(with: AvailableTheme)
Declaration
Swift
public enum Size : CaseIterable -
State represents state values for NatCounter component.
These are all states allowed for a NatCounter:
- enabled
- disabled
Declaration
Swift
public enum State -
Undocumented
See moreDeclaration
Swift
public enum MinValue