@@ -9,30 +9,59 @@ import androidx.compose.foundation.layout.height
99import androidx.compose.foundation.layout.padding
1010import androidx.compose.material3.Text
1111import androidx.compose.runtime.Composable
12+ import androidx.compose.runtime.derivedStateOf
13+ import androidx.compose.runtime.getValue
14+ import androidx.compose.runtime.mutableStateOf
15+ import androidx.compose.runtime.remember
16+ import androidx.compose.runtime.rememberCoroutineScope
17+ import androidx.compose.runtime.saveable.rememberSaveable
18+ import androidx.compose.runtime.setValue
1219import androidx.compose.ui.Modifier
1320import androidx.compose.ui.res.stringResource
1421import androidx.compose.ui.tooling.preview.Preview
1522import androidx.compose.ui.unit.dp
1623import com.texthip.thip.R
1724import com.texthip.thip.ui.common.forms.FormTextFieldDefault
25+ import com.texthip.thip.ui.common.forms.WarningTextField
1826import com.texthip.thip.ui.common.topappbar.InputTopAppBar
1927import com.texthip.thip.ui.theme.ThipTheme.colors
2028import com.texthip.thip.ui.theme.ThipTheme.typography
29+ import kotlinx.coroutines.delay
30+ import kotlinx.coroutines.launch
2131
2232@Composable
2333fun SigninNicknameScreen () {
34+ var nickname by rememberSaveable { mutableStateOf(" " ) }
35+ var showWarning by remember { mutableStateOf(false ) }
36+ var warningMessageResId by remember { mutableStateOf<Int ?>(null ) }
37+ val isRightButtonEnabled by remember {derivedStateOf {nickname.isNotBlank()}} // 닉네임 공백 아닐때 버튼 활성화
38+ val coroutineScope = rememberCoroutineScope()
39+
2440 Column (
2541 Modifier
2642 .background(colors.Black )
2743 .fillMaxSize()
2844 ) {
2945 InputTopAppBar (
3046 title = stringResource(R .string.settings_1),
31- isRightButtonEnabled = false ,
47+ isRightButtonEnabled = isRightButtonEnabled ,
3248 rightButtonName = stringResource(R .string.next),
3349 isLeftIconVisible = false ,
3450 onLeftClick = {},
35- onRightClick = {}
51+ onRightClick = {
52+ // TODO 서버 연동시 로직 변경 필요
53+ coroutineScope.launch {
54+ delay(500 ) // 서버 응답 시뮬레이션
55+ if (nickname == " test" ) {
56+ showWarning = true
57+ warningMessageResId = R .string.nickname_warning
58+ } else {
59+ showWarning = false
60+ warningMessageResId = null
61+ // 다음 페이지로 이동
62+ }
63+ }
64+ }
3665 )
3766 Spacer (modifier = Modifier .height(40 .dp))
3867 Column (
@@ -48,13 +77,19 @@ fun SigninNicknameScreen() {
4877 .fillMaxWidth()
4978 .padding(bottom = 12 .dp)
5079 )
51- // TODO 컴포넌트 수정필요 -> 경고 메시지 처리
52- FormTextFieldDefault (
80+ WarningTextField (
81+ containerColor = colors.DarkGrey02 ,
82+ text = nickname,
83+ onTextChange = {
84+ nickname = it
85+ showWarning = false // 입력 중에는 경고 숨기기
86+ },
5387 hint = stringResource(R .string.nickname_condition),
88+ showWarning = showWarning,
89+ showIcon = false ,
5490 showLimit = true ,
5591 limit = 10 ,
56- showIcon = false ,
57- containerColor= colors.DarkGrey02
92+ warningMessage = warningMessageResId?.let { stringResource(it) } ? : " "
5893 )
5994 }
6095 }
0 commit comments