diff --git a/app/src/main/java/app/cashadvisor/authorization/presentation/ui/LoginFragment.kt b/app/src/main/java/app/cashadvisor/authorization/presentation/ui/LoginFragment.kt index 8348269..3862cac 100644 --- a/app/src/main/java/app/cashadvisor/authorization/presentation/ui/LoginFragment.kt +++ b/app/src/main/java/app/cashadvisor/authorization/presentation/ui/LoginFragment.kt @@ -63,11 +63,9 @@ class LoginFragment : //navigation to support screen. It`s not exist yet } - etConfirmationCode.addTextChangedListener { - it?.let { code -> - if (code.length == 4) { - viewModel.confirmLoginUsingCode(requireContext(), code) - } + codeConfirmationView.setCallback { + if (it.length == 4) { + viewModel.confirmLoginUsingCode(requireContext(), it) } } @@ -112,7 +110,7 @@ class LoginFragment : tvSubtitle.text = getString(R.string.enter_account_data) clLoginForms.visibility = View.VISIBLE clConfirmationCode.visibility = View.GONE - etConfirmationCode.text?.clear() + codeConfirmationView.setCode("") btnLogin.isEnabled = state.isBtnLoginEnabled manageEmailValidation(state.emailState) @@ -266,14 +264,14 @@ class LoginFragment : is LoginScreenMessageContent.ConfirmationCodeMessage -> { showSnackbar( content.message, - etConfirmationCode + codeConfirmationView ) } } } } - private fun showSnackbar(message: String, viewToFocus: TextInputEditText) { + private fun showSnackbar(message: String, viewToFocus: View) { hideKeyboard() Snackbar.make(binding.root, message, SNACKBAR_DURATION) .setBackgroundTint(resources.getColor(R.color.black, null)) diff --git a/app/src/main/java/app/cashadvisor/authorization/presentation/viewmodel/LoginViewModel.kt b/app/src/main/java/app/cashadvisor/authorization/presentation/viewmodel/LoginViewModel.kt index 47baed8..0c4a00d 100644 --- a/app/src/main/java/app/cashadvisor/authorization/presentation/viewmodel/LoginViewModel.kt +++ b/app/src/main/java/app/cashadvisor/authorization/presentation/viewmodel/LoginViewModel.kt @@ -320,12 +320,12 @@ class LoginViewModel @Inject constructor( } } - fun confirmLoginUsingCode(context: Context, confirmationCode: Editable?) { + fun confirmLoginUsingCode(context: Context, confirmationCode: String) { viewModelScope.launch(Dispatchers.IO) { val result = loginInteractor.confirmLoginByEmailWithCode( Email(emailInput), - ConfirmCode(confirmationCode.toString()) + ConfirmCode(confirmationCode) ) when (result) { @@ -387,15 +387,6 @@ class LoginViewModel @Inject constructor( result.error.lockDuration if (result.error.lockDuration > 0) { - /*_messageEvent.emit( - LoginScreenMessageContent.ConfirmationCodeMessage( - context.getString( - R.string.wrong_code_number_lock_duration, - getRightEndingMinutes(minutesLeft.toInt()) - ) - ) - )*/ - _sideEffects.emit(LoginScreenSideEffects.FailedToConfirmLogin(getRightEndingMinutes(minutesLeft.toInt()))) } else { diff --git a/app/src/main/res/layout/fragment_login.xml b/app/src/main/res/layout/fragment_login.xml index 01a2cb6..8dee629 100644 --- a/app/src/main/res/layout/fragment_login.xml +++ b/app/src/main/res/layout/fragment_login.xml @@ -44,7 +44,8 @@ android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/login_screen_basic_horizontal_margin" android:layout_marginTop="@dimen/login_screen_forms_top_margin" - android:visibility="visible"> + android:visibility="visible" + tools:visibility="gone"> @@ -125,10 +126,10 @@ android:layout_height="@dimen/login_screen_progress_bar_size" android:indeterminateTint="@color/black" android:visibility="gone" - app:layout_constraintStart_toStartOf="@id/btn_login" + app:layout_constraintBottom_toBottomOf="@id/btn_login" app:layout_constraintEnd_toEndOf="@id/btn_login" - app:layout_constraintTop_toTopOf="@id/btn_login" - app:layout_constraintBottom_toBottomOf="@id/btn_login"/> + app:layout_constraintStart_toStartOf="@id/btn_login" + app:layout_constraintTop_toTopOf="@id/btn_login" /> + tools:visibility="visible"> - - - - + app:layout_constraintTop_toBottomOf="@id/tv_enter_confirmation_code" + app:symbolFont="@font/gilroysemibold" + app:symbolTextColor="@color/black" + /> + app:layout_constraintTop_toBottomOf="@id/tv_enter_confirmation_code" /> 52dp 1dp 80dp + 40dp + 75dp + 2dp 24dp + 85dp 16sp