Skip to content

Commit

Permalink
82 Adding custom confirmation view to login screen
Browse files Browse the repository at this point in the history
  • Loading branch information
alexxk2 committed Jun 6, 2024
1 parent 982a88e commit 20d15bf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ 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)
Expand Down Expand Up @@ -118,7 +110,6 @@ 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class LoginViewModel @Inject constructor(

val result = loginInteractor.confirmLoginByEmailWithCode(
Email(emailInput),
ConfirmCode(confirmationCode.toString())
ConfirmCode(confirmationCode)
)

when (result) {
Expand Down Expand Up @@ -353,15 +353,6 @@ class LoginViewModel @Inject constructor(
result.error.lockDuration / DURATION_CONVERTING_CONST

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 {
Expand Down
61 changes: 21 additions & 40 deletions app/src/main/res/layout/fragment_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +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"
tools:visibility="gone"
android:visibility="visible">
android:visibility="visible"
tools:visibility="gone">

<TextView
android:id="@+id/tv_enter_email"
Expand Down Expand Up @@ -93,8 +93,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/login_screen_edit_text_top_margin"
app:helperTextTextColor="@color/subcolor_2"
app:helperTextTextAppearance="@style/Widget.CashAdvisor.Text.Subtext"
app:helperTextTextColor="@color/subcolor_2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_enter_password">
Expand Down Expand Up @@ -126,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" />

<TextView
android:id="@+id/tv_forget_password"
Expand Down Expand Up @@ -166,51 +166,32 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/ti_confirmation_code"
style="@style/TextInputLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/login_screen_edit_text_top_margin"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_enter_confirmation_code">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_confirmation_code"
style="@style/EditText"
android:inputType="number"
android:maxLength="4"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>

<app.cashadvisor.customView.CodeConfirmationView
android:id="@+id/code_confirmation_view"
android:layout_width="0dp"
app:codeLength="4"
app:symbolFont="@font/gilroysemibold"
app:symbolHeight="50dp"
app:symbolTextColor="@color/black"
app:symbolsSpacing="60dp"

android:gravity="center"
app:borderColor="@color/subcolour2"
app:borderWidth="2dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:symbolHeight="40dp"
app:symbolWidth="75dp"
app:symbolsSpacing="0dp"
app:backgroundColour="@color/bg1"
app:backgroundCornerRadius="12dp"
app:borderColor="@color/subcolour2"
app:borderWidth="2dp"
app:codeLength="4"
android:layout_marginTop="5dp"
app:layout_constraintEnd_toEndOf="parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_enter_confirmation_code"/>
app:layout_constraintTop_toBottomOf="@id/tv_enter_confirmation_code"
app:symbolFont="@font/gilroysemibold"
app:symbolTextColor="@color/black"
/>


<TextView
android:id="@+id/tv_send_again"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/login_screen_btn_send_again_top_margin"
android:layout_marginTop="85dp"
android:paddingVertical="@dimen/login_screen_text_input_vertical_padding"
android:text="@string/send_confirmation_code_again"
android:textAlignment="center"
Expand All @@ -220,7 +201,7 @@
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ti_confirmation_code" />
app:layout_constraintTop_toBottomOf="@id/tv_enter_confirmation_code" />

<TextView
android:id="@+id/tv_cant_get_code"
Expand Down

0 comments on commit 20d15bf

Please sign in to comment.