-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
팀원 분의 코드리뷰 반영 6a028a6#r140847470
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.example.introduce | ||
|
||
data class SignUpInputErrorState( | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
rlaxodud214
Author
Owner
|
||
val name: CommonValidState, | ||
val email: CommonValidState, | ||
val passwordInput: CommonValidState, | ||
val passwordConfirm: CommonValidState, | ||
val enabled: Boolean, | ||
) { | ||
companion object { | ||
fun init() = SignUpInputErrorState( | ||
name = CommonValidState.Init, | ||
email = CommonValidState.Init, | ||
passwordInput = CommonValidState.Init, | ||
passwordConfirm = CommonValidState.Init, | ||
enabled = false | ||
) | ||
} | ||
} | ||
|
||
sealed interface CommonValidState { | ||
data object Init : CommonValidState // 초기 상태 | ||
data object Blank : CommonValidState // 비어 있음 | ||
data object Valid : CommonValidState // 적합 | ||
} | ||
|
||
sealed interface NameValidState : CommonValidState { | ||
data object Length : NameValidState | ||
} | ||
|
||
sealed interface EmailValidState : CommonValidState { | ||
data object IncludeAt : EmailValidState | ||
data object TypeNotAllowed : EmailValidState | ||
} | ||
|
||
sealed interface PasswordInputValidState : CommonValidState { | ||
data object Length : PasswordInputValidState | ||
data object SpecialChar : PasswordInputValidState | ||
data object UpperCase : PasswordInputValidState | ||
} | ||
|
||
sealed interface PssswordConfirmValidState : CommonValidState { | ||
data object Equals : PssswordConfirmValidState | ||
} |
https://github.com/android/nowinandroid/blob/main/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/OnboardingUiState.kt
보통 상태를 담을 때에는 에러 상태도 함께 담아요!
왜냐하면 성공, 로딩, 에러는 동시에 나타나서는 안되기 때문입니다.
현재 코드에서는 에러 상태일 때와 적합 상태가 동시에 올 수 있기 때문에 코드상으로 헷갈릴 수 있을 것 같습니다
예를들어서 아래 코드와 같습니다
sealed interface PssswordConfirmValidState {
data object Equals : PssswordConfirmValidState
data object Unequal: PssswordConfirmValidState
}
fun function1(passwordConfirmValidState: PssswordConfirmValidState) {
}
물론 제 말이 정답은 아니니 이렇게 생각할 수도 있다고 봐주세요~~~
또한 팀플 때 열심히 제 코드 리뷰해 주신 거 이렇게 갚습니다 😊😊