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] Introduce Customs initial form #13378

Merged
merged 51 commits into from
Feb 3, 2025

Conversation

ThomazFB
Copy link
Contributor

@ThomazFB ThomazFB commented Jan 22, 2025

Why

Partially fix issue #13366 by introducing the initial Customs form connected with the main Shipping Labels creation form.

The data validation and error handling will be delivered in the following PR.

The Product Details section will be delivered through issue #13367.

How

Introduces the ViewModel, Screen, and Fragment set for the Customs form, with the navigation action coming from the Shipping Labels creation form. It also defines the basic UI structure alongside the Content, Restriction, and ITN fields, with proper support for the Other option, opening an additional Text field for additional description.

Unit tests are also added for the ViewModel viewState and events controls.

Screen Capture

Screen_recording_20250130_144547.mp4

How to Test

In case you want to avoid having to fill the address data to access the Customs form, you can simply override the ShouldRequireCustomsForm use case always to return true to trigger the Customs data requirement forcefully.

  1. Open the Shipping Labels Creation form, click the edit button inside the Customs section
  2. Verify all UI options are operational and interactable.

Update release notes:

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

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.

@ThomazFB ThomazFB added type: task An internally driven task. feature: shipping labels Related to creating, ordering, or printing shipping labels. labels Jan 22, 2025
@ThomazFB ThomazFB added this to the 21.5 milestone Jan 22, 2025
@ThomazFB ThomazFB linked an issue Jan 22, 2025 that may be closed by this pull request
@dangermattic
Copy link
Collaborator

dangermattic commented Jan 22, 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

wpmobilebot commented Jan 22, 2025

📲 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
Commitbf4d4de
Direct Downloadwoocommerce-wear-prototype-build-pr13378-bf4d4de.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 22, 2025

📲 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
Commitbf4d4de
Direct Downloadwoocommerce-prototype-build-pr13378-bf4d4de.apk

@ThomazFB ThomazFB changed the base branch from trunk to issue/add-initial-customs-entry-point January 28, 2025 19:38
@codecov-commenter
Copy link

codecov-commenter commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 85.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 41.15%. Comparing base (092eeb8) to head (3fb4558).
Report is 331 commits behind head on trunk.

Files with missing lines Patch % Lines
...glabels/customs/WooShippingCustomsFormViewModel.kt 89.47% 6 Missing ⚠️
...hippinglabels/WooShippingLabelCreationViewModel.kt 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #13378      +/-   ##
============================================
+ Coverage     41.12%   41.15%   +0.03%     
- Complexity     6497     6507      +10     
============================================
  Files          1326     1327       +1     
  Lines         77601    77661      +60     
  Branches      10699    10701       +2     
============================================
+ Hits          31913    31964      +51     
- Misses        42851    42860       +9     
  Partials       2837     2837              

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

@ThomazFB ThomazFB marked this pull request as ready for review January 30, 2025 18:25
@ThomazFB ThomazFB requested a review from atorresveiga January 30, 2025 18:25
@atorresveiga atorresveiga self-assigned this Jan 31, 2025
@wpmobilebot wpmobilebot modified the milestones: 21.6, 21.7 Jan 31, 2025
@wpmobilebot
Copy link
Collaborator

Version 21.6 has now entered code-freeze, so the milestone of this PR has been updated to 21.7.

Base automatically changed from issue/add-initial-customs-entry-point to trunk January 31, 2025 19:32
)
}

is ShowRestrictionTypeDialog -> {
Copy link
Contributor

@atorresveiga atorresveiga Jan 31, 2025

Choose a reason for hiding this comment

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

np: Should we move away from these dialogs and start relying only on Jetpack Compose? Maybe with the use of a Dropdown or a BottomSheet?

This is a np and not a blocker for the PR ☝️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That might be a good idea. I think the best approach would be to adjust this usage on both the Customs and Packages UIs, which are the ones I introduced this old fragment-reliant strategy. Should we add a side nice-to-have task to tackle this improvement as a separate issue? WDYT?


@Composable
fun WooShippingCustomsFormScreen(
modifier: Modifier = Modifier,
Copy link
Contributor

Choose a reason for hiding this comment

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

np: modifier should be the first optional parameter


fun onITNChanged(newItnValue: String) {
_viewState.update {
it.copy(itnValue = newItnValue)
Copy link
Contributor

Choose a reason for hiding this comment

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

From this article, I learned this:

At the moment, it is not recommended to use reactive streams to define the state variable for TextField

That is why I used mutable state for input fields in other screens of the new experience.

That said ☝️ I tested typing new values, and the functionality worked fine, maybe because it is exposed as a livedata

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, very interesting approach. Thanks for sharing @atorresveiga! Yeah, I was always curious if the reactive stream approach wouldn't risk to introduce a circular reference of changes, but the Live Data always took care of avoiding that. I agree that we should adopt this strategy.

In that case, similar to what I said in the previous comment, WDYT if we add a separate task to fix this both on the Customs UI and Packages UI? I believe I can actually fix this for the Customs UI in upcoming PRs since I'm still working on that screen, but I think the Packages part also need a bit of attention since it's also using inputs like this.

Copy link
Contributor

@atorresveiga atorresveiga left a comment

Choose a reason for hiding this comment

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

The code looks nice and is working as expected. I left a couple of minor notes that are not blockers for this PR.

LGTM! :shipit:

@ThomazFB
Copy link
Contributor Author

ThomazFB commented Feb 3, 2025

Thanks for the inputs and review, @atorresveiga! I've replied to your inputs suggesting we to adjust both the TextField reactive approach and adopting the native Compose spinner as fixes for upcoming PRs, since this one is already quite big.

So, to unblock the upcoming PRs, I'll merge this one and ensure that both adjustments are covered 🫡

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.compose.material.Surface

Check warning

Code scanning / Android Lint

material and material3 are separate, incompatible design system libraries Warning

Using a material import while also using the material3 library
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button

Check warning

Code scanning / Android Lint

material and material3 are separate, incompatible design system libraries Warning

Using a material import while also using the material3 library
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button
import androidx.compose.material.Checkbox

Check warning

Code scanning / Android Lint

material and material3 are separate, incompatible design system libraries Warning

Using a material import while also using the material3 library
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button
import androidx.compose.material.Checkbox
import androidx.compose.material.CheckboxDefaults

Check warning

Code scanning / Android Lint

material and material3 are separate, incompatible design system libraries Warning

Using a material import while also using the material3 library
import androidx.compose.material.Button
import androidx.compose.material.Checkbox
import androidx.compose.material.CheckboxDefaults
import androidx.compose.material.MaterialTheme

Check warning

Code scanning / Android Lint

material and material3 are separate, incompatible design system libraries Warning

Using a material import while also using the material3 library
import androidx.compose.material.Checkbox
import androidx.compose.material.CheckboxDefaults
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text

Check warning

Code scanning / Android Lint

material and material3 are separate, incompatible design system libraries Warning

Using a material import while also using the material3 library
@ThomazFB ThomazFB merged commit 8418862 into trunk Feb 3, 2025
15 checks passed
@ThomazFB ThomazFB deleted the issue/introduce-customs-section branch February 3, 2025 20:46
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: task An internally driven task. unit-tests-exemption
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Shipping Labels: Customs] Introduce Customs form main layout
5 participants