Skip to content
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

[Shipping Labels Revamp] Refactor shipping label notices #13817

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from

Conversation

irfano
Copy link
Contributor

@irfano irfano commented Mar 20, 2025

Description

We currently use different Compose components and management methods for notice banners on the shipping label creation screens. This PR introduces a unified Compose component (NoticeBanner), a single class to manage all banners (ObserveShippingLabelNotice), and includes several fixes.

Steps to reproduce

  1. Go to orders.
  2. Create a new order.
  3. Tap the created order item to go to the detail.
  4. Tap the "Create shipping label" button.
  5. To edit addresses, tap the "Shipment details" button.

Testing information

Unverified Origin

I don't know how to reproduce this scenario.

Missing destination

When creating an order, leave the first name, last name, and company fields empty. Feel free to test various combinations.

Unverified destination

Fill in the shipping address, but intentionally use incorrect details, such as an invalid postal code.

Verified destination

After reproducing the missing or unverified destination scenario, enter a valid address and tap the Validate & Save button.

Missing ITN

Create an order valued above $2,500. Ensure the shipping address country is different from the store address. I used TR as the shipping country, but the ITN requirement logic is still a work in progress, so I’m not certain about it. If the origin and destination addresses are valid but customs information is missing, you’ll see the corresponding notice.

The tests that have been performed

Steps above

Images/gif

This video demonstrates three notice types within a single flow: Missing Destination, Verified Destination, and Missing ITN. It also shows how the Verified Destination notice is automatically dismissed after two seconds, followed by the ITN notice being displayed.

after.webm
  • I have considered if this change warrants release notes and have added them to 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:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

@irfano irfano added type: enhancement A request for an enhancement. feature: shipping labels Related to creating, ordering, or printing shipping labels. labels Mar 20, 2025
@irfano irfano added this to the 22.1 milestone Mar 20, 2025
@dangermattic
Copy link
Collaborator

dangermattic commented Mar 20, 2025

1 Warning
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit50e67e5
Direct Downloadwoocommerce-wear-prototype-build-pr13817-50e67e5.apk

@wpmobilebot
Copy link
Collaborator

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit50e67e5
Direct Downloadwoocommerce-prototype-build-pr13817-50e67e5.apk

@codecov-commenter
Copy link

codecov-commenter commented Mar 20, 2025

Codecov Report

Attention: Patch coverage is 56.02410% with 73 lines in your changes missing coverage. Please review.

Project coverage is 38.09%. Comparing base (bd92d40) to head (50e67e5).

Files with missing lines Patch % Lines
...rders/wooshippinglabels/components/NoticeBanner.kt 0.00% 54 Missing ⚠️
...ippinglabels/address/ObserveShippingLabelNotice.kt 88.31% 0 Missing and 9 partials ⚠️
...hippinglabels/WooShippingLabelCreationViewModel.kt 55.55% 7 Missing and 1 partial ⚠️
...oid/ui/orders/wooshippinglabels/ShipmentDetails.kt 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #13817      +/-   ##
============================================
+ Coverage     38.04%   38.09%   +0.04%     
- Complexity     9221     9231      +10     
============================================
  Files          2074     2076       +2     
  Lines        114424   114394      -30     
  Branches      14563    14558       -5     
============================================
+ Hits          43535    43579      +44     
+ Misses        66939    66861      -78     
- Partials       3950     3954       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@irfano irfano marked this pull request as ready for review March 20, 2025 21:25
Comment on lines -131 to +116
ShippingAddressNotification(
addressNotification = addressNotification,
onDismiss = onDismissAddressNotification,
onAction = {
addressNotification?.let {
when {
it.isSuccess.not() && it.isDestinationNotification -> {
onEditDestinationAddress(shippingAddresses.shipTo)
}
it.isSuccess.not() && it.isDestinationNotification.not() -> {
onEditOriginAddress(shippingAddresses.shipFrom)
}
}
}
}
)
ItnMissingNotification(itnNotification)
NoticeBanner(noticeBannerUiState)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll use NoticeBanner for all notice types.

Comment on lines -170 to -172
fun onDismissAddressNotification() {
uiState.update { it.copy(addressNotification = null) }
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ObserveShippingLabelNotice class manages notice dismissal events, so it's removed from the viewmodel.

Comment on lines -137 to -142
it.isSuccess.not() && it.isDestinationNotification -> {
onEditDestinationAddress(shippingAddresses.shipTo)
}
it.isSuccess.not() && it.isDestinationNotification.not() -> {
onEditOriginAddress(shippingAddresses.shipFrom)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This onAction logic has been moved into the view model.

Comment on lines -377 to -382
itnNotification = takeIf { isItnMissing }?.let {
ItnMissingNotification(
errorMessage = stringResource(R.string.woo_shipping_labels_customs_itn_required_error),
onErrorDismissed = onDismissItnNotice
)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic has been moved into the ObserveShippingLabelNotice class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed “notification” to “notice” to prevent confusion with Android system notifications.

Comment on lines +40 to +46
if (state.autoDismiss) {
// Dismiss the notice after AUTO_DISMISS_TIME passes
coroutineScope.launch {
delay(AUTO_DISMISS_TIME)
onDismissed(noticeType).invoke()
}
}
Copy link
Contributor Author

@irfano irfano Mar 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The auto-dismiss feature is managed exclusively here. After 2 seconds, we invoke onDismissed(), which updates the isDismissedFlow. Note the presence of isDismissedFlow in the combine parameters: whenever isDismissedFlow is updated, this transform block runs again. As a result, the new noticeBannerUiState becomes null, and the banner is removed from Compose.

Comment on lines +38 to +42
enter = fadeIn(
animationSpec = tween(durationMillis = 180)
) + scaleIn(
animationSpec = tween(durationMillis = 180)
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve removed the exit animation previously used in the current Compose implementation. The exit animation was already broken due to the line:

if (noticeBannerUiState == null) return@AnimatedVisibility

Implementing the exit animation properly requires additional development since we can’t manage the animation’s visible property based solely on the state’s nullability. The state must persist throughout the animation. This means we’ll need a new parameter to control the exit animation separately.
This PR is already large. If you think there’s value in addressing the animation issue, I can create a separate PR to handle it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The colors varied across different notices. I’ve updated them to match the colors specified in Figma.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve updated the red and green colors to align with the latest version from https://color-studio.blog/. While this update affects the entire app, the impact should be minimal since the adjustments are subtle.

@@ -725,35 +725,6 @@ class WooShippingLabelCreationViewModelTest : BaseUnitTest() {
assertThat(dataState.customsState).isEqualTo(CustomsState.ItnMissing)
}

@Test
fun `ItnMissing is dismissed when onDismissItnNotice is called`() = testBlocking {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Managing notice dismissals is now the responsibility of the ObserveShippingLabelNotice class.

@irfano irfano requested review from ThomazFB and atorresveiga March 20, 2025 21:50
}

NoticeType.MISSING_ITN -> {
onEditCustomsClick()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This behavior was introduced in this PR. Tapping the missing ITN notice will open the Edit Customs screen.

Comment on lines -484 to -486
fun onDismissItnNotice() {
customsState.value = Unavailable
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer need to set the customsState to Unavailable, as the visibility of banners is now managed by noticeBannersUiState.

@irfano irfano changed the title Refactor shipping label notices [Shipping Labels Revamp] Refactor shipping label notices Mar 20, 2025
@irfano
Copy link
Contributor Author

irfano commented Mar 21, 2025

@coderabbitai review

Copy link

coderabbitai bot commented Mar 21, 2025

📝 Walkthrough

Walkthrough

This pull request refactors the notification handling within the shipping label screens of the WooCommerce Android app. The previous approach using separate notification components and logic (e.g., ShippingAddressNotification, ItnMissingNotification, and GetAddressNotification) has been replaced by a unified notice system. The changes span UI composables, view models, tests, and color resources. New classes such as ObserveShippingLabelNotice, NoticeBanner, and NoticeBannerUiState have been introduced, while obsolete files and parameters have been removed to simplify the overall notification logic.

Changes

File(s) Change Summary
.../wooshippinglabels/ShipmentDetails.kt Removed ShippingAddressNotification and ItnMissingNotification components and related parameters; added noticeBannerUiState parameter; removed associated animations, logic, and the ItnMissingNotification data class.
.../wooshippinglabels/WooShippingLabelCreationScreen.kt and
.../wooshippinglabels/purchased/WooShippingLabelPurchasedScreen.kt
Removed parameters related to address and ITN notifications (e.g., onDismissAddressNotification, onDismissItnNotice, onEditOriginAddress); updated composable calls to reference uiState.noticeBannerUiState instead of legacy notification components.
.../wooshippinglabels/WooShippingLabelCreationViewModel.kt and
.../wooshippinglabels/WooShippingLabelCreationViewModelTest.kt
Replaced the observeNotifications method with a new observeNotices method; renamed getAddressNotification to observeShippingLabelNotice; updated the UIControlsState to use noticeBannerUiState; adjusted tests to assert new notice logic.
.../wooshippinglabels/address/GetAddressNotification.kt and
.../wooshippinglabels/address/GetAddressNotificationTests.kt
Removed the GetAddressNotification class and its associated data class and test file that previously handled shipping address validations and notifications.
.../wooshippinglabels/address/ObserveShippingLabelNotice.kt Added new class ObserveShippingLabelNotice to combine shipping address and customs state flows, determine notice types, and generate corresponding NoticeBannerUiState objects; introduced constant AUTO_DISMISS_TIME for auto-dismiss behavior.
.../wooshippinglabels/components/NoticeBanner.kt and
.../wooshippinglabels/components/NoticeBannerUiState.kt
Introduced the NoticeBanner composable to display notices using noticeBannerUiState with animations and adaptive UI; created NoticeBannerUiState data class and NoticeType enum to encapsulate banner properties.
.../res/values/colors_base.xml and
.../res/values/wc_colors_base.xml
Updated shipping label color definitions: changed success and error colors (e.g., from woo_green_50 to woo_green_60, from woo_red_50 to woo_red_60) and error surface colors; added new colors (woo_red_0 and woo_green_60); modified other color values.

Sequence Diagram(s)

sequenceDiagram
    participant UI as "Shipping Label Screen"
    participant VM as "WooShippingLabelCreationViewModel"
    participant NoticeObserver as "ObserveShippingLabelNotice"
    participant Banner as "NoticeBanner Component"

    UI->>VM: Initialize screen & subscribe to notices
    VM->>NoticeObserver: invoke observeNotices()
    NoticeObserver-->>VM: Emit NoticeBannerUiState
    VM->>UI: Update UI state with noticeBannerUiState
    UI->>Banner: Render NoticeBanner(noticeBannerUiState)
    Banner-->>UI: Handle user tap/dismiss events (if any)
Loading

Suggested labels

category: tooling, category: unit tests

Suggested reviewers

  • atorresveiga
  • AnirudhBhat

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (9)
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/components/NoticeBanner.kt (3)

34-44: Optimize visibility check logic.

The current implementation has a redundant null check after the AnimatedVisibility check. The early return after already checking visibility based on nullability creates unnecessary complexity.

@Composable
fun NoticeBanner(noticeBannerUiState: NoticeBannerUiState?, modifier: Modifier = Modifier) {
    AnimatedVisibility(
        visible = noticeBannerUiState != null,
        enter = fadeIn(
            animationSpec = tween(durationMillis = 180)
        ) + scaleIn(
            animationSpec = tween(durationMillis = 180)
        )
    ) {
-        if (noticeBannerUiState == null) return@AnimatedVisibility
+        noticeBannerUiState?.let {
            // Move the rest of the content here with "it" as the state reference
            // or continue with noticeBannerUiState as non-null
        }

86-90: Add content description for accessibility.

The icon is missing a content description, which affects screen reader accessibility.

Icon(
    imageVector = icon,
    tint = colorResource(color),
-    contentDescription = null
+    contentDescription = stringResource(
+        if (noticeBannerUiState.error) 
+            R.string.error 
+        else 
+            R.string.success
+    )
)

98-104: Add content description for close button.

The close icon is missing a content description, which affects screen reader accessibility.

Icon(
    imageVector = Icons.Outlined.Close,
    tint = colorResource(color),
-    contentDescription = null,
+    contentDescription = stringResource(R.string.dismiss),
    modifier = Modifier.clickable { noticeBannerUiState.onDismissed?.invoke() }
)
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/address/ObserveShippingLabelNotice.kt (4)

24-27: Encapsulate concurrency interactions with state flows.
By maintaining previousNotice and relying on isDismissedFlow, there's a chance multiple notices might overlap if a new notice is triggered within the auto-dismiss delay. Consider canceling or overriding the dismissal coroutine for the previous notice, if a new one is triggered, to prevent inconsistent UI states.


50-85: Consider reducing cyclomatic complexity in getNoticeType().
Although the logic is clear, the multiple clauses in this when statement may benefit from splitting them into smaller guard functions or refactoring to enhance readability and maintainability.


137-139: Validate concurrency in onDismissed().
The onDismissed lambda updates the state to mark the given noticeType as dismissed. This is fine for simple flows, but if multiple notices need to be dismissed simultaneously, you might want to ensure no race conditions exist.

Would you like guidance on concurrency testing strategies?


142-143: Reconsider the auto-dismiss duration.
AUTO_DISMISS_TIME is set to 2 seconds. Depending on user feedback, a slightly longer duration (like 3-5 seconds) might be more user-friendly, giving them appropriate time to read the notice.

WooCommerce/src/main/res/values/wc_colors_base.xml (1)

54-56: Updated woo_green_0, woo_green_5, and woo_green_10.
The adjusted shades align with a more subdued green palette. Confirm that existing UI elements relying on these values still meet accessibility requirements (e.g., contrast ratio).

Would you like help checking color usage for adequate contrast?

🧰 Tools
🪛 GitHub Check: Android Lint

[warning] 55-55: Unused resources
The resource R.color.woo_green_10 appears to be unused

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/address/ObserveShippingLabelNoticeTests.kt (1)

1-165: Well-structured test class with comprehensive coverage.

This test class thoroughly validates the different notification scenarios handled by the ObserveShippingLabelNotice class. The tests cover all the important cases including:

  • No issues
  • Verified addresses (both origin and destination)
  • Unverified addresses
  • Missing addresses
  • Multiple issues and their resolution flow
  • ITN notifications
  • Notification dismissal

The usage of TestScope for testing coroutines is appropriate, and the assertions verify the correct notification types are displayed.

The constant AUTO_DISMISS_TIME is used on line 137 but isn't defined in this file. Consider either importing it from the component under test or defining it locally as a companion object.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bd92d40 and 50e67e5.

📒 Files selected for processing (13)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/ShipmentDetails.kt (3 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/WooShippingLabelCreationScreen.kt (2 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/WooShippingLabelCreationViewModel.kt (6 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/address/GetAddressNotification.kt (0 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/address/ObserveShippingLabelNotice.kt (1 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/components/NoticeBanner.kt (1 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/components/NoticeBannerUiState.kt (1 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/purchased/WooShippingLabelPurchasedScreen.kt (0 hunks)
  • WooCommerce/src/main/res/values/colors_base.xml (1 hunks)
  • WooCommerce/src/main/res/values/wc_colors_base.xml (2 hunks)
  • WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/WooShippingLabelCreationViewModelTest.kt (4 hunks)
  • WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/address/GetAddressNotificationTests.kt (0 hunks)
  • WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/address/ObserveShippingLabelNoticeTests.kt (1 hunks)
💤 Files with no reviewable changes (3)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/purchased/WooShippingLabelPurchasedScreen.kt
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/address/GetAddressNotification.kt
  • WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/address/GetAddressNotificationTests.kt
🧰 Additional context used
🪛 GitHub Check: Android Lint
WooCommerce/src/main/res/values/wc_colors_base.xml

[warning] 23-23: Unused resources
The resource R.color.woo_red_10 appears to be unused


[warning] 55-55: Unused resources
The resource R.color.woo_green_10 appears to be unused

🔇 Additional comments (25)
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/components/NoticeBannerUiState.kt (2)

5-12: Well-structured data class for notice state management.

The NoticeBannerUiState data class is well-designed with all necessary properties to represent a notice banner's state, including message content, type, auto-dismiss behavior, error status, and callback handlers for interactions.


14-21: Good enumeration of notice types.

The NoticeType enum effectively categorizes the different types of notices related to shipping labels, making the code more maintainable and easier to understand.

WooCommerce/src/main/res/values/colors_base.xml (2)

335-335: Color update matches Figma specifications.

The success label color has been updated from woo_green_50 to woo_green_60 to match the design system in Figma.


337-338: Error color updates align with design guidelines.

The error label and surface colors have been updated to match the Figma specifications, improving visual consistency across the app.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/ShipmentDetails.kt (3)

56-57: Appropriate imports for the new notice banner components.

The imports for NoticeBanner and NoticeBannerUiState are correctly added to support the new unified notification system.


72-72: Function parameter updated to support the unified notice system.

The noticeBannerUiState parameter correctly replaces the previous notification parameters, supporting the PR's objective of unifying notice management.


116-116: Successfully integrated the unified notice banner.

The implementation correctly uses the new NoticeBanner component, replacing the previous separate notification components. This aligns with the goal of simplifying notification management across the app.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/address/ObserveShippingLabelNotice.kt (2)

28-48: Validate auto-dismiss for newly triggered notices.
When a notice has autoDismiss = true, you launch a delay of AUTO_DISMISS_TIME. Ensure that if a higher-priority notice arrives during that interval, the system properly dismisses the older notice or cancels its coroutine. This helps prevent UI flicker or confusion if multiple notices appear in quick succession.

Would you like a script to search if callers cancel or override the old coroutine?


87-135: Centralize textual messages in getNoticeBannerUiState().
Defining the UI text in one place is good practice. However, if new notices or message variations are introduced, consider using localized resource references in a single map or table for easier extension and testing.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/WooShippingLabelCreationScreen.kt (2)

317-317: Ensure bottom sheet peek height covers new notice banners.
Using uiState.noticeBannerUiState != null in requiresLargePeekHeight is a neat solution to ensure the bottom sheet accommodates the new banners. This looks correct and aligns well with the new unified notice system.


365-365: Good integration of noticeBannerUiState.
Passing uiState.noticeBannerUiState to the ShipmentDetails ensures the new NoticeBanner is displayed within the bottom sheet. This unification of notice logic is straightforward and more maintainable compared to the previous separate notification approach.

WooCommerce/src/main/res/values/wc_colors_base.xml (3)

22-22: New color definition woo_red_0.
Adding #F7EBEC helps achieve a lighter variant of red for subtle error surfaces or backgrounds. Make sure it's consistently used wherever light error tones are required.


24-24: Unused resource warning for woo_red_10.
Static analysis suggests this color might be unused. Verify its usage in layouts or themes. If truly unused, consider removing it to keep the resource set clean.

Would you like a script to scan the codebase for R.color.woo_red_10 references?


59-59: Added woo_green_60 to enrich your green palette.
Defining #007017 provides a darker, more intense shade of green suitable for text or accenting success states. This is consistent with the updated palette.

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/WooShippingLabelCreationViewModelTest.kt (5)

19-23: Appropriate imports for the new notice system.

The imports have been properly updated to use the new unified notice components.


238-238: Renamed mock to match new component.

Good renaming from getAddressNotification to observeShippingLabelNotice, maintaining consistency with the new architecture.


256-256: Updated constructor parameter with the new notice component.

The ViewModel constructor now correctly uses the new observeShippingLabelNotice component.


957-977: Test updated to verify notice display.

This test correctly verifies that notices from ObserveShippingLabelNotice are now displayed in the UI state's noticeBannerUiState.


980-996: Added test for when no notices are present.

Good addition of a test to verify the null case, ensuring the UI correctly handles when no notices should be displayed.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/WooShippingLabelCreationViewModel.kt (6)

24-29: Updated imports for the new notice system.

Appropriate imports for the unified notification system.


85-85: Updated constructor with the new notice component.

The ViewModel constructor now correctly includes the observeShippingLabelNotice dependency.


145-145: Updated initialization to observe notices.

The initialization block now launches the observeNotices() method to handle notifications in the unified way.


157-183: Well-implemented notice handling with appropriate actions.

The observeNotices() method provides a clean implementation of the new notification system:

  1. It uses observeShippingLabelNotice to collect notice information
  2. Updates the UI state with the notice banner
  3. Implements type-specific actions when notices are tapped:
    • For unverified origin address → opens origin address editor
    • For missing/unverified destination address → opens destination address editor
    • For missing ITN → opens customs editor

This approach simplifies notification management by centralizing it in a single component.


589-591: Added method for split shipment functionality.

New onSplitShipment() method correctly triggers the StartSplitShipment event.


762-762: Updated UIControlsState to use the new notice system.

The UIControlsState data class now includes noticeBannerUiState instead of the previous notification system, completing the refactoring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: shipping labels Related to creating, ordering, or printing shipping labels. type: enhancement A request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants