VoucherCreationFlowCoordinator

@interface VoucherCreationFlowCoordinator : NSObject

VoucherCreationFlowCoordinator is an object that initiates the creation of a Voucher.

  • Delegate methods called throughout the create process to allow for additional actions and screens to take place

    Note

    Default is nil.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<VoucherCreationFlowDelegate>
        delegate;

    Swift

    weak var delegate: VoucherCreationFlowDelegate? { get set }
  • Default initializer for VoucherCreationCoordinator.

    Declaration

    Objective-C

    + (nonnull instancetype)
    voucherCreationFlowCoordinatorWithCreationManager:
        (nonnull VoucherCreationManager *)creationManager
                                      discoverManager:(nullable DiscoverManager *)
                                                          discoverManager
                                          vouchrTheme:
                                              (nonnull VouchrTheme *)vouchrTheme
                                             delegate:
                                                 (nonnull id<
                                                     VoucherCreationFlowDelegate>)
                                                     delegate;

    Swift

    convenience init(creationManager: VoucherCreationManager, discoverManager: DiscoverManager?, vouchrTheme: VouchrTheme, delegate: VoucherCreationFlowDelegate)

    Parameters

    creationManager

    - An instance of VoucherCreationManager used in the flow of creating a new Voucher.

    discoverManager

    - An instance of DiscoverManager used to populate Discover content.

    vouchrTheme

    - The object that holds base theme settings for the creation flow.

    delegate

    - The object responsible for implementing VoucherCreationCoordinator callbacks.

  • Used to launch the Discover Screen flow on the specified view controller. Discover screen is a landing page from which the user can jumpstart their creation flow with prebuilt content.

    Declaration

    Objective-C

    - (void)
    launchDiscoverScreenOnViewController:(nonnull UIViewController *)viewController
                  personalizationOptions:
                      (nullable NSArray<PersonalizationOption *> *)
                          personalizationOptions
                         discoverBuilder:
                             (nonnull void (^)(DiscoverScreenBuilder *_Nonnull))
                                 builderBlock;

    Swift

    func launchDiscoverScreen(on viewController: UIViewController, personalizationOptions: [PersonalizationOption]?, discoverBuilder builderBlock: @escaping (DiscoverScreenBuilder) -> Void)

    Parameters

    viewController

    - The view controller the Discover Screen starts on.

    personalizationOptions

    - A list of PersonalizationOptions included in the creation flow.

  • Used to start the creation flow on selected view controller.

    Declaration

    Objective-C

    - (void)launchCreationScreenOnViewController:
                (nonnull UIViewController *)viewController
                          personalizationOptions:
                              (nullable NSArray<PersonalizationOption *> *)
                                  personalizationOptions;

    Swift

    func launchCreationScreen(on viewController: UIViewController, personalizationOptions: [PersonalizationOption]?)

    Parameters

    viewController

    - The view controller the creation flow starts on.

    personalizationOptions

    - A list of PersonalizationOptions included in the creation flow.

  • Used to launch the Preview Screen, which displays personalizations the user can add to their voucher.

    Declaration

    Objective-C

    - (void)
    launchPreviewScreenOnViewController:(nonnull UIViewController *)viewController
                 personalizationOptions:
                     (nullable NSArray<PersonalizationOption *> *)
                         personalizationOptions
                            vouchrTheme:(nonnull VouchrTheme *)vouchrTheme
                        creationManager:
                            (nonnull VoucherCreationManager *)creationManager
                        flowCoordinator:(nonnull VoucherCreationFlowCoordinator *)
                                            flowCoordinator
                                voucher:(nonnull Voucher *)voucher;

    Swift

    func launchPreviewScreen(on viewController: UIViewController, personalizationOptions: [PersonalizationOption]?, vouchrTheme: VouchrTheme, creationManager: VoucherCreationManager, flowCoordinator: VoucherCreationFlowCoordinator, voucher: Voucher)

    Parameters

    viewController

    - The view controller the creation flow starts on.

    personalizationOptions

    - A list of PersonalizationOptions included in the creation flow.

    vouchrTheme

    - The object that holds base theme settings for the creation flow.

    creationManager

    - An instance of VoucherCreationManager used in the flow of creating a new Voucher.

    flowCoordinator

    - An instance of ‘VoucherCreationFlowCoordinator’, which launches and receives callbacks from default personalization option screens.

    voucher

    - The voucher that includes contents to be previewed.

  • Used to launch the default Reveal Animation from the default Creation Screen.

    Declaration

    Objective-C

    - (void)launchRevealScreenFromCreationViewControllerWithVoucher:
        (nonnull Voucher *)voucher;

    Swift

    func launchRevealScreenFromCreationViewController(with voucher: Voucher)

    Parameters

    voucher

    - The voucher with contents for the reveal animation to show.

  • Used to launch the default Reveal Animation from the specified ‘viewController’ parameter.

    Declaration

    Objective-C

    - (void)launchRevealScreenFromViewController:
                (nonnull UIViewController *)viewController
                                     withVoucher:(nonnull Voucher *)voucher;

    Swift

    func launchRevealScreen(from viewController: UIViewController, with voucher: Voucher)

    Parameters

    voucher

    - The voucher with contents for the reveal animation to show.

  • Used to launch the default Edit Screen from the default Creation Screen.

    Declaration

    Objective-C

    - (void)launchEditScreenFromCreationViewControllerWithCreationItems:
        (nonnull NSMutableArray<CreationItemImageView *> *)creationItems;

    Swift

    func launchEditScreenFromCreationViewController(withCreationItems creationItems: NSMutableArray)

    Parameters

    creationItems

    - An array of ‘CreationItemImageView’s for the Edit Screen to display. Each item represents a personalization.

  • Used to launch the default Send Voucher Screen from the default or custom Creation Screen.

    Declaration

    Objective-C

    - (void)
    launchSendVoucherScreenFromCreationViewControllerWithCreationItems:
        (nonnull NSMutableArray<CreationItemImageView *> *)creationItems
                                                       backgroundColor:
                                                           (nonnull UIColor *)
                                                               backgroundColor;

    Swift

    func launchSendVoucherScreenFromCreationViewController(withCreationItems creationItems: NSMutableArray, backgroundColor: UIColor)

    Parameters

    creationItems

    - An array of ‘CreationItemImageView’s. Allows checking for minimum number of personalizations.

    backgroundColor

    - The background color of the default Send Voucher Screen.

  • Used to launch the default Send Voucher Screen from the default Creation Screen.

    Declaration

    Objective-C

    - (void)
    launchSendVoucherScreenFromCreationViewControllerWithEnvelopeView:
        (nonnull UIView *)envelopeView
                                                        creationItems:
                                                            (nonnull NSMutableArray<
                                                                CreationItemImageView
                                                                    *> *)
                                                                creationItems
                                                      backgroundColor:
                                                          (nonnull UIColor *)
                                                              backgroundColor;

    Swift

    func launchSendVoucherScreenFromCreationViewController(withEnvelopeView envelopeView: UIView, creationItems: NSMutableArray, backgroundColor: UIColor)

    Parameters

    envelopeView

    - The gift package from the default Creation Screen. The frame is used as a starting point for the transition animation.

    creationItems

    - An array of ‘CreationItemImageView’s. Allows checking for minimum number of personalizations.

    backgroundColor

    - The background color of the default Send Voucher Screen.

  • Used to launch a default Personalization Screen.

    Declaration

    Objective-C

    - (void)launchPersonalizationViewControllerForPersonalizationOption:
        (nonnull PersonalizationOption *)personalizationOption;

    Swift

    func launchPersonalizationViewController(for personalizationOption: PersonalizationOption)

    Parameters

    personalizationOption

    - The personalization option that identifies the default personalization screen to launch.

  • Used to populate the envelope with a pre-existing voucher.

    Declaration

    Objective-C

    - (void)populateWithVoucher:(nonnull Voucher *)voucher;

    Swift

    func populate(with voucher: Voucher)

    Parameters

    voucher

    - The voucher to be added to the envelope at the start of the creation flow.

  • Used to dismiss the Creation Screen.

    Note

    Default behavior pops the Creation Screen’s navigation controller. If a navigation controller is not present, ‘VoucherCreationFlowCoordinator’ calls its delegate’s ‘dismissPresentedViewControllerAnimated:completion:’ method.

    Declaration

    Objective-C

    - (void)createViewControllerCancelled;

    Swift

    func createViewControllerCancelled()
  • Prepares the creation flow coordinator for a new flow.

    Note

    Use this to deallocate leftover properties after successful voucher send.

    Declaration

    Objective-C

    - (void)resetCreationFlowCoordinator;

    Swift

    func resetCreationFlowCoordinator()
  • This callback occurs when the user wants to proceed with their Voucher but is not currently logged in. Perform a login or prompt the user to login during this callback and then execute the completion block.

    Declaration

    Objective-C

    - (void)createViewController:
                (nonnull UIViewController<VoucherCreationViewControllerProtocol> *)
                    viewController
        needsLoginWithCompletion:(nonnull void (^)(NSError *_Nonnull))completion;

    Swift

    func createViewController(_ viewController: UIViewController & VoucherCreationViewControllerProtocol, needsLoginWithCompletion completion: @escaping (Error) -> Void)

    Parameters

    viewController

    - The current VoucherCreationViewController being actioned on.

    completion

    - Block containing additional tasks to be executed upon logging in. Pass in nil if login was successful, the corresponding NSError if login has failed.

  • This callback occurs when the user has completed their actions on the VoucherCreationViewController and wants to proceed with sending their voucher.

    Declaration

    Objective-C

    - (void)createViewController:
                (nonnull UIViewController<VoucherCreationViewControllerProtocol> *)
                    viewController
        completedWithEnvelopeFrame:(CGRect)envelopeFrame
                   backgroundColor:(nonnull UIColor *)backgroundColor;

    Swift

    func createViewController(_ viewController: UIViewController & VoucherCreationViewControllerProtocol, completedWithEnvelopeFrame envelopeFrame: CGRect, backgroundColor: UIColor)

    Parameters

    viewController

    - The current VoucherCreationViewController being actioned on.

    envelopeFrame

    - The frame of the envelope on the VoucherCreationViewController. This frame is intended to be used for any custom transitions or animations of the envelope on the next view controller.

    backgroundColor

    - The current background color of the VoucherCreationViewController. It is supplied in the case consistency is required on the next screen.