generated from AND-SOPT-ANDROID/and-sopt-android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor #11 - SignUpScreen MVI 리팩토링
- Loading branch information
Showing
10 changed files
with
265 additions
and
167 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
app/src/main/java/org/sopt/and/core/utils/extension/Modifier.kt
This file contains 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 org.sopt.and.core.utils.extension | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.composed | ||
|
||
fun Modifier.noRippleClickable(onClick: () -> Unit): Modifier = composed { | ||
this.clickable( | ||
indication = null, | ||
interactionSource = remember { MutableInteractionSource() } | ||
) { onClick() } | ||
} |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/org/sopt/and/domain/entity/UserRegisterResult.kt
This file contains 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,5 @@ | ||
package org.sopt.and.domain.entity | ||
|
||
data class UserRegisterResult( | ||
val no: Int? | ||
) |
21 changes: 5 additions & 16 deletions
21
app/src/main/java/org/sopt/and/domain/repository/SignUpRepository.kt
This file contains 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 |
---|---|---|
@@ -1,21 +1,10 @@ | ||
package org.sopt.and.domain.repository | ||
|
||
import org.sopt.and.data.datasource.SignUpDataSource | ||
import org.sopt.and.data.repositoryimpl.SignUpRepositoryImpl | ||
import org.sopt.and.data.service.ServicePool | ||
import org.sopt.and.domain.model.SignUpInformationEntity | ||
import org.sopt.and.domain.model.SignUpResponseEntity | ||
import org.sopt.and.domain.entity.BaseResult | ||
import org.sopt.and.domain.entity.UserData | ||
import org.sopt.and.domain.entity.UserRegisterResult | ||
|
||
interface SignUpRepository { | ||
suspend fun signUp(request: SignUpInformationEntity): Result<SignUpResponseEntity> | ||
|
||
companion object { | ||
fun create(): SignUpRepositoryImpl { | ||
return SignUpRepositoryImpl( | ||
signUpDataSource = SignUpDataSource( | ||
userService = ServicePool.userService | ||
) | ||
) | ||
} | ||
} | ||
interface SignUpRepository { | ||
suspend fun registerUser(user : UserData): BaseResult<UserRegisterResult> | ||
} |
15 changes: 9 additions & 6 deletions
15
app/src/main/java/org/sopt/and/domain/usecase/SignUpUseCase.kt
This file contains 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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
package org.sopt.and.domain.usecase | ||
|
||
import org.sopt.and.domain.model.SignUpInformationEntity | ||
import org.sopt.and.domain.model.SignUpResponseEntity | ||
import org.sopt.and.domain.entity.BaseResult | ||
import org.sopt.and.domain.entity.UserData | ||
import org.sopt.and.domain.entity.UserRegisterResult | ||
import org.sopt.and.domain.repository.SignUpRepository | ||
import javax.inject.Inject | ||
|
||
class SignUpUseCase( | ||
private val signUpRepository: SignUpRepository | ||
class SignUpUseCase @Inject constructor( | ||
private val userRegisterRepository: SignUpRepository | ||
) { | ||
suspend operator fun invoke(request: SignUpInformationEntity): Result<SignUpResponseEntity> = | ||
signUpRepository.signUp(request = request) | ||
suspend operator fun invoke(user: UserData): BaseResult<UserRegisterResult> { | ||
return userRegisterRepository.registerUser(user) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/org/sopt/and/presentation/signup/SignUpContract.kt
This file contains 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,42 @@ | ||
package org.sopt.and.presentation.auth.signup | ||
|
||
import org.sopt.and.presentation.util.UiEffect | ||
import org.sopt.and.presentation.util.UiEvent | ||
import org.sopt.and.presentation.util.UiState | ||
|
||
class SignUpContract { | ||
data class SignUpUiState( | ||
val username: String = "", | ||
val password: String = "", | ||
val hobby: String = "", | ||
val isUserNameValid: Boolean = false, | ||
val isPasswordValid: Boolean = false, | ||
val isHobbyValid: Boolean = false, | ||
val isUserNameFieldFocused: Boolean = false, | ||
val isPasswordFieldFocused: Boolean = false, | ||
val isHobbyFieldFocused: Boolean = false, | ||
val isValid: Boolean = false, | ||
val isLoading: Boolean = false, | ||
val errorMessage: String? = null | ||
) : UiState | ||
|
||
sealed class SignUpUiEvent : UiEvent { | ||
data class UpdateUserName(val username: String) : SignUpUiEvent() | ||
data class UpdatePassword(val password: String) : SignUpUiEvent() | ||
data class UpdateHobby(val hobby: String) : SignUpUiEvent() | ||
data class UpdateFieldFocus(val field: Field, val isFocused: Boolean) : SignUpUiEvent() | ||
data object SignUpFormSubmit : SignUpUiEvent() | ||
data object Close : SignUpUiEvent() | ||
} | ||
|
||
sealed class SignUpUiEffect : UiEffect { | ||
data object ShowSuccessToast : SignUpUiEffect() | ||
data class ShowErrorToast(val message: String) : SignUpUiEffect() | ||
data object NavigateToSignIn : SignUpUiEffect() | ||
data object NavigateUp : SignUpUiEffect() | ||
} | ||
|
||
enum class Field { | ||
UserName, Password, Hobby | ||
} | ||
} |
This file contains 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.