Skip to content

Commit

Permalink
refactor: 하위 페이지에 uiState 만 넘기기
Browse files Browse the repository at this point in the history
  • Loading branch information
JuTaK97 committed Oct 26, 2024
1 parent b26a307 commit 889b285
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import com.wafflestudio.snutt2.ui.SNUTTTypography

@Composable
fun CheckIdStep(
userId: String,
uiState: FindPasswordViewModel.UIState.CheckId,
onSubmit: (String) -> Unit,
) {
val focusRequester = remember { FocusRequester() }
Expand All @@ -45,8 +45,8 @@ fun CheckIdStep(
var idField by remember {
mutableStateOf(
TextFieldValue(
text = userId,
selection = TextRange(userId.length), // 초기 커서를 텍스트 끝으로 설정
text = uiState.userId,
selection = TextRange(uiState.userId.length), // 초기 커서를 텍스트 끝으로 설정
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ import com.wafflestudio.snutt2.ui.SNUTTTypography

@Composable
fun EnterFullEmailStep(
userId: String,
maskedEmail: String,
fullEmail: String,
uiState: FindPasswordViewModel.UIState.EnterFullEmail,
notMyEmail: () -> Unit,
onSubmitFullEmail: (String) -> Unit,
) {
Expand All @@ -51,8 +49,8 @@ fun EnterFullEmailStep(
var emailField by remember {
mutableStateOf(
TextFieldValue(
text = fullEmail,
selection = TextRange(fullEmail.length), // 초기 커서를 텍스트 끝으로 설정
text = uiState.fullEmail,
selection = TextRange(uiState.fullEmail.length), // 초기 커서를 텍스트 끝으로 설정
),
)
}
Expand Down Expand Up @@ -99,7 +97,7 @@ fun EnterFullEmailStep(
modifier = Modifier.fillMaxWidth(),
value = "",
onValueChange = {},
hint = userId,
hint = uiState.userId,
enabled = false,
)

Expand Down Expand Up @@ -132,7 +130,7 @@ fun EnterFullEmailStep(
Spacer(modifier = Modifier.height(12.dp))

Text(
text = maskedEmail,
text = uiState.maskedEmail,
style = SNUTTTypography.body1.copy(color = SNUTTColors.EditTextLabel),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fun ResetPasswordPage() {
AnimatedContent(targetState = uiState, label = "") { state ->
when (state) {
is CheckId -> CheckIdStep(
userId = state.userId,
uiState = state,
onSubmit = { userId ->
scope.launch {
launchSuspendApi(apiOnProgress, apiOnError) {
Expand All @@ -81,9 +81,7 @@ fun ResetPasswordPage() {
)

is EnterFullEmail -> EnterFullEmailStep(
userId = state.userId,
maskedEmail = state.maskedEmail,
fullEmail = state.fullEmail,
uiState = state,
notMyEmail = viewModel::goToPreviousStep,
onSubmitFullEmail = { fullEmail ->
scope.launch {
Expand All @@ -95,7 +93,7 @@ fun ResetPasswordPage() {
)

is VerifyCode -> VerifyCodeStep(
fullEmail = state.fullEmail,
uiState = state,
onRequestResend = {
scope.launch {
launchSuspendApi(apiOnProgress, apiOnError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import com.wafflestudio.snutt2.ui.SNUTTTypography
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun VerifyCodeStep(
fullEmail: String,
uiState: FindPasswordViewModel.UIState.VerifyCode,
onRequestResend: () -> Unit,
onSubmit: (String) -> Unit,
) {
Expand Down Expand Up @@ -76,7 +76,7 @@ fun VerifyCodeStep(
.padding(vertical = 44.dp, horizontal = 20.dp),
) {
Text(
text = stringResource(R.string.find_password_verification_code_content, fullEmail),
text = stringResource(R.string.find_password_verification_code_content, uiState.fullEmail),
style = SNUTTTypography.h2.copy(fontSize = 17.sp),
)

Expand Down

0 comments on commit 889b285

Please sign in to comment.