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 moreshortcut
Declaration
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 moreStyle
applies the variant style forshortcut
Declaration
Swift
public struct Style
-
See moreColor
represents the possible colors forshortcut
Declaration
Swift
public enum Color
-
Sets the state for the component
Declaration
Swift
public func configure(state: State)
Parameters
state
a state option (enabled/disabled)
-
Sets an icon for the shortcut view
Declaration
Swift
public func configure(icon: String?)
Parameters
icon
An icon from
NatDSIcons
Example of usage:shortcut.configure(icon: getIcon(icon: .outlinedAlertNotification))
-
Configures text for shortcut bottom label
Declaration
Swift
public func configure(text: String)
Parameters
text
A string with the text to display on the label
-
Sets the functionality for the shortcut
Declaration
Swift
public func configure(action: @escaping () -> Void)
Parameters
action
A 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
delegate
the class that is the delegate for the action (usually, the class itself)
action
a 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
numberOfLines
the number of lines to be displayed
lineBreakMode
the 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
badge
A 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)