diff --git a/feature/src/main/java/team/aliens/dms/android/feature/signup/1_EnterSchoolVerificationCodeScreen.kt b/feature/src/main/java/team/aliens/dms/android/feature/signup/1_EnterSchoolVerificationCodeScreen.kt index e25a72aad..df4eb2c76 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/signup/1_EnterSchoolVerificationCodeScreen.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/signup/1_EnterSchoolVerificationCodeScreen.kt @@ -11,6 +11,7 @@ import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext @@ -19,9 +20,10 @@ import androidx.compose.ui.res.stringResource import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.ramcosta.composedestinations.annotation.Destination import team.aliens.dms.android.core.designsystem.ContainedButton -import team.aliens.dms.android.core.designsystem.Scaffold +import team.aliens.dms.android.core.designsystem.DmsIcon import team.aliens.dms.android.core.designsystem.DmsTopAppBar import team.aliens.dms.android.core.designsystem.LocalToast +import team.aliens.dms.android.core.designsystem.Scaffold import team.aliens.dms.android.core.designsystem.VerificationCodeInput import team.aliens.dms.android.core.designsystem.VerificationCodeInputDefaults import team.aliens.dms.android.core.ui.Banner @@ -46,6 +48,12 @@ internal fun EnterSchoolVerificationCodeScreen( val toast = LocalToast.current val context = LocalContext.current + LaunchedEffect(uiState.schoolVerificationCode) { + if (uiState.schoolVerificationCode.length == SignUpViewModel.SCHOOL_VERIFICATION_CODE_LENGTH) { + viewModel.postIntent(SignUpIntent.ExamineSchoolVerificationCode) + } + } + viewModel.sideEffectFlow.collectInLaunchedEffectWithLifecycle { sideEffect -> when (sideEffect) { SignUpSideEffect.SchoolVerificationCodeExamined -> navigator.openEnterSchoolVerificationQuestion() @@ -66,7 +74,7 @@ internal fun EnterSchoolVerificationCodeScreen( navigationIcon = { IconButton(onClick = navigator::navigateUp) { Icon( - painter = painterResource(id = R.drawable.ic_baseline_arrow_back_24), + painter = painterResource(id = DmsIcon.Back), contentDescription = stringResource(id = R.string.top_bar_back_button), ) } diff --git a/feature/src/main/java/team/aliens/dms/android/feature/signup/4_EnterEmailVerificationCodeScreen.kt b/feature/src/main/java/team/aliens/dms/android/feature/signup/4_EnterEmailVerificationCodeScreen.kt index 488648c35..c842e94aa 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/signup/4_EnterEmailVerificationCodeScreen.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/signup/4_EnterEmailVerificationCodeScreen.kt @@ -27,6 +27,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.ramcosta.composedestinations.annotation.Destination import team.aliens.dms.android.core.designsystem.ButtonDefaults import team.aliens.dms.android.core.designsystem.ContainedButton +import team.aliens.dms.android.core.designsystem.DmsIcon import team.aliens.dms.android.core.designsystem.Scaffold import team.aliens.dms.android.core.designsystem.DmsTheme import team.aliens.dms.android.core.designsystem.DmsTopAppBar @@ -79,6 +80,12 @@ internal fun SignUpEnterEmailVerificationCodeScreen( } } + LaunchedEffect(uiState.emailVerificationCode) { + if (uiState.emailVerificationCode.length == SignUpViewModel.EMAIL_VERIFICATION_CODE_LENGTH) { + viewModel.postIntent(SignUpIntent.CheckEmailVerificationCode) + } + } + LaunchedEffect(uiState.sessionId) { timer.start() } @@ -122,7 +129,7 @@ internal fun SignUpEnterEmailVerificationCodeScreen( navigationIcon = { IconButton(onClick = navigator::popUpToEnterEmail) { Icon( - painter = painterResource(id = R.drawable.ic_baseline_arrow_back_24), + painter = painterResource(id = DmsIcon.Back), contentDescription = stringResource(id = R.string.top_bar_back_button), ) } diff --git a/feature/src/main/java/team/aliens/dms/android/feature/signup/5_SetIdScreen.kt b/feature/src/main/java/team/aliens/dms/android/feature/signup/5_SetIdScreen.kt index 52a78e00c..4c88943c3 100644 --- a/feature/src/main/java/team/aliens/dms/android/feature/signup/5_SetIdScreen.kt +++ b/feature/src/main/java/team/aliens/dms/android/feature/signup/5_SetIdScreen.kt @@ -26,6 +26,8 @@ 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.painterResource import androidx.compose.ui.res.stringResource @@ -77,6 +79,9 @@ internal fun SetIdScreen( val toast = LocalToast.current val context = LocalContext.current + val classFocusRequest = remember { FocusRequester() } + val numberFocusRequest = remember { FocusRequester() } + val (studentConfirmed, onStudentConfirmedChange) = remember { mutableStateOf(false) } val (gradeClassNumberError, setGradeClassNumberError) = remember { mutableStateOf(false) } @@ -165,10 +170,14 @@ internal fun SetIdScreen( horizontalArrangement = Arrangement.spacedBy(DefaultHorizontalSpace), ) { TextField( - modifier = Modifier.weight(1f), + modifier = Modifier + .weight(1f), value = uiState.grade, hint = { Text(text = stringResource(id = R.string.sign_up_set_id_hint_grade)) }, - onValueChange = { viewModel.postIntent(SignUpIntent.UpdateGrade(value = it)) }, + onValueChange = { grade -> + viewModel.postIntent(SignUpIntent.UpdateGrade(value = grade)) + if (grade.isNotEmpty()) classFocusRequest.requestFocus() + }, supportingText = {}, isError = gradeClassNumberError, enabled = !studentConfirmed, @@ -178,10 +187,15 @@ internal fun SetIdScreen( ), ) TextField( - modifier = Modifier.weight(1f), + modifier = Modifier + .weight(1f) + .focusRequester(classFocusRequest), value = uiState.classroom, hint = { Text(text = stringResource(id = R.string.sign_up_set_id_hint_class)) }, - onValueChange = { viewModel.postIntent(SignUpIntent.UpdateClass(value = it)) }, + onValueChange = { classRoom -> + viewModel.postIntent(SignUpIntent.UpdateClass(value = classRoom)) + if (classRoom.isNotEmpty()) numberFocusRequest.requestFocus() + }, supportingText = {}, isError = gradeClassNumberError, enabled = !studentConfirmed, @@ -191,7 +205,9 @@ internal fun SetIdScreen( ), ) TextField( - modifier = Modifier.weight(1f), + modifier = Modifier + .weight(1f) + .focusRequester(numberFocusRequest), value = uiState.number, hint = { Text(text = stringResource(id = R.string.sign_up_set_id_hint_number)) }, onValueChange = { viewModel.postIntent(SignUpIntent.UpdateNumber(value = it)) },