diff --git a/app/src/main/java/org/sopt/dosoptkwanheejo/presentation/login/LoginActivity.kt b/app/src/main/java/org/sopt/dosoptkwanheejo/presentation/login/LoginActivity.kt index ea803b2..a2cc6ae 100644 --- a/app/src/main/java/org/sopt/dosoptkwanheejo/presentation/login/LoginActivity.kt +++ b/app/src/main/java/org/sopt/dosoptkwanheejo/presentation/login/LoginActivity.kt @@ -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 @@ -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::inflate) { private lateinit var loginViewModel: LoginViewModel @@ -159,16 +157,29 @@ class LoginActivity : BaseActivity(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) + } + } } \ No newline at end of file diff --git a/app/src/main/java/org/sopt/dosoptkwanheejo/view/SoptEditView.kt b/app/src/main/java/org/sopt/dosoptkwanheejo/view/SoptEditView.kt index 7620d5f..2774e00 100644 --- a/app/src/main/java/org/sopt/dosoptkwanheejo/view/SoptEditView.kt +++ b/app/src/main/java/org/sopt/dosoptkwanheejo/view/SoptEditView.kt @@ -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 @@ -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 + } } diff --git a/app/src/main/res/drawable/ic_error_ffffff_24.xml b/app/src/main/res/drawable/ic_error_ffffff_24.xml new file mode 100644 index 0000000..1757571 --- /dev/null +++ b/app/src/main/res/drawable/ic_error_ffffff_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/custom_edit_view.xml b/app/src/main/res/layout/custom_edit_view.xml index 2c3c53a..e8c8ec9 100644 --- a/app/src/main/res/layout/custom_edit_view.xml +++ b/app/src/main/res/layout/custom_edit_view.xml @@ -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" /> + + \ No newline at end of file