-
Notifications
You must be signed in to change notification settings - Fork 1
프로필 생성 플로우 구현 #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
The head ref may contain hidden characters: "feat/#99-\uD504\uB85C\uD544-\uC0DD\uC131-\uD654\uBA74-\uAD6C\uD604"
Merged
프로필 생성 플로우 구현 #102
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
858ed0d
feat: My(마이) 피처 모듈 추가 및 내비게이션 연결
moondev03 23a6b31
refactor: 바텀 내비게이션 ProfileScreen -> MyScreen으로 변경
moondev03 caeb228
refactor: PrezelTextField 내부 정렬 보정
moondev03 546a9ff
refactor: PrezelAvatar 기본 스타일 수정
moondev03 3edddff
닉네임 검증 도메인 계층 추가
moondev03 946bd56
프로필 생성 화면과 로그인 흐름 연결
moondev03 91256ff
마이 모듈 프로가드 파일 추가
moondev03 5c290b3
chore: core/model 및 core/domain 테스트 디렉토리 보존을 위한 .gitkeep 추가
moondev03 762c5cb
feat: User 프로필 관련 데이터 모델 추가
moondev03 e283823
feat: AdvancedImePadding 커스텀 Modifier 추가
moondev03 57dd5de
build: kotlinx-serialization 플러그인 추가
moondev03 75f374c
chore: MainActivity 소프트 키보드 처리 방식 수정
moondev03 a871dd4
feat: 프로필 이미지 변경 기능 구현
moondev03 1583300
refactor: User 모델의 nickname 타입을 String으로 변경
moondev03 16d519c
refactor: ValidateNicknameUseCase 파일 위치 변경
moondev03 c733cbf
refactor: PrezelAsyncImage 에러 로깅 추가 및 Timber 의존성 추가
moondev03 6707481
build: AndroidFeatureImplConventionPlugin에 Timber 의존성 추가
moondev03 781c63a
feat: FetchUserInfoUseCase 구현 및 UserRepository 개선
moondev03 c6192ac
feat: 프로필 정보 조회 기능 구현 및 화면 진입 로직 개선
moondev03 5c7bfb8
refactor: 프로필 제출 로직 개선 및 UI Effect 추가
moondev03 1568e5c
refactor: UserRepositoryImpl 내 테스트용 유저 데이터 수정
moondev03 2a49c0c
refactor: ProfileScreen UI 컴포넌트 분리 및 구조 개선
moondev03 fb91880
chore: `UserRepositoryImpl` 내 TODO 주석의 대소문자 수정
moondev03 af5d6d2
refactor: ProfileViewModel 닉네임 변경 로직 개선 및 공백 처리 위치 변경
moondev03 ea4174d
refactor: ProfileUiState의 사진 선택 가능 여부 로직 및 상속 구조 개선
moondev03 6a4bf13
refactor: ProfileViewModel 닉네임 검증 로직 개선
moondev03 b83b02d
refactor: AdvancedImePadding 위치 계산 로직 개선
moondev03 700cb82
refactor: ProfileUiState 내 제출 버튼 활성화 조건 수정
moondev03 e4167ff
fix: ProfileViewModel 내 닉네임 유효성 검사 결과 업데이트 로직 개선
moondev03 c539b69
refactor: 프로필 설정(ProfileUiState) 구조 개선 및 데이터 모델 정리
moondev03 0f8d5dc
refactor: Profile 유저 정보 조회 실패 처리 및 Effect 네이밍 개선
moondev03 ce9adb3
refactor: Nickname 생성 메서드 호출 방식 수정
moondev03 46bb5a7
style: 닉네임 입력란 플레이스홀더 텍스트 및 주석 수정
moondev03 7b8ddcd
Merge branch 'develop' into feat/#99-프로필-생성-화면-구현
moondev03 52041d9
refactor: ProfileUiIntent 명칭 변경 및 관련 로직 수정
moondev03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
Prezel/core/data/src/main/java/com/team/prezel/core/data/di/RepositoryModule.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.team.prezel.core.data.di | ||
|
|
||
| import com.team.prezel.core.data.repository.UserRepositoryImpl | ||
| import com.team.prezel.core.domain.repository.profile.UserRepository | ||
| import dagger.Binds | ||
| import dagger.Module | ||
| import dagger.hilt.InstallIn | ||
| import dagger.hilt.components.SingletonComponent | ||
| import javax.inject.Singleton | ||
|
|
||
| @Module | ||
| @InstallIn(SingletonComponent::class) | ||
| internal abstract class RepositoryModule { | ||
| @Binds | ||
| @Singleton | ||
| abstract fun bindUserRepository(impl: UserRepositoryImpl): UserRepository | ||
| } |
32 changes: 32 additions & 0 deletions
32
Prezel/core/data/src/main/java/com/team/prezel/core/data/repository/UserRepositoryImpl.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.team.prezel.core.data.repository | ||
|
|
||
| import com.team.prezel.core.domain.repository.profile.UserRepository | ||
| import com.team.prezel.core.model.profile.Nickname | ||
| import com.team.prezel.core.model.profile.User | ||
| import kotlinx.coroutines.delay | ||
| import javax.inject.Inject | ||
|
|
||
| internal class UserRepositoryImpl @Inject constructor() : UserRepository { | ||
| private var cachedUserInfo: User? = null | ||
|
|
||
| override suspend fun fetchUserInfo(isRefresh: Boolean): Result<User> = | ||
| runCatching { | ||
| if (!isRefresh && cachedUserInfo != null) return Result.success(cachedUserInfo!!) | ||
|
|
||
| User( | ||
| id = 1, | ||
| email = "test@gmail.com", | ||
| nickname = "", | ||
| profileImage = User.ProfileImage(url = "https://picsum.photos/200", isDefault = true), | ||
| isRegistered = false, | ||
| ) | ||
| }.onSuccess { user -> | ||
| cachedUserInfo = user | ||
| } | ||
|
|
||
| override suspend fun checkNicknameDuplication(nickname: Nickname): Result<Boolean> { | ||
| // todo: 실제 API 연동 후 서버 중복 검사 결과를 반환하도록 교체 | ||
| delay(200) | ||
| return Result.success(false) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| plugins { | ||
| alias(libs.plugins.prezel.jvm.library) | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(projects.coreModel) | ||
| implementation(libs.javax.inject) | ||
| implementation(libs.kotlinx.coroutines.core) | ||
| } |
10 changes: 10 additions & 0 deletions
10
...e/domain/src/main/kotlin/com/team/prezel/core/domain/repository/profile/UserRepository.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.team.prezel.core.domain.repository.profile | ||
|
|
||
| import com.team.prezel.core.model.profile.Nickname | ||
| import com.team.prezel.core.model.profile.User | ||
|
|
||
| interface UserRepository { | ||
| suspend fun fetchUserInfo(isRefresh: Boolean): Result<User> | ||
|
|
||
| suspend fun checkNicknameDuplication(nickname: Nickname): Result<Boolean> | ||
| } |
14 changes: 14 additions & 0 deletions
14
...e/domain/src/main/kotlin/com/team/prezel/core/domain/usecase/user/FetchUserInfoUseCase.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.team.prezel.core.domain.usecase.user | ||
|
|
||
| import com.team.prezel.core.domain.repository.profile.UserRepository | ||
| import com.team.prezel.core.model.profile.User | ||
| import javax.inject.Inject | ||
|
|
||
| /** | ||
| * 유저 데이터를 조회하는 UseCase. | ||
| */ | ||
| class FetchUserInfoUseCase @Inject constructor( | ||
| private val userRepository: UserRepository, | ||
| ) { | ||
| suspend operator fun invoke(isRefresh: Boolean = false): Result<User> = userRepository.fetchUserInfo(isRefresh = isRefresh) | ||
| } |
52 changes: 52 additions & 0 deletions
52
...omain/src/main/kotlin/com/team/prezel/core/domain/usecase/user/ValidateNicknameUseCase.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package com.team.prezel.core.domain.usecase.user | ||
|
|
||
| import com.team.prezel.core.domain.repository.profile.UserRepository | ||
| import com.team.prezel.core.model.profile.Nickname | ||
| import javax.inject.Inject | ||
|
|
||
| /** | ||
| * 닉네임 유효성 및 중복 여부를 검증하는 UseCase. | ||
| * | ||
| * ### 동작 흐름 | ||
| * 1. 입력된 문자열을 기반으로 [com.team.prezel.core.model.profile.Nickname.Companion.create]를 호출하여 도메인 규칙에 맞는 닉네임인지 검증합니다. | ||
| * 2. 닉네임 생성에 성공한 경우, [com.team.prezel.core.domain.repository.profile.UserRepository.checkNicknameDuplication]을 통해 서버에 중복 여부를 확인합니다. | ||
| * 3. 각 단계의 결과에 따라 [Result]를 반환합니다. | ||
| * | ||
| */ | ||
| class ValidateNicknameUseCase @Inject constructor( | ||
| private val userRepository: UserRepository, | ||
| ) { | ||
| suspend operator fun invoke(nickname: String): Result = | ||
| when (val creationResult = Nickname.create(nickname)) { | ||
| is Nickname.CreationResult.Success -> { | ||
| userRepository.checkNicknameDuplication(creationResult.nickname).fold( | ||
| onSuccess = { isDuplicated -> | ||
| if (isDuplicated) Result.Invalid.Duplicated else Result.Available(creationResult.nickname) | ||
| }, | ||
| onFailure = { throwable -> | ||
| Result.Error(throwable) | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
| is Nickname.CreationResult.Failure -> Result.Invalid.Format(reason = creationResult.reason) | ||
| } | ||
|
|
||
| sealed interface Result { | ||
| data class Available( | ||
| val nickname: Nickname, | ||
| ) : Result | ||
|
|
||
| sealed interface Invalid : Result { | ||
| data class Format( | ||
| val reason: Nickname.InvalidReason, | ||
| ) : Invalid | ||
|
|
||
| data object Duplicated : Invalid | ||
| } | ||
|
|
||
| data class Error( | ||
| val throwable: Throwable, | ||
| ) : Result | ||
| } | ||
| } |
Empty file.
53 changes: 53 additions & 0 deletions
53
Prezel/core/model/src/main/java/com/team/prezel/core/model/profile/Nickname.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package com.team.prezel.core.model.profile | ||
|
|
||
| @JvmInline | ||
| value class Nickname private constructor( | ||
| val value: String, | ||
| ) { | ||
| sealed interface CreationResult { | ||
| data class Success( | ||
| val nickname: Nickname, | ||
| ) : CreationResult | ||
|
|
||
| data class Failure( | ||
| val reason: InvalidReason, | ||
| ) : CreationResult | ||
| } | ||
|
|
||
| enum class InvalidReason { | ||
| TOO_SHORT, | ||
| TOO_LONG, | ||
| INVALID_CHARACTER, | ||
| } | ||
|
|
||
| companion object { | ||
| const val MAX_LENGTH = 10 | ||
| private const val MIN_LENGTH = 2 | ||
| private const val LATIN_UPPERCASE_START = 'A'.code | ||
| private const val LATIN_UPPERCASE_END = 'Z'.code | ||
| private const val LATIN_LOWERCASE_START = 'a'.code | ||
| private const val LATIN_LOWERCASE_END = 'z'.code | ||
|
|
||
| fun create(value: String): CreationResult = | ||
| when (val reason = invalidReasonOf(value)) { | ||
| null -> CreationResult.Success(Nickname(value)) | ||
| else -> CreationResult.Failure(reason) | ||
| } | ||
|
|
||
| private fun invalidReasonOf(value: String): InvalidReason? { | ||
| val length = value.codePointCount(0, value.length) | ||
|
|
||
| return when { | ||
| length < MIN_LENGTH -> InvalidReason.TOO_SHORT | ||
| length > MAX_LENGTH -> InvalidReason.TOO_LONG | ||
| !value.codePoints().allMatch(::isAllowedCodePoint) -> InvalidReason.INVALID_CHARACTER | ||
| else -> null | ||
| } | ||
| } | ||
|
|
||
| private fun isAllowedCodePoint(codePoint: Int): Boolean = | ||
| codePoint in LATIN_UPPERCASE_START..LATIN_UPPERCASE_END || | ||
| codePoint in LATIN_LOWERCASE_START..LATIN_LOWERCASE_END || | ||
| Character.UnicodeScript.of(codePoint) == Character.UnicodeScript.HANGUL | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
Prezel/core/model/src/main/java/com/team/prezel/core/model/profile/User.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.team.prezel.core.model.profile | ||
|
|
||
| data class User( | ||
| val id: Long, | ||
| val email: String, | ||
| val nickname: String, | ||
| val profileImage: ProfileImage, | ||
| val isRegistered: Boolean, | ||
| ) { | ||
| data class ProfileImage( | ||
| val url: String, | ||
| val isDefault: Boolean, | ||
| ) | ||
| } |
Empty file.
27 changes: 27 additions & 0 deletions
27
Prezel/core/ui/src/main/java/com/team/prezel/core/ui/AdvancedImePadding.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.team.prezel.core.ui | ||
|
|
||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.foundation.layout.consumeWindowInsets | ||
| import androidx.compose.foundation.layout.imePadding | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableIntStateOf | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.composed | ||
| import androidx.compose.ui.layout.findRootCoordinates | ||
| import androidx.compose.ui.layout.onGloballyPositioned | ||
| import androidx.compose.ui.layout.positionInRoot | ||
| import androidx.compose.ui.platform.LocalDensity | ||
| import kotlin.math.roundToInt | ||
|
|
||
| fun Modifier.advancedImePadding() = | ||
| composed { | ||
| var consumePadding by remember { mutableIntStateOf(0) } | ||
| onGloballyPositioned { coordinates -> | ||
| consumePadding = coordinates.findRootCoordinates().size.height - | ||
| (coordinates.positionInRoot().y + coordinates.size.height).roundToInt() | ||
| }.consumeWindowInsets( | ||
| PaddingValues(bottom = with(LocalDensity.current) { consumePadding.toDp() }), | ||
| ).imePadding() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.