FUIModalCheckoutViewController
@MainActor
open class FUIModalCheckoutViewController : UIViewController
A view controller to be presented as a modal form sheet. The view controller shows a CheckoutIndicatorView, which is drawn based on the set displayState.
Initialization
Programmatically:
let viewController = FUIModalCheckoutViewController.instantiateViewController()
viewController.title = "My Modal Checkout Title"
viewController.text = "Processing"
self.present(viewController, animated: false)
Inside a Storyboard:
- Drag and drop a
Storyboard Referencecomponent to Interface Builder’s canvas. - Enter
FUIModalCheckoutas Storyboard and the bundle for SAPFiori framework as Bundle. - Create a segue between your Button and the storyboard reference and select
Present Modallyas action. - Select the segue and in Interface Builder give it an identifier (e.g.
showModalCheckout). - In your view controller override
prepare(for segue: UIStoryboardSegue, sender: Any?) - From the segue get the destination and cast it to
FUIModalCheckoutViewController. - You can then register a delegate or change the controller’s display state.
Usage
// override `prepareForSegue`-method and retrieve view controller from segue destination.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard let showModalCheckoutSegue = segue.identifier, showModalCheckoutSegue == "showModalCheckout" else {
return
}
// keep a (weak) reference to modalCheckoutViewController
self.modalCheckoutViewController = segue.destination as? FUIModalCheckoutViewController
self.modalCheckoutViewController?.delegate = self
}
// implementation of FUIModalCheckoutViewControllerDelegate callback.
public func dismissController(_ controller: FUIModalCheckoutViewController) {
//stop any loading or checkout! User cancelled it...
//... or set state to completed.
self.modalCheckoutViewController?.changeDisplayState(to: .completed) {
self.modalCheckoutViewController?.dismiss(animated: true)
}
}
// While the FUIModalCheckoutViewController is shown, you might want to change the display state according to
// your loading / checkout progress. E.g. when you are done, you can change the state to `.completed`.
self.modalCheckoutViewController?.displayState = .completed
self.modalCheckoutViewController?.text = "Completed"
Theming
Supported style classes
fdlFUIModalCheckoutViewController
fdlFUIModalCheckoutViewController_textLabel
fdlFUIModalCheckoutViewController_navigationBar
Attention
The delegate object with type FUIModalCheckoutViewControllerDelegate is declared as a weak reference. So on deallocation it will be automatically set to nil. To keep it alive as expected, developer should retain the delegate object during its whole execution scope.
-
Sets the delegate of this FUIModalCheckoutViewController. If a delegate is set it is responsible for dismissing the view controller. If no delegate it set the view controller will dismiss itself, when the Done button is pressed.
Declaration
Swift
@MainActor public weak var delegate: FUIModalCheckoutViewControllerDelegate? -
This view controller’s navigation bar.
Declaration
Swift
@IBOutlet @MainActor public private(set) var navigationBar: UINavigationBar! { get } -
UILabel below the checkout indicator view, to indicate the current displayState using a text label.
Declaration
Swift
@IBOutlet @MainActor public private(set) var textLabel: UILabel! { get } -
The text displayed underneath the checkout indicator.
Declaration
Swift
@MainActor public var text: String? { get set } -
An array with the list of UIViews to display under the checkout Indicator Items should have intrinsic content size for proper layout
Declaration
Swift
@MainActor public var listItems: [UIView] { get set } -
Boolean value to determine if a Done button displays on DisplayState.completed The initial value is
falseDeclaration
Swift
@MainActor public var showDoneButtonOnCompletion: Bool -
The current
DisplayStateof the checkout indicator view controller. The initial value isDisplayState.processing.Declaration
Swift
@MainActor public var displayState: FUICheckoutIndicatorView.DisplayState { get }
-
Instantiates a new view controller instance from storyboard.
Declaration
Swift
@MainActor public class func instantiateViewController() -> FUIModalCheckoutViewControllerReturn Value
the new instance loaded from storyboard.
-
Changes the display state of this control. Use this to switch between different graphical representations of this control.
Declaration
Swift
@MainActor public func changeDisplayState(to newState: FUICheckoutIndicatorView.DisplayState, completion: (() -> Void)? = nil)Parameters
newStatethe new display state to switch to.
completioncompletion handler that will be called, once the display state change is done.