-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Woo POS][Cash & Receipts] Navigation via navigation component to the cash payment screen #13069
[Woo POS][Cash & Receipts] Navigation via navigation component to the cash payment screen #13069
Conversation
Generated by 🚫 Danger |
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
import com.woocommerce.android.ui.woopos.root.navigation.WooPosNavigationEvent | ||
|
||
@Composable | ||
fun WooPosCashPaymentScreen(onNavigationEvent: (WooPosNavigationEvent) -> Unit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mock of the UI as we still have no design ready
val state: StateFlow<WooPosCashPaymentState> = _state | ||
|
||
init { | ||
viewModelScope.launch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there is no finilized design yet, I don't know the state needed, therefore not unit tests
…complition-call-from-the-mocked-cash-payment-screen # Conflicts: # WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/totals/WooPosTotalsViewModel.kt # WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/home/totals/WooPosTotalsViewModelTest.kt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @kidinov. The navigation works as expected. I've left few nitpicks which are not blocking for the merge.
I also observed an issue with navigation where successive clicks on "take cash payment" button opens the cash payment screen twice.
cash_payment_issue.mp4
val enteredAmount: String, | ||
val changeDue: String, | ||
val total: String, | ||
val canBeOrderBeCompleted: Boolean, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ nitpick: canBeOrderBeCompleted
naming sounds confusing. Should it be canOrderBeCompleted
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. That's val is gone in the following PR where the actual state based on the design apepared
private const val ROUTE = "cash_payment/{orderId}" | ||
|
||
fun NavController.navigateToCashPaymentScreen(orderId: Long) { | ||
navigate("cash_payment/$orderId") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Using ROUTE.replace("{orderId}", orderId.toString()) would improve maintainability, avoiding mismatches between the navigation declaration and usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
) { | ||
Column( | ||
modifier = Modifier | ||
.width(540.dp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Do we need to hardcode this width here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. But as I mentioned this is a mock. The actual UI is implemented in the following PR
|
||
@WooPosPreview | ||
@Composable | ||
fun WooPosTotalsPaymentCashScreenScreen() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Should the name be WooPosTotalsPaymentCashScreenPreview
?
Also, since it's actually previewing WooPosCashPaymentScreen
. What do you think about calling it WooPosCashPaymentScreenPreview
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Fixed here f3412b4
viewModelScope.launch { | ||
val order = repository.getOrderById(orderId)!! | ||
_state.value = WooPosCashPaymentState.Collecting( | ||
enteredAmount = "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: enteredAmount is initialised as an empty string, and changeDue as BigDecimal.ZERO, which might not align with realistic scenarios. We could consider initialising these values based on prior state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's all mocks, as there were not design. It's redone all completely now in here
Closes: #13063
Description
The PR moves mock of the cash payment state to a separate screen. The screen now opened using compose navigation
Testing information
The tests that have been performed
Above
Images/gif
12-05--14-46.mp4
RELEASE-NOTES.txt
if necessary. Use the "[Internal]" label for non-user-facing changes.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: