FUIModalCheckoutViewController

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:

  1. Drag and drop a Storyboard Reference component to Interface Builder’s canvas.
  2. Enter FUIModalCheckout as Storyboard and com.sap.cp.sdk.ios.SAPFiori as Bundle.
  3. Create a segue between your Button and the storyboard reference and select Present Modally as action.
  4. Select the segue and in Interface Builder give it an identifier (e.g. showModalCheckout).
  5. In your view controller override prepare(for segue: UIStoryboardSegue, sender: Any?)
  6. From the segue get the destination and cast it to FUIModalCheckoutViewController.
  7. 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

    public weak var delegate: FUIModalCheckoutViewControllerDelegate?
  • This view controller’s navigation bar.

    Declaration

    Swift

    @IBOutlet
    public private(set) var navigationBar: UINavigationBar!
  • The navigation Bar Title Item

    Declaration

    Swift

    @IBOutlet
    public private(set) var navigationBarTitleItem: UINavigationItem!
  • UIBarButtonItem of the view controller, representing the Done-Button.

    Declaration

    Swift

    @IBOutlet
    public private(set) var leftBarButtonItem: UIBarButtonItem!
  • UILabel below the checkout indicator view, to indicate the current displayState using a text label.

    Declaration

    Swift

    @IBOutlet
    public private(set) var textLabel: UILabel!
  • The text displayed underneath the checkout indicator.

    Declaration

    Swift

    public var text: String? { get set }
  • The current DisplayState of the checkout indicator view controller. The initial value is DisplayState.processing.

    Declaration

    Swift

    public var displayState: FUICheckoutIndicatorView.DisplayState { get }
  • Instantiates a new view controller instance from storyboard.

    Declaration

    Swift

    public class func instantiateViewController() -> FUIModalCheckoutViewController

    Return 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

    public func changeDisplayState(to newState: FUICheckoutIndicatorView.DisplayState, completion: (()->Void)? = nil)

    Parameters

    newState

    the new display state to switch to.

    completion

    completion handler that will be called, once the display state change is done.