Skip to content

Commit

Permalink
Boolti-331 refactor: 문자열 리소스 추출, 토스트 showMessage 의 dismissPrevious 기본…
Browse files Browse the repository at this point in the history
… 값 true 설정
  • Loading branch information
mangbaam committed Nov 14, 2024
1 parent 1b18310 commit ff193a1
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.nexters.boolti.presentation.extension

import androidx.annotation.DrawableRes
import com.nexters.boolti.domain.model.Sns
import com.nexters.boolti.domain.model.Sns.SnsType.INSTAGRAM
import com.nexters.boolti.domain.model.Sns.SnsType.YOUTUBE
import com.nexters.boolti.presentation.R

val Sns.SnsType.label: String
get() = when (this) {
INSTAGRAM -> "instagram"
YOUTUBE -> "youtube"
}

val Sns.SnsType.icon: Int
@DrawableRes
get() = when (this) {
INSTAGRAM -> R.drawable.ic_logo_instagram
YOUTUBE -> R.drawable.ic_logo_youtube
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ import com.nexters.boolti.presentation.component.BtAppBar
import com.nexters.boolti.presentation.component.BtAppBarDefaults
import com.nexters.boolti.presentation.component.BtCircularProgressIndicator
import com.nexters.boolti.presentation.component.UserThumbnail
import com.nexters.boolti.presentation.extension.icon
import com.nexters.boolti.presentation.extension.label
import com.nexters.boolti.presentation.extension.takeForUnicode
import com.nexters.boolti.presentation.screen.LocalSnackbarController
import com.nexters.boolti.presentation.theme.Grey15
Expand Down Expand Up @@ -197,38 +199,14 @@ fun ProfileEditScreen(

ObserveAsEvents(event) {
when (it) {
ProfileEditEvent.OnLinkAdded -> snackbarHostState.showMessage(
linkAddMsg,
dismissPrevious = true
)

ProfileEditEvent.OnLinkEdited -> snackbarHostState.showMessage(
linkEditMsg,
dismissPrevious = true
)

ProfileEditEvent.OnLinkRemoved -> snackbarHostState.showMessage(
linkRemoveMsg,
dismissPrevious = true
)

ProfileEditEvent.OnSnsAdded -> snackbarHostState.showMessage(
snsAddMsg,
dismissPrevious = true
)

ProfileEditEvent.OnSnsEdited -> snackbarHostState.showMessage(
snsEditMsg,
dismissPrevious = true
)

ProfileEditEvent.OnSnsRemoved -> snackbarHostState.showMessage(
snsRemoveMsg,
dismissPrevious = true
)

ProfileEditEvent.OnLinkAdded -> snackbarHostState.showMessage(linkAddMsg)
ProfileEditEvent.OnLinkEdited -> snackbarHostState.showMessage(linkEditMsg)
ProfileEditEvent.OnLinkRemoved -> snackbarHostState.showMessage(linkRemoveMsg)
ProfileEditEvent.OnSnsAdded -> snackbarHostState.showMessage(snsAddMsg)
ProfileEditEvent.OnSnsEdited -> snackbarHostState.showMessage(snsEditMsg)
ProfileEditEvent.OnSnsRemoved -> snackbarHostState.showMessage(snsRemoveMsg)
ProfileEditEvent.OnSuccessEditProfile -> {
snackbarHostState.showMessage(profileEditSuccessMsg, dismissPrevious = true)
snackbarHostState.showMessage(profileEditSuccessMsg)
navigateBack()
}
}
Expand Down Expand Up @@ -455,11 +433,6 @@ private fun SnsItem(
modifier: Modifier = Modifier,
onClickEdit: () -> Unit,
) {
val (icon, label) = when (sns.type) {
Sns.SnsType.INSTAGRAM -> R.drawable.ic_logo_instagram to "instagram"
Sns.SnsType.YOUTUBE -> R.drawable.ic_logo_youtube to "youtube"
}

Row(
modifier = modifier
.fillMaxWidth()
Expand All @@ -469,15 +442,15 @@ private fun SnsItem(
) {
Icon(
modifier = Modifier.size(24.dp),
imageVector = ImageVector.vectorResource(icon),
imageVector = ImageVector.vectorResource(sns.type.icon),
tint = Grey30,
contentDescription = label,
contentDescription = sns.type.label,
)
Text(
modifier = Modifier
.padding(start = 8.dp)
.defaultMinSize(minWidth = 72.dp),
text = label,
text = sns.type.label,
style = MaterialTheme.typography.bodyLarge,
color = Grey30,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ private fun SnsEditScreen(
modifier = modifier.fillMaxSize(),
topBar = {
BtAppBar(
title = if (isEditMode) "SNS 편집" else "SNS 추가",
title = if (isEditMode) {
stringResource(R.string.sns_edit)
} else {
stringResource(R.string.sns_add)
},
navigateButtons = {
BtAppBarDefaults.AppBarIconButton(
iconRes = R.drawable.ic_arrow_back,
Expand All @@ -123,35 +127,35 @@ private fun SnsEditScreen(
verticalArrangement = Arrangement.spacedBy(20.dp),
) {
InfoRow(
label = "SNS",
label = stringResource(R.string.sns),
) {
Row(verticalAlignment = Alignment.CenterVertically) {
SelectableIcon(
selected = selectedSns == Sns.SnsType.INSTAGRAM,
iconRes = R.drawable.ic_logo_instagram,
onClick = { onChangeSns(Sns.SnsType.INSTAGRAM) },
contentDescription = "인스타그램 선택",
contentDescription = stringResource(R.string.sns_select_instagram_description),
)
SelectableIcon(
modifier = Modifier.padding(start = 12.dp),
selected = selectedSns == Sns.SnsType.YOUTUBE,
iconRes = R.drawable.ic_logo_youtube,
onClick = { onChangeSns(Sns.SnsType.YOUTUBE) },
contentDescription = "유튜브 선택",
contentDescription = stringResource(R.string.sns_select_youtube_description),
)
}
}
InfoRow(
label = "Username",
label = stringResource(R.string.username),
) {
BTTextField(
modifier = Modifier.weight(1f),
text = username,
isError = usernameHasError,
placeholder = "ex) boolti_official",
placeholder = stringResource(R.string.sns_username_placeholder),
supportingText = when {
username.contains('@') -> "@을 제외환 Username을 입력해 주세요"
usernameHasError -> "지원하지 않는 특수문자가 포함되어 있습니다"
username.contains('@') -> stringResource(R.string.sns_username_contains_at_error)
usernameHasError -> stringResource(R.string.contains_unsupported_char_error)
else -> null
},
trailingIcon = if (username.isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SnackbarController(
) {
fun showMessage(
message: String,
dismissPrevious: Boolean = false,
dismissPrevious: Boolean = true,
) {
coroutineScope.launch {
if (dismissPrevious) snackbarHostState.currentSnackbarData?.dismiss()
Expand Down
8 changes: 8 additions & 0 deletions presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,20 @@
<string name="profile_withdraw_user_message">탈퇴한 회원의 프로필입니다.</string>
<string name="profile_invalid_user_message">존재하지 않는 프로필입니다.</string>

<string name="sns">SNS</string>
<string name="username">Username</string>
<string name="sns_add">SNS 추가</string>
<string name="sns_edit">SNS 편집</string>
<string name="sns_delete">SNS 삭제</string>
<string name="sns_delete_message">SNS를 삭제하시겠어요?</string>
<string name="sns_add_msg">SNS를 추가했어요</string>
<string name="sns_edit_msg">SNS를 편집했어요</string>
<string name="sns_remove_msg">SNS를 삭제했어요</string>
<string name="sns_username_placeholder">ex) boolti_official</string>
<string name="sns_username_contains_at_error">\@을 제외환 Username을 입력해 주세요</string>
<string name="contains_unsupported_char_error">지원하지 않는 특수문자가 포함되어 있습니다</string>
<string name="sns_select_instagram_description">인스타그램 선택</string>
<string name="sns_select_youtube_description">유튜브 선택</string>

<string name="label_nickname">닉네임</string>
<string name="label_introduction">소개</string>
Expand Down

0 comments on commit ff193a1

Please sign in to comment.