GenericViewController
The GenericViewController
is a UIViewController
that conforms to the HaapiUIViewController
protocol and is capable of displaying a GenericModel
which contains one of any combination of an optional SelectorModel
and an optional FormModel
.
UI structure
The root structure is composed of a container StackView
, this UIViewcontroller is responsible for dynamically loading the SelectorModel
UIViewController and/or the FormModel
UIViewController that represent the content of the GenericModel
. It is also responsible for forwarding the content updates to the contained views.
Name | Description |
---|---|
selectorViewController | The ViewControllerResolver provided implementation for the UI that can represent a SelectorModel . |
formViewController | The ViewControllerResolver provided implementation for the UI that can represent a FormModel . |
Subclassing
When subclassing and registering your new view controller
@available(iOS 14.0, *)
class CustomGenericViewController: GenericViewController {
override func preSubmit(
interactionActionModel: any InteractionActionModel,
parameters: [String : Any],
closure: (Bool, [String : Any]) -> Void
) {
// Your custom implementation
closure(true, parameters)
}
// ...
}
// Registering your custom view controller to be used when displaying a GenericModel
HaapiUIKitApplicationBuilder(haapiUIKitConfiguration: haapiUIKitConfiguration)
.setViewControllerFactoryRegistry(registry: ViewControllerFactoryRegistry().registerViewControllerFactoryGenericModel(factory: { model, style, commonStyle in
CustomGenericViewController(model, style: style, commonStyle: commonStyle)
}))
.build()