private fun updateCountryList(countrySelected: Int) { _uiState.value = uiState.value.copy( addressFields = uiState.value.addressFields.copy( selectedCountry = uiState.value.addressFields.selectedCountry.copy( value = uiState.value.countryOptions[countrySelected].name ), selectedIso2Code = uiState.value.countryOptions[countrySelected].isoA2Code, selectedIso3Code = uiState.value.countryOptions[countrySelected].isoA3Code ), stateList = uiState.value.countryOptions[countrySelected].states?: listOf() ) if (uiState.value.countryOptions[countrySelected].isoA2Code.equals("US",ignoreCase = true)) { _uiState.value = uiState.value.copy( isZipCodeVerificationRequired = true ) } else { _uiState.value = uiState.value.copy( isZipCodeVerificationRequired = false ) } }
This method saves the selected country in the view-state and also updates the state list to be shown in the State dropdown menu