From 1cbb5e0bf0130d602005a9e3e8cd435ccf5b367d Mon Sep 17 00:00:00 2001 From: arinming Date: Thu, 23 May 2024 22:21:26 +0900 Subject: [PATCH] =?UTF-8?q?[Refactor]=20string=20=EB=A6=AC=EC=86=8C?= =?UTF-8?q?=EC=8A=A4=20=EC=B6=94=EA=B0=80,=20toast=20message=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=20=EC=88=98=EC=A0=95=20(#10)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sopt/now/ui/signUp/SignUpActivity.kt | 13 +++++-------- app/src/main/res/values/strings.xml | 3 +++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/sopt/now/ui/signUp/SignUpActivity.kt b/app/src/main/java/com/sopt/now/ui/signUp/SignUpActivity.kt index d86a6a1..1cdbbd4 100644 --- a/app/src/main/java/com/sopt/now/ui/signUp/SignUpActivity.kt +++ b/app/src/main/java/com/sopt/now/ui/signUp/SignUpActivity.kt @@ -9,6 +9,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle +import com.sopt.now.R import com.sopt.now.data.model.RequestSignUpDto import com.sopt.now.databinding.ActivitySignUpBinding import com.sopt.now.ui.signUp.viewModel.SignUpViewModel @@ -41,7 +42,7 @@ class SignUpActivity : AppCompatActivity() { binding.btnSignUp.setOnClickListener { when { isInputValid() -> viewModel.signUp(getSignUpRequestDto()) - else -> showToastMessage("모든 정보를 입력해주세요.") + else -> showToastMessage(R.string.toast_sign_up_fail) } } } @@ -51,7 +52,6 @@ class SignUpActivity : AppCompatActivity() { repeatOnLifecycle(Lifecycle.State.STARTED) { viewModel.signUpState.collect { signUpState -> if (signUpState.message.isNotBlank()) { - showToastMessage(signUpState.message) if (signUpState.isSuccess) { handleValidInput() } @@ -86,9 +86,6 @@ class SignUpActivity : AppCompatActivity() { private fun isPwValid(): Boolean { val pwText = binding.edtSignUpPw.text.toString() return pwText.isNotBlank() && pwText.length >= MIN_LENGTH_PASSWORD - && Regex("^(?=.*[A-Za-z])(?=.*[0-9])(?=.*[\$@!%*#?&.])[A-Za-z[0-9]\$@!%*#?&.]{8,20}\$").matches( - pwText - ) } private fun isNicknameValid(): Boolean { @@ -98,15 +95,15 @@ class SignUpActivity : AppCompatActivity() { private fun isPhoneNumberValid(): Boolean { val phoneNumberText = binding.edtSignUpPhoneNumber.text.toString() - return phoneNumberText.isNotBlank() && Regex("^010-\\d{4}-\\d{4}\$").matches(phoneNumberText) + return phoneNumberText.isNotBlank() } private fun handleValidInput() { - showToastMessage("회원가입이 완료되었습니다.") + showToastMessage(R.string.toast_sign_up_success) finish() } - private fun showToastMessage(text: String) { + private fun showToastMessage(text: Int) { Toast.makeText(this, text, Toast.LENGTH_SHORT).show() } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index adf55e4..e270d75 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -26,4 +26,7 @@ 이름 소개 + + 모든 정보를 입력해주세요. + 회원가입이 완료되었습니다. \ No newline at end of file