NatShortcut
public final class NatShortcut : UIView
extension NatShortcut: Pulsable
Note
This component is available in the following variants:- ✅ Contained (default)
- ✅ Outlined
With the following attribute status:
- ✅ Disabled
- ✅ Interaction State Pressed
- Color:
- ✅
Primary(default) - ✅
Neutral
- ✅
- Notify:
- ✅
None(default) - ✅
Standard
- ✅
- Interaction state:
- ✅
Enabled - ✅
Pressed
- ✅
NatShortcut is a class that represents the component shortcut from the design system.
Its colors change according to the configured theme.
The component has the following variants:
- Contained (default)
- Outlined
And the colors:
- Primary (default)
- Neutral
And the states:
- Enabled
- Disabled
Example of usage:
let containedPrimary = NatShortcut(style: .containedPrimary)
Requires
It’s necessary to configure the Design System with a theme or fatalError will be raised.
DesignSystem().configure(with: AvailableTheme)
-
An enum that indicates possible states for the component
See moreshortcutDeclaration
Swift
public enum State -
The variant for the component
Declaration
Swift
public var style: Style { get set } -
The color for the component
Declaration
Swift
public var color: Color { get set } -
The state of the component
Declaration
Swift
public var state: State { get set } -
A boolean that indicates the state of the component
Declaration
Swift
public var isEnabled: Bool { get set }
-
Undocumented
Declaration
Swift
public convenience init(style: Style = .contained, color: Color = .primary, theme:AvailableTheme = .none) -
Undocumented
Declaration
Swift
public convenience init(style: Style = .contained, color: Color = .primary, text: String? = nil, icon: String? = nil, theme:AvailableTheme = .none) -
See moreStyleapplies the variant style forshortcutDeclaration
Swift
public struct Style -
See moreColorrepresents the possible colors forshortcutDeclaration
Swift
public enum Color
-
Sets the state for the component
Declaration
Swift
public func configure(state: State)Parameters
statea state option (enabled/disabled)
-
Sets an icon for the shortcut view
Declaration
Swift
public func configure(icon: String?)Parameters
iconAn icon from
NatDSIconsExample of usage:shortcut.configure(icon: getIcon(icon: .outlinedAlertNotification))
-
Configures text for shortcut bottom label
Declaration
Swift
public func configure(text: String)Parameters
textA string with the text to display on the label
-
Sets the functionality for the shortcut
Declaration
Swift
public func configure(action: @escaping () -> Void)Parameters
actionA block of functionality to be executed when the shorcut is pressed
-
Sets the functionality for the shortcut. Example:
yourShortcut.configure(delegate: self) { (self) in // your code for shortcut's action }Declaration
Swift
public func configure<Object: AnyObject>(delegate: Object, action: @escaping (Object) -> Void)Parameters
delegatethe class that is the delegate for the action (usually, the class itself)
actiona block of code to be run when the shortcut is pressed
-
Configures label text width and lines for long texts
Declaration
Swift
public func configureText(numberOfLines: Int, lineBreakMode: NSLineBreakMode)Parameters
numberOfLinesthe number of lines to be displayed
lineBreakModethe line break mode for long texts
-
Configures a badge to the shortcut.
Example of usage:
let badge = NatBadge(style: .standard, color: .primary) badge.configure(limit: .max99) badge.configure(count: 100) shortcut.configure(badge: badge)Declaration
Swift
public func configure(badge: NatBadge)Parameters
badgeA badge from the design system. The badge must be created and configured before setting it to the shortcut.
-
Undocumented
Declaration
Swift
public func configure(badgeValue: UInt)