-
Notifications
You must be signed in to change notification settings - Fork 1
[Fix#60] 비공개 테스트 4차 업데이트 #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a02ed2e
8c95aac
e817b45
e1eae3c
cce0ed5
69ce875
e062fc2
210b44a
09c9bb6
424c54f
75cc442
ebc0b89
ef2c4d0
0db552e
36c921b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,24 +100,27 @@ class ProfileModViewModel @Inject constructor( | |
| val filteredText = text.filter { it.isAllowedChar() } | ||
|
|
||
| var nicknameCount = 0 | ||
| var limitedText = "" | ||
| for (char in filteredText) { | ||
| nicknameCount += if (char.isKorean()) 2 else 1 | ||
| if (nicknameCount > 16) break | ||
| val weight = if (char.isKorean()) 2 else 1 | ||
| if (nicknameCount + weight > 16) break | ||
| limitedText += char | ||
| nicknameCount += weight | ||
| } | ||
|
|
||
| val updatedNicknameStatus = when { | ||
| filteredText.isEmpty() -> NicknameStatus.Empty | ||
| text.isEmpty() -> NicknameStatus.Empty | ||
| else -> NicknameStatus.Typing | ||
| } | ||
|
|
||
| val updatedFieldStatus = when { | ||
| filteredText.isEmpty() -> TextFieldStatus.Empty | ||
| text.isEmpty() -> TextFieldStatus.Empty | ||
| else -> state.nickNameFieldStatus | ||
| } | ||
|
|
||
| reduce { | ||
| state.copy( | ||
| nickNameState = filteredText, | ||
| nickNameState = limitedText, | ||
| nicknameCount = nicknameCount, | ||
| nicknameStatus = updatedNicknameStatus, | ||
| nickNameFieldStatus = updatedFieldStatus | ||
|
|
@@ -134,23 +137,23 @@ class ProfileModViewModel @Inject constructor( | |
|
|
||
| val errors = mutableListOf<NicknameErrorType>() | ||
|
|
||
| if (filteredText.any { it in "!@#$%^&*()-=+[]{};:'\",<>/?\\|" }) { | ||
| if (text.any { it in "!@#$%^&*()-=+[]{};:'\",<>/?\\|" }) { | ||
| errors.add(NicknameErrorType.InvalidChar) | ||
| } | ||
|
|
||
| val allowedChars = (33..126).map { it.toChar() } + | ||
| ('가'..'힣') + ('ㄱ'..'ㅎ') + ('ㅏ'..'ㅣ') | ||
| if (filteredText.any { it !in allowedChars }) { | ||
| if (text.any { it !in allowedChars }) { | ||
| errors.add(NicknameErrorType.InvalidLang) | ||
| } | ||
|
Comment on lines
+140
to
148
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 정규식을 사용하지 않은 이유가 있나요 ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이것도 원래 되어있던 코드를 그대로 활용한건데 다른 것들 고치느라 바빠서 정규식을 생각해볼 겨를이 없었네요. |
||
|
|
||
| validateNickname(nickname = filteredText, errors = errors) | ||
| validateNickname(nickname = limitedText, errors = errors) | ||
|
|
||
| intent { | ||
| reduce { | ||
| state.copy( | ||
| nicknameStatus = when { | ||
| filteredText.isBlank() -> NicknameStatus.Empty | ||
| limitedText.isBlank() -> NicknameStatus.Empty | ||
| errors.isNotEmpty() -> NicknameStatus.Error(errors) | ||
| else -> NicknameStatus.Valid | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,7 @@ import com.acon.acon.feature.profile.composable.utils.BirthdayTransformation | |
| import com.acon.acon.feature.profile.composable.utils.isAllowedChar | ||
| import com.acon.acon.feature.profile.composable.utils.isKorean | ||
| import org.orbitmvi.orbit.compose.collectAsState | ||
| import org.orbitmvi.orbit.compose.collectSideEffect | ||
|
|
||
| @Composable | ||
| fun ProfileModScreenContainer( | ||
|
|
@@ -82,42 +83,39 @@ fun ProfileModScreenContainer( | |
| val context = LocalContext.current | ||
|
|
||
| LaunchedEffect(selectedPhotoId) { | ||
| selectedPhotoId.let { | ||
| viewModel.updateProfileImage(selectedPhotoId) | ||
| } | ||
| viewModel.updateProfileImage(selectedPhotoId) | ||
| } | ||
|
|
||
| LaunchedEffect(Unit) { | ||
| viewModel.container.sideEffectFlow.collect { effect -> | ||
| when (effect) { | ||
| is ProfileModSideEffect.NavigateToSettings -> { | ||
| val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { | ||
| data = Uri.fromParts("package", effect.packageName, null) | ||
| } | ||
| context.startActivity(intent) | ||
| } | ||
|
|
||
| is ProfileModSideEffect.NavigateBack -> { | ||
| backToProfile() | ||
| viewModel.collectSideEffect { effect -> | ||
| when (effect) { | ||
| is ProfileModSideEffect.NavigateToSettings -> { | ||
| val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { | ||
| data = Uri.fromParts("package", effect.packageName, null) | ||
| } | ||
| context.startActivity(intent) | ||
| } | ||
|
|
||
| is ProfileModSideEffect.NavigateToCustomGallery -> { | ||
| onNavigateToCustomGallery() | ||
| } | ||
| is ProfileModSideEffect.NavigateBack -> { | ||
| backToProfile() | ||
| } | ||
|
|
||
| is ProfileModSideEffect.UpdateProfileImage -> { | ||
| selectedPhotoId.let { | ||
| viewModel.updateProfileImage(selectedPhotoId) | ||
| } | ||
| } | ||
| is ProfileModSideEffect.NavigateToCustomGallery -> { | ||
| onNavigateToCustomGallery() | ||
| } | ||
|
|
||
| is ProfileModSideEffect.NavigateToProfileSuccess -> { | ||
| onNavigateToProfile(ProfileUpdateResult.SUCCESS) | ||
| is ProfileModSideEffect.UpdateProfileImage -> { | ||
| selectedPhotoId.let { | ||
| viewModel.updateProfileImage(selectedPhotoId) | ||
| } | ||
|
Comment on lines
+108
to
110
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여긴 왜 let으로 감싸져 있나요 ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ProfileModScreen은 제가 만든 화면은 아니라 질문하신 부분은 원래 만들어져 있던 그대로 놔뒀어요 (따로 손 안대고 그대로 뒀어요!) 바뀐거로 나온건 코드 정리 최적화 기능 때문에 된 것 같아요 |
||
| } | ||
|
|
||
| is ProfileModSideEffect.NavigateToProfileFailed -> { | ||
| onNavigateToProfile(ProfileUpdateResult.FAILURE) | ||
| } | ||
| is ProfileModSideEffect.NavigateToProfileSuccess -> { | ||
| onNavigateToProfile(ProfileUpdateResult.SUCCESS) | ||
| } | ||
|
|
||
| is ProfileModSideEffect.NavigateToProfileFailed -> { | ||
| onNavigateToProfile(ProfileUpdateResult.FAILURE) | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -326,22 +324,23 @@ fun ProfileModScreen( | |
| onTextChanged = { fieldValue -> | ||
| val inputText = fieldValue.text | ||
| var count = 0 | ||
| var textLimit = false | ||
|
|
||
| val validText = buildString { | ||
| val displayText = buildString { | ||
| for (char in inputText) { | ||
| if (!char.isAllowedChar()) continue | ||
| val weight = if (char.isKorean()) 2 else 1 | ||
| if (count + weight > 16) break | ||
| append(char) | ||
| count += weight | ||
| if (count + weight > 16) { | ||
| textLimit = true | ||
| break | ||
| } | ||
| if (char.isAllowedChar()) { | ||
| append(char) | ||
| count += weight | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (validText.length < inputText.length) { | ||
| // 초과된 입력이므로 무시하고 아무것도 하지 않음 (16자 이상은 입력 무시(불가능)) | ||
| } else { | ||
| // 정상적인 입력만 가능 | ||
| nicknameText = fieldValue | ||
| if (!textLimit || displayText.length <= nicknameText.text.length) { | ||
| nicknameText = fieldValue.copy(text = displayText) | ||
| onNicknameChanged(inputText) | ||
| } | ||
| }, | ||
|
|
@@ -486,9 +485,11 @@ fun ProfileModScreen( | |
| enabledTextColor = AconTheme.color.White, | ||
| onClick = onSaveClicked, | ||
| isEnabled = (state.nicknameStatus == NicknameStatus.Valid) && | ||
| (state.birthdayStatus != BirthdayStatus.Invalid("정확한 생년월일을 입력해주세요")) && | ||
| ((state.nickNameState != state.originalNickname || state.birthdayState != state.originalBirthday || state.selectedPhotoUri != state.originalPhotoUri) | ||
| && state.birthdayState.isNotEmpty()) | ||
| ( | ||
| (state.nickNameState != state.originalNickname) || | ||
| (state.birthdayState != state.originalBirthday && state.birthdayStatus == BirthdayStatus.Valid) || | ||
| (state.selectedPhotoUri != state.originalPhotoUri) | ||
| ) | ||
| ) | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null인게 나을거같네요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contentDescription 말 하시는 건가요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네네