RSDUIActionHandlerObject

open class RSDUIActionHandlerObject : RSDUIActionHandler

RSDUIActionHandlerObject is intended as an abstract implementation of the action handler that implements the Codable protocol.

  • A mapping dictionary of action type to action.

    Declaration

    Swift

    public var actions: [RSDUIActionType : RSDUIAction]?
  • A list of action types that should be hidden by default.

    Declaration

    Swift

    public var shouldHideActions: [RSDUIActionType]?
  • Base class initializer.

    Declaration

    Swift

    public init()
  • Customizable actions to return for a given action type. The RSDStepController can use these to customize the display of buttons to the user. If nil, shouldHideAction() will be called to determine if the default action should be used or if the action button should be hidden.

    Declaration

    Swift

    open func action(for actionType: RSDUIActionType, on step: RSDStep) -> RSDUIAction?

    Parameters

    actionType

    The action type for the button.

    step

    The step that the action is on.

    Return Value

    A custom UI action for this button. If nil, the default action will be used.

  • Should the action button be hidden? This implementation will check the shouldHideActions array and return true if found. Otherwise, this implementation will return nil.

    Declaration

    Swift

    open func shouldHideAction(for actionType: RSDUIActionType, on step: RSDStep) -> Bool?

    Parameters

    actionType

    The action type for the button.

    step

    The step that the action is on.

    Return Value

    Whether or not the button should be hidden or nil if there is no explicit action.

  • Initialize from a Decoder. This decoding method will use the RSDFactory instance associated with the decoder to decode the actions.

  • example:

        // Example JSON for the `actions` coding.
        let json = """
           {
               "actions": { "goForward": { "type": "default", "buttonTitle" : "Go, Dogs! Go!" },
                            "cancel": { "type": "default", "iconName" : "closeX" },
                            "learnMore": {  "type": "webView",
                                            "iconName" : "infoIcon",
                                            "url" : "fooInfo" },
                            "skip": {   "type": "navigation", 
                                        "buttonTitle" : "not applicable",
                                        "skipToIdentifier": "boo"}
                           },
               "shouldHideActions": ["goBackward"]
           }
           """.data(using: .utf8)! // our data in native (JSON) format
    
  • Throws

    DecodingError

    Declaration

    Swift

    public required init(from decoder: Decoder) throws

    Parameters

    decoder

    The decoder to use to decode this instance.

  • Define the encoder, but do not require protocol conformance of subclasses.

    Throws

    EncodingError

    Declaration

    Swift

    open func encode(to encoder: Encoder) throws

    Parameters

    encoder

    The encoder to use to encode this instance.