Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ fun YappNavHost(
noticeDetailNavGraph(
navigateBack = { navigator.popBackStack() }
)
profileNavGraph()
profileNavGraph(
onNavigateToSetting = { navigator.navigateSettingScreen() }
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ interface OperationsRepository {

fun getPrivacyPolicyLink(): Flow<String>

fun getAppVersion(): String

suspend fun isForceUpdateRequired(): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ internal class OperationsRepositoryImpl @Inject constructor(
emit(operationsApi.getPrivacyPolicyLink().link)
}.flowOn(ioDispatcher)

override fun getAppVersion(): String {
return context.packageManager.getPackageInfo(context.packageName, 0).versionName ?: ""
}

override suspend fun isForceUpdateRequired(): Boolean {
val version = context.packageManager.getPackageInfo(context.packageName, 0).versionName ?: ""
val version = getAppVersion()
return operationsApi.isForceUpdateRequired(
version = version,
).needForceUpdate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@ package com.yapp.feature.home.setting

data class SettingState(
val isNotificationEnabled: Boolean = false,
val showLogoutDialog: Boolean = false,
val showDeleteAccountDialog: Boolean = false,
val appVersion: String = ""
)

sealed interface SettingIntent {
data object EnterScreen : SettingIntent
data object ClickNotificationSwitch : SettingIntent
data object ClickLogoutItem : SettingIntent
data object ClickBackButton : SettingIntent
data object ClickPrivacyPolicyItem : SettingIntent
data object ClickTermsItem : SettingIntent
data object ClickInquiryItem : SettingIntent
data object ClickDeleteAccountItem : SettingIntent
data object DismissLogoutDialog : SettingIntent
data object ClickLogoutDialogCancelButton : SettingIntent
data object ClickLogoutDialogLogoutButton : SettingIntent
data object DismissDeleteAccountDialog : SettingIntent
data object ClickDeleteAccountDialogCancelButton : SettingIntent
data object ClickDeleteAccountDialogDeleteButton : SettingIntent
}

sealed interface SettingSideEffect {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.yapp.feature.home.setting

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Icon
Expand All @@ -18,8 +17,6 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.yapp.core.designsystem.component.alert.YappAlertDialog
import com.yapp.core.designsystem.component.button.outlined.YappOutlinedSecondaryButtonXLarge
import com.yapp.core.designsystem.component.control.switches.YappSwitchMedium
import com.yapp.core.designsystem.component.header.YappHeaderActionbarExpanded
import com.yapp.core.designsystem.theme.YappTheme
Expand Down Expand Up @@ -152,63 +149,19 @@ fun SettingScreen(
.borderBottom(
color = YappTheme.colorScheme.lineNormalAlternative,
),
text = stringResource(id = R.string.setting_screen_item_inquiry),
text = stringResource(id = R.string.setting_screen_item_app_version),
onClick = {
onIntent(SettingIntent.ClickInquiryItem)
},
slot = {
Icon(
painter = painterResource(id = com.yapp.core.designsystem.R.drawable.icon_chevron_right),
contentDescription = null,
tint = YappTheme.colorScheme.labelAssistive,
Text(
text = uiState.appVersion,
style = YappTheme.typography.body1NormalRegular,
color = YappTheme.colorScheme.labelAlternative
)
}
)

SettingItemLarge(
text = stringResource(id = R.string.setting_screen_item_delete_account),
onClick = {
onIntent(SettingIntent.ClickDeleteAccountItem)
}
)
}

Spacer(Modifier.weight(1f))

YappOutlinedSecondaryButtonXLarge(
modifier = Modifier
.padding(horizontal = 20.dp)
.fillMaxWidth(),
text = stringResource(id = R.string.setting_screen_item_logout),
onClick = {
onIntent(SettingIntent.ClickLogoutItem)
}
)

Spacer(Modifier.height(16.dp))
}

if (uiState.showLogoutDialog) {
YappAlertDialog(
title = stringResource(R.string.logout_dialog_title),
actionButtonText = stringResource(R.string.logout_dialog_action_button),
recommendActionButtonText = stringResource(R.string.logout_dialog_recommend_action_button),
onDismissRequest = { onIntent(SettingIntent.DismissLogoutDialog) },
onActionButtonClick = { onIntent(SettingIntent.ClickLogoutDialogCancelButton) },
onRecommendActionButtonClick = { onIntent(SettingIntent.ClickLogoutDialogLogoutButton) },
)
}

if (uiState.showDeleteAccountDialog) {
YappAlertDialog(
title = stringResource(R.string.delete_account_dialog_title),
body = stringResource(R.string.delete_account_dialog_body),
actionButtonText = stringResource(R.string.delete_account_dialog_action_button),
recommendActionButtonText = stringResource(R.string.delete_account_dialog_recommend_action_button),
onDismissRequest = { onIntent(SettingIntent.DismissDeleteAccountDialog) },
onActionButtonClick = { onIntent(SettingIntent.ClickDeleteAccountDialogCancelButton) },
onRecommendActionButtonClick = { onIntent(SettingIntent.ClickDeleteAccountDialogDeleteButton) },
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import com.yapp.core.ui.mvi.MviIntentStore
import com.yapp.core.ui.mvi.mviIntentStore
import com.yapp.dataapi.AlarmRepository
import com.yapp.dataapi.OperationsRepository
import com.yapp.domain.DeleteAccountUseCase
import com.yapp.domain.LogoutUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.combine
Expand All @@ -19,9 +17,7 @@ import javax.inject.Inject

@HiltViewModel
class SettingViewModel @Inject constructor(
private val logoutUseCase: LogoutUseCase,
private val alarmRepository: AlarmRepository,
private val deleteAccountUseCase: DeleteAccountUseCase,
private val operationsRepository: OperationsRepository,
) : ViewModel() {
private var privacyPolicyLink = ""
Expand All @@ -44,7 +40,8 @@ class SettingViewModel @Inject constructor(
SettingIntent.EnterScreen -> {
viewModelScope.launch {
val enabled = alarmRepository.getMasterAlarmStatus()
reduce { copy(isNotificationEnabled = enabled) }
val appVersion = operationsRepository.getAppVersion()
reduce { copy(isNotificationEnabled = enabled, appVersion = appVersion) }
}

combine(
Expand All @@ -69,10 +66,6 @@ class SettingViewModel @Inject constructor(
}
}

SettingIntent.ClickLogoutItem -> {
reduce { copy(showLogoutDialog = true) }
}

SettingIntent.ClickBackButton -> {
postSideEffect(SettingSideEffect.NavigateBack)
}
Expand All @@ -88,34 +81,6 @@ class SettingViewModel @Inject constructor(
SettingIntent.ClickInquiryItem -> {
postSideEffect(SettingSideEffect.OpenWebBrowser(inquiryLink))
}

SettingIntent.ClickDeleteAccountItem -> {
reduce { copy(showDeleteAccountDialog = true) }
}

SettingIntent.DismissDeleteAccountDialog,
SettingIntent.ClickDeleteAccountDialogCancelButton -> {
reduce { copy(showDeleteAccountDialog = false) }
}

SettingIntent.DismissLogoutDialog,
SettingIntent.ClickLogoutDialogCancelButton -> {
reduce { copy(showLogoutDialog = false) }
}

SettingIntent.ClickDeleteAccountDialogDeleteButton -> {
viewModelScope.launch {
deleteAccountUseCase()
postSideEffect(SettingSideEffect.NavigateToLogin)
}
}

SettingIntent.ClickLogoutDialogLogoutButton -> {
viewModelScope.launch {
logoutUseCase()
postSideEffect(SettingSideEffect.NavigateToLogin)
}
}
}
}
}
2 changes: 1 addition & 1 deletion feature/home/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<string name="setting_screen_item_notification">알림</string>
<string name="setting_screen_item_terms">이용약관</string>
<string name="setting_screen_item_privacy_policy">개인정보 처리방침</string>
<string name="setting_screen_item_inquiry">이용문의</string>
<string name="setting_screen_item_app_version">앱 버전</string>
<string name="setting_screen_item_delete_account">회원탈퇴</string>
<string name="setting_screen_item_logout">로그아웃</string>
<string name="logout_dialog_title">로그아웃 할까요?</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.yapp.feature.profile

import com.yapp.core.ui.component.UserRole

data class ProfileState(
val name: String = "",
val role: UserRole = UserRole.ACTIVE,
val generation: Int = 0,
val position: String = "",
val showLogoutDialog: Boolean = false,
val showWithDrawDialog: Boolean = false
Comment on lines +10 to +11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

변수명 일관성 유지

showLogoutDialogshowWithDrawDialog에서 'WithDraw'의 'W'가 대문자로 되어 있어 camelCase 규칙을 따르지 않습니다. 변수명을 일관성 있게 수정하는 것이 좋습니다.

data class ProfileState(
    val name: String = "",
    val role: UserRole = UserRole.ACTIVE,
    val generation: Int = 0,
    val position: String = "",
    val showLogoutDialog: Boolean = false,
-    val showWithDrawDialog: Boolean = false
+    val showWithdrawDialog: Boolean = false
)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
val showLogoutDialog: Boolean = false,
val showWithDrawDialog: Boolean = false
data class ProfileState(
val name: String = "",
val role: UserRole = UserRole.ACTIVE,
val generation: Int = 0,
val position: String = "",
val showLogoutDialog: Boolean = false,
val showWithdrawDialog: Boolean = false
)

)

sealed interface ProfileIntent {
data object OnEntryScreen : ProfileIntent
data object OnClickSettings : ProfileIntent
data object OnClickAttendHistory : ProfileIntent
data object OnClickPreviousHistory : ProfileIntent
data object OnClickUsage : ProfileIntent
data object OnClickWithdraw : ProfileIntent
data object OnClickLogout : ProfileIntent
data object OnCancelLogout : ProfileIntent
data object OnDismissLogout : ProfileIntent
data object OnLaunchedLogout : ProfileIntent
}

sealed interface ProfileSideEffect {
data object NavigateToSetting : ProfileSideEffect
data object NavigateToAttendHistory : ProfileSideEffect
data object NavigateToPreviousHistory : ProfileSideEffect
data object NavigateToLogin : ProfileSideEffect
}
Loading