fun handleRegistrationScreenEvent(registrationScreenEvent: RegistrationScreenEvent) { when(registrationScreenEvent) { is RegistrationScreenEvent.TouClicked -> { _uiState.value = uiState.value.copy( isTouChecked = registrationScreenEvent.checked, displayTouError = false ) } is RegistrationScreenEvent.PrivacyStatementClicked -> { _uiState.value = uiState.value.copy( isPrivacyStatementChecked = registrationScreenEvent.checked, displayPrivacyStatementError = false ) } is RegistrationScreenEvent.NextClicked -> { navigateToNextScreen(registrationScreenEvent.registrationScreenType) } is RegistrationScreenEvent.SignInClicked -> {  } is RegistrationScreenEvent.ShowError -> { val pError = uiState.value.privacyStatementVisible && !uiState.value.isPrivacyStatementChecked val tError = uiState.value.touVisible && !uiState.value.isTouChecked _uiState.value = uiState.value.copy( displayPrivacyStatementError = pError, displayTouError = tError ) } is RegistrationScreenEvent.CompanyNameUpdated -> { setCompanyName(registrationScreenEvent.name) } is RegistrationScreenEvent.AddressFieldsUpdated -> { setAddress( address1 = registrationScreenEvent.address1, address2 = registrationScreenEvent.address2, address3 = registrationScreenEvent.address3, city = registrationScreenEvent.city, zipcode = registrationScreenEvent.zipCode ) } is RegistrationScreenEvent.CountrySelected -> { updateCountryList(registrationScreenEvent.index) } is RegistrationScreenEvent.StateSelected -> { saveSelectedState(registrationScreenEvent.index) } is RegistrationScreenEvent.RecommendationSelected -> { _uiState.value = uiState.value.copy( isRecommendedSelected = registrationScreenEvent.isSelected ) } is RegistrationScreenEvent.RecommendationConfirmed -> { _uiState.value = uiState.value.copy( recommendedScreenSeen = true ) navigateToNextScreen(RegistrationScreenType.CompanyInformationScreen()) } is RegistrationScreenEvent.EmailChanged -> { setEmail(registrationScreenEvent.emailAddress) } is RegistrationScreenEvent.PasswordChanged -> { setPassword(registrationScreenEvent.password) } is RegistrationScreenEvent.ConfirmPasswordChanged -> { setConfirmPassword(registrationScreenEvent.confirmPassword) } is RegistrationScreenEvent.UserEmailAsUsername -> { useEmailAsUserName(registrationScreenEvent.checked) } is RegistrationScreenEvent.UserNameChanged -> { userNameChanged(registrationScreenEvent.userName) } is RegistrationScreenEvent.SelectedMatchedResult -> { matchResultSelected(registrationScreenEvent.result) } is RegistrationScreenEvent.ContinueNewAccountClicked -> { navigateToNextScreen(RegistrationScreenType.UserInformationScreen()) } is RegistrationScreenEvent.UserNameUpdated -> { yourNameUpdated(registrationScreenEvent.name) } is RegistrationScreenEvent.UserPhoneUpdated -> { userPhoneUpdated(registrationScreenEvent.number) } is RegistrationScreenEvent.SendEmailClicked -> { sendEmailClicked() } is RegistrationScreenEvent.UserMessageUpdated -> { userMessageUpdated(registrationScreenEvent.message) } is RegistrationScreenEvent.DifferentAccount -> { viewModelScope.launch(Dispatchers.Main) { navigationEvent.emit(RegistrationNavigationEvent.OpenAccountReviewScreen) } } is RegistrationScreenEvent.ContinueNewAccount -> { viewModelScope.launch(Dispatchers.Main) { navigationEvent.emit(RegistrationNavigationEvent.OpenAccountInformationScreen) } } is RegistrationScreenEvent.FirstNameUpdated -> { setFirstName(registrationScreenEvent.firstName) } is RegistrationScreenEvent.LastNameUpdated -> { setLastName(registrationScreenEvent.lastName) } is RegistrationScreenEvent.BusinessRoleUpdated -> { setBusinessRole(registrationScreenEvent.businessRole) } is RegistrationScreenEvent.OtherBusinessRoleUpdated -> { setOtherBusinessRole(registrationScreenEvent.otherBusinessRole) } } }
@param registrationScreenEvent - [RegistrationScreenEvent] is a class which holds multiple Events types from UI to ViewModel This method helps in communicating the UI events from Registration Screen and ViewModel. Any future Event that is added needs to be added in the as well.