AddToCartButton
AddToCartButton allows the users to add a product to their carts. AddToCartButton is included in form selection module, included by platform module. If you need to include this module, add it to your build.gradle
:
implementation ("com.poqstudio:catalogue.formselection:$VERSION_NAME")
Usage
You can use it in the layout: In the layout:
<com.poqstudio.platform.view.formselection.addtocart.ui.PoqAddToCartButton android:layout_width="wrap_content" android:layout_height="wrap_content" app:addToCartViewDTO="@{viewModel.addToCartViewDTO}" />
To display the success and error events, inject MainAddToCartViewModel
into your Activity or Fragment with activity scope and observe the appropriate LiveData:
mainAddToCartViewModel: MainAddToCartViewModel by context.poqViewModelActivity()
If you need to select more forms when the user clicks on the AddToCartButton, you can observe MainAddToCartViewModel.formToSelectEvent
LiveData with your logic to present a form picker:
mainAddToCartViewModel.formToSelectEvent.observeLiveData(context) { //Your logic to present a form picker}