Skip to content

Commit

Permalink
[ADD/#15] : show fail id & password
Browse files Browse the repository at this point in the history
  • Loading branch information
Jokwanhee committed Nov 28, 2023
1 parent 1fc9d4d commit 876619b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.os.Bundle
import android.text.Editable
import android.text.InputType
import android.text.TextWatcher
import android.util.Log
import androidx.activity.result.contract.ActivityResultContracts
import androidx.lifecycle.ViewModelProvider
import org.sopt.dosoptkwanheejo.DoSoptApp
Expand All @@ -30,8 +29,7 @@ import org.sopt.dosoptkwanheejo.util.AuthViewModelFactory
import org.sopt.dosoptkwanheejo.util.hideKeyboard
import org.sopt.dosoptkwanheejo.util.showShortSnackBar
import org.sopt.dosoptkwanheejo.util.showShortToastMessage
import org.w3c.dom.Text
import java.util.regex.Pattern
import org.sopt.dosoptkwanheejo.view.SoptEditView

class LoginActivity : BaseActivity<ActivityLoginBinding>(ActivityLoginBinding::inflate) {
private lateinit var loginViewModel: LoginViewModel
Expand Down Expand Up @@ -159,16 +157,29 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>(ActivityLoginBinding::i
}

is RespResult -> {
setCustomEditContent(binding.soptEvId, true)
setCustomEditContent(binding.soptEvPwd, true)
binding.root.showShortSnackBar(it.message)
hideKeyboard(binding.root)
}
}
}
loginViewModel.idFlag.observe(this) {
setCustomEditContent(binding.soptEvId, false)
binding.btLogin.isEnabled = it && loginViewModel.passwordFlag.value == true
}
loginViewModel.passwordFlag.observe(this) {
setCustomEditContent(binding.soptEvPwd, false)
binding.btLogin.isEnabled = it && loginViewModel.idFlag.value == true
}
}

private fun setCustomEditContent(editView: SoptEditView, visible: Boolean) {
editView.isVisibleError(visible)
if (visible) {
editView.setBackgroundTint(R.color.color_f44336)
} else {
editView.setBackgroundTint(R.color.black)
}
}
}
11 changes: 11 additions & 0 deletions app/src/main/java/org/sopt/dosoptkwanheejo/view/SoptEditView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import android.text.TextWatcher
import android.util.AttributeSet
import android.util.TypedValue
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import org.sopt.dosoptkwanheejo.R
import org.sopt.dosoptkwanheejo.databinding.CustomEditViewBinding

Expand Down Expand Up @@ -69,4 +71,13 @@ class SoptEditView @JvmOverloads constructor(
fun addTextChangedListener(textWatcher: TextWatcher) {
binding.etContent.addTextChangedListener(textWatcher)
}

fun setBackgroundTint(color: Int) {
binding.etContent.backgroundTintList =
ContextCompat.getColorStateList(binding.root.context, color)
}

fun isVisibleError(visible: Boolean) {
binding.ivError.isVisible = visible
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_error_ffffff_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-2h2v2zM13,13h-2L11,7h2v6z"/>
</vector>
13 changes: 13 additions & 0 deletions app/src/main/res/layout/custom_edit_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,22 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="20sp"
android:backgroundTint="@color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_title"
tools:hint="aaaaaaaaaaaaaaaaaaa" />

<ImageView
android:id="@+id/iv_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:tint="@color/color_f44336"
android:visibility="invisible"
android:src="@drawable/ic_error_ffffff_24"
android:layout_marginEnd="4dp"
app:layout_constraintBottom_toBottomOf="@id/et_content"
app:layout_constraintEnd_toEndOf="@id/et_content"
app:layout_constraintTop_toTopOf="@id/et_content"/>

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 876619b

Please sign in to comment.