From baac2049ebe6432c12fa85a44168fd8714787f73 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 21 Oct 2023 14:18:25 +0900 Subject: [PATCH 01/37] =?UTF-8?q?[CHORE]=20#32=20:=20Firebase=20Manager=20?= =?UTF-8?q?Const=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/wap/wapp/core/network/constant/FirebaseConstant.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/constant/FirebaseConstant.kt b/core/network/src/main/java/com/wap/wapp/core/network/constant/FirebaseConstant.kt index e41885d6..fd4fca11 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/constant/FirebaseConstant.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/constant/FirebaseConstant.kt @@ -4,3 +4,5 @@ package com.wap.wapp.core.network.constant 파이어스토어 유저 컬렉션 */ const val USER_COLLECTION = "users" + +const val MANAGER_COLLECTION = "managers" From a73e1e12bc356f60b851a23170f8e15a13e58d39 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 21 Oct 2023 14:19:42 +0900 Subject: [PATCH 02/37] =?UTF-8?q?[FEATURE]=20#32=20:=20=EB=A7=A4=EB=8B=88?= =?UTF-8?q?=EC=A0=80=20=EC=A1=B0=ED=9A=8C=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/manage/ManageRepository.kt | 5 +++++ .../repository/manage/ManageRepositoryImpl.kt | 12 ++++++++++++ .../network/source/manage/ManageDataSource.kt | 5 +++++ .../source/manage/ManageDataSourceImpl.kt | 19 +++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt create mode 100644 core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt create mode 100644 core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt create mode 100644 core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt new file mode 100644 index 00000000..3d192078 --- /dev/null +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt @@ -0,0 +1,5 @@ +package com.wap.wapp.core.data.repository.manage + +interface ManageRepository { + suspend fun getManager(userId: String): Result +} diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt new file mode 100644 index 00000000..3b44b9ab --- /dev/null +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt @@ -0,0 +1,12 @@ +package com.wap.wapp.core.data.repository.manage + +import com.wap.wapp.core.network.source.manage.ManageDataSource +import javax.inject.Inject + +class ManageRepositoryImpl @Inject constructor( + private val manageDataSource: ManageDataSource, +) : ManageRepository { + override suspend fun getManager(userId: String): Result { + return manageDataSource.getManager(userId) + } +} diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt new file mode 100644 index 00000000..06da4a7f --- /dev/null +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt @@ -0,0 +1,5 @@ +package com.wap.wapp.core.network.source.manage + +interface ManageDataSource { + suspend fun getManager(userId: String): Result +} diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt new file mode 100644 index 00000000..cdf771ad --- /dev/null +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt @@ -0,0 +1,19 @@ +package com.wap.wapp.core.network.source.manage + +import com.google.firebase.firestore.FirebaseFirestore +import com.wap.wapp.core.network.constant.MANAGER_COLLECTION +import com.wap.wapp.core.network.utils.await +import javax.inject.Inject + +class ManageDataSourceImpl @Inject constructor( + private val firebaseFirestore: FirebaseFirestore, +) : ManageDataSource { + override suspend fun getManager(userId: String): Result { + return runCatching { + firebaseFirestore.collection(MANAGER_COLLECTION) + .document(userId) + .get() + .await() + } + } +} From b14a2a0482c54dacf2bb86fb830974853216778f Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 21 Oct 2023 14:20:05 +0900 Subject: [PATCH 03/37] =?UTF-8?q?[FEATURE]=20#32=20:=20ManageDataSource=20?= =?UTF-8?q?binds=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/wap/wapp/core/network/di/NetworkModule.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/di/NetworkModule.kt b/core/network/src/main/java/com/wap/wapp/core/network/di/NetworkModule.kt index d36b8a79..65148e66 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/di/NetworkModule.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/di/NetworkModule.kt @@ -1,5 +1,7 @@ package com.wap.wapp.core.network.di +import com.wap.wapp.core.network.source.manage.ManageDataSource +import com.wap.wapp.core.network.source.manage.ManageDataSourceImpl import com.wap.wapp.core.network.source.user.UserDataSource import com.wap.wapp.core.network.source.user.UserDataSourceImpl import dagger.Binds @@ -17,4 +19,10 @@ abstract class NetworkModule { abstract fun bindsUserDataSource( userDataSourceImpl: UserDataSourceImpl, ): UserDataSource + + @Binds + @Singleton + abstract fun bindsManageDataSource( + manageDataSourceImpl: ManageDataSourceImpl, + ): ManageDataSource } From 8c1d89730ee0646ddf1bbf2e118d2e7e637fe20f Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 21 Oct 2023 14:20:17 +0900 Subject: [PATCH 04/37] =?UTF-8?q?[FEATURE]=20#32=20:=20ManageRepository=20?= =?UTF-8?q?binds=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/wap/wapp/core/data/di/DataModule.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/di/DataModule.kt b/core/data/src/main/java/com/wap/wapp/core/data/di/DataModule.kt index 7191e64a..115b598d 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/di/DataModule.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/di/DataModule.kt @@ -1,5 +1,7 @@ package com.wap.wapp.core.data.di +import com.wap.wapp.core.data.repository.manage.ManageRepository +import com.wap.wapp.core.data.repository.manage.ManageRepositoryImpl import com.wap.wapp.core.data.repository.user.UserRepository import com.wap.wapp.core.data.repository.user.UserRepositoryImpl import dagger.Binds @@ -16,4 +18,10 @@ abstract class DataModule { abstract fun bindsUserRepository( userRepositoryImpl: UserRepositoryImpl, ): UserRepository + + @Binds + @Singleton + abstract fun bindsManageRepository( + manageRepositoryImpl: ManageRepositoryImpl, + ): ManageRepository } From 5ba3b14daf84c479aa2245326a96de69cdcc9203 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 21 Oct 2023 14:20:52 +0900 Subject: [PATCH 05/37] =?UTF-8?q?[FEATURE]=20#32=20:=20=EB=93=B1=EB=A1=9D?= =?UTF-8?q?=EB=90=9C=20=EB=A7=A4=EB=8B=88=EC=A0=80=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=9C=A0=EC=8A=A4=EC=BC=80=EC=9D=B4=EC=8A=A4=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/CheckManagerStatusUseCase.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerStatusUseCase.kt diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerStatusUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerStatusUseCase.kt new file mode 100644 index 00000000..612822d1 --- /dev/null +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerStatusUseCase.kt @@ -0,0 +1,18 @@ +package com.wap.wapp.core.domain.usecase.manage + +import com.wap.wapp.core.data.repository.manage.ManageRepository +import com.wap.wapp.core.data.repository.user.UserRepository +import javax.inject.Inject + +class CheckManagerStatusUseCase @Inject constructor( + private val manageRepository: ManageRepository, + private val userRepository: UserRepository, +) { + suspend operator fun invoke(): Result { + return runCatching { + val userId = userRepository.getUserId().getOrThrow() + + manageRepository.getManager(userId) + } + } +} From 46aa7795f286a5f91664acd66902b11c845c914c Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 21 Oct 2023 15:06:33 +0900 Subject: [PATCH 06/37] =?UTF-8?q?[CHORE]=20#32=20:=20code=20collection=20c?= =?UTF-8?q?onst=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/wapp/core/network/constant/FirebaseConstant.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/constant/FirebaseConstant.kt b/core/network/src/main/java/com/wap/wapp/core/network/constant/FirebaseConstant.kt index fd4fca11..e38a5b5e 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/constant/FirebaseConstant.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/constant/FirebaseConstant.kt @@ -1,8 +1,10 @@ package com.wap.wapp.core.network.constant /* -파이어스토어 유저 컬렉션 +Firestore Collection, Document Id */ const val USER_COLLECTION = "users" const val MANAGER_COLLECTION = "managers" + +const val CODES_COLLECTION = "codes" From fbe4b513dad12eb087febd95ee9d019e7e83e2f9 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 21 Oct 2023 15:06:56 +0900 Subject: [PATCH 07/37] =?UTF-8?q?[FEATURE]=20#32=20:=20=EC=9A=B4=EC=98=81?= =?UTF-8?q?=EC=A7=84=20=EC=BD=94=EB=93=9C=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EB=B0=8F=20=EC=9A=B4=EC=98=81=EC=A7=84=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/manage/ManageRepository.kt | 4 +++ .../repository/manage/ManageRepositoryImpl.kt | 8 ++++++ .../network/source/manage/ManageDataSource.kt | 4 +++ .../source/manage/ManageDataSourceImpl.kt | 27 +++++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt index 3d192078..88d3ec15 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt @@ -2,4 +2,8 @@ package com.wap.wapp.core.data.repository.manage interface ManageRepository { suspend fun getManager(userId: String): Result + + suspend fun postManager(userId: String): Result + + suspend fun postManagerCode(code: String): Result } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt index 3b44b9ab..4be7353b 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt @@ -9,4 +9,12 @@ class ManageRepositoryImpl @Inject constructor( override suspend fun getManager(userId: String): Result { return manageDataSource.getManager(userId) } + + override suspend fun postManager(userId: String): Result { + return manageDataSource.postManager(userId) + } + + override suspend fun postManagerCode(code: String): Result { + return manageDataSource.postManagerCode(code) + } } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt index 06da4a7f..4c428321 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt @@ -2,4 +2,8 @@ package com.wap.wapp.core.network.source.manage interface ManageDataSource { suspend fun getManager(userId: String): Result + + suspend fun postManager(userId: String): Result + + suspend fun postManagerCode(code: String): Result } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt index cdf771ad..56f62ffb 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt @@ -1,6 +1,8 @@ package com.wap.wapp.core.network.source.manage import com.google.firebase.firestore.FirebaseFirestore +import com.google.firebase.firestore.SetOptions +import com.wap.wapp.core.network.constant.CODES_COLLECTION import com.wap.wapp.core.network.constant.MANAGER_COLLECTION import com.wap.wapp.core.network.utils.await import javax.inject.Inject @@ -10,10 +12,35 @@ class ManageDataSourceImpl @Inject constructor( ) : ManageDataSource { override suspend fun getManager(userId: String): Result { return runCatching { + val result = firebaseFirestore.collection(MANAGER_COLLECTION) + .whereEqualTo("userId", userId) + .get() + .await() + + check(result.isEmpty.not()) + } + } + + override suspend fun postManager(userId: String): Result { + return runCatching { + val userIdMap = mapOf("userId" to userId) + val setOption = SetOptions.merge() + firebaseFirestore.collection(MANAGER_COLLECTION) .document(userId) + .set(userIdMap, setOption) + .await() + } + } + + override suspend fun postManagerCode(code: String): Result { + return runCatching { + val result = firebaseFirestore.collection(CODES_COLLECTION) + .whereEqualTo("manager", code) .get() .await() + + check(result.isEmpty.not()) } } } From 10e1be4d8a39321f5912e9e7c7bafeaef9421a18 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 21 Oct 2023 15:07:15 +0900 Subject: [PATCH 08/37] =?UTF-8?q?[FEATURE]=20#32=20:=20=EC=9A=B4=EC=98=81?= =?UTF-8?q?=EC=A7=84=20=EC=BD=94=EB=93=9C=20=EA=B2=80=EC=A6=9D=20=EC=9C=A0?= =?UTF-8?q?=EC=8A=A4=EC=BC=80=EC=9D=B4=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/manage/CheckManagerCodeUseCase.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerCodeUseCase.kt diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerCodeUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerCodeUseCase.kt new file mode 100644 index 00000000..232c2677 --- /dev/null +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerCodeUseCase.kt @@ -0,0 +1,21 @@ +package com.wap.wapp.core.domain.usecase.manage + +import com.wap.wapp.core.data.repository.manage.ManageRepository +import com.wap.wapp.core.data.repository.user.UserRepository +import javax.inject.Inject + +class CheckManagerCodeUseCase @Inject constructor( + private val manageRepository: ManageRepository, + private val userRepository: UserRepository, +) { + suspend operator fun invoke(code: String): Result { + return runCatching { + // 운영진 코드 검증 + manageRepository.postManagerCode(code).getOrThrow() + + // 운영진 등록 + val userId = userRepository.getUserId().getOrThrow() + manageRepository.postManager(userId) + } + } +} From 138fdd0a4d8963d9caea3087a87cbd2b5a7f12f6 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 21 Oct 2023 21:42:25 +0900 Subject: [PATCH 09/37] =?UTF-8?q?[REFACTOR]=20#32=20:=20=EC=9A=B4=EC=98=81?= =?UTF-8?q?=EC=A7=84=20=EC=BD=94=EB=93=9C=20=EC=9D=B8=EC=A6=9D=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B0=8F=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=20=ED=83=80=EC=9E=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/core/data/repository/manage/ManageRepository.kt | 2 +- .../wapp/core/data/repository/manage/ManageRepositoryImpl.kt | 4 ++-- .../wap/wapp/core/network/source/manage/ManageDataSource.kt | 2 +- .../wapp/core/network/source/manage/ManageDataSourceImpl.kt | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt index 88d3ec15..2331e5fb 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt @@ -5,5 +5,5 @@ interface ManageRepository { suspend fun postManager(userId: String): Result - suspend fun postManagerCode(code: String): Result + suspend fun getManagerCode(code: String): Result } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt index 4be7353b..c43fdd5d 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt @@ -14,7 +14,7 @@ class ManageRepositoryImpl @Inject constructor( return manageDataSource.postManager(userId) } - override suspend fun postManagerCode(code: String): Result { - return manageDataSource.postManagerCode(code) + override suspend fun getManagerCode(code: String): Result { + return manageDataSource.getManagerCode(code) } } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt index 4c428321..88b7fe50 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt @@ -5,5 +5,5 @@ interface ManageDataSource { suspend fun postManager(userId: String): Result - suspend fun postManagerCode(code: String): Result + suspend fun getManagerCode(code: String): Result } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt index 56f62ffb..bccef0e5 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt @@ -33,14 +33,14 @@ class ManageDataSourceImpl @Inject constructor( } } - override suspend fun postManagerCode(code: String): Result { + override suspend fun getManagerCode(code: String): Result { return runCatching { val result = firebaseFirestore.collection(CODES_COLLECTION) .whereEqualTo("manager", code) .get() .await() - check(result.isEmpty.not()) + result.isEmpty.not() } } } From c224478d8e0e6e2d2642debb9f8e9ea9ac86d9d9 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 21 Oct 2023 21:44:14 +0900 Subject: [PATCH 10/37] =?UTF-8?q?[REFACTOR]=20#32=20:=20=EA=B2=80=EC=A6=9D?= =?UTF-8?q?,=20=EB=AF=B8=EA=B2=80=EC=A6=9D=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=83=9D=EC=84=B1=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C,=20=EA=B2=80=EC=A6=9D=20=EC=8B=A4=ED=8C=A8=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EC=B6=94=EA=B0=80=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/domain/model/CodeVerification.kt | 5 +++++ .../usecase/manage/CheckManagerCodeUseCase.kt | 21 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/model/CodeVerification.kt diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/model/CodeVerification.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/model/CodeVerification.kt new file mode 100644 index 00000000..16bae844 --- /dev/null +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/model/CodeVerification.kt @@ -0,0 +1,5 @@ +package com.wap.wapp.core.domain.model + +enum class CodeVerification { + UNVERIFIED, VERIFIED +} diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerCodeUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerCodeUseCase.kt index 232c2677..63e4159d 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerCodeUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerCodeUseCase.kt @@ -2,20 +2,35 @@ package com.wap.wapp.core.domain.usecase.manage import com.wap.wapp.core.data.repository.manage.ManageRepository import com.wap.wapp.core.data.repository.user.UserRepository +import com.wap.wapp.core.domain.model.CodeVerification import javax.inject.Inject +import javax.inject.Singleton +@Singleton class CheckManagerCodeUseCase @Inject constructor( private val manageRepository: ManageRepository, private val userRepository: UserRepository, ) { - suspend operator fun invoke(code: String): Result { + suspend operator fun invoke(code: String): Result { return runCatching { - // 운영진 코드 검증 - manageRepository.postManagerCode(code).getOrThrow() + manageRepository.getManagerCode(code) + .onSuccess { isVerified -> + if (isVerified.not()) { // 코드가 틀렸을 경우 + return@runCatching CodeVerification.UNVERIFIED + } + } // 운영진 등록 val userId = userRepository.getUserId().getOrThrow() manageRepository.postManager(userId) + .fold( + onSuccess = { + CodeVerification.VERIFIED + }, + onFailure = { exception -> + throw(exception) + }, + ) } } } From cd311e91b3147df5c983e7f539ffa51ea376356a Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sat, 21 Oct 2023 21:44:29 +0900 Subject: [PATCH 11/37] =?UTF-8?q?[CHORE]=20#32=20:=20Singleton=20Hilt=20sc?= =?UTF-8?q?oped=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/domain/usecase/manage/CheckManagerStatusUseCase.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerStatusUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerStatusUseCase.kt index 612822d1..7a0cb86e 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerStatusUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerStatusUseCase.kt @@ -3,7 +3,9 @@ package com.wap.wapp.core.domain.usecase.manage import com.wap.wapp.core.data.repository.manage.ManageRepository import com.wap.wapp.core.data.repository.user.UserRepository import javax.inject.Inject +import javax.inject.Singleton +@Singleton class CheckManagerStatusUseCase @Inject constructor( private val manageRepository: ManageRepository, private val userRepository: UserRepository, From c3f6301f0983ae1adbed5033e5b6bf559863a810 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 13:25:30 +0900 Subject: [PATCH 12/37] =?UTF-8?q?[CHORE]=20#38=20:=20Color=20Naming=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20Color=20+=20=EC=83=89=EC=83=81=EC=BD=94?= =?UTF-8?q?=EB=93=9C=202=20char?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/wap/designsystem/Color.kt | 30 +++++++++---------- .../wapp/feature/auth/signin/SignInScreen.kt | 2 +- .../wapp/feature/auth/signup/SignUpChip.kt | 2 +- .../wapp/feature/auth/signup/SignUpScreen.kt | 2 +- .../feature/auth/signup/SignUpTextField.kt | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/core/designsystem/src/main/java/com/wap/designsystem/Color.kt b/core/designsystem/src/main/java/com/wap/designsystem/Color.kt index afb10bca..b454f7e8 100644 --- a/core/designsystem/src/main/java/com/wap/designsystem/Color.kt +++ b/core/designsystem/src/main/java/com/wap/designsystem/Color.kt @@ -9,11 +9,11 @@ import androidx.compose.ui.graphics.Color val White = Color(0xFFFFFFFF) val Black = Color(0xFF000000) val BackgroundBlack = Color(0xFF131313) -val Black3 = Color(0xFF828282) -val Black2 = Color(0xFF424242) -val Black1 = Color(0xFF252424) -val Gray2 = Color(0xFFF4F4F4) -val Gray1 = Color(0xFFA2A2A2) +val Black82 = Color(0xFF828282) // 3 +val Black42 = Color(0xFF424242) // 2 +val Black25 = Color(0xFF252424) // 1 +val GrayF4 = Color(0xFFF4F4F4) // 2 +val GrayA2 = Color(0xFFA2A2A2) // 1 val Yellow = Color(0xFFFBCF34) @Stable @@ -21,11 +21,11 @@ class WappColor( white: Color = White, black: Color = Black, backgroundBlack: Color = BackgroundBlack, - black1: Color = Black1, - black2: Color = Black2, - black3: Color = Black3, - gray1: Color = Gray1, - gray2: Color = Gray2, + black25: Color = Black25, + black42: Color = Black42, + black82: Color = Black82, + grayA2: Color = GrayA2, + grayF4: Color = GrayF4, yellow: Color = Yellow, ) { var white by mutableStateOf(white) @@ -34,15 +34,15 @@ class WappColor( private set var backgroundBlack by mutableStateOf(backgroundBlack) private set - var black1 by mutableStateOf(black1) + var black25 by mutableStateOf(Black25) private set - var black2 by mutableStateOf(black2) + var black42 by mutableStateOf(Black42) private set - var black3 by mutableStateOf(black3) + var black82 by mutableStateOf(Black82) private set - var gray1 by mutableStateOf(gray1) + var grayA2 by mutableStateOf(GrayA2) private set - var gray2 by mutableStateOf(gray2) + var grayF4 by mutableStateOf(GrayF4) private set var yellow by mutableStateOf(yellow) private set diff --git a/feature/auth/src/main/java/com/wap/wapp/feature/auth/signin/SignInScreen.kt b/feature/auth/src/main/java/com/wap/wapp/feature/auth/signin/SignInScreen.kt index 81b69cbb..598f3ecc 100644 --- a/feature/auth/src/main/java/com/wap/wapp/feature/auth/signin/SignInScreen.kt +++ b/feature/auth/src/main/java/com/wap/wapp/feature/auth/signin/SignInScreen.kt @@ -123,7 +123,7 @@ internal fun SignInScreen( contentColor = WappTheme.colors.white, containerColor = WappTheme.colors.yellow, disabledContentColor = WappTheme.colors.white, - disabledContainerColor = WappTheme.colors.gray1, + disabledContainerColor = WappTheme.colors.grayA2, ), shape = RoundedCornerShape(10.dp), ) { diff --git a/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpChip.kt b/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpChip.kt index 1e5a30d7..ad946bef 100644 --- a/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpChip.kt +++ b/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpChip.kt @@ -41,7 +41,7 @@ internal fun SignUpChip( ) }, colors = FilterChipDefaults.filterChipColors( - containerColor = WappTheme.colors.black3, + containerColor = WappTheme.colors.black82, selectedContainerColor = WappTheme.colors.yellow, ), ) diff --git a/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpScreen.kt b/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpScreen.kt index 64f671dd..9bfc1f6e 100644 --- a/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpScreen.kt +++ b/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpScreen.kt @@ -109,7 +109,7 @@ internal fun SignUpScreen( Text( text = stringResource(id = string.sign_up_content), style = WappTheme.typography.contentMedium, - color = WappTheme.colors.gray1, + color = WappTheme.colors.grayA2, ) Spacer(modifier = Modifier.height(32.dp)) diff --git a/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpTextField.kt b/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpTextField.kt index e82b3199..a0ce7673 100644 --- a/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpTextField.kt +++ b/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpTextField.kt @@ -58,7 +58,7 @@ internal fun SignUpTextField( unfocusedIndicatorColor = WappTheme.colors.white, ), placeholder = { - Text(text = hint, color = WappTheme.colors.gray1) + Text(text = hint, color = WappTheme.colors.grayA2) }, keyboardOptions = keyboardOptions, ) From 9129995b6f91074f6305ab09f4f0c35bba97fdb7 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 13:28:51 +0900 Subject: [PATCH 13/37] =?UTF-8?q?[FEATURE]=20#38=20:=20=EA=B3=B5=EC=9A=A9?= =?UTF-8?q?=20TopBar=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/designsystem/component/TopBar.kt | 139 ++++++++++++++++++ .../src/main/res/drawable/ic_back.xml | 9 ++ .../src/main/res/drawable/ic_close.xml | 5 + .../src/main/res/values/strings.xml | 6 + 4 files changed, 159 insertions(+) create mode 100644 core/designsystem/src/main/java/com/wap/designsystem/component/TopBar.kt create mode 100644 core/designsystem/src/main/res/drawable/ic_back.xml create mode 100644 core/designsystem/src/main/res/drawable/ic_close.xml create mode 100644 core/designsystem/src/main/res/values/strings.xml diff --git a/core/designsystem/src/main/java/com/wap/designsystem/component/TopBar.kt b/core/designsystem/src/main/java/com/wap/designsystem/component/TopBar.kt new file mode 100644 index 00000000..1353d2f5 --- /dev/null +++ b/core/designsystem/src/main/java/com/wap/designsystem/component/TopBar.kt @@ -0,0 +1,139 @@ +package com.wap.designsystem.component + +import androidx.annotation.DrawableRes +import androidx.annotation.StringRes +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.material3.Icon +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import com.wap.designsystem.WappTheme +import com.wap.wapp.core.designsystem.R + +@Composable +fun WappTopBar( + @StringRes titleRes: Int, + showLeftButton: Boolean = false, + showRightButton: Boolean = false, + onClickLeftButton: () -> Unit = {}, + onClickRightButton: () -> Unit = {}, + @StringRes leftButtonDescriptionRes: Int = R.string.back_button, + @StringRes rightButtonDescriptionRes: Int = R.string.close_button, + @DrawableRes leftButtonDrawableRes: Int = R.drawable.ic_back, + @DrawableRes rightButtonDrawableRes: Int = R.drawable.ic_close, +) { + Column( + modifier = Modifier.fillMaxSize(), + ) { + Row( + modifier = Modifier + .fillMaxSize() + .padding(16.dp), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically, + ) { + if (showLeftButton) { + Icon( + modifier = Modifier + .size(48.dp) + .clickable { onClickLeftButton() }, + painter = painterResource(leftButtonDrawableRes), + contentDescription = stringResource(leftButtonDescriptionRes), + tint = WappTheme.colors.white, + ) + } + + Text( + text = stringResource(titleRes), + textAlign = TextAlign.Center, + modifier = Modifier.weight(1f), + style = WappTheme.typography.titleBold, + color = WappTheme.colors.white, + ) + + if (showRightButton) { + Icon( + modifier = Modifier + .size(48.dp) + .clickable { onClickRightButton() }, + painter = painterResource(rightButtonDrawableRes), + contentDescription = stringResource(rightButtonDescriptionRes), + tint = WappTheme.colors.white, + ) + } + } + } +} + +@Preview("without Button TopBar") +@Composable +fun WappTopBarWithoutButton() { + WappTheme { + Surface( + color = WappTheme.colors.backgroundBlack, + ) { + WappTopBar( + titleRes = R.string.notice, + ) + } + } +} + +@Preview("with Right Button TopBar") +@Composable +fun WappTopBarWithRightButton() { + WappTheme { + Surface( + color = WappTheme.colors.backgroundBlack, + ) { + WappTopBar( + titleRes = R.string.notice, + showRightButton = true, + ) + } + } +} + +@Preview("with Left Button TopBar") +@Composable +fun WappTopBarWithLeftButton() { + WappTheme { + Surface( + color = WappTheme.colors.backgroundBlack, + ) { + WappTopBar( + titleRes = R.string.notice, + showLeftButton = true, + ) + } + } +} + +@Preview("with Both Button TopBar") +@Composable +fun WappTopBarWithBothButton() { + WappTheme { + Surface( + color = WappTheme.colors.backgroundBlack, + ) { + WappTopBar( + titleRes = R.string.notice, + showRightButton = true, + showLeftButton = true, + ) + } + } +} diff --git a/core/designsystem/src/main/res/drawable/ic_back.xml b/core/designsystem/src/main/res/drawable/ic_back.xml new file mode 100644 index 00000000..0aaf6561 --- /dev/null +++ b/core/designsystem/src/main/res/drawable/ic_back.xml @@ -0,0 +1,9 @@ + + + diff --git a/core/designsystem/src/main/res/drawable/ic_close.xml b/core/designsystem/src/main/res/drawable/ic_close.xml new file mode 100644 index 00000000..844b6b62 --- /dev/null +++ b/core/designsystem/src/main/res/drawable/ic_close.xml @@ -0,0 +1,5 @@ + + + diff --git a/core/designsystem/src/main/res/values/strings.xml b/core/designsystem/src/main/res/values/strings.xml new file mode 100644 index 00000000..bff1f9bf --- /dev/null +++ b/core/designsystem/src/main/res/values/strings.xml @@ -0,0 +1,6 @@ + + + 뒤로가기 버튼 + 닫기 버튼 + 공지사항 + From d8b6e27c134aafad0aef4ddc6f7689804b04f3ef Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 14:15:53 +0900 Subject: [PATCH 14/37] =?UTF-8?q?[CHORE]=20#38=20:=20TopBar=20Modifier=20?= =?UTF-8?q?=EB=A7=A4=EA=B0=9C=EB=B3=80=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/designsystem/component/TopBar.kt | 82 ++++++++++--------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/core/designsystem/src/main/java/com/wap/designsystem/component/TopBar.kt b/core/designsystem/src/main/java/com/wap/designsystem/component/TopBar.kt index 1353d2f5..49f8dc1b 100644 --- a/core/designsystem/src/main/java/com/wap/designsystem/component/TopBar.kt +++ b/core/designsystem/src/main/java/com/wap/designsystem/component/TopBar.kt @@ -4,9 +4,8 @@ import androidx.annotation.DrawableRes import androidx.annotation.StringRes import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.material3.Icon @@ -26,6 +25,7 @@ import com.wap.wapp.core.designsystem.R @Composable fun WappTopBar( @StringRes titleRes: Int, + modifier: Modifier = Modifier, showLeftButton: Boolean = false, showRightButton: Boolean = false, onClickLeftButton: () -> Unit = {}, @@ -35,45 +35,39 @@ fun WappTopBar( @DrawableRes leftButtonDrawableRes: Int = R.drawable.ic_back, @DrawableRes rightButtonDrawableRes: Int = R.drawable.ic_close, ) { - Column( - modifier = Modifier.fillMaxSize(), + Row( + modifier = modifier, + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically, ) { - Row( - modifier = Modifier - .fillMaxSize() - .padding(16.dp), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - ) { - if (showLeftButton) { - Icon( - modifier = Modifier - .size(48.dp) - .clickable { onClickLeftButton() }, - painter = painterResource(leftButtonDrawableRes), - contentDescription = stringResource(leftButtonDescriptionRes), - tint = WappTheme.colors.white, - ) - } - - Text( - text = stringResource(titleRes), - textAlign = TextAlign.Center, - modifier = Modifier.weight(1f), - style = WappTheme.typography.titleBold, - color = WappTheme.colors.white, + if (showLeftButton) { + Icon( + modifier = Modifier + .size(20.dp) + .clickable { onClickLeftButton() }, + painter = painterResource(leftButtonDrawableRes), + contentDescription = stringResource(leftButtonDescriptionRes), + tint = WappTheme.colors.white, ) + } - if (showRightButton) { - Icon( - modifier = Modifier - .size(48.dp) - .clickable { onClickRightButton() }, - painter = painterResource(rightButtonDrawableRes), - contentDescription = stringResource(rightButtonDescriptionRes), - tint = WappTheme.colors.white, - ) - } + Text( + text = stringResource(titleRes), + textAlign = TextAlign.Center, + modifier = Modifier.weight(1f), + style = WappTheme.typography.titleBold, + color = WappTheme.colors.white, + ) + + if (showRightButton) { + Icon( + modifier = Modifier + .size(20.dp) + .clickable { onClickRightButton() }, + painter = painterResource(rightButtonDrawableRes), + contentDescription = stringResource(rightButtonDescriptionRes), + tint = WappTheme.colors.white, + ) } } } @@ -86,6 +80,9 @@ fun WappTopBarWithoutButton() { color = WappTheme.colors.backgroundBlack, ) { WappTopBar( + modifier = Modifier + .fillMaxWidth() + .padding(16.dp), titleRes = R.string.notice, ) } @@ -100,6 +97,9 @@ fun WappTopBarWithRightButton() { color = WappTheme.colors.backgroundBlack, ) { WappTopBar( + modifier = Modifier + .fillMaxWidth() + .padding(16.dp), titleRes = R.string.notice, showRightButton = true, ) @@ -115,6 +115,9 @@ fun WappTopBarWithLeftButton() { color = WappTheme.colors.backgroundBlack, ) { WappTopBar( + modifier = Modifier + .fillMaxWidth() + .padding(16.dp), titleRes = R.string.notice, showLeftButton = true, ) @@ -130,6 +133,9 @@ fun WappTopBarWithBothButton() { color = WappTheme.colors.backgroundBlack, ) { WappTopBar( + modifier = Modifier + .fillMaxWidth() + .padding(16.dp), titleRes = R.string.notice, showRightButton = true, showLeftButton = true, From c7dbe6ec558aa8a3b6d79a4dfee781a646d3ec55 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 14:16:15 +0900 Subject: [PATCH 15/37] =?UTF-8?q?[CHORE]=20#38=20:=20=EA=B8=B0=EC=A1=B4=20?= =?UTF-8?q?TopBar=20=EA=B3=B5=EC=9A=A9=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/feature/auth/signup/SignUpScreen.kt | 51 +++++++------------ 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpScreen.kt b/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpScreen.kt index 9bfc1f6e..a4660a5b 100644 --- a/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpScreen.kt +++ b/feature/auth/src/main/java/com/wap/wapp/feature/auth/signup/SignUpScreen.kt @@ -1,9 +1,6 @@ package com.wap.wapp.feature.auth.signup -import androidx.compose.foundation.Image -import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -11,7 +8,6 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardOptions @@ -27,14 +23,14 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.KeyboardType -import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.hilt.navigation.compose.hiltViewModel import com.wap.designsystem.WappTheme +import com.wap.designsystem.component.WappTopBar import com.wap.wapp.core.commmon.extensions.toSupportingText import com.wap.wapp.core.designresource.R import com.wap.wapp.feature.auth.R.drawable.ic_card @@ -57,6 +53,7 @@ internal fun SignUpScreen( is SignUpEvent.Success -> { navigateToNotice() } + is SignUpEvent.Failure -> { snackBarHostState.showSnackbar( message = it.throwable.toSupportingText(), @@ -76,34 +73,20 @@ internal fun SignUpScreen( .fillMaxSize() .padding(horizontal = 16.dp), ) { - Box( - modifier = Modifier.fillMaxWidth(), - ) { - Image( - painterResource(id = R.drawable.ic_back_btn), - contentDescription = stringResource(id = string.back_button_description), - modifier = Modifier - .padding(vertical = 16.dp) - .size(20.dp) - .clickable { navigateToSignIn() }, - ) - Text( - text = stringResource(id = string.sign_up), - style = WappTheme.typography.titleBold, - color = WappTheme.colors.white, - fontSize = 20.sp, - modifier = Modifier - .fillMaxWidth() - .padding(vertical = 16.dp), - textAlign = TextAlign.Center, - ) - } - - Spacer(modifier = Modifier.height(32.dp)) + WappTopBar( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 16.dp), + titleRes = string.sign_up, + showLeftButton = true, + onClickLeftButton = { navigateToSignIn() }, + ) + Spacer(modifier = Modifier.height(16.dp)) Text( text = stringResource(id = string.sign_up_title), style = WappTheme.typography.titleBold, + fontSize = 22.sp, color = WappTheme.colors.white, ) Text( @@ -190,11 +173,11 @@ internal fun SignUpScreen( } } -/*@Preview +@Preview @Composable fun previewSignUpScreen() { SignUpScreen( - "", - navigateToNotice = { } + navigateToSignIn = { }, + navigateToNotice = { }, ) -}*/ +} From 1219603a23a33c4784e31a5aad7bf0074145d186 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 14:16:30 +0900 Subject: [PATCH 16/37] =?UTF-8?q?[CHORE]=20#38=20:=20Title=2022sp=20->=201?= =?UTF-8?q?8sp=20=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designsystem/src/main/java/com/wap/designsystem/Type.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/designsystem/src/main/java/com/wap/designsystem/Type.kt b/core/designsystem/src/main/java/com/wap/designsystem/Type.kt index c48b3a4e..03c67b8e 100644 --- a/core/designsystem/src/main/java/com/wap/designsystem/Type.kt +++ b/core/designsystem/src/main/java/com/wap/designsystem/Type.kt @@ -86,21 +86,21 @@ class WappTypography internal constructor( fun WappTypography(): WappTypography { return WappTypography( titleBold = TextStyle( - fontSize = 22.sp, + fontSize = 18.sp, fontFamily = NotoSansBold, platformStyle = PlatformTextStyle( includeFontPadding = false, ), ), titleMedium = TextStyle( - fontSize = 22.sp, + fontSize = 18.sp, fontFamily = NotoSansMedium, platformStyle = PlatformTextStyle( includeFontPadding = false, ), ), titleRegular = TextStyle( - fontSize = 22.sp, + fontSize = 18.sp, fontFamily = NotoSansRegular, platformStyle = PlatformTextStyle( includeFontPadding = false, From 4023deeea189f4e779d32703f797457cc2bd1bb4 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 14:17:31 +0900 Subject: [PATCH 17/37] =?UTF-8?q?[CHORE]=20#38=20:=20=EC=A2=85=EC=86=8D?= =?UTF-8?q?=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 --- feature/auth/build.gradle.kts | 1 - feature/manage/build.gradle.kts | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/feature/auth/build.gradle.kts b/feature/auth/build.gradle.kts index d2f266d2..75ae8466 100644 --- a/feature/auth/build.gradle.kts +++ b/feature/auth/build.gradle.kts @@ -1,6 +1,5 @@ plugins { id("com.wap.wapp.feature") - id("com.wap.wapp.compose") id("com.wap.wapp.hilt") } diff --git a/feature/manage/build.gradle.kts b/feature/manage/build.gradle.kts index beefff28..934d9678 100644 --- a/feature/manage/build.gradle.kts +++ b/feature/manage/build.gradle.kts @@ -1,5 +1,6 @@ plugins { id("com.wap.wapp.feature") + id("com.wap.wapp.hilt") } android { @@ -22,11 +23,15 @@ android { } dependencies { - implementation(project(":core:designresource")) + implementation(project(":core:domain")) + implementation(project(":core:model")) implementation(project(":core:designsystem")) + implementation(project(":core:designresource")) + implementation(project(":core:common")) implementation(libs.bundles.androidx) implementation(libs.material) + testImplementation(libs.junit) androidTestImplementation(libs.androidx.test.junit) androidTestImplementation(libs.androidx.test.espresso) From 7d1ae38a30c53457e50554aa19729fa4f9628ba3 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 14:18:14 +0900 Subject: [PATCH 18/37] =?UTF-8?q?[REFACTOR]=20#38=20:=20=EB=A7=A4=EB=8B=88?= =?UTF-8?q?=EC=A0=80=20State=20=EA=B5=AC=ED=95=98=EB=8A=94=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EB=B0=98=ED=99=98=EA=B0=92=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 --- .../repository/manage/ManageRepository.kt | 2 +- .../repository/manage/ManageRepositoryImpl.kt | 2 +- .../network/source/manage/ManageDataSource.kt | 2 +- .../source/manage/ManageDataSourceImpl.kt | 4 +- .../wap/wapp/feature/manage/ManageFragment.kt | 53 +++++-------------- 5 files changed, 17 insertions(+), 46 deletions(-) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt index 2331e5fb..aa3e6e4b 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt @@ -1,7 +1,7 @@ package com.wap.wapp.core.data.repository.manage interface ManageRepository { - suspend fun getManager(userId: String): Result + suspend fun getManager(userId: String): Result suspend fun postManager(userId: String): Result diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt index c43fdd5d..f28ede2b 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt @@ -6,7 +6,7 @@ import javax.inject.Inject class ManageRepositoryImpl @Inject constructor( private val manageDataSource: ManageDataSource, ) : ManageRepository { - override suspend fun getManager(userId: String): Result { + override suspend fun getManager(userId: String): Result { return manageDataSource.getManager(userId) } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt index 88b7fe50..00027597 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt @@ -1,7 +1,7 @@ package com.wap.wapp.core.network.source.manage interface ManageDataSource { - suspend fun getManager(userId: String): Result + suspend fun getManager(userId: String): Result suspend fun postManager(userId: String): Result diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt index bccef0e5..c0afc362 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt @@ -10,14 +10,14 @@ import javax.inject.Inject class ManageDataSourceImpl @Inject constructor( private val firebaseFirestore: FirebaseFirestore, ) : ManageDataSource { - override suspend fun getManager(userId: String): Result { + override suspend fun getManager(userId: String): Result { return runCatching { val result = firebaseFirestore.collection(MANAGER_COLLECTION) .whereEqualTo("userId", userId) .get() .await() - check(result.isEmpty.not()) + result.isEmpty.not() } } diff --git a/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageFragment.kt b/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageFragment.kt index 201a00fd..4df0fe72 100644 --- a/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageFragment.kt +++ b/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageFragment.kt @@ -4,57 +4,28 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment +import com.wap.designsystem.WappTheme -// TODO: Rename parameter arguments, choose names that match -// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER -private const val ARG_PARAM1 = "param1" -private const val ARG_PARAM2 = "param2" - -/** - * A simple [Fragment] subclass. - * Use the [ManageFragment.newInstance] factory method to - * create an instance of this fragment. - */ class ManageFragment : Fragment() { - // TODO: Rename and change types of parameters - private var param1: String? = null - private var param2: String? = null - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - arguments?.let { - param1 = it.getString(ARG_PARAM1) - param2 = it.getString(ARG_PARAM2) - } - } + private lateinit var composeView: ComposeView override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?, - ): View? { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_manage, container, false) + ): View { + return ComposeView(requireContext()).also { + composeView = it + } } - companion object { - /** - * Use this factory method to create a new instance of - * this fragment using the provided parameters. - * - * @param param1 Parameter 1. - * @param param2 Parameter 2. - * @return A new instance of fragment ManageFragment. - */ - // TODO: Rename and change types and number of parameters - @JvmStatic - fun newInstance(param1: String, param2: String) = - ManageFragment().apply { - arguments = Bundle().apply { - putString(ARG_PARAM1, param1) - putString(ARG_PARAM2, param2) - } - } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + composeView.setContent { + WappTheme {} + } } } From 8dad305b32d294a22f3a148aee792492cf7f7468 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 14:19:16 +0900 Subject: [PATCH 19/37] =?UTF-8?q?[REFACTOR]=20#38=20:=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=20=EA=B0=92=20=EC=88=98=EC=A0=95=20Unit=20->=20Boolean?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ManagerStatusUseCase.kt => HasManagerStateUseCase.kt} | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) rename core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/{CheckManagerStatusUseCase.kt => HasManagerStateUseCase.kt} (62%) diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerStatusUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/HasManagerStateUseCase.kt similarity index 62% rename from core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerStatusUseCase.kt rename to core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/HasManagerStateUseCase.kt index 7a0cb86e..61c5b10a 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerStatusUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/HasManagerStateUseCase.kt @@ -6,15 +6,18 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class CheckManagerStatusUseCase @Inject constructor( +class HasManagerStateUseCase @Inject constructor( private val manageRepository: ManageRepository, private val userRepository: UserRepository, ) { - suspend operator fun invoke(): Result { + suspend operator fun invoke(): Result { return runCatching { val userId = userRepository.getUserId().getOrThrow() - manageRepository.getManager(userId) + manageRepository.getManager(userId).fold( + onSuccess = { hasManagerState -> hasManagerState }, + onFailure = { throw(it) }, + ) } } } From 9d18cb8f5d943273c63384b62b36380eb130cf61 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 14:19:44 +0900 Subject: [PATCH 20/37] =?UTF-8?q?[STYLE]=20#38=20:=20Verification=20->=20V?= =?UTF-8?q?alidation=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/core/domain/model/CodeValidation.kt | 5 +++++ .../wap/wapp/core/domain/model/CodeVerification.kt | 5 ----- ...odeUseCase.kt => ValidateManagerCodeUseCase.kt} | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/model/CodeValidation.kt delete mode 100644 core/domain/src/main/java/com/wap/wapp/core/domain/model/CodeVerification.kt rename core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/{CheckManagerCodeUseCase.kt => ValidateManagerCodeUseCase.kt} (66%) diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/model/CodeValidation.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/model/CodeValidation.kt new file mode 100644 index 00000000..c8693f8a --- /dev/null +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/model/CodeValidation.kt @@ -0,0 +1,5 @@ +package com.wap.wapp.core.domain.model + +enum class CodeValidation { + INVALID, VALID +} diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/model/CodeVerification.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/model/CodeVerification.kt deleted file mode 100644 index 16bae844..00000000 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/model/CodeVerification.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.wap.wapp.core.domain.model - -enum class CodeVerification { - UNVERIFIED, VERIFIED -} diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerCodeUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/ValidateManagerCodeUseCase.kt similarity index 66% rename from core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerCodeUseCase.kt rename to core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/ValidateManagerCodeUseCase.kt index 63e4159d..22a76c6b 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/CheckManagerCodeUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/ValidateManagerCodeUseCase.kt @@ -2,21 +2,21 @@ package com.wap.wapp.core.domain.usecase.manage import com.wap.wapp.core.data.repository.manage.ManageRepository import com.wap.wapp.core.data.repository.user.UserRepository -import com.wap.wapp.core.domain.model.CodeVerification +import com.wap.wapp.core.domain.model.CodeValidation import javax.inject.Inject import javax.inject.Singleton @Singleton -class CheckManagerCodeUseCase @Inject constructor( +class ValidateManagerCodeUseCase @Inject constructor( private val manageRepository: ManageRepository, private val userRepository: UserRepository, ) { - suspend operator fun invoke(code: String): Result { + suspend operator fun invoke(code: String): Result { return runCatching { manageRepository.getManagerCode(code) - .onSuccess { isVerified -> - if (isVerified.not()) { // 코드가 틀렸을 경우 - return@runCatching CodeVerification.UNVERIFIED + .onSuccess { isValid -> + if (isValid.not()) { // 코드가 틀렸을 경우 + return@runCatching CodeValidation.INVALID } } @@ -25,7 +25,7 @@ class CheckManagerCodeUseCase @Inject constructor( manageRepository.postManager(userId) .fold( onSuccess = { - CodeVerification.VERIFIED + CodeValidation.VALID }, onFailure = { exception -> throw(exception) From af1a5cd6734394a31a4cafa66d6794030e223691 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 20:24:49 +0900 Subject: [PATCH 21/37] [STYLE] #38 : Rename ManagerCode -> ManageCode --- .../wap/wapp/core/data/repository/manage/ManageRepository.kt | 2 +- .../wapp/core/data/repository/manage/ManageRepositoryImpl.kt | 4 ++-- ...dateManagerCodeUseCase.kt => ValidateManageCodeUseCase.kt} | 4 ++-- .../wap/wapp/core/network/source/manage/ManageDataSource.kt | 2 +- .../wapp/core/network/source/manage/ManageDataSourceImpl.kt | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/{ValidateManagerCodeUseCase.kt => ValidateManageCodeUseCase.kt} (91%) diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt index aa3e6e4b..4880a354 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepository.kt @@ -5,5 +5,5 @@ interface ManageRepository { suspend fun postManager(userId: String): Result - suspend fun getManagerCode(code: String): Result + suspend fun getManageCode(code: String): Result } diff --git a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt index f28ede2b..0574264d 100644 --- a/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt +++ b/core/data/src/main/java/com/wap/wapp/core/data/repository/manage/ManageRepositoryImpl.kt @@ -14,7 +14,7 @@ class ManageRepositoryImpl @Inject constructor( return manageDataSource.postManager(userId) } - override suspend fun getManagerCode(code: String): Result { - return manageDataSource.getManagerCode(code) + override suspend fun getManageCode(code: String): Result { + return manageDataSource.getManageCode(code) } } diff --git a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/ValidateManagerCodeUseCase.kt b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/ValidateManageCodeUseCase.kt similarity index 91% rename from core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/ValidateManagerCodeUseCase.kt rename to core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/ValidateManageCodeUseCase.kt index 22a76c6b..87d32d57 100644 --- a/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/ValidateManagerCodeUseCase.kt +++ b/core/domain/src/main/java/com/wap/wapp/core/domain/usecase/manage/ValidateManageCodeUseCase.kt @@ -7,13 +7,13 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class ValidateManagerCodeUseCase @Inject constructor( +class ValidateManageCodeUseCase @Inject constructor( private val manageRepository: ManageRepository, private val userRepository: UserRepository, ) { suspend operator fun invoke(code: String): Result { return runCatching { - manageRepository.getManagerCode(code) + manageRepository.getManageCode(code) .onSuccess { isValid -> if (isValid.not()) { // 코드가 틀렸을 경우 return@runCatching CodeValidation.INVALID diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt index 00027597..7f3f1761 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSource.kt @@ -5,5 +5,5 @@ interface ManageDataSource { suspend fun postManager(userId: String): Result - suspend fun getManagerCode(code: String): Result + suspend fun getManageCode(code: String): Result } diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt index c0afc362..2a1811dc 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt @@ -33,7 +33,7 @@ class ManageDataSourceImpl @Inject constructor( } } - override suspend fun getManagerCode(code: String): Result { + override suspend fun getManageCode(code: String): Result { return runCatching { val result = firebaseFirestore.collection(CODES_COLLECTION) .whereEqualTo("manager", code) From f159417aac0e0f23de9351666127df9555af79bf Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 22:57:29 +0900 Subject: [PATCH 22/37] [CHORE] #38 : nav_manage -> nav_management rename --- app/src/main/res/menu/menu_main.xml | 4 ++-- app/src/main/res/navigation/nav_main.xml | 2 +- .../navigation/{nav_manage.xml => nav_management.xml} | 9 ++++----- 3 files changed, 7 insertions(+), 8 deletions(-) rename feature/manage/src/main/res/navigation/{nav_manage.xml => nav_management.xml} (67%) diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index d487e1f7..a88082fd 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -16,7 +16,7 @@ android:icon="@drawable/selector_profile" /> - \ No newline at end of file + diff --git a/app/src/main/res/navigation/nav_main.xml b/app/src/main/res/navigation/nav_main.xml index 3640d92b..76b8d678 100644 --- a/app/src/main/res/navigation/nav_main.xml +++ b/app/src/main/res/navigation/nav_main.xml @@ -5,7 +5,7 @@ app:startDestination="@id/nav_splash"> - + diff --git a/feature/manage/src/main/res/navigation/nav_manage.xml b/feature/manage/src/main/res/navigation/nav_management.xml similarity index 67% rename from feature/manage/src/main/res/navigation/nav_manage.xml rename to feature/manage/src/main/res/navigation/nav_management.xml index 64bb71df..c64e40b8 100644 --- a/feature/manage/src/main/res/navigation/nav_manage.xml +++ b/feature/manage/src/main/res/navigation/nav_management.xml @@ -2,14 +2,13 @@ + android:label="fragment_manage" /> - - \ No newline at end of file + + From 8c77ce1a005edfe62317ee0af276470837184dad Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 22:57:51 +0900 Subject: [PATCH 23/37] [CHORE] #38 : bottomNavView add controller --- app/src/main/java/com/wap/wapp/MainActivity.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/wap/wapp/MainActivity.kt b/app/src/main/java/com/wap/wapp/MainActivity.kt index 07324139..09b37df0 100644 --- a/app/src/main/java/com/wap/wapp/MainActivity.kt +++ b/app/src/main/java/com/wap/wapp/MainActivity.kt @@ -5,6 +5,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.view.isVisible import androidx.navigation.NavController import androidx.navigation.fragment.NavHostFragment +import androidx.navigation.ui.setupWithNavController import com.wap.wapp.databinding.ActivityMainBinding import dagger.hilt.android.AndroidEntryPoint @@ -27,6 +28,7 @@ class MainActivity : AppCompatActivity() { navController = navHostFragment.navController bnvMainBottomNaviView.itemIconTintList = null + bnvMainBottomNaviView.setupWithNavController(navController) setBottomNavigationVisiblity() } From ea95a3eccbf3e2a0b55220f55c7dac0c6c9709b2 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 22:58:15 +0900 Subject: [PATCH 24/37] [CHORE] #38 : delete manage fragment xml view --- .../manage/src/main/res/layout/fragment_manage.xml | 14 -------------- feature/manage/src/main/res/values/strings.xml | 5 ++--- 2 files changed, 2 insertions(+), 17 deletions(-) delete mode 100644 feature/manage/src/main/res/layout/fragment_manage.xml diff --git a/feature/manage/src/main/res/layout/fragment_manage.xml b/feature/manage/src/main/res/layout/fragment_manage.xml deleted file mode 100644 index 1d26b222..00000000 --- a/feature/manage/src/main/res/layout/fragment_manage.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/feature/manage/src/main/res/values/strings.xml b/feature/manage/src/main/res/values/strings.xml index 6048840e..b2f03de0 100644 --- a/feature/manage/src/main/res/values/strings.xml +++ b/feature/manage/src/main/res/values/strings.xml @@ -1,4 +1,3 @@ - - Hello blank fragment - \ No newline at end of file + 관리 + From 9adf0fd22528db98d14bc44ee28d1092549089e3 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 22:58:30 +0900 Subject: [PATCH 25/37] =?UTF-8?q?[FEATURE]=20#38=20:=20=EA=B3=B5=EC=9A=A9?= =?UTF-8?q?=20Button=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wap/designsystem/component/Button.kt | 39 +++++++++++++++++++ .../src/main/res/values/strings.xml | 1 + 2 files changed, 40 insertions(+) create mode 100644 core/designsystem/src/main/java/com/wap/designsystem/component/Button.kt diff --git a/core/designsystem/src/main/java/com/wap/designsystem/component/Button.kt b/core/designsystem/src/main/java/com/wap/designsystem/component/Button.kt new file mode 100644 index 00000000..a8fa1f69 --- /dev/null +++ b/core/designsystem/src/main/java/com/wap/designsystem/component/Button.kt @@ -0,0 +1,39 @@ +package com.wap.designsystem.component + +import androidx.annotation.StringRes +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import com.wap.designsystem.WappTheme +import com.wap.wapp.core.designsystem.R + +@Composable +fun WappButton( + modifier: Modifier = Modifier, + @StringRes textRes: Int = R.string.done, + onClick: () -> Unit, + isEnabled: Boolean = true, +) { + Button( + modifier = modifier + .fillMaxWidth() + .height(48.dp), + onClick = { onClick() }, + enabled = isEnabled, + colors = ButtonDefaults.buttonColors( + contentColor = WappTheme.colors.black, + containerColor = WappTheme.colors.yellow, + disabledContentColor = WappTheme.colors.white, + disabledContainerColor = WappTheme.colors.grayA2, + ), + shape = RoundedCornerShape(10.dp), + content = { Text(text = stringResource(textRes)) }, + ) +} diff --git a/core/designsystem/src/main/res/values/strings.xml b/core/designsystem/src/main/res/values/strings.xml index bff1f9bf..f7194552 100644 --- a/core/designsystem/src/main/res/values/strings.xml +++ b/core/designsystem/src/main/res/values/strings.xml @@ -3,4 +3,5 @@ 뒤로가기 버튼 닫기 버튼 공지사항 + 완료 From 83a9f056a02904a6ddc2199bf020a7b29669aee0 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Sun, 22 Oct 2023 23:00:37 +0900 Subject: [PATCH 26/37] =?UTF-8?q?[CHORE]=20#38=20:=20firestore=20field=20n?= =?UTF-8?q?ame=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt index 2a1811dc..ed97637b 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/manage/ManageDataSourceImpl.kt @@ -36,7 +36,7 @@ class ManageDataSourceImpl @Inject constructor( override suspend fun getManageCode(code: String): Result { return runCatching { val result = firebaseFirestore.collection(CODES_COLLECTION) - .whereEqualTo("manager", code) + .whereEqualTo("management", code) .get() .await() From 74cc7fac787bdfd836a98cd077fe8beba695f992 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Mon, 23 Oct 2023 20:09:58 +0900 Subject: [PATCH 27/37] =?UTF-8?q?[CHORE]=20#38=20:=20toast=20extensions=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/commmon/extensions/ContextExtensions.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 core/common/src/main/java/com/wap/wapp/core/commmon/extensions/ContextExtensions.kt diff --git a/core/common/src/main/java/com/wap/wapp/core/commmon/extensions/ContextExtensions.kt b/core/common/src/main/java/com/wap/wapp/core/commmon/extensions/ContextExtensions.kt new file mode 100644 index 00000000..7344f5f9 --- /dev/null +++ b/core/common/src/main/java/com/wap/wapp/core/commmon/extensions/ContextExtensions.kt @@ -0,0 +1,12 @@ +package com.wap.wapp.core.commmon.extensions + +import android.content.Context +import android.widget.Toast + +fun Context.showToast(message: String) { + Toast.makeText(this, message, Toast.LENGTH_SHORT).show() +} + +fun Context.showLongToast(message: String) { + Toast.makeText(this, message, Toast.LENGTH_LONG).show() +} From 7bb8f8b60063815b3a59203b3e773c73f53f620a Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Mon, 23 Oct 2023 20:10:22 +0900 Subject: [PATCH 28/37] =?UTF-8?q?[CHORE]=20#38=20:=20=EA=B4=80=EB=A6=AC=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20string=20=EB=93=B1=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/manage/src/main/res/values/strings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/feature/manage/src/main/res/values/strings.xml b/feature/manage/src/main/res/values/strings.xml index b2f03de0..3a8fb4c3 100644 --- a/feature/manage/src/main/res/values/strings.xml +++ b/feature/manage/src/main/res/values/strings.xml @@ -1,3 +1,8 @@ 관리 + 회원 코드를 입력하세요 + 회원만 해당 내용을 확인할 수 있어요 + code + Hint : WAPP + 잘못된 코드입니다. From fa407991008b27332678452074cda98e88414b54 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Mon, 23 Oct 2023 20:10:36 +0900 Subject: [PATCH 29/37] =?UTF-8?q?[FEATURE]=20#38=20:=20=EA=B3=B5=EC=9A=A9?= =?UTF-8?q?=20TextField=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/designsystem/component/TextField.kt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 core/designsystem/src/main/java/com/wap/designsystem/component/TextField.kt diff --git a/core/designsystem/src/main/java/com/wap/designsystem/component/TextField.kt b/core/designsystem/src/main/java/com/wap/designsystem/component/TextField.kt new file mode 100644 index 00000000..cbb6d152 --- /dev/null +++ b/core/designsystem/src/main/java/com/wap/designsystem/component/TextField.kt @@ -0,0 +1,44 @@ +package com.wap.designsystem.component + +import androidx.annotation.StringRes +import androidx.compose.material3.Text +import androidx.compose.material3.TextField +import androidx.compose.material3.TextFieldDefaults +import androidx.compose.runtime.Composable +import androidx.compose.ui.res.stringResource +import com.wap.designsystem.WappTheme + +@Composable +fun WappTextField( + value: String, + onValueChanged: (String) -> Unit, + @StringRes label: Int, + isError: Boolean = false, + supportingText: String = "", +) { + TextField( + value = value, + onValueChange = { value -> onValueChanged(value) }, + colors = TextFieldDefaults.colors( + unfocusedContainerColor = WappTheme.colors.black25, + focusedContainerColor = WappTheme.colors.black25, + errorContainerColor = WappTheme.colors.black25, + unfocusedLabelColor = WappTheme.colors.white, + focusedLabelColor = WappTheme.colors.white, + unfocusedTextColor = WappTheme.colors.white, + focusedTextColor = WappTheme.colors.white, + errorTextColor = WappTheme.colors.white, + unfocusedSupportingTextColor = WappTheme.colors.white, + focusedSupportingTextColor = WappTheme.colors.white, + focusedIndicatorColor = WappTheme.colors.yellow, + cursorColor = WappTheme.colors.yellow, + ), + label = { + Text(text = stringResource(label)) + }, + isError = isError, + supportingText = { + Text(text = supportingText) + }, + ) +} From 1e6015e792a4c279ecb24c674b526e0b62296490 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Mon, 23 Oct 2023 20:11:05 +0900 Subject: [PATCH 30/37] =?UTF-8?q?[FEATURE]=20#38=20:=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/feature/manage/ManageScreen.kt | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageScreen.kt diff --git a/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageScreen.kt b/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageScreen.kt new file mode 100644 index 00000000..1e72f39e --- /dev/null +++ b/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageScreen.kt @@ -0,0 +1,74 @@ +package com.wap.wapp.feature.manage + +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Scaffold +import androidx.compose.material3.SnackbarHost +import androidx.compose.material3.SnackbarHostState +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.remember +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.hilt.navigation.compose.hiltViewModel +import com.wap.designsystem.WappTheme +import com.wap.wapp.core.commmon.extensions.toSupportingText +import com.wap.wapp.feature.manage.ManageViewModel.ManagerState +import kotlinx.coroutines.flow.collectLatest + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +internal fun ManageScreen( + showManageCodeDialog: () -> Unit, + viewModel: ManageViewModel = hiltViewModel(), +) { + val snackBarHostState = remember { SnackbarHostState() } + + LaunchedEffect(true) { + viewModel.managerState.collectLatest { managerState -> + when (managerState) { + ManagerState.NonManager -> { + showManageCodeDialog() + } + ManagerState.Init -> { } + ManagerState.Manager -> { } + } + } + + viewModel.errorFlow.collectLatest { throwable -> + snackBarHostState.showSnackbar( + message = throwable.toSupportingText(), + ) + } + } + + Scaffold( + containerColor = WappTheme.colors.backgroundBlack, + snackbarHost = { SnackbarHost(snackBarHostState) }, + topBar = { + TopAppBar( + title = { + Text( + text = stringResource(id = R.string.manage), + style = WappTheme.typography.titleBold, + color = WappTheme.colors.white, + ) + }, + colors = TopAppBarDefaults.topAppBarColors( + containerColor = WappTheme.colors.black25, + ), + ) + }, + ) { padding -> + } +} + +@Preview +@Composable +fun previewManageScreen() { + WappTheme { + // ManageScreen() + } +} From 44c388467d4e7bd463216744197460f1e06e9dec Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Mon, 23 Oct 2023 20:11:43 +0900 Subject: [PATCH 31/37] =?UTF-8?q?[FEATURE]=20#38=20:=20=EC=9A=B4=EC=98=81?= =?UTF-8?q?=EC=A7=84=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C=EC=A7=81=EC=9D=B4=20?= =?UTF-8?q?=ED=8F=AC=ED=95=A8=EB=90=9C=20ManageviewModel=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wapp/feature/manage/ManageViewModel.kt | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageViewModel.kt diff --git a/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageViewModel.kt b/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageViewModel.kt new file mode 100644 index 00000000..8bad0647 --- /dev/null +++ b/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageViewModel.kt @@ -0,0 +1,50 @@ +package com.wap.wapp.feature.manage + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.wap.wapp.core.domain.usecase.manage.HasManagerStateUseCase +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.launch + +@HiltViewModel +class ManageViewModel @Inject constructor( + private val hasManagerStateUseCase: HasManagerStateUseCase, +) : ViewModel() { + + private val _errorFlow: MutableSharedFlow = MutableSharedFlow() + val errorFlow: SharedFlow get() = _errorFlow + + private val _managerState: MutableStateFlow = MutableStateFlow(ManagerState.Init) + val managerState: StateFlow get() = _managerState + + init { + hasManagerState() + } + + private fun hasManagerState() { + viewModelScope.launch { + hasManagerStateUseCase() + .onSuccess { hasManageState -> + if (hasManageState) { + _managerState.emit(ManagerState.Manager) + } else { + _managerState.emit(ManagerState.NonManager) + } + } + .onFailure { exception -> + _errorFlow.emit(exception) + } + } + } + + sealed class ManagerState { + data object Init : ManagerState() + data object Manager : ManagerState() + data object NonManager : ManagerState() + } +} From 75dba23259156d2a8a354e82244bceb161f8b1f1 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Mon, 23 Oct 2023 20:12:13 +0900 Subject: [PATCH 32/37] =?UTF-8?q?[FEATURE]=20#38=20:=20=EC=9A=B4=EC=98=81?= =?UTF-8?q?=EC=A7=84=20=EC=BD=94=EB=93=9C=20=EC=9D=B8=EC=A6=9D=20=EB=94=94?= =?UTF-8?q?=EC=95=8C=EB=A1=9C=EA=B7=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/manage/code/ManageCodeDialog.kt | 104 ++++++++++++++++++ .../manage/code/ManagementCodeViewModel.kt | 62 +++++++++++ 2 files changed, 166 insertions(+) create mode 100644 feature/manage/src/main/java/com/wap/wapp/feature/manage/code/ManageCodeDialog.kt create mode 100644 feature/manage/src/main/java/com/wap/wapp/feature/manage/code/ManagementCodeViewModel.kt diff --git a/feature/manage/src/main/java/com/wap/wapp/feature/manage/code/ManageCodeDialog.kt b/feature/manage/src/main/java/com/wap/wapp/feature/manage/code/ManageCodeDialog.kt new file mode 100644 index 00000000..c7fa847d --- /dev/null +++ b/feature/manage/src/main/java/com/wap/wapp/feature/manage/code/ManageCodeDialog.kt @@ -0,0 +1,104 @@ +package com.wap.wapp.feature.manage.code + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.AlertDialog +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.collectAsState +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.DialogProperties +import androidx.hilt.navigation.compose.hiltViewModel +import com.wap.designsystem.WappTheme +import com.wap.designsystem.component.WappButton +import com.wap.designsystem.component.WappTextField +import com.wap.wapp.feature.manage.R +import com.wap.wapp.feature.manage.code.ManagementCodeViewModel.ManagementCodeUiState +import kotlinx.coroutines.flow.collectLatest + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun ManageCodeDialog( + viewModel: ManagementCodeViewModel = hiltViewModel(), + onDismissRequest: () -> Unit, + showToast: (Throwable) -> Unit, +) { + LaunchedEffect(true) { + viewModel.managementCodeUiState.collectLatest { + when (it) { + is ManagementCodeUiState.Success -> { + onDismissRequest() + } + is ManagementCodeUiState.Failure -> { + showToast(it.throwable) + } + is ManagementCodeUiState.Init -> { } + } + } + } + + AlertDialog( + onDismissRequest = { onDismissRequest() }, + modifier = Modifier.padding(horizontal = 16.dp), + properties = DialogProperties( + dismissOnBackPress = false, + dismissOnClickOutside = false, + ), + ) { + Column( + modifier = Modifier.padding(16.dp), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(16.dp), + ) { + Column { + Text( + text = stringResource(R.string.management_dialog_title), + style = WappTheme.typography.titleBold, + color = WappTheme.colors.white, + textAlign = TextAlign.Center, + ) + Text( + text = stringResource(R.string.management_dialog_content), + style = WappTheme.typography.captionMedium, + color = WappTheme.colors.white, + textAlign = TextAlign.Center, + ) + } + + WappTextField( + value = viewModel.manageCode.collectAsState().value, + onValueChanged = { code -> viewModel.setManagementCode(code = code) }, + label = R.string.code, + isError = viewModel.isError.collectAsState().value, + supportingText = stringResource( + id = viewModel.errorSupportingText.collectAsState().value, + ), + ) + + WappButton( + onClick = { viewModel.validateManageCode() }, + isEnabled = viewModel.manageCode + .collectAsState() + .value + .isNotBlank(), + ) + } + } +} + +/* +@Preview +@Composable +fun previewDialog() { + WappTheme { + ManageCodeDialog() + } +} +*/ diff --git a/feature/manage/src/main/java/com/wap/wapp/feature/manage/code/ManagementCodeViewModel.kt b/feature/manage/src/main/java/com/wap/wapp/feature/manage/code/ManagementCodeViewModel.kt new file mode 100644 index 00000000..705d7941 --- /dev/null +++ b/feature/manage/src/main/java/com/wap/wapp/feature/manage/code/ManagementCodeViewModel.kt @@ -0,0 +1,62 @@ +package com.wap.wapp.feature.manage.code + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.wap.wapp.core.domain.model.CodeValidation +import com.wap.wapp.core.domain.usecase.manage.ValidateManageCodeUseCase +import com.wap.wapp.feature.manage.R +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.launch + +@HiltViewModel +class ManagementCodeViewModel @Inject constructor( + private val validateManageCodeUseCase: ValidateManageCodeUseCase, +) : ViewModel() { + private val _managementCodeUiState: MutableStateFlow = + MutableStateFlow(ManagementCodeUiState.Init) + val managementCodeUiState: StateFlow + get() = _managementCodeUiState + + private val _manageCode: MutableStateFlow = MutableStateFlow("") + val manageCode: StateFlow get() = _manageCode + + private val _isError: MutableStateFlow = MutableStateFlow(false) + val isError: StateFlow get() = _isError + + private val _errorSupportingText: MutableStateFlow = + MutableStateFlow(R.string.management_dialog_hint) + val errorSupportingText: StateFlow get() = _errorSupportingText + + fun validateManageCode() { + viewModelScope.launch { + validateManageCodeUseCase(_manageCode.value) + .onSuccess { + when (it) { + CodeValidation.VALID -> { + _managementCodeUiState.value = ManagementCodeUiState.Success + } + CodeValidation.INVALID -> { + _isError.value = true + _errorSupportingText.value = R.string.management_incorrect_code + } + } + } + .onFailure { throwable -> + _managementCodeUiState.value = ManagementCodeUiState.Failure(throwable) + } + } + } + + fun setManagementCode(code: String) { + _manageCode.value = code + } + + sealed class ManagementCodeUiState { + data object Init : ManagementCodeUiState() + data object Success : ManagementCodeUiState() + data class Failure(val throwable: Throwable) : ManagementCodeUiState() + } +} From 1c7c72ecf596fa532b4547578a5ac6d28fb82ab7 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Mon, 23 Oct 2023 20:12:43 +0900 Subject: [PATCH 33/37] =?UTF-8?q?[FEATURE]=20#38=20:=20ManageFragment?= =?UTF-8?q?=EC=97=90=20Screen,=20Dialog=20=EB=B3=B4=EC=97=AC=EC=A7=80?= =?UTF-8?q?=EB=8A=94=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/feature/manage/ManageFragment.kt | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageFragment.kt b/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageFragment.kt index 4df0fe72..8d2277ce 100644 --- a/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageFragment.kt +++ b/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageFragment.kt @@ -4,10 +4,19 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment import com.wap.designsystem.WappTheme +import com.wap.wapp.core.commmon.extensions.showToast +import com.wap.wapp.core.commmon.extensions.toSupportingText +import com.wap.wapp.feature.manage.code.ManageCodeDialog +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class ManageFragment : Fragment() { private lateinit var composeView: ComposeView @@ -25,7 +34,24 @@ class ManageFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) composeView.setContent { - WappTheme {} + var isShowDialog by rememberSaveable { mutableStateOf(false) } + + WappTheme { + ManageScreen( + showManageCodeDialog = { isShowDialog = true }, + ) + + if (isShowDialog) { + ManageCodeDialog( + onDismissRequest = { isShowDialog = false }, + showToast = { throwable -> + requireContext().showToast( + throwable.toSupportingText(), + ) + }, + ) + } + } } } } From 40579233255d58fa3bb5a0231780805f0a7dd85d Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Mon, 23 Oct 2023 20:17:48 +0900 Subject: [PATCH 34/37] =?UTF-8?q?[CHORE]=20#38=20:=20String.xml=20?= =?UTF-8?q?=ED=9A=8C=EC=9B=90=20->=20=EC=9A=B4=EC=98=81=EC=A7=84=20?= =?UTF-8?q?=EC=A0=95=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/manage/src/main/res/values/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feature/manage/src/main/res/values/strings.xml b/feature/manage/src/main/res/values/strings.xml index 3a8fb4c3..b9eea92e 100644 --- a/feature/manage/src/main/res/values/strings.xml +++ b/feature/manage/src/main/res/values/strings.xml @@ -1,7 +1,7 @@ 관리 - 회원 코드를 입력하세요 - 회원만 해당 내용을 확인할 수 있어요 + 운영진 코드를 입력하세요 + 운영진만 해당 내용을 확인할 수 있어요 code Hint : WAPP 잘못된 코드입니다. From 1037bc1aaaf77f03ddcf1e1839c4c1cf84c6c00f Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Mon, 23 Oct 2023 22:24:55 +0900 Subject: [PATCH 35/37] =?UTF-8?q?[CHORE]=20#38=20:=20Lint=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/wap/wapp/feature/manage/ManageScreen.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageScreen.kt b/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageScreen.kt index 1e72f39e..63b72332 100644 --- a/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageScreen.kt +++ b/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageScreen.kt @@ -61,8 +61,8 @@ internal fun ManageScreen( ), ) }, - ) { padding -> - } + content = { }, + ) } @Preview From b76b616624867aa8b6045421880e63c3de65f7b4 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Mon, 23 Oct 2023 22:47:20 +0900 Subject: [PATCH 36/37] =?UTF-8?q?[CHORE]=20#38=20:=20ktlint=20unused=20par?= =?UTF-8?q?ameter=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/wap/wapp/feature/manage/ManageScreen.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageScreen.kt b/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageScreen.kt index 63b72332..dae89413 100644 --- a/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageScreen.kt +++ b/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageScreen.kt @@ -1,5 +1,7 @@ package com.wap.wapp.feature.manage +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.padding import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarHost @@ -10,6 +12,7 @@ import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.hilt.navigation.compose.hiltViewModel @@ -61,8 +64,13 @@ internal fun ManageScreen( ), ) }, - content = { }, - ) + ) { paddingValues -> + Column( + modifier = Modifier.padding(top = paddingValues.calculateTopPadding()), + ) { + Text("avoid to ktlint") + } + } } @Preview From 7c1eff3ee56240bb8c48c453661a55e4e2a45932 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Fri, 27 Oct 2023 18:39:45 +0900 Subject: [PATCH 37/37] =?UTF-8?q?[CHORE]=20#38=20:=20Context=20->=20Activi?= =?UTF-8?q?ty=20Extensions=20=EC=A3=BC=EC=B2=B4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/core/commmon/extensions/ContextExtensions.kt | 6 +++--- .../main/java/com/wap/wapp/feature/manage/ManageFragment.kt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/common/src/main/java/com/wap/wapp/core/commmon/extensions/ContextExtensions.kt b/core/common/src/main/java/com/wap/wapp/core/commmon/extensions/ContextExtensions.kt index 7344f5f9..e2c81e41 100644 --- a/core/common/src/main/java/com/wap/wapp/core/commmon/extensions/ContextExtensions.kt +++ b/core/common/src/main/java/com/wap/wapp/core/commmon/extensions/ContextExtensions.kt @@ -1,12 +1,12 @@ package com.wap.wapp.core.commmon.extensions -import android.content.Context +import android.app.Activity import android.widget.Toast -fun Context.showToast(message: String) { +fun Activity.showToast(message: String) { Toast.makeText(this, message, Toast.LENGTH_SHORT).show() } -fun Context.showLongToast(message: String) { +fun Activity.showLongToast(message: String) { Toast.makeText(this, message, Toast.LENGTH_LONG).show() } diff --git a/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageFragment.kt b/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageFragment.kt index 8d2277ce..1b5d1b9b 100644 --- a/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageFragment.kt +++ b/feature/manage/src/main/java/com/wap/wapp/feature/manage/ManageFragment.kt @@ -45,7 +45,7 @@ class ManageFragment : Fragment() { ManageCodeDialog( onDismissRequest = { isShowDialog = false }, showToast = { throwable -> - requireContext().showToast( + requireActivity().showToast( throwable.toSupportingText(), ) },