-
Notifications
You must be signed in to change notification settings - Fork 134
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
Allow Re-creating Shipping Label #3961
Allow Re-creating Shipping Label #3961
Conversation
…ng labels existence.
…bel" menu item to it.
…ing shipping label. If there are shipping label(s), we want to move the option to re-create shipping label in the Products area's menu.
You can test the changes on this Pull Request by downloading the APK here. |
Also refactor viewmodel to make the code more testable.
isShipmentTrackingAvailable = shipmentTracking.isVisible, | ||
isProductListVisible = orderProducts.isVisible, | ||
areShippingLabelsVisible = shippingLabels.isVisible | ||
areShippingLabelsVisible = shippingLabels.isVisible, | ||
isProductListMenuVisible = shippingLabels.isVisible |
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.
Previously I used areShippingLabelsVisible
as checker for displaying/hiding the Products list menu button. However, I found that it made it not super obvious for unit testing it. So while this is a bit redundant (i.e.: isProductListMenuVisible
will always have the same value as areShippingLabelsVisible
), it helps make it be more obvious during unit testing, like so:
assertThat(shippingLabels).isNotEmpty
assertThat(isCreateShippingLabelButtonVisible).isFalse()
assertThat(isProductListMenuVisible).isTrue()
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.
Really great job @hafizrahman 👏
I left some comments about the usage of the Woo.Card.ExpanderButton
style, as it's not matching the mockups, and some other small tips.
@@ -545,7 +538,8 @@ class OrderDetailViewModel @AssistedInject constructor( | |||
val refreshedProductId: Long? = null, | |||
val isCreateShippingLabelButtonVisible: Boolean? = null, | |||
val isProductListVisible: Boolean? = null, | |||
val areShippingLabelsVisible: Boolean? = null | |||
val areShippingLabelsVisible: Boolean? = null, | |||
val isProductListMenuVisible: Boolean? = null |
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.
It's nice to have a an explicit variable about this as you said in https://github.com/woocommerce/woocommerce-android/pull/3961/files#r626326768, I like it.
But as its value is always same as areShippingLabelsVisible
, we can simplify the logic a bit, and avoid any unwanted bugs (for example changing isProductListMenuVisible
in some other areas of the viewmodel) by making it a property without a backing field, similar to the below property isMarkOrderCompleteButtonVisible
, we can do this like this:
val isProductListMenuVisible: Boolean?
get() = areShippingLabelsVisible
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.
Thank you, that's a great tips!
if (isChecked) | ||
WooAnimUtils.fadeIn(viewBinding.shippingLabelListProducts) | ||
else | ||
WooAnimUtils.fadeOut(viewBinding.shippingLabelListProducts) |
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.
Normally we should avoid using single-line statement if blocks without braces, so either move the statement to the same line:
if (isChecked) WooAnimUtils.fadeIn(viewBinding.shippingLabelListProducts)
else WooAnimUtils.fadeOut(viewBinding.shippingLabelListProducts)
or add curly braces to those statements.
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.
Awesome, learned something new here. Thanks.
@@ -300,6 +300,7 @@ | |||
<string name="orderdetail_shipping_notice">This order is using extensions to calculate shipping. The shipping methods shown might be incomplete.</string> | |||
<string name="orderdetail_issue_refund_button">Issue refund</string> | |||
<string name="orderdetail_collect_payment_button">Collect Payment</string> | |||
<string name="orderdetail_products_more_button">Create new shipping label</string> |
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.
np, I think in our last session we were planning to rename this string resource to something more meaningful, and that this was temporary 🤔, can you please rename it to something like orderdetail_products_recreate_label_button
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 reminding me! I missed this part.
<ToggleButton | ||
android:id="@+id/shippingLabelList_countExpander" | ||
style="@style/Woo.Card.ExpanderButton" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingTop="@dimen/major_85" | ||
android:paddingBottom="@dimen/major_85" /> |
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.
I don't think we can use the style Woo.Card.ExpanderButton
here, as the arrow image there uses a smaller size 12dp, while in the designs we have 24dp, and also the color is different.
I think you can achieve similar effect using the same technique as the button shippingLabelItem_viewMoreButtonTitle
below, and with more customizability.
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.
Nice attention to details, I didn't realize the button size and behavior are different. I've refactored this to be something similar to shippingLabelItem_viewMoreButtonTitle
instead.
Refer to https://softwareengineering.stackexchange.com/a/16530 for more discussions, concluding that putting things in-line with the "if"/"else" statement is better.
It should now match the "Show Shipment Details" toggle as well.
Thanks for your feedbacks @hichamboushaba . This is now ready for another review. |
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.
Really good job @hafizrahman, looks good to me
To fix #3856
What this PR does
Allow user to re-purchase Shipping Label on the same Order, and modify the Order Details screen's design to accommodate it.
Testing Instructions
Prepare two Orders: one with no Shipping Labels created yet (but eligible for creation), and one with Shipping Labels already created.
1. Order with no Shipping Label
2. Order with One Shipping Label
Update release notes:
RELEASE-NOTES.txt
if necessary.