Skip to content

Commit

Permalink
refactor : lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nohjunh committed Jan 26, 2025
1 parent 73c9e8b commit c702268
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
implementation(projects.core.designsystem)
implementation(projects.core.model)
implementation(projects.core.notifications)

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.navigation.compose)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ interface UserRepository {
val userData: Flow<UserData>

suspend fun completeOnBoarding(): Result<Unit>

suspend fun setGoalNotificationChecked(checked: Boolean): Result<Unit>

suspend fun disableSystemNotificationDialog(): Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ private fun UserPreferences.toModel() =
UserData(
isOnboardingCompleted = isOnboardingCompleted,
isGoalNotificationChecked = notificationSetting.isGoalNotificationChecked,
isSystemNotificationDialogDisabled = notificationSetting.isSystemNotificationDialogDisabled
isSystemNotificationDialogDisabled = notificationSetting.isSystemNotificationDialogDisabled,
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,33 @@ fun DobeDobeDialog(
onDismissRequest: () -> Unit,
title: String,
modifier: Modifier = Modifier,
content: @Composable () -> Unit
content: @Composable () -> Unit,
) {
Dialog(
onDismissRequest = onDismissRequest,
properties = DialogProperties(
usePlatformDefaultWidth = false
usePlatformDefaultWidth = false,
),
) {
Surface(
modifier = modifier
.width(253.dp),
shape = RoundedCornerShape(16.dp),
color = Color.White
color = Color.White,
) {
Column(
modifier = Modifier.padding(
vertical = 24.dp,
horizontal = 15.dp
horizontal = 15.dp,
),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(
text = title,
fontSize = 17.sp,
fontWeight = FontWeight.SemiBold,
color = Color.Black
color = Color.Black,
)

Spacer(modifier = Modifier.height(16.dp))
Expand All @@ -72,10 +72,10 @@ private fun DobeDobeDialogPreview() {
DobeDobeTheme {
DobeDobeDialog(
onDismissRequest = {},
title = "TEST"
title = "TEST",
) {
Button(
onClick = {}
onClick = {},
) {
Text(text = "TEST")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package com.chipichipi.dobedobe.core.model
data class UserData(
val isOnboardingCompleted: Boolean,
val isGoalNotificationChecked: Boolean,
val isSystemNotificationDialogDisabled: Boolean
val isSystemNotificationDialogDisabled: Boolean,
)
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private fun DashboardScreen(
when (uiState) {
is DashboardUiState.Error,
is DashboardUiState.Loading,
-> {
-> {
CircularProgressIndicator(
modifier = Modifier.size(24.dp),
)
Expand Down Expand Up @@ -161,7 +161,7 @@ private fun DashboardBody(
GoalNotificationPermissionEffect(
isSystemNotificationDialogDisabled = uiState.isSystemNotificationDialogDisabled,
setGoalNotificationChecked = setGoalNotificationChecked,
disableSystemNotificationDialog = disableSystemNotificationDialog
disableSystemNotificationDialog = disableSystemNotificationDialog,
)
}

Expand All @@ -170,7 +170,7 @@ private fun DashboardBody(
private fun GoalNotificationPermissionEffect(
isSystemNotificationDialogDisabled: Boolean,
setGoalNotificationChecked: (Boolean) -> Unit,
disableSystemNotificationDialog: () -> Unit
disableSystemNotificationDialog: () -> Unit,
) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) return
val notificationsPermissionState = rememberPermissionState(
Expand All @@ -181,9 +181,9 @@ private fun GoalNotificationPermissionEffect(
LaunchedEffect(notificationsPermissionState, isSystemNotificationDialogDisabled) {
val status = notificationsPermissionState.status

if (status is PermissionStatus.Denied
&& !status.shouldShowRationale
&& !isSystemNotificationDialogDisabled
if (status is PermissionStatus.Denied &&
!status.shouldShowRationale &&
!isSystemNotificationDialogDisabled
) {
showGoalNotificationDialog = true
}
Expand All @@ -195,15 +195,15 @@ private fun GoalNotificationPermissionEffect(
showGoalNotificationDialog = false
},
// TODO : 변경 필요
title = "목표에 대한 알림을 위해\n 권한이 필요합니다."
title = "목표에 대한 알림을 위해\n 권한이 필요합니다.",
) {
Button(
onClick = {
notificationsPermissionState.launchPermissionRequest()
setGoalNotificationChecked(true)
disableSystemNotificationDialog()
showGoalNotificationDialog = false
}
},
) {
// TODO : 변경 필요
Text("확인")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sealed interface DashboardUiState {

data class Success(
val photoState: List<DashboardPhotoState>,
val isSystemNotificationDialogDisabled: Boolean
val isSystemNotificationDialogDisabled: Boolean,
) : DashboardUiState

data object Error : DashboardUiState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ private val fakeDashboardPhotoState =
internal class DashboardViewModel(
private val userRepository: UserRepository,
) : ViewModel() {

private val isSystemNotificationDialogDisabledFlow = userRepository.userData
.map { it.isSystemNotificationDialogDisabled }
.distinctUntilChanged()

val uiState: StateFlow<DashboardUiState> = combine(
fakeDashboardPhotoState,
isSystemNotificationDialogDisabledFlow
isSystemNotificationDialogDisabledFlow,
) { photoState, isSystemNotificationDialogDisabled ->
val dashboardPhotoStates = DashboardPhotoConfig.entries.map { config ->
val photo = photoState.find { it.id == config.id }
Expand All @@ -47,7 +46,7 @@ internal class DashboardViewModel(

DashboardUiState.Success(
dashboardPhotoStates,
isSystemNotificationDialogDisabled
isSystemNotificationDialogDisabled,
)
}
.stateIn(
Expand Down

0 comments on commit c702268

Please sign in to comment.