From e72050bff05a5d0691a7b2d97717df9d766fdd57 Mon Sep 17 00:00:00 2001 From: KwakEuiJin Date: Sat, 11 Nov 2023 00:58:00 +0900 Subject: [PATCH] [feat/school_auth]: Add Token Verify Screen --- .../ui/signup/school/SchoolAuthScreen.kt | 57 +++----------- .../ui/signup/school/SchoolContract.kt | 1 + .../school/email/SchoolAuthPostEmailScreen.kt | 75 +++++++++++++++++++ presentation/src/main/res/values/strings.xml | 2 + 4 files changed, 90 insertions(+), 45 deletions(-) create mode 100644 presentation/src/main/java/com/everymeal/presentation/ui/signup/school/email/SchoolAuthPostEmailScreen.kt diff --git a/presentation/src/main/java/com/everymeal/presentation/ui/signup/school/SchoolAuthScreen.kt b/presentation/src/main/java/com/everymeal/presentation/ui/signup/school/SchoolAuthScreen.kt index 5c5c39b2..4fd1535b 100644 --- a/presentation/src/main/java/com/everymeal/presentation/ui/signup/school/SchoolAuthScreen.kt +++ b/presentation/src/main/java/com/everymeal/presentation/ui/signup/school/SchoolAuthScreen.kt @@ -1,9 +1,6 @@ package com.everymeal.presentation.ui.signup.school import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.material3.CenterAlignedTopAppBar @@ -24,10 +21,13 @@ import androidx.hilt.navigation.compose.hiltViewModel import com.everymeal.presentation.R import com.everymeal.presentation.components.EveryMealConditionAgreeDialog import com.everymeal.presentation.components.EveryMealConditionAgreeDialogItem -import com.everymeal.presentation.components.EveryMealMainButton -import com.everymeal.presentation.components.EveryMealTextField +import com.everymeal.presentation.ui.signup.school.email.SchoolAuthPostEmailScreen import com.everymeal.presentation.ui.theme.EveryMealTypography -import com.everymeal.presentation.ui.theme.Main100 + +enum class SchoolAuthScreenType { + POST_EMAIL, + VERIFY_TOKEN, +} @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -59,8 +59,7 @@ fun SchoolAuthScreen( SchoolAuthContent( modifier = Modifier .padding(innerPadding) - .padding(horizontal = 20.dp) - .padding(top = 28.dp), + .padding(horizontal = 20.dp), viewModel = viewModel, state = viewState ) @@ -112,43 +111,11 @@ fun SchoolAuthContent( viewModel: SchoolAuthViewModel, state: SchoolContract.State ) { - Column( - modifier = modifier - ) { - Text( - text = stringResource(id = R.string.school_auth_content), - style = EveryMealTypography.Heading1 - ) - Spacer(modifier = Modifier.size(40.dp)) - Text( - text = stringResource(id = R.string.email), - style = EveryMealTypography.Body5 - ) - Spacer(modifier = Modifier.size(6.dp)) - EveryMealTextField( - modifier = Modifier.fillMaxWidth(), - value = state.emailLink, - onValueChange = { - viewModel.setEvent(SchoolContract.Event.OnEmailTextChanged(it)) - }, - supportingText = { - if (state.isEmailError) { - Text( - text = stringResource(id = R.string.email_error), - style = EveryMealTypography.Body5, - color = Main100 - ) - } - } - ) - Spacer(modifier = Modifier.weight(1f)) - EveryMealMainButton( - text = stringResource(id = R.string.next), - onClick = { - viewModel.setEvent(SchoolContract.Event.OnNextButtonClicked) - }, - ) - } + SchoolAuthPostEmailScreen( + modifier = modifier, + viewModel = viewModel, + state = state, + ) } diff --git a/presentation/src/main/java/com/everymeal/presentation/ui/signup/school/SchoolContract.kt b/presentation/src/main/java/com/everymeal/presentation/ui/signup/school/SchoolContract.kt index cfc4eec4..9edecde4 100644 --- a/presentation/src/main/java/com/everymeal/presentation/ui/signup/school/SchoolContract.kt +++ b/presentation/src/main/java/com/everymeal/presentation/ui/signup/school/SchoolContract.kt @@ -7,6 +7,7 @@ import com.everymeal.presentation.base.ViewState class SchoolContract { data class State( + val schoolAuthScreenType: SchoolAuthScreenType = SchoolAuthScreenType.POST_EMAIL, val isShowConditionBottomSheet: Boolean = false, val isEmailError: Boolean = false, val emailLink: String = "", diff --git a/presentation/src/main/java/com/everymeal/presentation/ui/signup/school/email/SchoolAuthPostEmailScreen.kt b/presentation/src/main/java/com/everymeal/presentation/ui/signup/school/email/SchoolAuthPostEmailScreen.kt new file mode 100644 index 00000000..6a43dc3e --- /dev/null +++ b/presentation/src/main/java/com/everymeal/presentation/ui/signup/school/email/SchoolAuthPostEmailScreen.kt @@ -0,0 +1,75 @@ +package com.everymeal.presentation.ui.signup.school.email + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import com.everymeal.presentation.R +import com.everymeal.presentation.components.EveryMealMainButton +import com.everymeal.presentation.components.EveryMealTextField +import com.everymeal.presentation.ui.signup.school.SchoolAuthScreenType +import com.everymeal.presentation.ui.signup.school.SchoolAuthViewModel +import com.everymeal.presentation.ui.signup.school.SchoolContract +import com.everymeal.presentation.ui.theme.EveryMealTypography +import com.everymeal.presentation.ui.theme.Gray100 +import com.everymeal.presentation.ui.theme.Gray900 +import com.everymeal.presentation.ui.theme.Main100 + +@Composable +fun SchoolAuthPostEmailScreen( + modifier: Modifier, + state: SchoolContract.State, + viewModel: SchoolAuthViewModel +) { + Column( + modifier = modifier.padding(top = 48.dp) + ) { + Text( + text = when (state.schoolAuthScreenType) { + SchoolAuthScreenType.POST_EMAIL -> stringResource(id = R.string.school_auth_content) + SchoolAuthScreenType.VERIFY_TOKEN -> stringResource(id = R.string.email_token_verify_title) + }, + style = EveryMealTypography.Heading1, + color = Gray900 + ) + Spacer(modifier = Modifier.size(40.dp)) + Text( + text = when(state.schoolAuthScreenType) { + SchoolAuthScreenType.POST_EMAIL -> stringResource(id = R.string.email) + SchoolAuthScreenType.VERIFY_TOKEN -> stringResource(id = R.string.verify_token) + }, + style = EveryMealTypography.Body5, + color = Gray100 + ) + Spacer(modifier = Modifier.size(6.dp)) + EveryMealTextField( + modifier = Modifier.fillMaxWidth(), + value = state.emailLink, + onValueChange = { + viewModel.setEvent(SchoolContract.Event.OnEmailTextChanged(it)) + }, + supportingText = { + if (state.isEmailError) { + Text( + text = stringResource(id = R.string.email_error), + style = EveryMealTypography.Body5, + color = Main100 + ) + } + } + ) + Spacer(modifier = Modifier.weight(1f)) + EveryMealMainButton( + text = stringResource(id = R.string.next), + onClick = { + viewModel.setEvent(SchoolContract.Event.OnNextButtonClicked) + }, + ) + } +} diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 9756e7fc..cb764820 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -9,6 +9,7 @@ 나가기 다음 이메일 + 인증번호 잘못된 이메일 형식이에요 @@ -123,6 +124,7 @@ 학교 인증을 위해\n대학 메일을 입력해주세요 이용을 위한 동의가 필요해요 [필수] 이용 약관 동의 + 메일로 전달받은\n인증번호를 입력해주세요