Cart Navigation Button

Last Updated - Platform 22.0 - SDK 17.0

The CartNavigationButton is an optional sub-feature of the PoqCart framework that can be placed anywhere to replace the tab button. This is usually used to move the button to the navigation bar when using Swipe to Like.

Overview

The cart button is a subclass of BadgeButton which observes the cartUpdated notification to update it's BadgeView. It handles navigation to the Cart and updating the CartButtonLocation.default used as the end location of the add to cart animation.

Add to the navigation bar

The SDK provides a convenient way of setting the CartNavigationButton as the right navigation bar button on most screens.

Container.shared.views.navigationBarButtonItem.replace { .cart }

To use a custom subclass you can inject the CartNavigationBarButtonItem instead.

Container.shared.views.navigationBarButtonItem.replace {
CartNavigationBarButtonItem(button: CustomCartNavigationButton())
}

Customise navigation to the Cart

When the button is tapped it navigates to the Cart. This can be overridden by subclassing and overriding the handleTap function.

import PoqCart
class CustomCartNavigationButton: CartNavigationButton {
override func handleTap() {
print("Navigate to the Cart!")
}
}