From 071fb010b1f58f7d0f14b753e9d309bc2ea6731b Mon Sep 17 00:00:00 2001 From: Junsu Park <101160207+JunJaBoy@users.noreply.github.com> Date: Wed, 13 Mar 2024 08:47:03 +0900 Subject: [PATCH 01/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20CI=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df5237817..841b2f7fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,10 +25,12 @@ jobs: run: | echo $PROD_BASE_URL >> ./local.properties echo $DEV_BASE_URL >> ./local.properties + echo $TERMS_URL >> ./local.properties cat env: PROD_BASE_URL: ${{secrets.PROD_BASE_URL}} DEV_BASE_URL: ${{secrets.DEV_BASE_URL}} + TERMS_URL: ${{secrets.TERMS_URL}} - name: Grant execute permission for gradlew run: chmod +x gradlew From aab5eef443dafd874bd2debe7c301bd127926f7d Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 09:42:38 +0900 Subject: [PATCH 02/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20validator=20?= =?UTF-8?q?=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/validator/build.gradle.kts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shared/validator/build.gradle.kts b/shared/validator/build.gradle.kts index 773bf8ac8..272d4d4ce 100644 --- a/shared/validator/build.gradle.kts +++ b/shared/validator/build.gradle.kts @@ -6,4 +6,8 @@ plugins { java { sourceCompatibility = Versions.java targetCompatibility = Versions.java + + dependencies { + implementation(libs.junit) + } } \ No newline at end of file From a006ed1bf877f9e5ef78e8a8a40e19777d51a0bf Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 10:11:59 +0900 Subject: [PATCH 03/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20validator=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dms/android/shared/validator/AsciiValidator.kt | 7 +------ .../dms/android/shared/validator/EmailValidator.kt | 7 +------ .../aliens/dms/android/shared/validator/IdValidator.kt | 7 +------ .../dms/android/shared/validator/PasswordValidator.kt | 10 +++------- 4 files changed, 6 insertions(+), 25 deletions(-) diff --git a/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/AsciiValidator.kt b/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/AsciiValidator.kt index 290df3607..4752ec02d 100644 --- a/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/AsciiValidator.kt +++ b/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/AsciiValidator.kt @@ -6,12 +6,7 @@ object AsciiValidator : Validator() { override fun validate(value: String): Boolean = value.matches(regex) } -fun checkIfAscii(value: String): Boolean { - if (value.isEmpty()) { - return false - } - return AsciiValidator.validate(value) -} +fun checkIfAscii(value: String): Boolean = AsciiValidator.validate(value) val String.isAscii: Boolean inline get() = AsciiValidator.validate(this) diff --git a/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/EmailValidator.kt b/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/EmailValidator.kt index c58bae990..adc8a8660 100644 --- a/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/EmailValidator.kt +++ b/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/EmailValidator.kt @@ -7,9 +7,4 @@ object EmailValidator : Validator() { override fun validate(value: String): Boolean = value.matches(regex) } -fun checkIfEmailValid(value: String): Boolean { - if (value.isEmpty()) { - return false - } - return EmailValidator.validate(value) -} +fun checkIfEmailValid(value: String): Boolean = EmailValidator.validate(value) diff --git a/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/IdValidator.kt b/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/IdValidator.kt index fb71c9349..a46659430 100644 --- a/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/IdValidator.kt +++ b/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/IdValidator.kt @@ -6,9 +6,4 @@ object IdValidator : Validator() { override fun validate(value: String): Boolean = value.matches(regex) } -fun checkIfIdValid(value: String): Boolean { - if (value.isEmpty()) { - return false - } - return IdValidator.validate(value) -} +fun checkIfIdValid(value: String): Boolean = IdValidator.validate(value) diff --git a/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/PasswordValidator.kt b/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/PasswordValidator.kt index 6eb6be7c4..641666796 100644 --- a/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/PasswordValidator.kt +++ b/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/PasswordValidator.kt @@ -2,14 +2,10 @@ package team.aliens.dms.android.shared.validator object PasswordValidator : Validator() { - override val regex = Regex("^.*(?=^.{8,20}\$)(?=.*\\d)(?=.*[a-zA-Z])(?=.*[!@#\$%^&+=]).*\$") + override val regex = + Regex("(?=.*[a-z])(?=.*[0-9])(?=.*[!#\$%&'()*+,./:;<=>?@\^_`{|}~-])[a-zA-Z0-9!#\$%&'()*+,./:;<=>?@\^_`{|}~-]{8,20}\$") override fun validate(value: String): Boolean = value.matches(regex) } -fun checkIfPasswordValid(value: String): Boolean { - if (value.isEmpty()) { - return false - } - return PasswordValidator.validate(value) -} +fun checkIfPasswordValid(value: String): Boolean = PasswordValidator.validate(value) From 8baa5b090cc32d8a88b47d2bb2cb0b8e4804d0e3 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 10:16:14 +0900 Subject: [PATCH 04/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20Password=20vali?= =?UTF-8?q?dator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../validator/test/PasswordValidatorTest.kt | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 shared/validator/src/test/java/team/aliens/dms/android/shared/validator/test/PasswordValidatorTest.kt diff --git a/shared/validator/src/test/java/team/aliens/dms/android/shared/validator/test/PasswordValidatorTest.kt b/shared/validator/src/test/java/team/aliens/dms/android/shared/validator/test/PasswordValidatorTest.kt new file mode 100644 index 000000000..ac79fbbb1 --- /dev/null +++ b/shared/validator/src/test/java/team/aliens/dms/android/shared/validator/test/PasswordValidatorTest.kt @@ -0,0 +1,58 @@ +package team.aliens.dms.android.shared.validator.test + +import org.junit.Test +import team.aliens.dms.android.shared.validator.PasswordValidator +import team.aliens.dms.android.shared.validator.checkIfPasswordValid + +@Suppress("SimplifyBooleanWithConstants", "LocalVariableName") +class PasswordValidatorTest { + + @Test + fun `Test empty password`() { + val `empty password` = "" + + assert(PasswordValidator.validate(`empty password`) == false) + assert(checkIfPasswordValid(`empty password`) == false) + } + + @Test + fun `Test password with only english digits`() { + val `english only password` = "abcdefgh" + + assert(PasswordValidator.validate(`english only password`) == false) + assert(checkIfPasswordValid(`english only password`) == false) + } + + @Test + fun `Test password with only numbers`() { + val `numbers only password` = "12345678" + + assert(PasswordValidator.validate(`numbers only password`) == false) + assert(checkIfPasswordValid(`numbers only password`) == false) + } + + @Test + fun `Test password under length 8`() { + val `password under length 8` = "abc123!" + + assert(PasswordValidator.validate(`password under length 8`) == false) + assert(checkIfPasswordValid(`password under length 8`) == false) + } + + @Test + fun `Test password over length 20`() { + val `password over length 20` = + "abcd1234" + "abcd1234" + "!!.." + "-" + + assert(PasswordValidator.validate(`password over length 20`) == false) + assert(checkIfPasswordValid(`password over length 20`) == false) + } + + @Test + fun `Test password containing blank`() { + val `password with blank` = "ab d1234!" + + assert(PasswordValidator.validate(`password with blank`) == false) + assert(checkIfPasswordValid(`password with blank`) == false) + } +} From 5879c08ebf7f636965e6366f2a1efd274810a264 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 10:31:02 +0900 Subject: [PATCH 05/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/src/main/res/values/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feature/src/main/res/values/strings.xml b/feature/src/main/res/values/strings.xml index 68643e14b..5fba15ad0 100644 --- a/feature/src/main/res/values/strings.xml +++ b/feature/src/main/res/values/strings.xml @@ -148,9 +148,9 @@ 비밀번호 설정 이용약관 확인 비밀번호를 입력해 주세요 - 비밀번호가 일치하지 않습니다 - 비밀번호를 입력해 주세요 비밀번호를 한 번 더 입력해 주세요 + 비밀번호가 일치하지 않습니다 + 올바르지 않은 비밀번호 형식입니다 비밀번호가 재설정 되었습니다 비밀번호는 영문, 숫자, 기호를 포함한 8~20자이어야 합니다 From ae4d1e80202d9b4ed2002d17e1bea26359aaa17b Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 10:31:14 +0900 Subject: [PATCH 06/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/feature/signup/SignUpViewModel.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt b/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt index 705a0536a..cae89406f 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt @@ -13,6 +13,7 @@ import team.aliens.dms.android.data.auth.repository.AuthRepository import team.aliens.dms.android.data.school.repository.SchoolRepository import team.aliens.dms.android.data.student.repository.StudentRepository import team.aliens.dms.android.shared.validator.checkIfEmailValid +import team.aliens.dms.android.shared.validator.checkIfPasswordValid import java.util.UUID import javax.inject.Inject @@ -227,13 +228,16 @@ class SignUpViewModel @Inject constructor( val capturedState = stateFlow.value val password = capturedState.password val passwordRepeat = capturedState.passwordRepeat - postSideEffect( - sideEffect = if (password != passwordRepeat) { - SignUpSideEffect.PasswordMismatch - } else { - SignUpSideEffect.PasswordSet - }, - ) + + if (password != passwordRepeat) { + postSideEffect(SignUpSideEffect.PasswordMismatch) + } + + if (checkIfPasswordValid(password)) { + postSideEffect(SignUpSideEffect.InvalidPassword) + } + + postSideEffect(SignUpSideEffect.PasswordSet) } private fun signUp() = viewModelScope.launch(Dispatchers.IO) { @@ -372,6 +376,7 @@ sealed class SignUpSideEffect : SideEffect() { // SetPassword data object PasswordSet : SignUpSideEffect() data object PasswordMismatch : SignUpSideEffect() + data object InvalidPassword : SignUpSideEffect() // Terms data object SignedUp : SignUpSideEffect() From b3c5953cff1f292cd1c782c73a1ff6815e381277 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 10:31:49 +0900 Subject: [PATCH 07/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20set=20password?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/signup/6_SetPasswordScreen.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/feature/src/main/java/team/aliens/dms/android/feature/signup/6_SetPasswordScreen.kt b/feature/src/main/java/team/aliens/dms/android/feature/signup/6_SetPasswordScreen.kt index 8841cb804..b0d9fd91f 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/signup/6_SetPasswordScreen.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/signup/6_SetPasswordScreen.kt @@ -60,6 +60,14 @@ internal fun SignUpSetPasswordScreen( val (shouldShowQuitSignUpDialog, onShouldShowQuitSignUpDialogChange) = remember { mutableStateOf(false) } + + val (isPasswordInvalid, onChangeIsPasswordInvalid) = remember( + uiState.password, + uiState.passwordRepeat + ) { + mutableStateOf(false) + } + if (shouldShowQuitSignUpDialog) { AlertDialog( title = { Text(text = stringResource(id = R.string.sign_up)) }, @@ -90,6 +98,13 @@ internal fun SignUpSetPasswordScreen( message = context.getString(R.string.sign_up_set_password_error_password_mismatch), ) + SignUpSideEffect.InvalidPassword -> { + toast.showErrorToast( + message = context.getString(R.string.sign_up_set_password_invalid_password), + ) + onChangeIsPasswordInvalid(true) + } + else -> {/* explicit blank */ } } @@ -167,4 +182,4 @@ internal fun SignUpSetPasswordScreen( BackHandler { onShouldShowQuitSignUpDialogChange(true) } -} \ No newline at end of file +} From dd83ff00b5d2d31bc9c85e1cffbcf8fb5b611fab Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 10:33:42 +0900 Subject: [PATCH 08/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20return?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/aliens/dms/android/feature/signup/SignUpViewModel.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt b/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt index cae89406f..df07125d6 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt @@ -231,10 +231,12 @@ class SignUpViewModel @Inject constructor( if (password != passwordRepeat) { postSideEffect(SignUpSideEffect.PasswordMismatch) + return } if (checkIfPasswordValid(password)) { postSideEffect(SignUpSideEffect.InvalidPassword) + return } postSideEffect(SignUpSideEffect.PasswordSet) From 167fd3d27bfcdb5a6d5b3e2e6f54aa385fba0977 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 10:34:18 +0900 Subject: [PATCH 09/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/aliens/dms/android/feature/signup/SignUpViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt b/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt index df07125d6..8a881bd28 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt @@ -234,7 +234,7 @@ class SignUpViewModel @Inject constructor( return } - if (checkIfPasswordValid(password)) { + if (!checkIfPasswordValid(password)) { postSideEffect(SignUpSideEffect.InvalidPassword) return } From 730569e49de9be5cb39384dd2466ab1838558774 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 10:35:36 +0900 Subject: [PATCH 10/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20edit=20pw=20vm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editpassword/EditPasswordViewModel.kt | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/feature/src/main/java/team/aliens/dms/android/feature/editpassword/EditPasswordViewModel.kt b/feature/src/main/java/team/aliens/dms/android/feature/editpassword/EditPasswordViewModel.kt index 164b34d50..c6b6da203 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/editpassword/EditPasswordViewModel.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/editpassword/EditPasswordViewModel.kt @@ -57,27 +57,30 @@ class EditPasswordViewModel @Inject constructor( ), ) - private fun editPassword() = viewModelScope.launch(Dispatchers.IO) { + private fun editPassword() = run { val capturedState = stateFlow.value - if (capturedState.newPassword != capturedState.newPasswordRepeat) { + val newPassword = capturedState.newPassword + val newPasswordRepeat = capturedState.newPasswordRepeat + + if (newPassword != newPasswordRepeat) { postSideEffect(EditPasswordSideEffect.PasswordMismatch) - return@launch + return@run } - if (!checkIfPasswordValid(capturedState.newPassword)) { + if (!checkIfPasswordValid(newPassword)) { postSideEffect(EditPasswordSideEffect.PasswordFormatError) - return@launch + return@run } - - runCatching { - userRepository.editPassword( - currentPassword = capturedState.currentPassword, - newPassword = capturedState.newPassword, - ) - }.onSuccess { - postSideEffect(EditPasswordSideEffect.PasswordEdited) - }.onFailure { - it.printStackTrace() - postSideEffect(EditPasswordSideEffect.PasswordFormatError) + viewModelScope.launch(Dispatchers.IO) { + runCatching { + userRepository.editPassword( + currentPassword = capturedState.currentPassword, + newPassword = newPassword, + ) + }.onSuccess { + postSideEffect(EditPasswordSideEffect.PasswordEdited) + }.onFailure { + postSideEffect(EditPasswordSideEffect.PasswordEditFailure) + } } } } @@ -111,4 +114,5 @@ sealed class EditPasswordSideEffect : SideEffect() { data object PasswordEdited : EditPasswordSideEffect() data object PasswordFormatError : EditPasswordSideEffect() data object PasswordMismatch : EditPasswordSideEffect() + data object PasswordEditFailure : EditPasswordSideEffect() } From ce90ce51d03bc269c61d4e1292cd15afb18809ad Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 10:37:26 +0900 Subject: [PATCH 11/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20set=20pw?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dms/android/feature/editpassword/2_SetPasswordScreen.kt | 4 ++++ feature/src/main/res/values/strings.xml | 1 + 2 files changed, 5 insertions(+) diff --git a/feature/src/main/java/team/aliens/dms/android/feature/editpassword/2_SetPasswordScreen.kt b/feature/src/main/java/team/aliens/dms/android/feature/editpassword/2_SetPasswordScreen.kt index 66e77e63a..8fdfa04e0 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/editpassword/2_SetPasswordScreen.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/editpassword/2_SetPasswordScreen.kt @@ -99,6 +99,10 @@ internal fun EditPasswordSetPasswordScreen( EditPasswordSideEffect.PasswordFormatError -> isPasswordFormatError = true + EditPasswordSideEffect.PasswordEditFailure -> toast.showErrorToast( + message = context.getString(R.string.edit_password_error_password_edit_failure), + ) + else -> {/* explicit blank */ } } diff --git a/feature/src/main/res/values/strings.xml b/feature/src/main/res/values/strings.xml index 5fba15ad0..acea72363 100644 --- a/feature/src/main/res/values/strings.xml +++ b/feature/src/main/res/values/strings.xml @@ -212,6 +212,7 @@ 비밀번호를 변경했습니다 비밀번호가 일치하지 않습니다 유효하지 않은 형식입니다 + 비밀번호를 변경할 수 없습니다 기존 비밀번호를 입력해 주세요 새로운 비밀번호를 입력해 주세요 비밀번호를 한 번 더 입력해 주세요 From 62daf47db91c03efdee35566dd1a526c8f67aedb Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 11:09:25 +0900 Subject: [PATCH 12/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20id=20validator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shared/validator/test/IdValidatorTest.kt | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 shared/validator/src/test/java/team/aliens/dms/android/shared/validator/test/IdValidatorTest.kt diff --git a/shared/validator/src/test/java/team/aliens/dms/android/shared/validator/test/IdValidatorTest.kt b/shared/validator/src/test/java/team/aliens/dms/android/shared/validator/test/IdValidatorTest.kt new file mode 100644 index 000000000..102467f94 --- /dev/null +++ b/shared/validator/src/test/java/team/aliens/dms/android/shared/validator/test/IdValidatorTest.kt @@ -0,0 +1,74 @@ +package team.aliens.dms.android.shared.validator.test + +import org.junit.Test +import team.aliens.dms.android.shared.validator.IdValidator +import team.aliens.dms.android.shared.validator.checkIfIdValid + +@Suppress("SimplifyBooleanWithConstants", "LocalVariableName") +class IdValidatorTest { + + @Test + fun `Test empty id`() { + val `empty id` = "" + + assert(IdValidator.validate(`empty id`) == false) + assert(checkIfIdValid(`empty id`) == false) + } + + @Test + fun `Test id not in English`() { + val `id not in english` = "박준수" + + assert(IdValidator.validate(`id not in english`) == false) + assert(checkIfIdValid(`id not in english`) == false) + } + + @Test + fun `Test id with only english digits`() { + val `english only id` = "abcdefgh" + + assert(IdValidator.validate(`english only id`) == true) + assert(checkIfIdValid(`english only id`) == true) + } + + @Test + fun `Test id with only numbers`() { + val `numbers only id` = "12345678" + + assert(IdValidator.validate(`numbers only id`) == true) + assert(checkIfIdValid(`numbers only id`) == true) + } + + @Test + fun `Test id under length 4`() { + val `id under length 4` = "ab1" + + assert(IdValidator.validate(`id under length 4`) == false) + assert(checkIfIdValid(`id under length 4`) == false) + } + + @Test + fun `Test id over length 20`() { + val `id over length 20` = + "abcd1234" + "abcd1234" + "abcd" + "1" + + assert(IdValidator.validate(`id over length 20`) == false) + assert(checkIfIdValid(`id over length 20`) == false) + } + + @Test + fun `Test id containing blank`() { + val `id with blank` = "ab d1234!" + + assert(IdValidator.validate(`id with blank`) == false) + assert(checkIfIdValid(`id with blank`) == false) + } + + @Test + fun `Test id containing special character`() { + val `id with special character` = "abcd1234!" + + assert(IdValidator.validate(`id with special character`) == false) + assert(checkIfIdValid(`id with special character`) == false) + } +} From 247db2cabdf72d5e3d74a8fbda1159c156c6d185 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 11:10:23 +0900 Subject: [PATCH 13/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20id=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/feature/signup/SignUpViewModel.kt | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt b/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt index 8a881bd28..96ba64f22 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/signup/SignUpViewModel.kt @@ -13,6 +13,7 @@ import team.aliens.dms.android.data.auth.repository.AuthRepository import team.aliens.dms.android.data.school.repository.SchoolRepository import team.aliens.dms.android.data.student.repository.StudentRepository import team.aliens.dms.android.shared.validator.checkIfEmailValid +import team.aliens.dms.android.shared.validator.checkIfIdValid import team.aliens.dms.android.shared.validator.checkIfPasswordValid import java.util.UUID import javax.inject.Inject @@ -202,13 +203,22 @@ class SignUpViewModel @Inject constructor( ), ) - private fun confirmId() = viewModelScope.launch(Dispatchers.IO) { - runCatching { - studentRepository.checkIdDuplication(id = stateFlow.value.id) - }.onSuccess { - postSideEffect(SignUpSideEffect.IdAvailable) - }.onFailure { - postSideEffect(SignUpSideEffect.IdDuplicated) + private fun confirmId() = run { + val capturedId = stateFlow.value.id + + if (!checkIfIdValid(capturedId)) { + postSideEffect(SignUpSideEffect.InvalidId) + return@run + } + + viewModelScope.launch(Dispatchers.IO) { + runCatching { + studentRepository.checkIdDuplication(id = capturedId) + }.onSuccess { + postSideEffect(SignUpSideEffect.IdAvailable) + }.onFailure { + postSideEffect(SignUpSideEffect.IdDuplicated) + } } } @@ -374,6 +384,7 @@ sealed class SignUpSideEffect : SideEffect() { data object UserNotFound : SignUpSideEffect() data object IdAvailable : SignUpSideEffect() data object IdDuplicated : SignUpSideEffect() + data object InvalidId : SignUpSideEffect() // SetPassword data object PasswordSet : SignUpSideEffect() From 8b2b78fc864eb3f22c38b057b65c261b3ac93ff6 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 11:16:56 +0900 Subject: [PATCH 14/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20id=20validator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shared/validator/test/IdValidatorTest.kt | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/shared/validator/src/test/java/team/aliens/dms/android/shared/validator/test/IdValidatorTest.kt b/shared/validator/src/test/java/team/aliens/dms/android/shared/validator/test/IdValidatorTest.kt index 102467f94..98b235134 100644 --- a/shared/validator/src/test/java/team/aliens/dms/android/shared/validator/test/IdValidatorTest.kt +++ b/shared/validator/src/test/java/team/aliens/dms/android/shared/validator/test/IdValidatorTest.kt @@ -4,7 +4,7 @@ import org.junit.Test import team.aliens.dms.android.shared.validator.IdValidator import team.aliens.dms.android.shared.validator.checkIfIdValid -@Suppress("SimplifyBooleanWithConstants", "LocalVariableName") +@Suppress("SimplifyBooleanWithConstants", "LocalVariableName", "ConvertToStringTemplate") class IdValidatorTest { @Test @@ -65,10 +65,27 @@ class IdValidatorTest { } @Test - fun `Test id containing special character`() { - val `id with special character` = "abcd1234!" + fun `Test id containing not allowed spacial character`() { + val `id with not allowed special character` = "abcd1234!" - assert(IdValidator.validate(`id with special character`) == false) - assert(checkIfIdValid(`id with special character`) == false) + assert(IdValidator.validate(`id with not allowed special character`) == false) + assert(checkIfIdValid(`id with not allowed special character`) == false) + } + + @Test + fun `Test id containing with allowed special character`() { + val `base id` = "abcd1234" + val case1 = `base id` + '.' + val case2 = `base id` + '_' + val case3 = `base id` + '-' + + assert(IdValidator.validate(case1) == true) + assert(checkIfIdValid(case1) == true) + + assert(IdValidator.validate(case2) == true) + assert(checkIfIdValid(case2) == true) + + assert(IdValidator.validate(case3) == true) + assert(checkIfIdValid(case3) == true) } } From b33c1b9fabfd872ade2b13be1e5aa8dd737a1858 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 11:16:59 +0900 Subject: [PATCH 15/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20id=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/aliens/dms/android/shared/validator/IdValidator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/IdValidator.kt b/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/IdValidator.kt index a46659430..fbb073845 100644 --- a/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/IdValidator.kt +++ b/shared/validator/src/main/java/team/aliens/dms/android/shared/validator/IdValidator.kt @@ -1,7 +1,7 @@ package team.aliens.dms.android.shared.validator object IdValidator : Validator() { - override val regex = Regex("^[A-Za-z0-9]{4,20}\$") + override val regex = Regex("^[A-Za-z0-9._-]{4,20}\$") override fun validate(value: String): Boolean = value.matches(regex) } From 057e64cbcc501cc8b1ef76ff420ddc83476dd8e7 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 11:21:44 +0900 Subject: [PATCH 16/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=B2=84?= =?UTF-8?q?=EC=A0=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e5c9ced23..7b1659e92 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -17,8 +17,8 @@ android { minSdk = libs.versions.minSdk.get().toInt() targetSdk = libs.versions.targetSdk.get().toInt() - versionCode = 6 - versionName = "v1.2.0" + versionCode = 7 + versionName = "v1.2.1" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } From bc19fc3797dc8ceefc4efb65cab92f8348495e80 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 12:51:35 +0900 Subject: [PATCH 17/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20swipe=20refresh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/meal/repository/MealRepository.kt | 2 ++ .../meal/repository/MealRepositoryImpl.kt | 12 ++++--- .../android/feature/main/home/HomeScreen.kt | 25 +++++++++++++-- .../feature/main/home/HomeViewModel.kt | 31 +++++++++++++++++-- 4 files changed, 60 insertions(+), 10 deletions(-) diff --git a/data/src/main/java/team/aliens/dms/android/data/meal/repository/MealRepository.kt b/data/src/main/java/team/aliens/dms/android/data/meal/repository/MealRepository.kt index ef4d5b188..326f70ef4 100644 --- a/data/src/main/java/team/aliens/dms/android/data/meal/repository/MealRepository.kt +++ b/data/src/main/java/team/aliens/dms/android/data/meal/repository/MealRepository.kt @@ -6,4 +6,6 @@ import team.aliens.dms.android.data.meal.model.Meal abstract class MealRepository { abstract suspend fun fetchMeal(date: LocalDate): Meal + + abstract suspend fun updateMeal(date: LocalDate): Meal } diff --git a/data/src/main/java/team/aliens/dms/android/data/meal/repository/MealRepositoryImpl.kt b/data/src/main/java/team/aliens/dms/android/data/meal/repository/MealRepositoryImpl.kt index 84e854a3c..7fadced42 100644 --- a/data/src/main/java/team/aliens/dms/android/data/meal/repository/MealRepositoryImpl.kt +++ b/data/src/main/java/team/aliens/dms/android/data/meal/repository/MealRepositoryImpl.kt @@ -17,12 +17,16 @@ internal class MealRepositoryImpl @Inject constructor( databaseMealDataSource.queryMeal(date).toModel() } catch (_: Exception) { try { - networkMealDataSource.fetchMeals(date).toModel().also { meals -> - databaseMealDataSource.saveMeals(meals.toEntity()) - } - .find { it.date == date }!! + this.updateMeal(date = date) } catch (_: Exception) { throw CannotFindMealException() } } + + override suspend fun updateMeal(date: LocalDate): Meal { + return networkMealDataSource.fetchMeals(date).toModel().also { meals -> + databaseMealDataSource.saveMeals(meals.toEntity()) + } + .find { it.date == date }!! + } } diff --git a/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt b/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt index 2419a5f57..ed4885c21 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt @@ -34,6 +34,8 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.OutlinedCard import androidx.compose.material3.Text +import androidx.compose.material3.pulltorefresh.PullToRefreshContainer +import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.runtime.LaunchedEffect @@ -49,6 +51,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource @@ -67,12 +70,12 @@ import team.aliens.dms.android.core.designsystem.DmsCalendar import team.aliens.dms.android.core.designsystem.DmsScaffold import team.aliens.dms.android.core.designsystem.DmsTheme import team.aliens.dms.android.core.designsystem.DmsTopAppBar +import team.aliens.dms.android.core.designsystem.LocalToast import team.aliens.dms.android.core.designsystem.ModalBottomSheet import team.aliens.dms.android.core.designsystem.OutlinedButton import team.aliens.dms.android.core.designsystem.PrimaryDefault import team.aliens.dms.android.core.designsystem.ShadowDefaults import team.aliens.dms.android.core.designsystem.clickable -import team.aliens.dms.android.core.designsystem.rememberToastState import team.aliens.dms.android.core.ui.DefaultHorizontalSpace import team.aliens.dms.android.core.ui.DefaultVerticalSpace import team.aliens.dms.android.core.ui.PaddingDefaults @@ -100,13 +103,18 @@ internal fun HomeScreen( onChangeBottomAppBarVisibility: (visible: Boolean) -> Unit, onNavigateToAnnouncementList: () -> Unit, ) { - val toast = rememberToastState() + val toast = LocalToast.current val context = LocalContext.current val uiState by viewModel.stateFlow.collectAsStateWithLifecycle() + val pullToRefreshState = rememberPullToRefreshState() viewModel.sideEffectFlow.collectInLaunchedEffectWithLifecycle { sideEffect -> when (sideEffect) { - HomeSideEffect.CannotFindMeal -> toast.showErrorToast(context.getString(R.string.meal_error_not_found)) // FIXME: toast not showing + HomeSideEffect.CannotFindMeal, HomeSideEffect.MealUpdateFailed -> toast.showErrorToast( + context.getString(R.string.meal_error_not_found), + ) + + HomeSideEffect.MealUpdated -> pullToRefreshState.endRefresh() } } @@ -119,6 +127,12 @@ internal fun HomeScreen( val (shouldShowCalendar, onShouldShowCalendarChange) = remember { mutableStateOf(false) } + LaunchedEffect(pullToRefreshState.isRefreshing) { + if (pullToRefreshState.isRefreshing) { + viewModel.postIntent(HomeIntent.UpdateMeal) + } + } + if (shouldShowCalendar) { ModalBottomSheet( onDismissRequest = { @@ -151,12 +165,17 @@ internal fun HomeScreen( ) { padValues -> Column( modifier = Modifier + .nestedScroll(pullToRefreshState.nestedScrollConnection) .animateContentSize() .background(brush = HomeBackgroundBrush) .fillMaxSize() .padding(padValues), verticalArrangement = Arrangement.spacedBy(DefaultHomeScreenVerticalSpace), ) { + PullToRefreshContainer( + modifier = Modifier.align(Alignment.CenterHorizontally), + state = pullToRefreshState, + ) if (uiState.newNoticesExist) { AnnouncementCard( modifier = Modifier.fillMaxWidth(), diff --git a/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeViewModel.kt b/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeViewModel.kt index 6c4771e2b..45cb05c00 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeViewModel.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeViewModel.kt @@ -25,12 +25,13 @@ internal class HomeViewModel @Inject constructor( ) { init { fetchWhetherNewNoticeExists() - updateMeal(date = stateFlow.value.selectedDate) + updateDate(date = stateFlow.value.selectedDate) } override fun processIntent(intent: HomeIntent) { when (intent) { - is HomeIntent.UpdateSelectedDate -> updateMeal(intent.selectedDate) + is HomeIntent.UpdateSelectedDate -> updateDate(intent.selectedDate) + HomeIntent.UpdateMeal -> updateMeal() } } @@ -44,7 +45,7 @@ internal class HomeViewModel @Inject constructor( } } - private fun updateMeal(date: LocalDate) { + private fun updateDate(date: LocalDate) { viewModelScope.launch(Dispatchers.IO) { runCatching { mealRepository.fetchMeal(date) @@ -62,6 +63,27 @@ internal class HomeViewModel @Inject constructor( } } } + + private fun updateMeal() = + viewModelScope.launch(Dispatchers.IO) { + println("LOGLOG1") + val capturedDate = stateFlow.value.selectedDate + runCatching { + mealRepository.updateMeal(capturedDate) + }.onSuccess { meal -> + reduce( + newState = stateFlow.value.copy( + selectedDate = capturedDate, + currentMeal = meal, + ), + ) + postSideEffect(HomeSideEffect.MealUpdated) + }.onFailure { + postSideEffect(HomeSideEffect.MealUpdateFailed) + }.also { + println("LOGLOG ${it.isSuccess}") + } + } } internal data class HomeUiState( @@ -94,10 +116,13 @@ internal data class HomeUiState( internal sealed class HomeIntent : Intent() { class UpdateSelectedDate(val selectedDate: LocalDate) : HomeIntent() + data object UpdateMeal : HomeIntent() } internal sealed class HomeSideEffect : SideEffect() { data object CannotFindMeal : HomeSideEffect() + data object MealUpdated : HomeSideEffect() + data object MealUpdateFailed : HomeSideEffect() } /* From 9ba6110bf7fbe7ed7de0957941a322e052551279 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 12:57:06 +0900 Subject: [PATCH 18/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20swipe=20refresh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dms/android/feature/main/home/HomeScreen.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt b/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt index ed4885c21..a936dc21f 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt @@ -172,10 +172,6 @@ internal fun HomeScreen( .padding(padValues), verticalArrangement = Arrangement.spacedBy(DefaultHomeScreenVerticalSpace), ) { - PullToRefreshContainer( - modifier = Modifier.align(Alignment.CenterHorizontally), - state = pullToRefreshState, - ) if (uiState.newNoticesExist) { AnnouncementCard( modifier = Modifier.fillMaxWidth(), @@ -214,6 +210,14 @@ internal fun HomeScreen( ) Spacer(modifier = Modifier.height(92.dp)) } + Box( + modifier = Modifier + .fillMaxWidth() + .padding(top = padValues.calculateTopPadding()), + contentAlignment = Alignment.TopCenter, + ) { + PullToRefreshContainer(state = pullToRefreshState) + } } } From a2a45425a1a9c1c54a52452f2eeedd91334c024b Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 13:09:01 +0900 Subject: [PATCH 19/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20refresh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/feature/main/home/HomeScreen.kt | 35 +++++++++++++++---- feature/src/main/res/values/strings.xml | 2 ++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt b/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt index a936dc21f..32ec4a094 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt @@ -75,6 +75,7 @@ import team.aliens.dms.android.core.designsystem.ModalBottomSheet import team.aliens.dms.android.core.designsystem.OutlinedButton import team.aliens.dms.android.core.designsystem.PrimaryDefault import team.aliens.dms.android.core.designsystem.ShadowDefaults +import team.aliens.dms.android.core.designsystem.TextButton import team.aliens.dms.android.core.designsystem.clickable import team.aliens.dms.android.core.ui.DefaultHorizontalSpace import team.aliens.dms.android.core.ui.DefaultVerticalSpace @@ -106,6 +107,7 @@ internal fun HomeScreen( val toast = LocalToast.current val context = LocalContext.current + val onRefresh = remember { { viewModel.postIntent(HomeIntent.UpdateMeal); Unit } } val uiState by viewModel.stateFlow.collectAsStateWithLifecycle() val pullToRefreshState = rememberPullToRefreshState() viewModel.sideEffectFlow.collectInLaunchedEffectWithLifecycle { sideEffect -> @@ -114,7 +116,12 @@ internal fun HomeScreen( context.getString(R.string.meal_error_not_found), ) - HomeSideEffect.MealUpdated -> pullToRefreshState.endRefresh() + HomeSideEffect.MealUpdated -> { + pullToRefreshState.endRefresh() + toast.showSuccessToast( + message = context.getString(R.string.home_success_meal_refreshed), + ) + } } } @@ -129,7 +136,7 @@ internal fun HomeScreen( LaunchedEffect(pullToRefreshState.isRefreshing) { if (pullToRefreshState.isRefreshing) { - viewModel.postIntent(HomeIntent.UpdateMeal) + onRefresh() } } @@ -207,6 +214,7 @@ internal fun HomeScreen( meal = uiState.currentMeal, onNextDay = { onSelectedDateChange(uiState.selectedDate.plusDays(1)) }, onPreviousDay = { onSelectedDateChange(uiState.selectedDate.minusDays(1)) }, + onRefresh = onRefresh, ) Spacer(modifier = Modifier.height(92.dp)) } @@ -385,6 +393,7 @@ private fun MealCards( meal: Meal, onNextDay: () -> Unit, onPreviousDay: () -> Unit, + onRefresh: () -> Unit, ) { val pagerState = rememberPagerState( initialPage = getProperMeal(), @@ -467,6 +476,7 @@ private fun MealCards( ) } }, + onRefresh = onRefresh, ) } } @@ -502,6 +512,7 @@ private fun MealCard( kcalOfDinner: String?, onSwipeToLeft: () -> Unit, onSwipeToRight: () -> Unit, + onRefresh: () -> Unit, ) { var dragDirection: DragDirection? by remember { mutableStateOf(null) } @@ -542,14 +553,24 @@ private fun MealCard( ), elevation = CardDefaults.outlinedCardElevation(defaultElevation = ShadowDefaults.SmallElevation), ) { + val dishes = when (currentCardType) { + BREAKFAST -> breakfast + LUNCH -> lunch + DINNER -> dinner + } + if (dishes.isEmpty()) { + TextButton( + modifier = Modifier.fillMaxWidth(), + onClick = onRefresh, + colors = ButtonDefaults.textGrayButtonColors(), + ) { + Text(text = stringResource(id = R.string.refresh)) + } + } Dishes( modifier = Modifier.fillMaxWidth(), iconRes = currentCardType.iconRes, - dishes = when (currentCardType) { - BREAKFAST -> breakfast - LUNCH -> lunch - DINNER -> dinner - }, + dishes = dishes, kcal = when (currentCardType) { BREAKFAST -> kcalOfBreakfast LUNCH -> kcalOfLunch diff --git a/feature/src/main/res/values/strings.xml b/feature/src/main/res/values/strings.xml index acea72363..5e02bc60e 100644 --- a/feature/src/main/res/values/strings.xml +++ b/feature/src/main/res/values/strings.xml @@ -288,4 +288,6 @@ 번호 %s 님이 맞으신가요? + 새로고침 + 급식을 다시 불러왔습니다 \ No newline at end of file From ff02a3e9f3ec3f78c87a11bfd5f843ecf9550ae9 Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 13:12:16 +0900 Subject: [PATCH 20/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20swipe=20animati?= =?UTF-8?q?on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aliens/dms/android/feature/main/home/HomeScreen.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt b/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt index 32ec4a094..8fd2133af 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/main/home/HomeScreen.kt @@ -106,10 +106,15 @@ internal fun HomeScreen( ) { val toast = LocalToast.current val context = LocalContext.current - - val onRefresh = remember { { viewModel.postIntent(HomeIntent.UpdateMeal); Unit } } val uiState by viewModel.stateFlow.collectAsStateWithLifecycle() val pullToRefreshState = rememberPullToRefreshState() + + val onRefresh = remember { + { + pullToRefreshState.startRefresh() + viewModel.postIntent(HomeIntent.UpdateMeal); Unit + } + } viewModel.sideEffectFlow.collectInLaunchedEffectWithLifecycle { sideEffect -> when (sideEffect) { HomeSideEffect.CannotFindMeal, HomeSideEffect.MealUpdateFailed -> toast.showErrorToast( From a7562fdb510222586489625a85115566ddece8fd Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 18:40:41 +0900 Subject: [PATCH 21/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20study=20room?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../studyroom/details/StudyRoomDetailsScreen.kt | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/feature/src/main/java/team/aliens/dms/android/feature/studyroom/details/StudyRoomDetailsScreen.kt b/feature/src/main/java/team/aliens/dms/android/feature/studyroom/details/StudyRoomDetailsScreen.kt index 4eabe0c3a..07188835b 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/studyroom/details/StudyRoomDetailsScreen.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/studyroom/details/StudyRoomDetailsScreen.kt @@ -352,17 +352,14 @@ private fun SeatList( onSelectSeat: (seat: StudyRoom.Seat) -> Unit, ) { // FIXME: 리컴포지션 방지하도록 작성하기 - val formedSeats: List> = List( - size = countOfRows - ) { indexOfRows -> - arrayOfNulls(size = countOfColumns) - }.apply { - seats.forEach { seat -> - val rowIndexOfSeat = seat.row - 1 - val columnIndexOfSeat = seat.column - 1 - this[rowIndexOfSeat][columnIndexOfSeat] = seat + val formedSeats: List> = + List(size = countOfRows) { arrayOfNulls(size = countOfColumns).apply {} }.apply { + seats.forEach { seat -> + val rowIndexOfSeat = seat.column - 1 + val columnIndexOfSeat = seat.row - 1 + this[rowIndexOfSeat][columnIndexOfSeat] = seat + } } - } Box( modifier = modifier From 405f8841dc1158f34293c525022bc67150860fcb Mon Sep 17 00:00:00 2001 From: junsuPark Date: Wed, 13 Mar 2024 18:52:19 +0900 Subject: [PATCH 22/22] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 7b1659e92..f9ab46fa4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -17,8 +17,8 @@ android { minSdk = libs.versions.minSdk.get().toInt() targetSdk = libs.versions.targetSdk.get().toInt() - versionCode = 7 - versionName = "v1.2.1" + versionCode = 8 + versionName = "v1.2.2" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" }