Skip to content

Commit

Permalink
ui/#9: 회원가입 ui 수정
Browse files Browse the repository at this point in the history
- 취미 입력란 추가
  • Loading branch information
boiledEgg-s committed Nov 5, 2024
1 parent 9df14b4 commit 3dfdfc5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.VisualTransformation
Expand All @@ -26,8 +27,8 @@ import androidx.compose.ui.unit.dp
fun WavveBasicTextField(
value: String,
hint: String,
cursorBrush: Brush,
modifier: Modifier = Modifier,
cursorBrush: Brush = SolidColor(Color.Blue),
hintColor: Color = Color.LightGray,
valueColor: Color = Color.White,
onValueChange: (String) -> Unit = {},
Expand Down
24 changes: 18 additions & 6 deletions app/src/main/java/org/sopt/and/presentation/signup/SignUpScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
Expand Down Expand Up @@ -57,9 +56,8 @@ fun SignUpRoute(
uiState = uiState,
onIdChange = viewModel::updateId,
onPasswordChange = viewModel::updatePassword,
onSignUpButtonPress = {
if (uiState.isButtonEnabled) viewModel.registerUser()
},
onHobbyChange = viewModel::updateHobby,
onSignUpButtonPress = viewModel::registerUser,
onCloseClick = {}
)
}
Expand All @@ -70,6 +68,7 @@ private fun SignUpScreen(
onCloseClick: () -> Unit,
onIdChange: (String) -> Unit,
onPasswordChange: (String) -> Unit,
onHobbyChange: (String) -> Unit,
onSignUpButtonPress: () -> Unit,
modifier: Modifier = Modifier,
) {
Expand All @@ -91,7 +90,6 @@ private fun SignUpScreen(
hint = stringResource(R.string.signup_text_field_id_hint),
onValueChange = onIdChange,
value = uiState.id,
cursorBrush = SolidColor(Color.Blue),
modifier = Modifier.padding(top = 20.dp, start = 5.dp, end = 5.dp)
)
Text(
Expand All @@ -105,7 +103,7 @@ private fun SignUpScreen(
hint = stringResource(R.string.signup_text_field_pw_hint),
value = uiState.password,
onValueChange = onPasswordChange,
modifier = Modifier.padding(top = 10.dp, start = 5.dp, end = 5.dp)
modifier = Modifier.padding(top = 15.dp, start = 5.dp, end = 5.dp)
)
Text(
text = stringResource(R.string.signup_text_field_pw_guide),
Expand All @@ -114,6 +112,19 @@ private fun SignUpScreen(
modifier = Modifier.padding(start = 5.dp, end = 5.dp)
)

WavveBasicTextField(
hint = stringResource(R.string.signup_text_field_hobby_hint),
value = uiState.hobby,
onValueChange = onHobbyChange,
modifier = Modifier.padding(top = 15.dp, start = 5.dp, end = 5.dp)
)
Text(
text = stringResource(R.string.signup_text_field_hobby_guide),
color = Color.Gray,
fontSize = 12.sp,
modifier = Modifier.padding(start = 5.dp, end = 5.dp)
)

SocialAccountGroup(modifier = modifier.padding(top = 40.dp))

BulletAnnotedText(
Expand All @@ -138,6 +149,7 @@ fun SignUpScreenPreview() {
onCloseClick = {},
onIdChange = {},
onPasswordChange = {},
onHobbyChange = {},
onSignUpButtonPress = {}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,38 @@ class SignUpViewModel @Inject constructor(
updateButtonEnabled()
}

fun updateHobby(hobby: String) {
_uiState.update { currentState ->
currentState.copy(hobby = hobby)
}
updateButtonEnabled()
}

private fun updateButtonEnabled() = _uiState.update { currentState ->
currentState.copy(
isButtonEnabled = _uiState.value.id.isNotBlank() && _uiState.value.password.isNotBlank()
isButtonEnabled = _uiState.value.id.isNotBlank()
&& _uiState.value.password.isNotBlank()
&& _uiState.value.hobby.isNotBlank()
)
}

fun registerUser() = viewModelScope.launch {
val user = with(_uiState.value) { User(id, password, "hobby") }
signUpRepository.registerUser(user)
.onSuccess { response ->
_sideEffect.emit(SignUpSideEffect.Toast(response.message))
if(response.id != null) {
_sideEffect.emit(SignUpSideEffect.NavigateUp)
}
}.onFailure {
_sideEffect.emit(SignUpSideEffect.Toast(R.string.signup_toast_failure_unknown))
with(_uiState.value) {
if (isButtonEnabled) {
signUpRepository.registerUser(User(id, password, hobby))
.onSuccess { response ->
_sideEffect.emit(SignUpSideEffect.Toast(response.message))
if (response.id != null) {
_sideEffect.emit(SignUpSideEffect.NavigateUp)
}
}.onFailure {
_sideEffect.emit(SignUpSideEffect.Toast(R.string.signup_toast_failure_unknown))
}
}
}
}



/**
* 4주차 이후로 쓸모가 없어진 코드
* 만든게 아까워서 전시용으로 놔둠
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package org.sopt.and.presentation.signup.state
data class SignUpUiState(
val id: String = "",
val password: String = "",
val hobby: String = "",
val isButtonEnabled: Boolean = false
)
8 changes: 5 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
<string name="signup_intro2">만으로\n</string>
<string name="signup_intro3">Wavve를 즐길 수 </string>
<string name="signup_intro4">있어요!</string>
<string name="signup_text_field_id_hint">[email protected]</string>
<string name="signup_text_field_id_guide">로그인, 비밀번호 찾기, 알림에 사용되니 정확한 이메일을 입력해주세요</string>
<string name="signup_text_field_id_hint">Wavve 아이디 설정</string>
<string name="signup_text_field_id_guide">로그인, 비밀번호 찾기, 알림에 사용됩니다. 8자 이내로 입력해주세요.</string>
<string name="signup_text_field_pw_hint">Wavve 비밀번호 설정</string>
<string name="signup_text_field_pw_guide">비밀번호는 8~20자 이내로 영문 대소문자, 숫자, 특수문자 중 3가지 이상 혼용하여 입력해주세요.</string>
<string name="signup_text_field_pw_guide">비밀번호는 8자 이내로 입력해주세요.</string>
<string name="signup_text_field_hobby_hint">취미 (예시: 영화, 음악, 게임)</string>
<string name="signup_text_field_hobby_guide">취미는 8자 이내로 입력해주세요.</string>
<string name="signup_divider">또는 다른 서비스 계정으로 가입</string>
<string name="signup_text_sns_guide">"\tSNS계정을 간편하게 가입하여 서비스를 이용하실 수 있습니다. 기\n\t존 POOQ 계정 또는 Wavve 계정과는 연동되지 않으니 이용에 참고\n\t하세요."</string>
<string name="signup_button_signup">Wavve 회원가입</string>
Expand Down

0 comments on commit 3dfdfc5

Please sign in to comment.