Skip to content

Commit

Permalink
♻️ :: 아이디 설정 학번 자동으로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
parkuiery committed Jun 7, 2024
1 parent 253b01d commit 37a66b8
Showing 1 changed file with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) }
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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)) },
Expand Down

0 comments on commit 37a66b8

Please sign in to comment.