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.
- Loading branch information
1 parent
1159e91
commit 75304bf
Showing
3 changed files
with
111 additions
and
47 deletions.
There are no files selected for viewing
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
59 changes: 59 additions & 0 deletions
59
app/src/main/java/org/sopt/and/presentation/ui/signup/SignUpRoute.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,59 @@ | ||
package org.sopt.and.presentation.ui.signup | ||
|
||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
import org.sopt.and.presentation.viewmodel.SignUpViewModel | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import org.sopt.and.presentation.utils.contract.SignUpContract | ||
import org.sopt.and.utils.showToastMsg | ||
|
||
@Composable | ||
fun SignUpRoute( | ||
navigateSignIn: () -> Unit, | ||
viewModel: SignUpViewModel = hiltViewModel() | ||
) { | ||
val signUpState by viewModel.uiState.collectAsStateWithLifecycle() | ||
val signupEffect = viewModel.effect | ||
val context = LocalContext.current | ||
|
||
LaunchedEffect(signupEffect) { | ||
signupEffect.collect { | ||
when(it) { | ||
is SignUpContract.Effect.ShowToast -> { | ||
context.showToastMsg(it.message) | ||
} | ||
} | ||
} | ||
} | ||
|
||
LaunchedEffect(signUpState.status) { | ||
if (signUpState.status == SignUpContract.SignUpStatus.SUCCESS) { | ||
navigateSignIn() | ||
} | ||
} | ||
|
||
Scaffold( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
) { innerPadding -> | ||
SignUpScreen( | ||
signUpName = signUpState.username, | ||
signUpPwd = signUpState.password, | ||
signUpHobby = signUpState.hobby, | ||
onNameChange = { viewModel.setEvent(SignUpContract.Event.OnUsernameChanged(it)) }, | ||
onPwdChange = { viewModel.setEvent(SignUpContract.Event.OnPasswordChanged(it)) }, | ||
onHobbyChange = { viewModel.setEvent(SignUpContract.Event.OnHobbyChanged(it)) }, | ||
isPwdVisibility = signUpState.isPassWordVisibility, | ||
onSignUpBtnClick = { viewModel.setEvent(SignUpContract.Event.OnSignUpButtonClicked) }, | ||
modifier = Modifier.padding(innerPadding) | ||
) | ||
} | ||
|
||
} |
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