From df5df9f69563b815f5536bcfdd11768af1571fab Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Wed, 18 Sep 2024 19:25:48 +0900 Subject: [PATCH 01/16] =?UTF-8?q?[Chore/#6]=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=20NavGraph=20composable=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/auth/navigation/AuthNavGraph.kt | 22 ++----------------- .../ui/home/navigation/HomeNavGraph.kt | 5 ++--- .../presentation/ui/navigator/MainNavHost.kt | 2 +- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/navigation/AuthNavGraph.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/navigation/AuthNavGraph.kt index 112207b..c8f74b7 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/navigation/AuthNavGraph.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/navigation/AuthNavGraph.kt @@ -9,10 +9,8 @@ import com.sopt.now.compose.presentation.ui.auth.screen.SignUpRoute import com.sopt.now.compose.presentation.ui.home.navigation.HomeNavigator import com.sopt.now.compose.presentation.ui.home.screen.HomeRoute -fun NavGraphBuilder.authNavGraph( - authNavigator: AuthNavigator, - homeNavigator: HomeNavigator -) { +fun NavGraphBuilder.authNavGraph(authNavigator: AuthNavigator) { + composable( route = "signIn/{id}/{password}/{nickname}/{phoneNumber}", arguments = listOf( @@ -32,20 +30,4 @@ fun NavGraphBuilder.authNavGraph( composable(route = "signUp") { SignUpRoute(authNavigator) } - - composable( - route = "home/{id}/{password}/{nickname}/{phoneNumber}", - arguments = listOf( - navArgument("id") { type = NavType.StringType }, - navArgument("password") { type = NavType.StringType }, - navArgument("nickname") { type = NavType.StringType }, - navArgument("phoneNumber") { type = NavType.StringType } - ) - ) { backStackEntry -> - val id = backStackEntry.arguments?.getString("id") ?: "" - val password = backStackEntry.arguments?.getString("password") ?: "" - val nickname = backStackEntry.arguments?.getString("nickname") ?: "" - val phoneNumber = backStackEntry.arguments?.getString("phoneNumber") ?: "" - HomeRoute(homeNavigator, id, password, nickname, phoneNumber) - } } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/home/navigation/HomeNavGraph.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/home/navigation/HomeNavGraph.kt index a50b78e..01504da 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/home/navigation/HomeNavGraph.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/home/navigation/HomeNavGraph.kt @@ -6,9 +6,8 @@ import androidx.navigation.compose.composable import androidx.navigation.navArgument import com.sopt.now.compose.presentation.ui.home.screen.HomeRoute -fun NavGraphBuilder.homeNavGraph( - homeNavigator: HomeNavigator -) { +fun NavGraphBuilder.homeNavGraph(homeNavigator: HomeNavigator) { + composable( route = "home/{id}/{password}/{nickname}/{phoneNumber}", arguments = listOf( diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/navigator/MainNavHost.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/navigator/MainNavHost.kt index 7b01057..c84d865 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/navigator/MainNavHost.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/navigator/MainNavHost.kt @@ -29,7 +29,7 @@ fun MainNavHost( navController = navHostController, startDestination = "signIn/{id}/{password}/{nickname}/{phoneNumber}" ) { - authNavGraph(authNavigator, homeNavigator) + authNavGraph(authNavigator) homeNavGraph(homeNavigator) } } From 7ef7566317274f39e7a3d5d0524fd6c4ddac321e Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Wed, 18 Sep 2024 19:26:41 +0900 Subject: [PATCH 02/16] =?UTF-8?q?[Chore/#6]=20=EC=BB=B4=ED=8F=AC=EB=84=8C?= =?UTF-8?q?=ED=8A=B8=20=EA=B0=9C=EC=84=A0=20:=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=EB=B2=84=ED=8A=BC=20textDecoration=20?= =?UTF-8?q?=EC=86=8D=EC=84=B1=20=EC=82=AC=EC=9A=A9,=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=ED=95=98=EA=B8=B0=20=EB=B2=84=ED=8A=BC=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EB=82=B4=20=ED=95=A9=EB=B3=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/auth/component/SignInButton.kt | 62 ------------------ .../ui/auth/component/SignUpTextButton.kt | 37 ----------- .../ui/auth/screen/SignInScreen.kt | 63 ++++++++++++++++--- 3 files changed, 54 insertions(+), 108 deletions(-) delete mode 100644 app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/SignInButton.kt delete mode 100644 app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/SignUpTextButton.kt diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/SignInButton.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/SignInButton.kt deleted file mode 100644 index 1cceee7..0000000 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/SignInButton.kt +++ /dev/null @@ -1,62 +0,0 @@ -package com.sopt.now.compose.presentation.ui.auth.component - -import android.content.Context -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.Button -import androidx.compose.material3.ButtonDefaults -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.sopt.now.compose.R -import com.sopt.now.compose.presentation.utils.showToast -import com.sopt.now.compose.ui.theme.CustomTheme - -@Composable -fun SignInButton( - context: Context, - inputId: String, - inputPassword: String, - id: String, - password: String, - nickname: String, - phoneNumber: String, - onClickSignIn: (String, String, String, String) -> Unit -) { - Button( - onClick = { - when { - inputId.isEmpty() || inputPassword.isEmpty() -> showToast( - context, - context.getString(R.string.signin_signin_failure_toast) - ) - - inputId != id -> showToast( - context, - context.getString(R.string.signin_signin_id_incorrect) - ) - - inputPassword != password -> showToast( - context, - context.getString(R.string.signin_signin_password_incorrect) - ) - - else -> { - showToast(context, context.getString(R.string.signin_signin_success_toast)) - onClickSignIn(id, password, nickname, phoneNumber) - } - } - }, - modifier = Modifier - .fillMaxWidth(), - colors = ButtonDefaults.buttonColors(CustomTheme.colors.mainYellow), - shape = RoundedCornerShape(10.dp) - ) { - Text( - text = stringResource(R.string.signin_signin_button), - color = CustomTheme.colors.gray01 - ) - } -} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/SignUpTextButton.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/SignUpTextButton.kt deleted file mode 100644 index 16bce3d..0000000 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/SignUpTextButton.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.sopt.now.compose.presentation.ui.auth.component - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.width -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.unit.dp -import com.sopt.now.compose.R -import com.sopt.now.compose.ui.theme.CustomTheme - -@Composable -fun SignUpTextButton( - modifier: Modifier -) { - Column( - modifier = modifier, - horizontalAlignment = Alignment.CenterHorizontally - ) { - Text( - text = stringResource(R.string.signin_signup_button), - color = CustomTheme.colors.gray04, - style = CustomTheme.typography.body2Medium - ) - Box( - modifier = Modifier - .height(1.dp) - .width(60.dp) - .background(CustomTheme.colors.gray04) - ) - } -} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt index 3ca5c4c..3af0792 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt @@ -1,17 +1,13 @@ package com.sopt.now.compose.presentation.ui.auth.screen import android.content.Context -import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Button @@ -28,12 +24,11 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.text.input.TextFieldValue +import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.sopt.now.compose.R import com.sopt.now.compose.presentation.ui.auth.component.AuthTextField -import com.sopt.now.compose.presentation.ui.auth.component.SignInButton -import com.sopt.now.compose.presentation.ui.auth.component.SignUpTextButton import com.sopt.now.compose.presentation.ui.auth.navigation.AuthNavigator import com.sopt.now.compose.presentation.utils.showToast import com.sopt.now.compose.ui.theme.CustomTheme @@ -115,11 +110,14 @@ fun SignInScreen( visualTransformation = PasswordVisualTransformation() ) Spacer(modifier = Modifier.height(40.dp)) - SignUpTextButton( + Text( + text = stringResource(R.string.signin_signup_button), modifier = Modifier - .wrapContentSize() .align(Alignment.End) - .clickable { onClickSignUp() } + .clickable { onClickSignUp() }, + color = CustomTheme.colors.gray04, + textDecoration = TextDecoration.Underline, + style = CustomTheme.typography.body2Medium ) Spacer(modifier = Modifier.weight(1f)) SignInButton( @@ -135,6 +133,53 @@ fun SignInScreen( } } +@Composable +fun SignInButton( + context: Context, + inputId: String, + inputPassword: String, + id: String, + password: String, + nickname: String, + phoneNumber: String, + onClickSignIn: (String, String, String, String) -> Unit +) { + Button( + onClick = { + when { + inputId.isEmpty() || inputPassword.isEmpty() -> showToast( + context, + context.getString(R.string.signin_signin_failure_toast) + ) + + inputId != id -> showToast( + context, + context.getString(R.string.signin_signin_id_incorrect) + ) + + inputPassword != password -> showToast( + context, + context.getString(R.string.signin_signin_password_incorrect) + ) + + else -> { + showToast(context, context.getString(R.string.signin_signin_success_toast)) + onClickSignIn(id, password, nickname, phoneNumber) + } + } + }, + modifier = Modifier + .fillMaxWidth(), + colors = ButtonDefaults.buttonColors(CustomTheme.colors.mainYellow), + shape = RoundedCornerShape(10.dp) + ) { + Text( + text = stringResource(R.string.signin_signin_button), + color = CustomTheme.colors.gray01 + ) + } +} + @Preview(showBackground = true) @Composable fun show() { From d83ff7a4120112adb310d48d5c942eaaf54ae114 Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Wed, 18 Sep 2024 19:33:57 +0900 Subject: [PATCH 03/16] =?UTF-8?q?[Feat/#6]=20UX=20=EA=B0=9C=EC=84=A0=20:?= =?UTF-8?q?=20=ED=99=88=ED=99=94=EB=A9=B4=EC=97=90=EC=84=9C=20=EB=92=A4?= =?UTF-8?q?=EB=A1=9C=EA=B0=80=EA=B8=B0=EB=A5=BC=20=EB=91=90=20=EB=B2=88=20?= =?UTF-8?q?=ED=81=B4=EB=A6=AD=20=EC=8B=9C=20=EC=95=B1=20=EC=A2=85=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/home/screen/HomeScreen.kt | 25 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + 2 files changed, 26 insertions(+) diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/home/screen/HomeScreen.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/home/screen/HomeScreen.kt index 6aad6ea..406e938 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/home/screen/HomeScreen.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/home/screen/HomeScreen.kt @@ -1,5 +1,7 @@ package com.sopt.now.compose.presentation.ui.home.screen +import android.app.Activity +import androidx.activity.compose.BackHandler import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -10,8 +12,13 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableLongStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview @@ -19,6 +26,7 @@ import androidx.compose.ui.unit.dp import com.sopt.now.compose.R import com.sopt.now.compose.presentation.ui.home.component.UserInfoText import com.sopt.now.compose.presentation.ui.home.navigation.HomeNavigator +import com.sopt.now.compose.presentation.utils.showToast import com.sopt.now.compose.ui.theme.CustomTheme @Composable @@ -29,6 +37,23 @@ fun HomeRoute( nickname: String, phoneNumber: String, ) { + var backPressedTime by remember { mutableLongStateOf(0L) } + val backPressThreshold = 2000 + val context = LocalContext.current + + BackHandler { + val currentTime = System.currentTimeMillis() + if (currentTime - backPressedTime <= backPressThreshold) { + (context as? Activity)?.finish() + } else { + backPressedTime = currentTime + showToast( + context = context, + message = context.getString(R.string.home_backhandler_caution) + ) + } + } + HomeScreen( id = id, password = password, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 93951c9..1c74af3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -30,4 +30,5 @@ 아이디 비밀번호 전화번호 + 뒤로 버튼을 한 번 더 누르시면 종료됩니다. \ No newline at end of file From 087e15984328731872abd316a712b88a3f75654f Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Wed, 18 Sep 2024 19:40:52 +0900 Subject: [PATCH 04/16] =?UTF-8?q?[Feat/#6]=20UX=20=EA=B0=9C=EC=84=A0=20:?= =?UTF-8?q?=20=ED=81=B4=EB=A6=AD=20=EC=8B=9C=20=EB=A6=AC=ED=94=8C=20?= =?UTF-8?q?=ED=9A=A8=EA=B3=BC=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/auth/component/AuthTextField.kt | 10 +++++++--- .../presentation/ui/auth/screen/SignInScreen.kt | 7 ++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt index ef16c93..7d81b96 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt @@ -3,6 +3,7 @@ package com.sopt.now.compose.presentation.ui.auth.component import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -13,13 +14,13 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.text.BasicTextField import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.focus.onFocusChanged import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.input.VisualTransformation import androidx.compose.ui.unit.dp @@ -76,9 +77,12 @@ fun AuthTextField( contentDescription = null, modifier = Modifier .padding(end = 6.dp) - .clickable { onRemove() } + .clickable( + indication = null, + interactionSource = remember { MutableInteractionSource() }, + onClick = onRemove + ) ) - } Spacer(modifier = Modifier.height(4.dp)) Box( diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt index 3af0792..2bbaa8c 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt @@ -2,6 +2,7 @@ package com.sopt.now.compose.presentation.ui.auth.screen import android.content.Context import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -114,7 +115,11 @@ fun SignInScreen( text = stringResource(R.string.signin_signup_button), modifier = Modifier .align(Alignment.End) - .clickable { onClickSignUp() }, + .clickable( + indication = null, + interactionSource = remember { MutableInteractionSource() }, + onClick = onClickSignUp + ), color = CustomTheme.colors.gray04, textDecoration = TextDecoration.Underline, style = CustomTheme.typography.body2Medium From afa41ce47ddc6e04a5817f63d3d3f3f36ba0bbbb Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Wed, 18 Sep 2024 19:52:27 +0900 Subject: [PATCH 05/16] =?UTF-8?q?[Chore/#6]=20TextField=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=EC=9D=B4=20=EA=B8=B8=EC=96=B4=EC=A7=88=20=EC=8B=9C=20?= =?UTF-8?q?=ED=81=B4=EB=A6=AC=EC=96=B4=20=EB=B2=84=ED=8A=BC=EC=9D=B4=20?= =?UTF-8?q?=EB=B0=80=EB=A6=AC=EB=8A=94=20=ED=98=84=EC=83=81=EC=9D=84=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compose/presentation/ui/auth/component/AuthTextField.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt index 7d81b96..40b72c1 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt @@ -61,7 +61,9 @@ fun AuthTextField( .fillMaxWidth(), verticalAlignment = Alignment.CenterVertically ) { - Box { + Box( + modifier = Modifier.weight(1f) + ) { if (value.text.isEmpty()) { Text( text = hint, @@ -71,7 +73,6 @@ fun AuthTextField( } innerTextField() } - Spacer(modifier = Modifier.weight(1f)) Image( painter = painterResource(id = R.drawable.ic_textfield_clear), contentDescription = null, From f064a3c1505a93e889efdfd4a03a000cd3ce0afd Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Wed, 18 Sep 2024 20:41:39 +0900 Subject: [PATCH 06/16] =?UTF-8?q?[Feat/#6]=20UX=20=EA=B0=9C=EC=84=A0=20:?= =?UTF-8?q?=20=EC=97=94=ED=84=B0=ED=82=A4=20=EC=9E=85=EB=A0=A5=20=EC=8B=9C?= =?UTF-8?q?=20=EB=8B=A4=EC=9D=8C=20TextField=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/auth/component/AuthTextField.kt | 12 +++++++- .../ui/auth/screen/SignInScreen.kt | 22 ++++++++++++--- .../ui/auth/screen/SignUpScreen.kt | 28 ++++++++++++++++--- 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt index 40b72c1..39a9b4b 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt @@ -12,11 +12,15 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.text.BasicTextField +import androidx.compose.foundation.text.KeyboardActions +import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.focus.onFocusChanged import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.res.painterResource @@ -36,7 +40,10 @@ fun AuthTextField( onFocusChanged: (Boolean) -> Unit, onRemove: () -> Unit, hint: String, - visualTransformation: VisualTransformation = VisualTransformation.None + visualTransformation: VisualTransformation = VisualTransformation.None, + focusRequester: FocusRequester = FocusRequester(), + keyboardOptions: KeyboardOptions = KeyboardOptions.Default, + keyboardActions: KeyboardActions = KeyboardActions.Default, ) { Box(modifier = modifier) { BasicTextField( @@ -44,10 +51,13 @@ fun AuthTextField( onValueChange = onValueChange, modifier = Modifier .fillMaxWidth() + .focusRequester(focusRequester) .onFocusChanged { focusState -> onFocusChanged(focusState.isFocused) }, textStyle = TextStyle(color = CustomTheme.colors.gray01), + keyboardOptions = keyboardOptions, + keyboardActions = keyboardActions, singleLine = true, visualTransformation = visualTransformation, cursorBrush = SolidColor(CustomTheme.colors.gray01), diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt index 2bbaa8c..6324365 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt @@ -11,6 +11,8 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.text.KeyboardActions +import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Text @@ -21,8 +23,11 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.style.TextDecoration @@ -74,6 +79,9 @@ fun SignInScreen( var isIdTextFieldFocused by remember { mutableStateOf(false) } var isPasswordTextFieldFocused by remember { mutableStateOf(false) } + val idFocusRequester = remember { FocusRequester() } + val passwordFocusRequester = remember { FocusRequester() } + Column( modifier = Modifier .fillMaxSize() @@ -96,7 +104,10 @@ fun SignInScreen( isFocused = isIdTextFieldFocused, onFocusChanged = { isIdTextFieldFocused = it }, onRemove = { inputId = TextFieldValue("") }, - hint = stringResource(R.string.signin_id_hint) + hint = stringResource(R.string.signin_id_hint), + focusRequester = idFocusRequester, + keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), + keyboardActions = KeyboardActions(onNext = { passwordFocusRequester.requestFocus() }) ) Spacer(modifier = Modifier.height(40.dp)) AuthTextField( @@ -108,7 +119,8 @@ fun SignInScreen( onFocusChanged = { isPasswordTextFieldFocused = it }, onRemove = { inputPassword = TextFieldValue("") }, hint = stringResource(R.string.signin_password_hint), - visualTransformation = PasswordVisualTransformation() + visualTransformation = PasswordVisualTransformation(), + focusRequester = passwordFocusRequester, ) Spacer(modifier = Modifier.height(40.dp)) Text( @@ -126,6 +138,8 @@ fun SignInScreen( ) Spacer(modifier = Modifier.weight(1f)) SignInButton( + modifier = Modifier + .fillMaxWidth(), context = context, inputId = inputId.text, inputPassword = inputPassword.text, @@ -140,6 +154,7 @@ fun SignInScreen( @Composable fun SignInButton( + modifier: Modifier = Modifier, context: Context, inputId: String, inputPassword: String, @@ -173,8 +188,7 @@ fun SignInButton( } } }, - modifier = Modifier - .fillMaxWidth(), + modifier = modifier, colors = ButtonDefaults.buttonColors(CustomTheme.colors.mainYellow), shape = RoundedCornerShape(10.dp) ) { diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt index 20c483a..6f1a2d5 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt @@ -8,6 +8,8 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.text.KeyboardActions +import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Text @@ -18,8 +20,11 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.tooling.preview.Preview @@ -63,6 +68,11 @@ fun SignUpScreen( var isNicknameTextFieldFocused by remember { mutableStateOf(false) } var isPhoneNumberTextFieldFocused by remember { mutableStateOf(false) } + val idFocusRequester= remember { FocusRequester() } + val passwordFocusRequester= remember { FocusRequester() } + val nicknameFocusRequester= remember { FocusRequester() } + val phoneNumberFocusRequester= remember { FocusRequester() } + Column( modifier = Modifier .fillMaxSize() @@ -96,7 +106,10 @@ fun SignUpScreen( isFocused = isIdTextFieldFocused, onFocusChanged = { isIdTextFieldFocused = it }, onRemove = { inputId = TextFieldValue("") }, - hint = stringResource(R.string.signup_id_hint) + hint = stringResource(R.string.signup_id_hint), + focusRequester = idFocusRequester, + keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), + keyboardActions = KeyboardActions(onNext = { passwordFocusRequester.requestFocus() }) ) Spacer(modifier = Modifier.height(30.dp)) @@ -118,7 +131,10 @@ fun SignUpScreen( onFocusChanged = { isPasswordTextFieldFocused = it }, onRemove = { inputPassword = TextFieldValue("") }, hint = stringResource(R.string.signup_password_hint), - visualTransformation = PasswordVisualTransformation() + visualTransformation = PasswordVisualTransformation(), + focusRequester = passwordFocusRequester, + keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), + keyboardActions = KeyboardActions(onNext = { nicknameFocusRequester.requestFocus() }) ) Spacer(modifier = Modifier.height(30.dp)) @@ -139,7 +155,10 @@ fun SignUpScreen( isFocused = isNicknameTextFieldFocused, onFocusChanged = { isNicknameTextFieldFocused = it }, onRemove = { inputNickname = TextFieldValue("") }, - hint = stringResource(R.string.signup_nickname_hint) + hint = stringResource(R.string.signup_nickname_hint), + focusRequester = nicknameFocusRequester, + keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), + keyboardActions = KeyboardActions(onNext = { phoneNumberFocusRequester.requestFocus() }) ) Spacer(modifier = Modifier.height(30.dp)) @@ -160,7 +179,8 @@ fun SignUpScreen( isFocused = isPhoneNumberTextFieldFocused, onFocusChanged = { isPhoneNumberTextFieldFocused = it }, onRemove = { inputPhoneNumber = TextFieldValue("") }, - hint = stringResource(R.string.signup_phone_number_hint) + hint = stringResource(R.string.signup_phone_number_hint), + focusRequester = phoneNumberFocusRequester ) Spacer(modifier = Modifier.weight(1f)) From 3183684cf23cced62ed93ecd3544ce09e1fcc08d Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Wed, 18 Sep 2024 23:24:02 +0900 Subject: [PATCH 07/16] =?UTF-8?q?[Feat/#6]=20UX=20=EA=B0=9C=EC=84=A0=20:?= =?UTF-8?q?=20=ED=82=A4=EB=B3=B4=EB=93=9C=20=EC=9C=84=EB=A1=9C=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=EC=9D=B4=20=EC=98=AC=EB=9D=BC=EC=98=A4=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 1 + .../ui/auth/screen/SignUpScreen.kt | 224 +++++++++--------- 2 files changed, 110 insertions(+), 115 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4523ccb..17dd675 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,6 +15,7 @@ diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt index 6f1a2d5..d09a1d6 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt @@ -1,12 +1,12 @@ package com.sopt.now.compose.presentation.ui.auth.screen -import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions @@ -21,12 +21,12 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester -import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.text.input.TextFieldValue +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.sopt.now.compose.R @@ -68,129 +68,119 @@ fun SignUpScreen( var isNicknameTextFieldFocused by remember { mutableStateOf(false) } var isPhoneNumberTextFieldFocused by remember { mutableStateOf(false) } - val idFocusRequester= remember { FocusRequester() } - val passwordFocusRequester= remember { FocusRequester() } - val nicknameFocusRequester= remember { FocusRequester() } - val phoneNumberFocusRequester= remember { FocusRequester() } + val idFocusRequester = remember { FocusRequester() } + val passwordFocusRequester = remember { FocusRequester() } + val nicknameFocusRequester = remember { FocusRequester() } + val phoneNumberFocusRequester = remember { FocusRequester() } - Column( + Box( modifier = Modifier .fillMaxSize() .padding(30.dp), - horizontalAlignment = Alignment.CenterHorizontally + contentAlignment = Alignment.TopCenter ) { - Spacer(modifier = Modifier.height(30.dp)) - - Text( - text = stringResource(R.string.signup_title), + LazyColumn( modifier = Modifier - .wrapContentSize(), - style = CustomTheme.typography.head1 - ) + .fillMaxWidth() + .padding(bottom = 80.dp), + horizontalAlignment = Alignment.Start + ) { + item { + Spacer(modifier = Modifier.height(30.dp)) + + Text( + text = stringResource(R.string.signup_title), + modifier = Modifier.fillMaxWidth(), + textAlign = TextAlign.Center, + style = CustomTheme.typography.head1 + ) - Spacer(modifier = Modifier.height(30.dp)) + Spacer(modifier = Modifier.height(30.dp)) - Text( - text = stringResource(R.string.signup_id_title), - modifier = Modifier - .wrapContentSize() - .align(Alignment.Start), - style = CustomTheme.typography.head2 - ) - Spacer(modifier = Modifier.height(18.dp)) - AuthTextField( - value = inputId, - onValueChange = { inputId = it }, - modifier = Modifier - .fillMaxWidth(), - isFocused = isIdTextFieldFocused, - onFocusChanged = { isIdTextFieldFocused = it }, - onRemove = { inputId = TextFieldValue("") }, - hint = stringResource(R.string.signup_id_hint), - focusRequester = idFocusRequester, - keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), - keyboardActions = KeyboardActions(onNext = { passwordFocusRequester.requestFocus() }) - ) - - Spacer(modifier = Modifier.height(30.dp)) - - Text( - text = stringResource(R.string.signup_password_title), - modifier = Modifier - .wrapContentSize() - .align(Alignment.Start), - style = CustomTheme.typography.head2 - ) - Spacer(modifier = Modifier.height(18.dp)) - AuthTextField( - value = inputPassword, - onValueChange = { inputPassword = it }, - modifier = Modifier - .fillMaxWidth(), - isFocused = isPasswordTextFieldFocused, - onFocusChanged = { isPasswordTextFieldFocused = it }, - onRemove = { inputPassword = TextFieldValue("") }, - hint = stringResource(R.string.signup_password_hint), - visualTransformation = PasswordVisualTransformation(), - focusRequester = passwordFocusRequester, - keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), - keyboardActions = KeyboardActions(onNext = { nicknameFocusRequester.requestFocus() }) - ) - - Spacer(modifier = Modifier.height(30.dp)) - - Text( - text = stringResource(R.string.signup_nickname_title), - modifier = Modifier - .wrapContentSize() - .align(Alignment.Start), - style = CustomTheme.typography.head2 - ) - Spacer(modifier = Modifier.height(18.dp)) - AuthTextField( - value = inputNickname, - onValueChange = { inputNickname = it }, - modifier = Modifier - .fillMaxWidth(), - isFocused = isNicknameTextFieldFocused, - onFocusChanged = { isNicknameTextFieldFocused = it }, - onRemove = { inputNickname = TextFieldValue("") }, - hint = stringResource(R.string.signup_nickname_hint), - focusRequester = nicknameFocusRequester, - keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), - keyboardActions = KeyboardActions(onNext = { phoneNumberFocusRequester.requestFocus() }) - ) - - Spacer(modifier = Modifier.height(30.dp)) - - Text( - text = stringResource(R.string.signup_phone_number_title), - modifier = Modifier - .wrapContentSize() - .align(Alignment.Start), - style = CustomTheme.typography.head2 - ) - Spacer(modifier = Modifier.height(18.dp)) - AuthTextField( - value = inputPhoneNumber, - onValueChange = { inputPhoneNumber = it }, - modifier = Modifier - .fillMaxWidth(), - isFocused = isPhoneNumberTextFieldFocused, - onFocusChanged = { isPhoneNumberTextFieldFocused = it }, - onRemove = { inputPhoneNumber = TextFieldValue("") }, - hint = stringResource(R.string.signup_phone_number_hint), - focusRequester = phoneNumberFocusRequester - ) + Text( + text = stringResource(R.string.signup_id_title), + style = CustomTheme.typography.head2 + ) + Spacer(modifier = Modifier.height(18.dp)) + AuthTextField( + value = inputId, + onValueChange = { inputId = it }, + modifier = Modifier.fillMaxWidth(), + isFocused = isIdTextFieldFocused, + onFocusChanged = { isIdTextFieldFocused = it }, + onRemove = { inputId = TextFieldValue("") }, + hint = stringResource(R.string.signup_id_hint), + focusRequester = idFocusRequester, + keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), + keyboardActions = KeyboardActions(onNext = { passwordFocusRequester.requestFocus() }) + ) - Spacer(modifier = Modifier.weight(1f)) + Spacer(modifier = Modifier.height(30.dp)) + Text( + text = stringResource(R.string.signup_password_title), + style = CustomTheme.typography.head2 + ) + Spacer(modifier = Modifier.height(18.dp)) + AuthTextField( + value = inputPassword, + onValueChange = { inputPassword = it }, + modifier = Modifier.fillMaxWidth(), + isFocused = isPasswordTextFieldFocused, + onFocusChanged = { isPasswordTextFieldFocused = it }, + onRemove = { inputPassword = TextFieldValue("") }, + hint = stringResource(R.string.signup_password_hint), + visualTransformation = PasswordVisualTransformation(), + focusRequester = passwordFocusRequester, + keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), + keyboardActions = KeyboardActions(onNext = { nicknameFocusRequester.requestFocus() }) + ) + + Spacer(modifier = Modifier.height(30.dp)) + + Text( + text = stringResource(R.string.signup_nickname_title), + style = CustomTheme.typography.head2 + ) + Spacer(modifier = Modifier.height(18.dp)) + AuthTextField( + value = inputNickname, + onValueChange = { inputNickname = it }, + modifier = Modifier.fillMaxWidth(), + isFocused = isNicknameTextFieldFocused, + onFocusChanged = { isNicknameTextFieldFocused = it }, + onRemove = { inputNickname = TextFieldValue("") }, + hint = stringResource(R.string.signup_nickname_hint), + focusRequester = nicknameFocusRequester, + keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), + keyboardActions = KeyboardActions(onNext = { phoneNumberFocusRequester.requestFocus() }) + ) + + Spacer(modifier = Modifier.height(30.dp)) + + Text( + text = stringResource(R.string.signup_phone_number_title), + style = CustomTheme.typography.head2 + ) + Spacer(modifier = Modifier.height(18.dp)) + AuthTextField( + value = inputPhoneNumber, + onValueChange = { inputPhoneNumber = it }, + modifier = Modifier.fillMaxWidth(), + isFocused = isPhoneNumberTextFieldFocused, + onFocusChanged = { isPhoneNumberTextFieldFocused = it }, + onRemove = { inputPhoneNumber = TextFieldValue("") }, + hint = stringResource(R.string.signup_phone_number_hint), + focusRequester = phoneNumberFocusRequester + ) + } + } Button( onClick = { val user = setUser( inputId.text, inputPassword.text, - inputPassword.text, + inputNickname.text, inputPhoneNumber.text ) if (SignUpValidation.isSignUpValid(user)) { @@ -201,10 +191,13 @@ fun SignUpScreen( inputNickname.text, inputPhoneNumber.text ) - } else showToast(context, context.getString(R.string.signup_signup_failure)) + } else { + showToast(context, context.getString(R.string.signup_signup_failure)) + } }, modifier = Modifier - .fillMaxWidth(), + .fillMaxWidth() + .align(Alignment.BottomCenter), colors = ButtonDefaults.buttonColors(CustomTheme.colors.mainYellow), shape = RoundedCornerShape(10.dp) ) { @@ -216,6 +209,7 @@ fun SignUpScreen( } } + fun setUser( inputId: String, inputPassword: String, @@ -231,6 +225,6 @@ fun setUser( @Preview(showBackground = true) @Composable -fun showSignUp() { - +fun ShowSignUp() { + SignUpScreen(onClickSignUp = { id, password, nickname, phoneNumber -> }) } \ No newline at end of file From ee5dafb5679a988ba11f6ad0c2bb19633c6fd514 Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Wed, 18 Sep 2024 23:25:29 +0900 Subject: [PATCH 08/16] =?UTF-8?q?[Chore/#6]=20=EB=B0=B0=EA=B2=BD=EC=83=89?= =?UTF-8?q?=20white=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../now/compose/presentation/ui/auth/screen/SignInScreen.kt | 2 ++ .../now/compose/presentation/ui/auth/screen/SignUpScreen.kt | 2 ++ .../sopt/now/compose/presentation/ui/home/screen/HomeScreen.kt | 2 ++ 3 files changed, 6 insertions(+) diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt index 6324365..6af678e 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt @@ -1,6 +1,7 @@ package com.sopt.now.compose.presentation.ui.auth.screen import android.content.Context +import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Column @@ -85,6 +86,7 @@ fun SignInScreen( Column( modifier = Modifier .fillMaxSize() + .background(color = CustomTheme.colors.white) .padding(30.dp), horizontalAlignment = Alignment.CenterHorizontally ) { diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt index d09a1d6..00b4ac3 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt @@ -1,5 +1,6 @@ package com.sopt.now.compose.presentation.ui.auth.screen +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -76,6 +77,7 @@ fun SignUpScreen( Box( modifier = Modifier .fillMaxSize() + .background(color = CustomTheme.colors.white) .padding(30.dp), contentAlignment = Alignment.TopCenter ) { diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/home/screen/HomeScreen.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/home/screen/HomeScreen.kt index 406e938..8d3edcb 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/home/screen/HomeScreen.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/home/screen/HomeScreen.kt @@ -3,6 +3,7 @@ package com.sopt.now.compose.presentation.ui.home.screen import android.app.Activity import androidx.activity.compose.BackHandler import androidx.compose.foundation.Image +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -72,6 +73,7 @@ fun HomeScreen( Column( modifier = Modifier .fillMaxSize() + .background(color = CustomTheme.colors.white) .padding(40.dp), horizontalAlignment = Alignment.Start ) { From 50e533ed4214d8f5422d763dd67f5a1461da47c3 Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Wed, 18 Sep 2024 23:30:04 +0900 Subject: [PATCH 09/16] =?UTF-8?q?[Chore/#6]=20padding,=20Spacer=20?= =?UTF-8?q?=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/auth/screen/SignInScreen.kt | 7 ++++--- .../presentation/ui/auth/screen/SignUpScreen.kt | 14 ++------------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt index 6af678e..3195ac1 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt @@ -31,6 +31,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.text.input.TextFieldValue +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp @@ -90,11 +91,11 @@ fun SignInScreen( .padding(30.dp), horizontalAlignment = Alignment.CenterHorizontally ) { + Spacer(modifier = Modifier.height(30.dp)) Text( text = stringResource(R.string.signin_title), - modifier = Modifier - .wrapContentWidth() - .padding(top = 30.dp), + modifier = Modifier.fillMaxWidth(), + textAlign = TextAlign.Center, style = CustomTheme.typography.head1 ) Spacer(modifier = Modifier.height(80.dp)) diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt index 00b4ac3..66bff5f 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt @@ -82,23 +82,18 @@ fun SignUpScreen( contentAlignment = Alignment.TopCenter ) { LazyColumn( - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 80.dp), + modifier = Modifier.fillMaxWidth(), horizontalAlignment = Alignment.Start ) { item { Spacer(modifier = Modifier.height(30.dp)) - Text( text = stringResource(R.string.signup_title), modifier = Modifier.fillMaxWidth(), textAlign = TextAlign.Center, style = CustomTheme.typography.head1 ) - Spacer(modifier = Modifier.height(30.dp)) - Text( text = stringResource(R.string.signup_id_title), style = CustomTheme.typography.head2 @@ -116,9 +111,7 @@ fun SignUpScreen( keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), keyboardActions = KeyboardActions(onNext = { passwordFocusRequester.requestFocus() }) ) - Spacer(modifier = Modifier.height(30.dp)) - Text( text = stringResource(R.string.signup_password_title), style = CustomTheme.typography.head2 @@ -137,9 +130,7 @@ fun SignUpScreen( keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), keyboardActions = KeyboardActions(onNext = { nicknameFocusRequester.requestFocus() }) ) - Spacer(modifier = Modifier.height(30.dp)) - Text( text = stringResource(R.string.signup_nickname_title), style = CustomTheme.typography.head2 @@ -157,9 +148,7 @@ fun SignUpScreen( keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), keyboardActions = KeyboardActions(onNext = { phoneNumberFocusRequester.requestFocus() }) ) - Spacer(modifier = Modifier.height(30.dp)) - Text( text = stringResource(R.string.signup_phone_number_title), style = CustomTheme.typography.head2 @@ -175,6 +164,7 @@ fun SignUpScreen( hint = stringResource(R.string.signup_phone_number_hint), focusRequester = phoneNumberFocusRequester ) + Spacer(modifier = Modifier.height(80.dp)) } } Button( From 98e009d0ede4353a4052f27b8d4e8c07d6b8190f Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Wed, 18 Sep 2024 23:31:32 +0900 Subject: [PATCH 10/16] [Chore/#6] - --- .../ui/auth/screen/SignInScreen.kt | 33 ++++++------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt index 3195ac1..c9769c9 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt @@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions @@ -25,7 +24,6 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester -import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction @@ -52,10 +50,7 @@ fun SignInRoute( SignInScreen( onClickSignIn = { id, password, nickname, phoneNumber -> authNavigator.navigateToHome( - id, - password, - nickname, - phoneNumber + id, password, nickname, phoneNumber ) }, onClickSignUp = { authNavigator.navigateToSignUp() }, @@ -88,8 +83,7 @@ fun SignInScreen( modifier = Modifier .fillMaxSize() .background(color = CustomTheme.colors.white) - .padding(30.dp), - horizontalAlignment = Alignment.CenterHorizontally + .padding(30.dp), horizontalAlignment = Alignment.CenterHorizontally ) { Spacer(modifier = Modifier.height(30.dp)) Text( @@ -102,8 +96,7 @@ fun SignInScreen( AuthTextField( value = inputId, onValueChange = { inputId = it }, - modifier = Modifier - .fillMaxWidth(), + modifier = Modifier.fillMaxWidth(), isFocused = isIdTextFieldFocused, onFocusChanged = { isIdTextFieldFocused = it }, onRemove = { inputId = TextFieldValue("") }, @@ -116,8 +109,7 @@ fun SignInScreen( AuthTextField( value = inputPassword, onValueChange = { inputPassword = it }, - modifier = Modifier - .fillMaxWidth(), + modifier = Modifier.fillMaxWidth(), isFocused = isPasswordTextFieldFocused, onFocusChanged = { isPasswordTextFieldFocused = it }, onRemove = { inputPassword = TextFieldValue("") }, @@ -141,8 +133,7 @@ fun SignInScreen( ) Spacer(modifier = Modifier.weight(1f)) SignInButton( - modifier = Modifier - .fillMaxWidth(), + modifier = Modifier.fillMaxWidth(), context = context, inputId = inputId.text, inputPassword = inputPassword.text, @@ -171,18 +162,15 @@ fun SignInButton( onClick = { when { inputId.isEmpty() || inputPassword.isEmpty() -> showToast( - context, - context.getString(R.string.signin_signin_failure_toast) + context, context.getString(R.string.signin_signin_failure_toast) ) inputId != id -> showToast( - context, - context.getString(R.string.signin_signin_id_incorrect) + context, context.getString(R.string.signin_signin_id_incorrect) ) inputPassword != password -> showToast( - context, - context.getString(R.string.signin_signin_password_incorrect) + context, context.getString(R.string.signin_signin_password_incorrect) ) else -> { @@ -196,14 +184,13 @@ fun SignInButton( shape = RoundedCornerShape(10.dp) ) { Text( - text = stringResource(R.string.signin_signin_button), - color = CustomTheme.colors.gray01 + text = stringResource(R.string.signin_signin_button), color = CustomTheme.colors.gray01 ) } } @Preview(showBackground = true) @Composable -fun show() { +fun ShowSignInScreen() { } \ No newline at end of file From 28fc37672301df2f9c20d53638699b0f97df13f1 Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Fri, 20 Sep 2024 13:15:56 +0900 Subject: [PATCH 11/16] [Chore/#6] value parameter type change : TextValue -> String --- .../compose/presentation/ui/auth/component/AuthTextField.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt index 39a9b4b..a7dd629 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/component/AuthTextField.kt @@ -33,8 +33,8 @@ import com.sopt.now.compose.ui.theme.CustomTheme @Composable fun AuthTextField( - value: TextFieldValue, - onValueChange: (TextFieldValue) -> Unit, + value: String, + onValueChange: (String) -> Unit, modifier: Modifier = Modifier, isFocused: Boolean, onFocusChanged: (Boolean) -> Unit, @@ -74,7 +74,7 @@ fun AuthTextField( Box( modifier = Modifier.weight(1f) ) { - if (value.text.isEmpty()) { + if (value.isEmpty()) { Text( text = hint, style = CustomTheme.typography.body1Medium, From 886c44027b8b6b35d5079971fd980cbf343ce402 Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Sat, 21 Sep 2024 17:15:03 +0900 Subject: [PATCH 12/16] =?UTF-8?q?[Feat/#6]=20hiltViewModel=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 30 ++++++++++++++----- app/src/main/AndroidManifest.xml | 1 + .../java/com/sopt/now/compose/NOWSoptApp.kt | 20 +++++++++++++ .../presentation/ui/main/MainActivity.kt | 2 ++ build.gradle | 4 ++- 5 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/com/sopt/now/compose/NOWSoptApp.kt diff --git a/app/build.gradle b/app/build.gradle index 045c25b..1e7e43a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,8 @@ plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' + id 'com.google.devtools.ksp' + id 'dagger.hilt.android.plugin' } android { @@ -50,24 +52,36 @@ dependencies { implementation 'androidx.core:core-ktx:1.12.0' implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0' implementation 'androidx.activity:activity-compose:1.8.2' + + // Compose BOM implementation platform('androidx.compose:compose-bom:2024.03.00') implementation 'androidx.compose.ui:ui' implementation 'androidx.compose.ui:ui-graphics' implementation 'androidx.compose.ui:ui-tooling-preview' implementation 'androidx.compose.material3:material3' - implementation 'androidx.compose.ui:ui-graphics-android:1.6.8' - implementation 'androidx.compose.ui:ui-test-android:1.6.8' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - androidTestImplementation platform('androidx.compose:compose-bom:2024.03.00') - androidTestImplementation 'androidx.compose.ui:ui-test-junit4' + + // Debugging and Testing debugImplementation 'androidx.compose.ui:ui-tooling' + androidTestImplementation 'androidx.compose.ui:ui-test-junit4' debugImplementation 'androidx.compose.ui:ui-test-manifest' + androidTestImplementation platform('androidx.compose:compose-bom:2024.03.00') // Navigation implementation 'androidx.navigation:navigation-compose:2.7.7' // Serialization - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0") + implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0' + + // Hilt (Dependency Injection) + implementation 'com.google.dagger:hilt-android:2.49' + ksp 'com.google.dagger:hilt-compiler:2.49' + implementation 'androidx.hilt:hilt-navigation-compose:1.2.0' + + // Testing + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + + implementation 'androidx.core:core-ktx:1.12.0' + implementation 'androidx.appcompat:appcompat:1.6.1' } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 17dd675..7e580ca 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,6 +3,7 @@ xmlns:tools="http://schemas.android.com/tools"> Date: Sat, 21 Sep 2024 17:15:58 +0900 Subject: [PATCH 13/16] =?UTF-8?q?[Add/#6]=20SignInState,=20SignUpState=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compose/presentation/ui/auth/screen/SignInState.kt | 8 ++++++++ .../compose/presentation/ui/auth/screen/SignUpState.kt | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInState.kt create mode 100644 app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpState.kt diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInState.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInState.kt new file mode 100644 index 0000000..9590e34 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInState.kt @@ -0,0 +1,8 @@ +package com.sopt.now.compose.presentation.ui.auth.screen + +sealed class SignInState { + data object Idle: SignInState() + data object IdInvalid: SignInState() + data object PasswordInvalid: SignInState() + data object Success: SignInState() +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpState.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpState.kt new file mode 100644 index 0000000..4264a15 --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpState.kt @@ -0,0 +1,10 @@ +package com.sopt.now.compose.presentation.ui.auth.screen + +sealed class SignUpState { + data object Idle: SignUpState() + data object IdInvalid: SignUpState() + data object PasswordInvalid: SignUpState() + data object NicknameInvalid: SignUpState() + data object PhoneNumberInvalid: SignUpState() + data object Success: SignUpState() +} \ No newline at end of file From 7007cc465bc1c241a907c24ba0e61d17604c8a6b Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Sat, 21 Sep 2024 17:16:21 +0900 Subject: [PATCH 14/16] =?UTF-8?q?[Feat/#6]=20AuthViewModel=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/auth/screen/AuthViewModel.kt | 174 ++++++++++++++++++ .../ui/auth/screen/SignUpValidation.kt | 47 ----- 2 files changed, 174 insertions(+), 47 deletions(-) create mode 100644 app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/AuthViewModel.kt delete mode 100644 app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpValidation.kt diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/AuthViewModel.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/AuthViewModel.kt new file mode 100644 index 0000000..3355d5c --- /dev/null +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/AuthViewModel.kt @@ -0,0 +1,174 @@ +package com.sopt.now.compose.presentation.ui.auth.screen + +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue +import androidx.lifecycle.ViewModel +import com.sopt.now.compose.data.User +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import java.util.regex.Pattern +import javax.inject.Inject + +@HiltViewModel +class AuthViewModel @Inject constructor() : ViewModel() { + var signInId by mutableStateOf("") + private set + var signInPassword by mutableStateOf("") + private set + var signUpId by mutableStateOf("") + private set + var signUpPassword by mutableStateOf("") + private set + var signUpNickname by mutableStateOf("") + private set + var signUpPhoneNumber by mutableStateOf("") + private set + + var isSignInIdTextFieldFocused by mutableStateOf(false) + private set + var isSignInPasswordTextFieldFocused by mutableStateOf(false) + private set + var isSignUpIdTextFieldFocused by mutableStateOf(false) + private set + var isSignUpPasswordTextFieldFocused by mutableStateOf(false) + private set + var isSignUpNicknameTextFieldFocused by mutableStateOf(false) + private set + var isSignUpPhoneNumberTextFieldFocused by mutableStateOf(false) + private set + + private val _user = MutableStateFlow(null) + val user: StateFlow = _user + + private val _signInState = MutableStateFlow(SignInState.Idle) + val signInState: StateFlow = _signInState + + private val _signUpState = MutableStateFlow(SignUpState.Idle) + val signUpState: StateFlow = _signUpState + + fun onSignInIdChange(newId: String) { + signInId = newId + } + + fun onSignInPasswordChange(newPassword: String) { + signInPassword = newPassword + } + + fun onSignInIdFocusChange(isFocused: Boolean) { + isSignInIdTextFieldFocused = isFocused + } + + fun onSignInPasswordFocusChange(isFocused: Boolean) { + isSignInPasswordTextFieldFocused = isFocused + } + + private fun signInIdValidation(): Boolean { + return signInId.isNotEmpty() && signInId == _user.value?.id + } + + private fun signInPasswordValidation(): Boolean { + return signInPassword.isNotEmpty() && signInPassword == _user.value?.password + } + + fun signInValidation() { + _signInState.value = + when { + (!signInIdValidation()) -> SignInState.IdInvalid + (!signInPasswordValidation()) -> SignInState.PasswordInvalid + else -> SignInState.Success + } + } + + fun onSignUpIdChange(newId: String) { + signUpId = newId + } + + fun onSignUpPasswordChange(newPassword: String) { + signUpPassword = newPassword + } + + fun onSignUpNicknameChange(newNickname: String) { + signUpNickname = newNickname + } + + fun onSignUpPhoneNumberChange(newPhoneNumber: String) { + signUpPhoneNumber = newPhoneNumber + } + + fun onSignUpIdFocusChange(isFocused: Boolean) { + isSignUpIdTextFieldFocused = isFocused + } + + fun onSignUpPasswordFocusChange(isFocused: Boolean) { + isSignUpPasswordTextFieldFocused = isFocused + } + + fun onSignUpNicknameFocusChange(isFocused: Boolean) { + isSignUpNicknameTextFieldFocused = isFocused + } + + fun onSignUpPhoneNumberFocusChange(isFocused: Boolean) { + isSignUpPhoneNumberTextFieldFocused = isFocused + } + + private fun setUser() { + _user.value = User( + id = signUpId, + password = signUpPassword, + nickname = signUpNickname, + phoneNumber = signUpPhoneNumber + ) + } + + private fun signUpIdValidation(): Boolean { + return ID_VALIDATION_PATTERN.matcher(_user.value?.id.toString()).matches() + } + + private fun signUpPasswordValidation(): Boolean { + return PW_VALIDATION_PATTERN.matcher(_user.value?.password.toString()).matches() + } + + private fun signUpNicknameValidation(): Boolean { + return NICKNAME_VALIDATION_PATTERN.matcher(_user.value?.nickname.toString()).matches() + } + + private fun signUpPhoneNumberValidation(): Boolean { + return PHONE_NUMBER_VALIDATION_PATTERN.matcher(_user.value?.phoneNumber.toString()) + .matches() + } + + fun signUpValidation() { + setUser() + _signUpState.value = + when { + (!signUpIdValidation()) -> SignUpState.IdInvalid + (!signUpPasswordValidation()) -> SignUpState.PasswordInvalid + (!signUpNicknameValidation()) -> SignUpState.NicknameInvalid + (!signUpPhoneNumberValidation()) -> SignUpState.PhoneNumberInvalid + else -> SignUpState.Success + } + } + + companion object { + private const val ID_MIN_LENGTH = 6 + private const val ID_MAX_LENGTH = 10 + private const val PW_MIN_LENGTH = 8 + private const val PW_MAX_LENGTH = 12 + + private const val ID_VALIDATION_REGEX = "^[a-zA-Z0-9]{$ID_MIN_LENGTH,$ID_MAX_LENGTH}$" + private val ID_VALIDATION_PATTERN: Pattern = Pattern.compile(ID_VALIDATION_REGEX) + + private const val PW_VALIDATION_REGEX = "^[a-zA-Z0-9]{$PW_MIN_LENGTH,$PW_MAX_LENGTH}$" + private val PW_VALIDATION_PATTERN: Pattern = Pattern.compile(PW_VALIDATION_REGEX) + + private const val NICKNAME_VALIDATION_REGEX = "^\\S+$" + private val NICKNAME_VALIDATION_PATTERN: Pattern = + Pattern.compile(NICKNAME_VALIDATION_REGEX) + + private const val PHONE_NUMBER_VALIDATION_REGEX = "^010-\\d{4}-\\d{4}$" + private val PHONE_NUMBER_VALIDATION_PATTERN: Pattern = + Pattern.compile(PHONE_NUMBER_VALIDATION_REGEX) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpValidation.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpValidation.kt deleted file mode 100644 index 6c68a76..0000000 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpValidation.kt +++ /dev/null @@ -1,47 +0,0 @@ -package com.sopt.now.compose.presentation.ui.auth.screen - -import com.sopt.now.compose.data.User -import java.util.regex.Pattern - -object SignUpValidation { - - private const val ID_MIN_LENGTH = 6 - private const val ID_MAX_LENGTH = 10 - private const val PW_MIN_LENGTH = 8 - private const val PW_MAX_LENGTH = 12 - - private const val ID_VALIDATION_REGEX = "^[a-zA-Z0-9]{$ID_MIN_LENGTH,$ID_MAX_LENGTH}$" - private val ID_VALIDATION_PATTERN: Pattern = Pattern.compile(ID_VALIDATION_REGEX) - - private const val PW_VALIDATION_REGEX = "^[a-zA-Z0-9]{$PW_MIN_LENGTH,$PW_MAX_LENGTH}$" - private val PW_VALIDATION_PATTERN: Pattern = Pattern.compile(PW_VALIDATION_REGEX) - - private const val NICKNAME_VALIDATION_REGEX = "^\\S+$" - private val NICKNAME_VALIDATION_PATTERN: Pattern = Pattern.compile(NICKNAME_VALIDATION_REGEX) - - private const val PHONE_NUMBER_VALIDATION_REGEX = "^010-\\d{4}-\\d{4}$" - private val PHONE_NUMBER_VALIDATION_PATTERN: Pattern = Pattern.compile(PHONE_NUMBER_VALIDATION_REGEX) - - private fun isIdValid(inputId: String): Boolean { - return ID_VALIDATION_PATTERN.matcher(inputId).matches() - } - - private fun isPasswordValid(inputPassword: String): Boolean { - return PW_VALIDATION_PATTERN.matcher(inputPassword).matches() - } - - private fun isNicknameValid(inputNickname: String): Boolean { - return NICKNAME_VALIDATION_PATTERN.matcher(inputNickname).matches() - } - - private fun isPhoneNumberValid(inputPhoneNumber: String): Boolean { - return PHONE_NUMBER_VALIDATION_PATTERN.matcher(inputPhoneNumber).matches() - } - - fun isSignUpValid(user: User): Boolean { - return isIdValid(user.id) && - isPasswordValid(user.password) && - isNicknameValid(user.nickname) && - isPhoneNumberValid(user.phoneNumber) - } -} \ No newline at end of file From 66e0eba276f9cbb4b196f4d38a643eceab4c2237 Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Sat, 21 Sep 2024 17:17:33 +0900 Subject: [PATCH 15/16] =?UTF-8?q?[Feat/#6]=20AuthViewModel=EC=9D=84=20Sign?= =?UTF-8?q?InScreen,=20SignUpScreen=EC=97=90=EC=84=9C=20=EA=B0=99=EC=9D=80?= =?UTF-8?q?=20=EA=B0=9D=EC=B2=B4=EB=A1=9C=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20=EC=9C=84=ED=95=B4=20=EB=84=A4=EB=B9=84=EA=B2=8C?= =?UTF-8?q?=EC=9D=B4=EC=85=98=EC=9D=84=20=ED=86=B5=ED=95=B4=20=EB=B6=80?= =?UTF-8?q?=EB=AA=A8=20=EC=BB=B4=ED=8F=AC=EC=A0=80=EB=B8=94=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=A0=84=EB=8B=AC=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/auth/navigation/AuthNavGraph.kt | 33 ++++++++----------- .../ui/auth/navigation/AuthNavigator.kt | 6 ++-- .../presentation/ui/main/MainActivity.kt | 4 +++ .../presentation/ui/navigator/MainNavHost.kt | 6 ++-- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/navigation/AuthNavGraph.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/navigation/AuthNavGraph.kt index c8f74b7..bc0529f 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/navigation/AuthNavGraph.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/navigation/AuthNavGraph.kt @@ -1,33 +1,26 @@ package com.sopt.now.compose.presentation.ui.auth.navigation import androidx.navigation.NavGraphBuilder -import androidx.navigation.NavType import androidx.navigation.compose.composable -import androidx.navigation.navArgument +import com.sopt.now.compose.presentation.ui.auth.screen.AuthViewModel import com.sopt.now.compose.presentation.ui.auth.screen.SignInRoute import com.sopt.now.compose.presentation.ui.auth.screen.SignUpRoute -import com.sopt.now.compose.presentation.ui.home.navigation.HomeNavigator -import com.sopt.now.compose.presentation.ui.home.screen.HomeRoute -fun NavGraphBuilder.authNavGraph(authNavigator: AuthNavigator) { - - composable( - route = "signIn/{id}/{password}/{nickname}/{phoneNumber}", - arguments = listOf( - navArgument("id") { type = NavType.StringType }, - navArgument("password") { type = NavType.StringType }, - navArgument("nickname") { type = NavType.StringType }, - navArgument("phoneNumber") { type = NavType.StringType } +fun NavGraphBuilder.authNavGraph( + authNavigator: AuthNavigator, + authViewModel: AuthViewModel +) { + composable(route = "signIn") { + SignInRoute( + authNavigator = authNavigator, + authViewModel = authViewModel ) - ) { backStackEntry -> - val id = backStackEntry.arguments?.getString("id") ?: "" - val password = backStackEntry.arguments?.getString("password") ?: "" - val nickname = backStackEntry.arguments?.getString("nickname") ?: "" - val phoneNumber = backStackEntry.arguments?.getString("phoneNumber") ?: "" - SignInRoute(authNavigator, id, password, nickname, phoneNumber) } composable(route = "signUp") { - SignUpRoute(authNavigator) + SignUpRoute( + authNavigator = authNavigator, + authViewModel = authViewModel + ) } } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/navigation/AuthNavigator.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/navigation/AuthNavigator.kt index d690c23..2c44a9a 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/navigation/AuthNavigator.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/navigation/AuthNavigator.kt @@ -5,15 +5,15 @@ import androidx.navigation.NavController class AuthNavigator( private val navController: NavController ) { - fun navigateToSignIn(id: String, password: String, nickname: String, phoneNumber: String) { - navController.navigate("signIn/$id/$password/$nickname/$phoneNumber") + fun navigateToSignIn() { + navController.navigate("signIn") } fun navigateToSignUp() { navController.navigate("signUp") } - fun navigateToHome(id: String, password: String, nickname: String, phoneNumber: String) { + fun navigateToHome(id: String?, password: String?, nickname: String?, phoneNumber: String?) { navController.navigate("home/$id/$password/$nickname/$phoneNumber") } diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/main/MainActivity.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/main/MainActivity.kt index 7ecf4f8..ddd21c4 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/main/MainActivity.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/main/MainActivity.kt @@ -8,8 +8,10 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.compose.rememberNavController import com.sopt.now.compose.presentation.ui.auth.navigation.AuthNavigator +import com.sopt.now.compose.presentation.ui.auth.screen.AuthViewModel import com.sopt.now.compose.presentation.ui.home.navigation.HomeNavigator import com.sopt.now.compose.presentation.ui.navigator.MainNavHost import com.sopt.now.compose.ui.theme.CUSTOMTheme @@ -23,6 +25,7 @@ class MainActivity : ComponentActivity() { CUSTOMTheme { val navController = rememberNavController() val authNavigator = remember(navController) { AuthNavigator(navController) } + val authViewModel: AuthViewModel = hiltViewModel() val homeNavigator = remember(navController) { HomeNavigator(navController) } Scaffold( @@ -32,6 +35,7 @@ class MainActivity : ComponentActivity() { navHostController = navController, modifier = Modifier.padding(paddingValues), authNavigator = authNavigator, + authViewModel = authViewModel, homeNavigator = homeNavigator ) } diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/navigator/MainNavHost.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/navigator/MainNavHost.kt index c84d865..93fd58f 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/navigator/MainNavHost.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/navigator/MainNavHost.kt @@ -10,6 +10,7 @@ import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import com.sopt.now.compose.presentation.ui.auth.navigation.AuthNavigator import com.sopt.now.compose.presentation.ui.auth.navigation.authNavGraph +import com.sopt.now.compose.presentation.ui.auth.screen.AuthViewModel import com.sopt.now.compose.presentation.ui.home.navigation.HomeNavigator import com.sopt.now.compose.presentation.ui.home.navigation.homeNavGraph @@ -18,6 +19,7 @@ fun MainNavHost( navHostController: NavHostController, modifier: Modifier = Modifier, authNavigator: AuthNavigator, + authViewModel: AuthViewModel, homeNavigator: HomeNavigator ) { Box( @@ -27,9 +29,9 @@ fun MainNavHost( ) { NavHost( navController = navHostController, - startDestination = "signIn/{id}/{password}/{nickname}/{phoneNumber}" + startDestination = "signIn" ) { - authNavGraph(authNavigator) + authNavGraph(authNavigator,authViewModel) homeNavGraph(homeNavigator) } } From d6f78920d39c5464d63eef0f042ad3a8da397a00 Mon Sep 17 00:00:00 2001 From: SYAAINN Date: Sat, 21 Sep 2024 17:18:25 +0900 Subject: [PATCH 16/16] =?UTF-8?q?[Feat/#6]=20AuthViewModel=EC=9D=84=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=A6=B0=EC=97=90=20=EC=A0=81=EC=9A=A9=20?= =?UTF-8?q?=EB=B0=8F=20Button=EC=9D=98=20=ED=81=B4=EB=A6=AD=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=20=ED=98=B8=EC=9D=B4=EC=8A=A4=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/auth/screen/SignInScreen.kt | 121 ++++++--------- .../ui/auth/screen/SignUpScreen.kt | 140 ++++++++---------- app/src/main/res/values/strings.xml | 5 +- 3 files changed, 110 insertions(+), 156 deletions(-) diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt index c9769c9..b75ab07 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignInScreen.kt @@ -1,6 +1,5 @@ package com.sopt.now.compose.presentation.ui.auth.screen -import android.content.Context import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource @@ -17,10 +16,7 @@ import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester @@ -28,7 +24,6 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.PasswordVisualTransformation -import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.tooling.preview.Preview @@ -42,40 +37,48 @@ import com.sopt.now.compose.ui.theme.CustomTheme @Composable fun SignInRoute( authNavigator: AuthNavigator, - id: String, - password: String, - nickname: String, - phoneNumber: String + authViewModel: AuthViewModel ) { + val context = LocalContext.current + + fun onClickSignIn() { + authViewModel.signInValidation() + when (authViewModel.signInState.value) { + is SignInState.IdInvalid -> { + showToast(context, context.getString(R.string.signin_signin_id_incorrect)) + } + + is SignInState.PasswordInvalid -> { + showToast(context, context.getString(R.string.signin_signin_password_incorrect)) + } + + is SignInState.Success -> { + showToast(context, context.getString(R.string.signin_signin_success_toast)) + authNavigator.navigateToHome( + authViewModel.user.value?.id, + authViewModel.user.value?.password, + authViewModel.user.value?.nickname, + authViewModel.user.value?.phoneNumber, + ) + } + + else -> {} + } + } + SignInScreen( - onClickSignIn = { id, password, nickname, phoneNumber -> - authNavigator.navigateToHome( - id, password, nickname, phoneNumber - ) - }, + authViewModel = authViewModel, + onClickSignIn = { onClickSignIn() }, onClickSignUp = { authNavigator.navigateToSignUp() }, - id = id, - password = password, - nickname = nickname, - phoneNumber = phoneNumber ) } @Composable fun SignInScreen( - onClickSignIn: (String, String, String, String) -> Unit, + authViewModel: AuthViewModel, + onClickSignIn: () -> Unit, onClickSignUp: () -> Unit, - id: String, - password: String, - nickname: String, - phoneNumber: String ) { - val context = LocalContext.current - var inputId by remember { mutableStateOf(TextFieldValue("")) } - var inputPassword by remember { mutableStateOf(TextFieldValue("")) } - var isIdTextFieldFocused by remember { mutableStateOf(false) } - var isPasswordTextFieldFocused by remember { mutableStateOf(false) } - val idFocusRequester = remember { FocusRequester() } val passwordFocusRequester = remember { FocusRequester() } @@ -83,7 +86,8 @@ fun SignInScreen( modifier = Modifier .fillMaxSize() .background(color = CustomTheme.colors.white) - .padding(30.dp), horizontalAlignment = Alignment.CenterHorizontally + .padding(30.dp), + horizontalAlignment = Alignment.CenterHorizontally ) { Spacer(modifier = Modifier.height(30.dp)) Text( @@ -94,12 +98,12 @@ fun SignInScreen( ) Spacer(modifier = Modifier.height(80.dp)) AuthTextField( - value = inputId, - onValueChange = { inputId = it }, + value = authViewModel.signInId, + onValueChange = { authViewModel.onSignInIdChange(it) }, modifier = Modifier.fillMaxWidth(), - isFocused = isIdTextFieldFocused, - onFocusChanged = { isIdTextFieldFocused = it }, - onRemove = { inputId = TextFieldValue("") }, + isFocused = authViewModel.isSignInIdTextFieldFocused, + onFocusChanged = { authViewModel.onSignInIdFocusChange(it) }, + onRemove = { authViewModel.onSignInIdChange("") }, hint = stringResource(R.string.signin_id_hint), focusRequester = idFocusRequester, keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), @@ -107,12 +111,12 @@ fun SignInScreen( ) Spacer(modifier = Modifier.height(40.dp)) AuthTextField( - value = inputPassword, - onValueChange = { inputPassword = it }, + value = authViewModel.signInPassword, + onValueChange = { authViewModel.onSignInPasswordChange(it) }, modifier = Modifier.fillMaxWidth(), - isFocused = isPasswordTextFieldFocused, - onFocusChanged = { isPasswordTextFieldFocused = it }, - onRemove = { inputPassword = TextFieldValue("") }, + isFocused = authViewModel.isSignInPasswordTextFieldFocused, + onFocusChanged = { authViewModel.onSignInPasswordFocusChange(it) }, + onRemove = { authViewModel.onSignInPasswordChange("") }, hint = stringResource(R.string.signin_password_hint), visualTransformation = PasswordVisualTransformation(), focusRequester = passwordFocusRequester, @@ -134,13 +138,6 @@ fun SignInScreen( Spacer(modifier = Modifier.weight(1f)) SignInButton( modifier = Modifier.fillMaxWidth(), - context = context, - inputId = inputId.text, - inputPassword = inputPassword.text, - id = id, - password = password, - nickname = nickname, - phoneNumber = phoneNumber, onClickSignIn = onClickSignIn ) } @@ -149,36 +146,10 @@ fun SignInScreen( @Composable fun SignInButton( modifier: Modifier = Modifier, - context: Context, - inputId: String, - inputPassword: String, - id: String, - password: String, - nickname: String, - phoneNumber: String, - onClickSignIn: (String, String, String, String) -> Unit + onClickSignIn: () -> Unit ) { Button( - onClick = { - when { - inputId.isEmpty() || inputPassword.isEmpty() -> showToast( - context, context.getString(R.string.signin_signin_failure_toast) - ) - - inputId != id -> showToast( - context, context.getString(R.string.signin_signin_id_incorrect) - ) - - inputPassword != password -> showToast( - context, context.getString(R.string.signin_signin_password_incorrect) - ) - - else -> { - showToast(context, context.getString(R.string.signin_signin_success_toast)) - onClickSignIn(id, password, nickname, phoneNumber) - } - } - }, + onClick = onClickSignIn, modifier = modifier, colors = ButtonDefaults.buttonColors(CustomTheme.colors.mainYellow), shape = RoundedCornerShape(10.dp) diff --git a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt index 66bff5f..8d98e1a 100644 --- a/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt +++ b/app/src/main/java/com/sopt/now/compose/presentation/ui/auth/screen/SignUpScreen.kt @@ -1,5 +1,6 @@ package com.sopt.now.compose.presentation.ui.auth.screen +import android.util.Log import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Spacer @@ -15,10 +16,7 @@ import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester @@ -26,12 +24,10 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.PasswordVisualTransformation -import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.sopt.now.compose.R -import com.sopt.now.compose.data.User import com.sopt.now.compose.presentation.ui.auth.component.AuthTextField import com.sopt.now.compose.presentation.ui.auth.navigation.AuthNavigator import com.sopt.now.compose.presentation.utils.showToast @@ -39,36 +35,51 @@ import com.sopt.now.compose.ui.theme.CustomTheme @Composable fun SignUpRoute( - authNavigator: AuthNavigator + authNavigator: AuthNavigator, + authViewModel: AuthViewModel ) { - SignUpScreen( - onClickSignUp = { id, password, nickname, phoneNumber -> - authNavigator.navigateToSignIn( - id, - password, - nickname, - phoneNumber - ) + val context = LocalContext.current + + fun onClickSignUp() { + authViewModel.signUpValidation() + when (authViewModel.signUpState.value) { + is SignUpState.IdInvalid -> { + showToast(context, context.getString(R.string.signup_id_invalid)) + } + + is SignUpState.PasswordInvalid -> { + showToast(context, context.getString(R.string.signup_password_invalid)) + } + + is SignUpState.NicknameInvalid -> { + showToast(context, context.getString(R.string.signup_nickname_invalid)) + } + + is SignUpState.PhoneNumberInvalid -> { + showToast(context, context.getString(R.string.signup_phone_number_invalid)) + } + + is SignUpState.Success -> { + showToast(context, context.getString(R.string.signup_signup_success)) + authNavigator.navigateToSignIn() + Log.d("user_info", authViewModel.user.value.toString()) + } + + else -> {} } + } + + SignUpScreen( + authViewModel = authViewModel, + onClickSignUp = { onClickSignUp() } ) } @Composable fun SignUpScreen( - onClickSignUp: (String, String, String, String) -> Unit + authViewModel: AuthViewModel, + onClickSignUp: () -> Unit ) { - val context = LocalContext.current - - var inputId by remember { mutableStateOf(TextFieldValue("")) } - var inputPassword by remember { mutableStateOf(TextFieldValue("")) } - var inputNickname by remember { mutableStateOf(TextFieldValue("")) } - var inputPhoneNumber by remember { mutableStateOf(TextFieldValue("")) } - - var isIdTextFieldFocused by remember { mutableStateOf(false) } - var isPasswordTextFieldFocused by remember { mutableStateOf(false) } - var isNicknameTextFieldFocused by remember { mutableStateOf(false) } - var isPhoneNumberTextFieldFocused by remember { mutableStateOf(false) } - val idFocusRequester = remember { FocusRequester() } val passwordFocusRequester = remember { FocusRequester() } val nicknameFocusRequester = remember { FocusRequester() } @@ -100,12 +111,12 @@ fun SignUpScreen( ) Spacer(modifier = Modifier.height(18.dp)) AuthTextField( - value = inputId, - onValueChange = { inputId = it }, + value = authViewModel.signUpId, + onValueChange = { authViewModel.onSignUpIdChange(it) }, modifier = Modifier.fillMaxWidth(), - isFocused = isIdTextFieldFocused, - onFocusChanged = { isIdTextFieldFocused = it }, - onRemove = { inputId = TextFieldValue("") }, + isFocused = authViewModel.isSignUpIdTextFieldFocused, + onFocusChanged = { authViewModel.onSignUpIdFocusChange(it) }, + onRemove = { authViewModel.onSignUpIdChange("") }, hint = stringResource(R.string.signup_id_hint), focusRequester = idFocusRequester, keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), @@ -118,12 +129,12 @@ fun SignUpScreen( ) Spacer(modifier = Modifier.height(18.dp)) AuthTextField( - value = inputPassword, - onValueChange = { inputPassword = it }, + value = authViewModel.signUpPassword, + onValueChange = { authViewModel.onSignUpPasswordChange(it) }, modifier = Modifier.fillMaxWidth(), - isFocused = isPasswordTextFieldFocused, - onFocusChanged = { isPasswordTextFieldFocused = it }, - onRemove = { inputPassword = TextFieldValue("") }, + isFocused = authViewModel.isSignUpPasswordTextFieldFocused, + onFocusChanged = { authViewModel.onSignUpPasswordFocusChange(it) }, + onRemove = { authViewModel.onSignUpPasswordChange("") }, hint = stringResource(R.string.signup_password_hint), visualTransformation = PasswordVisualTransformation(), focusRequester = passwordFocusRequester, @@ -137,12 +148,12 @@ fun SignUpScreen( ) Spacer(modifier = Modifier.height(18.dp)) AuthTextField( - value = inputNickname, - onValueChange = { inputNickname = it }, + value = authViewModel.signUpNickname, + onValueChange = { authViewModel.onSignUpNicknameChange(it) }, modifier = Modifier.fillMaxWidth(), - isFocused = isNicknameTextFieldFocused, - onFocusChanged = { isNicknameTextFieldFocused = it }, - onRemove = { inputNickname = TextFieldValue("") }, + isFocused = authViewModel.isSignUpNicknameTextFieldFocused, + onFocusChanged = { authViewModel.onSignUpNicknameFocusChange(it) }, + onRemove = { authViewModel.onSignUpNicknameChange("") }, hint = stringResource(R.string.signup_nickname_hint), focusRequester = nicknameFocusRequester, keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Next), @@ -155,12 +166,12 @@ fun SignUpScreen( ) Spacer(modifier = Modifier.height(18.dp)) AuthTextField( - value = inputPhoneNumber, - onValueChange = { inputPhoneNumber = it }, + value = authViewModel.signUpPhoneNumber, + onValueChange = { authViewModel.onSignUpPhoneNumberChange(it) }, modifier = Modifier.fillMaxWidth(), - isFocused = isPhoneNumberTextFieldFocused, - onFocusChanged = { isPhoneNumberTextFieldFocused = it }, - onRemove = { inputPhoneNumber = TextFieldValue("") }, + isFocused = authViewModel.isSignUpPhoneNumberTextFieldFocused, + onFocusChanged = { authViewModel.onSignUpPhoneNumberFocusChange(it) }, + onRemove = { authViewModel.onSignUpPhoneNumberChange("") }, hint = stringResource(R.string.signup_phone_number_hint), focusRequester = phoneNumberFocusRequester ) @@ -168,25 +179,7 @@ fun SignUpScreen( } } Button( - onClick = { - val user = setUser( - inputId.text, - inputPassword.text, - inputNickname.text, - inputPhoneNumber.text - ) - if (SignUpValidation.isSignUpValid(user)) { - showToast(context, context.getString(R.string.signup_signup_success)) - onClickSignUp( - inputId.text, - inputPassword.text, - inputNickname.text, - inputPhoneNumber.text - ) - } else { - showToast(context, context.getString(R.string.signup_signup_failure)) - } - }, + onClick = onClickSignUp, modifier = Modifier .fillMaxWidth() .align(Alignment.BottomCenter), @@ -202,21 +195,8 @@ fun SignUpScreen( } -fun setUser( - inputId: String, - inputPassword: String, - inputNickname: String, - inputPhoneNumber: String -): User = User( - id = inputId, - password = inputPassword, - nickname = inputNickname, - phoneNumber = inputPhoneNumber -) - - @Preview(showBackground = true) @Composable fun ShowSignUp() { - SignUpScreen(onClickSignUp = { id, password, nickname, phoneNumber -> }) + } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1c74af3..80512fd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -7,7 +7,6 @@ 비밀번호를 입력하세요 (8~12자) 회원가입 로그인 하기 - 입력하지 않은 정보가 있습니다 일치하지 않는 아이디입니다 일치하지 않는 비밀번호입니다 로그인에 성공했습니다 @@ -22,6 +21,10 @@ 닉네임을 입력하세요 전화번호 010-XXXX-XXXX + 아이디 형식이 잘못되었습니다 + 비밀번호 형식이 잘못되었습니다 + 닉네임 형식이 잘못되었습니다 + 전화번호 형식이 잘못되었습니다 회원가입에 성공했습니다 회원가입에 실패했습니다 회원가입 하기