RSDStepViewModel

open class RSDStepViewModel : NSObject, RSDStepViewPathComponent

Base class implementation for a step view model.

  • The step that backs this view model.

    Declaration

    Swift

    public let step: RSDStep
  • The identifier associated with this step. Default returns self.step.identifier.

    Declaration

    Swift

    open var identifier: String { get }
  • The child path component. Default returns nil.

    Declaration

    Swift

    open var currentChild: RSDNodePathComponent? { get }
  • The parent path component.

    Declaration

    Swift

    weak open var parent: RSDPathComponent? { get set }
  • The task result is the task result from the parent, unless the parent is nil in which case it uses a local instance variable.

    Declaration

    Swift

    public var taskResult: RSDTaskResult { get set }
  • Is the Next button enabled? The default implementation will check if the parent node is non-nil and return whether or not the parent has forward enabled, otherwise it will return true.

    Declaration

    Swift

    open var isForwardEnabled: Bool { get }
  • Is backward navigation allowed? Default is to allow backward navigation unless the step.stepType is .completion.

    Declaration

    Swift

    open var canNavigateBackward: Bool { get }
  • Calls through to !shouldHideAction(for: .navigation(.goForward))

    Declaration

    Swift

    public var hasStepAfter: Bool { get }
  • Returns the parent output directory.

    Declaration

    Swift

    public var outputDirectory: URL! { get }
  • Instantiates a step result for this step.

    Declaration

    Swift

    public func pathResult() -> RSDResult
  • Calls perform(action:) on the parent.

    Declaration

    Swift

    open func perform(actionType: RSDUIActionType)
  • Convenience method for accessing the step result associated with this step.

    Declaration

    Swift

    open func findStepResult() -> RSDResult?
  • Conveniece method for getting the progress through the task for the current step with the current result.

    Declaration

    Swift

    open func progress() -> (current: Int, total: Int, isEstimated: Bool)?

    Return Value

    • current: The current progress. This indicates progress within the task.
    • total: The total number of steps.
    • isEstimated: Whether or not the progress is an estimate (if the task has variable navigation).

  • An identifier string that can be appended to a step view controller to differentiate this step from another instance in a different section.

    Declaration

    Swift

    open func sectionIdentifier() -> String
  • The description of the path.

    Declaration

    Swift

    override open var description: String { get }
  • Convenience property for casting the step to a RSDUIStep.

    Declaration

    Swift

    public var uiStep: RSDUIStep? { get }
  • Convenience property for casting the step to a RSDActiveUIStep.

    Declaration

    Swift

    public var activeStep: RSDActiveUIStep? { get }
  • Get the action for the given action type. The default implementation check the step, the delegate and the task as follows:

    • Query the step for an action.
    • If that returns nil, it will then check the delegate.
    • If that returns nil, it will look up the task path chain for an action.
    • Finally, if not found it will return nil.

    Declaration

    Swift

    open func action(for actionType: RSDUIActionType) -> RSDUIAction?

    Parameters

    actionType

    The action type to get.

    Return Value

    The action if found.

  • Should the action be hidden for the given action type?

    • The default implementation will first look to see if the step overrides and forces the action to be hidden.
    • If not, then the delegate will be queried next.
    • If that does not return a value, then the task path will be checked.

    Finally, whether or not to hide the action will be determined based on the action type and the state of the task as follows:

    1. .navigation(.cancel) - Always defaults to false (not hidden).
    2. .navigation(.goForward) - Hidden if the step is an active step that transitions automatically.
    3. .navigation(.goBack) - Hidden if the step is an active step that transitions automatically, or if the task does not allow backward navigation.
    4. Others - Hidden if the action() is nil.

    Declaration

    Swift

    open func shouldHideAction(for actionType: RSDUIActionType) -> Bool

    Parameters

    actionType

    The action type to get.

    Return Value

    true if the action should be hidden.