CLASS
BaseViewController
Contents
- Properties
modelmainViewmessagesStackViewlinksStackViewhaapiFlowViewControllerDelegateuiStylableThemeDelegate
- Methods
init(_:style:commonStyle:)deinitinit(coder:)viewDidLoad()stopLoading()hasLoading()handleProblemModel(_:)handleInfoMessageModels(_:)handleLinkItemModels(_:)handleFormModel(_:)preSubmit(interactionActionModel:parameters:closure:)preSelect(selectorItemModel:closure:)preFollow(linkItemModel:closure:)preRender(uiModel:)apply(style:)insertView(_:aboveView:)insertView(_:belowView:)
open class BaseViewController< // swiftlint:disable:this type_body_length
AssociatedModel,
AssociatedStyle: UIViewControllerStyle
>: UIViewController, HaapiUIViewController, ViewControllable, UIStylable
The base UIViewController definition that is capable of presenting a Model that contains a list of Messages and list of Links from which the user can select one.
Actions are submited using delegation callback via HaapiFlowViewControllerDelegatereference stored in haapiFlowViewControllerDelegate property.
Properties
model
public let model: AssociatedModel
mainView
public internal(set) weak var mainView: UIView?
messagesStackView
public lazy var messagesStackView: UIStackView = {
let stack = UIStackView()
stack.accessibilityIdentifier = AccessibilityIdentifier.messagesStackView.rawValue
stack.axis = .vertical
return stack
}()
A vertical UIStackView that contains MessageView.
linksStackView
public lazy var linksStackView: UIStackView = {
let stack = UIStackView()
stack.accessibilityIdentifier = AccessibilityIdentifier.linksStackView.rawValue
stack.axis = .vertical
return stack
}()
A vertical UIStackView that contains LinkView.
haapiFlowViewControllerDelegate
public weak var haapiFlowViewControllerDelegate: HaapiFlowViewControllerDelegate?
The delegate object that serves as a Haapi flow view controller.
uiStylableThemeDelegate
public weak var uiStylableThemeDelegate: (any UIStylableThemeDelegate)?
Methods
init(_:style:commonStyle:)
public init(_ model: AssociatedModel, style: AssociatedStyle, commonStyle: HaapiUIViewControllerStyle)
deinit
deinit
init(coder:)
viewDidLoad()
override open func viewDidLoad()
stopLoading()
open func stopLoading()
hasLoading()
open func hasLoading() -> Bool
handleProblemModel(_:)
open func handleProblemModel(_ problemModel: ProblemModel) -> Bool
Parameters
| Name | Description |
|---|---|
| problemModel | An UIProblem that is mapped on a ProblemRepresentation. |
handleInfoMessageModels(_:)
open func handleInfoMessageModels(_ infoMessageModels: [InfoMessageModel])
Parameters
| Name | Description |
|---|---|
| infoMessageModels | An array of InfoMessageModel. |
handleLinkItemModels(_:)
open func handleLinkItemModels(_ linkItemModels: [LinkItemModel])
Parameters
| Name | Description |
|---|---|
| linkItemModels | An array of LinkItemModel. |
handleFormModel(_:)
open func handleFormModel(_ formModel: FormModel) -> Bool
Parameters
| Name | Description |
|---|---|
| formModel | A FormModel. |
preSubmit(interactionActionModel:parameters:closure:)
public func preSubmit(
interactionActionModel: any InteractionActionModel,
parameters: [String: any Sendable],
closure: @escaping (Bool, [String: any Sendable]) -> Void
)
Parameters
| Name | Description |
|---|---|
| interactionActionModel | The interaction action model to be submitted. |
| parameters | Parameters to be sent with the form action model. |
| closure | A closure of Bool and [String: Any]. If it is set to true, then the submission continues. Otherwise, no submission are made. |
preSelect(selectorItemModel:closure:)
open func preSelect(selectorItemModel: any SelectorItemInteractionActionModel, closure: @escaping (Bool) -> Void)
Parameters
| Name | Description |
|---|---|
| selectorItemModel | The selector item model that contains the action to trigger. |
| closure | A closure of Bool. If it set to true, the selector item model is being selected. Otherwise, no selector item models are selected. |
preFollow(linkItemModel:closure:)
open func preFollow(linkItemModel: any LinkItemModel, closure: @escaping (Bool) -> Void)
Parameters
| Name | Description |
|---|---|
| linkItemModel | The link item model to be followed. |
| closure | A closure of Bool. If it is set to true, the link is being followed. Otherwise, no links are being followed. |
preRender(uiModel:)
open func preRender(uiModel: AssociatedModel)
apply(style:)
public func apply(style: AssociatedStyle)
Parameters
| Name | Description |
|---|---|
| style | The style configuration to be applied to the component |
insertView(_:aboveView:)
public func insertView(_ view: UIView, aboveView: UIView) -> Bool
Insert a view above another view in the root stackView.
insertView(_:belowView:)
public func insertView(_ view: UIView, belowView: UIView) -> Bool
Insert a view below another view in the root stackView.