ContentRouter

class ContentRouter

The core navigation method within the SDK is the ContentRouter. Without this class not much could be accomplished and navigating from one page to another within the pay sheet would simply not be possible.

  • Closure type used for page change notifications

    Declaration

    Swift

    typealias PageChangeHandler = (ContentPage, ContentPage) -> Void
  • The page that the UX is currently displaying

    Declaration

    Swift

    var currentPage: ContentPage { get set }
  • The list of pages this router has registered.

    Declaration

    Swift

    var pages: [ContentPage] { get set }
  • Presents the actual page represented by the StaticIdentifier supplied. If you have a page such as LoadingPage which conforms to StaticIdentifiable, then LoadingPage.id is the standardized way to share this information

    Declaration

    Swift

    func presentPage(_ pageId: StaticIdentifier)

    Parameters

    pageId

    the StaticIdentifier used to navigate to the proper page. The page must be registered already via a call to addPage

  • Presents the previous page by invoking the presentPage function. We popLast() twice in order to remove both the current and previous pages.

    Declaration

    Swift

    func presentPreviousPage(offset: Int = 0)

    Parameters

    offset

    the offset to pop from (the number of pages to go back to + last one).

  • This subscript operator allows the retrieval of the actual ContentPage instance as it is registered. The key to do so should be the StaticIdentifier from the class itself. All ContentPages conform to StaticIdentifiable and as such the class name plus .id should be sufficient as a key for the instance desired.

    An example of this would be LoadingPage. To retrieve the previously registered LoadingPage instance, a call to Paysheet.shared[LoadingPage.id] would yield that object. It is a recommendation that the static helper subscript be used instead; so Paysheet[LoadingPage.id]

    Declaration

    Swift

    subscript(index: StaticIdentifier) -> ContentPage { get set }
  • Semantic method that indicates that something worth invoking height change and that may not automatically be picked up has occurred and the paysheet should display itself again.

    Declaration

    Swift

    func updatePage()