RSDUIStepObject

open class RSDUIStepObject : RSDUIActionHandlerObject, RSDThemedUIStep, RSDNavigationRule, Decodable, RSDMutableStep

RSDUIStepObject is the base class implementation for all UI display steps defined in this framework. Depending upon the available real-estate, more than one ui step may be displayed at a time. For example, on an iPad, you may choose to group a set of questions using a RSDSectionStep.

  • A short string that uniquely identifies the step within the task. The identifier is reproduced in the results of a step history.

    Declaration

    Swift

    public let identifier: String
  • The type of the step. This is used to decode the step using a RSDFactory. It can also be used to customize the UI.

    Declaration

    Swift

    public let stepType: RSDStepType
  • The primary text to display for the step in a localized string.

    Declaration

    Swift

    public var title: String?
  • Additional text to display for the step in a localized string.

    The additional text is often displayed in a smaller font below title. If you need to display a long question, it can work well to keep the title short and put the additional content in the text property.

    Declaration

    Swift

    public var text: String?
  • Additional detailed explanation for the step.

    The font size and display of this property will depend upon the device type.

    Declaration

    Swift

    public var detail: String?
  • Additional text to display for the step in a localized string at the bottom of the view.

    The footnote is intended to be displayed in a smaller font at the bottom of the screen. It is intended to be used in order to include disclaimer, copyright, etc. that is important to display in the step but should not distract from the main purpose of the step.

    Declaration

    Swift

    public var footnote: String?
  • The view info used to create a custom step.

    Declaration

    Swift

    open var viewTheme: RSDViewThemeElement?
  • The color theme.

    Declaration

    Swift

    open var colorTheme: RSDColorThemeElement?
  • The image theme.

    Declaration

    Swift

    open var imageTheme: RSDImageThemeElement?
  • The next step to jump to. This is used where direct navigation is required. For example, to allow the task to display information or a question on an alternate path and then exit the task. In that case, the main branch of navigation will need to jump over the alternate path step and the alternate path step will need to jump to the exit.

    Declaration

    Swift

    open var nextStepIdentifier: String?
  • Default initializer.

    Declaration

    Swift

    public init(identifier: String, type: RSDStepType? = nil)

    Parameters

    identifier

    A short string that uniquely identifies the step.

    type

    The type of the step. Default = RSDStepType.instruction

  • Instantiate a step result that is appropriate for this step. Default implementation will return a RSDResultObject.

    Declaration

    Swift

    open func instantiateStepResult() -> RSDResult

    Return Value

    A result for this step.

  • Required method. The base class implementation does nothing.

    Declaration

    Swift

    open func validate() throws
  • Identifier for the next step to navigate to based on the current task result. All parameters are ignored by this implementation of the navigation rule. Instead, this will return nextStepIdentifier if defined.

    Declaration

    Swift

    open func nextStepIdentifier(with result: RSDTaskResult?, conditionalRule: RSDConditionalRule?, isPeeking: Bool) -> String?

    Return Value

    The identifier of the next step.

  • Initialize from a Decoder.

    Note

    The imageTheme can be decoded as a RSDImageWrapper, RSDFetchableImageThemeElementObject, or RSDAnimatedImageThemeElementObject, depending upon the included dictionary.

  • example:

        // Example JSON for a step with an `RSDAnimatedImageThemeElement`.
        let json = """
           {
               "identifier": "foo",
               "type": "instruction",
               "title": "Hello World!",
               "text": "Some text.",
               "detail": "This is a test.",
               "footnote": "This is a footnote.",
               "nextStepIdentifier": "boo",
               "actions": { "goForward": { "buttonTitle" : "Go, Dogs! Go!" },
                            "cancel": { "iconName" : "closeX" },
                            "learnMore": { "iconName" : "infoIcon",
                                           "url" : "fooInfo" },
                            "skip": { "buttonTitle" : "not applicable",
                                       "skipToIdentifier": "boo"}
                           },
               "shouldHideActions": ["goBackward"],
               "image"  : {    "imageNames" : ["foo1", "foo2", "foo3", "foo4"],
                               "placementType" : "topBackground",
                               "animationDuration" : 2,
                                  },
               "colorTheme"     : { "backgroundColor" : "sky", "foregroundColor" : "cream", "usesLightStyle" : true },
               "viewTheme"      : { "viewIdentifier": "ActiveInstruction",
                                    "storyboardIdentifier": "ActiveTaskSteps",
                                    "bundleIdentifier": "org.example.SharedResources" }
           }
           """.data(using: .utf8)! // our data in native (JSON) format
    
        // Example JSON for a step with an `RSDFetchableImageThemeElement`.
        let json = """
           {
               "identifier"   : "goOutside",
               "type"         : "instruction",
               "title"        : "Go outside",
               "image"        : { "imageName": "goOutsideIcon", "placementType": "topBackground" },
               "colorTheme"   : { "backgroundColor" : "robinsEggBlue", "usesLightStyle" : true },
               "actions"      : { "goForward": { "buttonTitle": "I am outside" }},
           }
           """.data(using: .utf8)! // our data in native (JSON) format
    
        // Example JSON for a step with an `RSDImageWrapper`.
        let json = """
           {
               "identifier"   : "blueDog",
               "type"         : "instruction",
               "title"        : "This is a blue dog",
               "image"        : "blueDog",
           }
           """.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.

  • A step to merge with this step that carries replacement info. This step will look at the replacement info in the generic step and replace properties on self as appropriate.

    For an RSDUIStepObject, the title, text, detail, and footnote properties can be replaced.

    Declaration

    Swift

    open func replace(from step: RSDGenericStep) throws