NatChip
public final class NatChip : UIView
NatChip is a class that represents the Chip component from the design system.
Example of usage:
let chip = NatChip(size: .semi, color: .neutral)
chip.configure(text: "NatChip example text")
chip.configure(icon: getIcon(.outlinedDefaultMockup), position: .left)
chip.configure(avatar: natAvatar, position: .right)
chip.configure(state: .normal)
chip.configure(actionHandler: { isSelect in
//do something
})
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 static var currentTheme: AvailableTheme
-
Undocumented
Declaration
Swift
public private(set) var state: UIControl.State { get set }
-
Undocumented
Declaration
Swift
public private(set) var isSelected: Bool { get set }
-
Undocumented
Declaration
Swift
public private(set) var theme: AvailableTheme { get set }
-
Undocumented
Declaration
Swift
public var color: ThemeColor { get set }
-
Undocumented
Declaration
Swift
public init(size: NatChip.Size = .semi, color: NatChip.Color = .neutral, theme: AvailableTheme = .none)
-
Sets the text of the component.
Example of usage:
natChip.configure(text: "NatChip example text")
Declaration
Swift
public func configure(text: String)
Parameters
text
A
String
that set the text of the component -
Sets an icon to the component.
Example of usage:
natChip.configure(icon: getIcon(.outlinedDefaultMockup), position: .left)
Declaration
Swift
public func configure(icon: String?, position: NatChip.Position)
Parameters
icon
A
String
that set an icon to the componentposition
A
NatChip.Position
that indicates the position of the icon -
Sets an avatar to the component.
Example of usage:
natChip.configure(avatar: natAvatar, position: .left)
Parameters
avatar
A
NatAvatar
that set an avatar to the componentposition
A
NatChip.Position
that indicates the position of the avatar -
Sets the state of the component.
Example of usage:
natChip.configure(state: .normal)
Declaration
Swift
public func configure(state: UIControl.State)
Parameters
state
An
UIControl.State
that changes the state of the component -
Sets the handler to be executed when
isSelected
value changesExample of usage:
natChip.configure { isSelected in }
Declaration
Swift
public func configure(actionHandler: @escaping (Bool) -> Void)
Parameters
actionHandler
A closure to notify value change
-
Undocumented
Declaration
Swift
public func configure(color: Color)
-
Undocumented
See moreDeclaration
Swift
public enum Color
-
Undocumented
See moreDeclaration
Swift
public struct ThemeColor
-
Undocumented
See moreDeclaration
Swift
public enum Position
-
Size is an enum that represents the possible sizes for the NatChip size. The default size is
semi
.These are all sizes allowed for a NatChip:
- semi
- semiX
- medium
Declaration
Swift
public enum Size : CaseIterable