Skip to content

Commit 607d303

Browse files
committed
[refactor]: WarningTextField 컴포넌트 수정 , 닉네임 설정 페이지 적용(#37)
1 parent 34f56bf commit 607d303

3 files changed

Lines changed: 48 additions & 10 deletions

File tree

app/src/main/java/com/texthip/thip/ui/common/forms/WarningTextField.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ fun WarningTextField(
3939
showWarning: Boolean = false,
4040
showLimit: Boolean = true,
4141
limit: Int = 10,
42-
showIcon: Boolean = false
43-
) {
42+
showIcon: Boolean = false,
43+
containerColor: Color = colors.Black
44+
) {
4445
//var text by rememberSaveable { mutableStateOf("") }
4546
val myStyle = typography.menu_r400_s14_h24.copy(lineHeight = 14.sp)
4647

@@ -72,8 +73,8 @@ fun WarningTextField(
7273
focusedTextColor = colors.White,
7374
focusedIndicatorColor = if (showWarning) colors.Red else Color.Transparent,
7475
unfocusedIndicatorColor = if (showWarning) colors.Red else Color.Transparent,
75-
focusedContainerColor = colors.Black,
76-
unfocusedContainerColor = colors.Black,
76+
focusedContainerColor = containerColor,
77+
unfocusedContainerColor = containerColor,
7778
cursorColor = colors.NeonGreen
7879
),
7980
trailingIcon = {

app/src/main/java/com/texthip/thip/ui/signin/screen/SigninNicknameScreen.kt

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,59 @@ import androidx.compose.foundation.layout.height
99
import androidx.compose.foundation.layout.padding
1010
import androidx.compose.material3.Text
1111
import 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
1219
import androidx.compose.ui.Modifier
1320
import androidx.compose.ui.res.stringResource
1421
import androidx.compose.ui.tooling.preview.Preview
1522
import androidx.compose.ui.unit.dp
1623
import com.texthip.thip.R
1724
import com.texthip.thip.ui.common.forms.FormTextFieldDefault
25+
import com.texthip.thip.ui.common.forms.WarningTextField
1826
import com.texthip.thip.ui.common.topappbar.InputTopAppBar
1927
import com.texthip.thip.ui.theme.ThipTheme.colors
2028
import com.texthip.thip.ui.theme.ThipTheme.typography
29+
import kotlinx.coroutines.delay
30+
import kotlinx.coroutines.launch
2131

2232
@Composable
2333
fun 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
}

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,13 @@
168168
<string name="settings_1">설정 1/2</string>
169169
<string name="settings_2">설정 2/2</string>
170170
<string name="nickname">닉네임 (필수)</string>
171+
<string name="nickname_warning">이미 사용중인 닉네임입니다.</string>
171172
<string name="nickname_condition">한글/영어/숫자로 구성</string>
172173
<string name="hello_user">안녕하세요, %1$s님</string>
173174
<string name="signin_done">이제 Thip에서 활동할 준비를 모두 마쳤어요!</string>
174175
<string name="start_thip">지금 바로 Thip 시작하기</string>
175176

177+
176178
<!-- feed -->
177179
<string name="my_subscription_list">내 구독 리스트</string>
178180
<string name="whole_num">전체 %d</string>

0 commit comments

Comments
 (0)