A soft button wrapper object that is capable of storing and switching between states
The name of this button
@property (nonatomic, copy, readonly) NSString *_Nonnull name;
var name: String { get }
All states available to this button
@property (nonatomic, strong, readonly) NSArray<SDLSoftButtonState *> *_Nonnull states;
var states: [SDLSoftButtonState] { get }
The name of the current state of this soft button
@property (nonatomic, copy, readonly) SDLSoftButtonState *_Nonnull currentState;
@NSCopying var currentState: SDLSoftButtonState { get }
Describes an on-screen button which may be presented in various contexts, e.g. templates or alerts
@property (nonatomic, strong, readonly) SDLSoftButton *_Nonnull currentStateSoftButton;
var currentStateSoftButton: SDLSoftButton { get }
The handler to be called when the button is in the current state and is pressed
@property (nonatomic, strong, readonly) SDLRPCButtonNotificationHandler _Nonnull eventHandler;
var eventHandler: SDLRPCButtonNotificationHandler { get }
Create a multi-state (or single-state, but you should use initWithName:state: instead for that case) soft button. For example, a button that changes its image or text, such as a repeat or shuffle button.
- (nonnull instancetype)
initWithName:(nonnull NSString *)name
states:(nonnull NSArray<SDLSoftButtonState *> *)states
initialStateName:(nonnull NSString *)initialStateName
handler:(nullable SDLRPCButtonNotificationHandler)eventHandler;
init(name: String, states: [SDLSoftButtonState], initialStateName: String, handler eventHandler: SDLRPCButtonNotificationHandler? = nil)
The name of the button
The states available to the button
The handler to be called when the button is in the current state and is pressed
The first state to use
Create a single-state soft button. For example, a button that brings up a Perform Interaction menu.
- (nonnull instancetype)initWithName:(nonnull NSString *)name
state:(nonnull SDLSoftButtonState *)state
handler:(nullable SDLRPCButtonNotificationHandler)
eventHandler;
init(name: String, state: SDLSoftButtonState, handler eventHandler: SDLRPCButtonNotificationHandler? = nil)
The name of the button
The single state of the button
The handler to be called when the button is pressed
The button object
Create a single-state soft button. For example, a button that brings up a Perform Interaction menu.
- (nonnull instancetype)initWithName:(nonnull NSString *)name
text:(nullable NSString *)text
artwork:(nullable SDLArtwork *)artwork
handler:(nullable SDLRPCButtonNotificationHandler)
eventHandler;
init(name: String, text: String?, artwork: SDLArtwork?, handler eventHandler: SDLRPCButtonNotificationHandler? = nil)
The name of the button
The text to be displayed on the button
The artwork to be displayed on the button
The handler to be called when the button is pressed
The button object
Transition the soft button to another state in the states
property. The wrapper considers all transitions valid (assuming a state with that name exists).
Warning
This method will throw an exception and crash your app (on purpose) if you attempt an invalid transition. So…don’t do that.
- (BOOL)transitionToStateNamed:(nonnull NSString *)stateName;
func transition(toState stateName: String) -> Bool
The next state.
YES if a state was found with that name, NO otherwise.
Transition the soft button to the next state of the array set when in the states
property
- (void)transitionToNextState;
func transitionToNextState()
Return a state from the state array with a specific name.
- (nullable SDLSoftButtonState *)stateWithName:(nonnull NSString *)stateName;
func state(withName stateName: String) -> SDLSoftButtonState?
The name of the state to return
The state, or nil if no state with that name exists