BillingAddressDetailsScreen is default to make the country valid without checking what country is selected. ie, when the country is INVALID_COUNTRY, the Done button will be enabled if the other required fields are filled.
BillingAddress default the country by calling Locale.getdefault().country which might produce a empty string and thus get the INVALID_COUNTRY
Proposed changes
Default the country in BillingAddress constructor to INVALID_COUNTRY.
Make the country BillingAddressInputComponentState to be invalid if the country is INVALID_COUNTRY.
Add a new flag visitedCountryPicker: MutableStateFlow<Boolean> in PaymentStateManager to track whether the user has visited the CountryPickerScreen. If so and no valid country is chosen then it should display the error message.
Checklist
[x] Reviewers assigned
[x] I have performed a self-review of my code and manual testing
[x] Lint and unit tests pass locally with my changes
[x] I have added tests that prove my fix is effective or that my feature works
Further comments
Not really sure adding the new flag visitedCountryPicker: MutableStateFlow<Boolean> in PaymentStateManager is the best solution but a working one. The main purpose is to have a shared flag between CountryPickerViewModel and CountryViewModel, and determine whether we should show the error message after the picker is visited and non valid country is selected.
Issue
PIMOB-1767 AC2
BillingAddressDetailsScreen
is default to make the country valid without checking what country is selected. ie, when the country isINVALID_COUNTRY
, theDone
button will be enabled if the other required fields are filled.BillingAddress
default the country by callingLocale.getdefault().country
which might produce a empty string and thus get theINVALID_COUNTRY
Proposed changes
BillingAddress
constructor toINVALID_COUNTRY
.BillingAddressInputComponentState
to be invalid if the country isINVALID_COUNTRY
.visitedCountryPicker: MutableStateFlow<Boolean>
inPaymentStateManager
to track whether the user has visited theCountryPickerScreen
. If so and no valid country is chosen then it should display the error message.Checklist
Further comments
visitedCountryPicker: MutableStateFlow<Boolean>
inPaymentStateManager
is the best solution but a working one. The main purpose is to have a shared flag betweenCountryPickerViewModel
andCountryViewModel
, and determine whether we should show the error message after the picker is visited and non valid country is selected.