From 9133610075fcd83a102935c52f88e14202d6f5ae Mon Sep 17 00:00:00 2001 From: flashdragon Date: Mon, 2 Dec 2024 16:55:13 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=88=98=EB=A9=B4=EC=95=8C=EB=9E=8C=20?= =?UTF-8?q?=ED=99=9C=EC=84=B1=ED=99=94=20=EB=B9=84=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94=20=EC=9E=98=20=EB=B3=B4=EC=9D=B4=EA=B2=8C=20ui=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../setting/SettingNotificationScreen.kt | 26 +++++++++---------- .../setting/component/SettingOption.kt | 5 ++-- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/feature/setting/src/main/java/com/boostcamp/dreamteam/dreamdiary/setting/SettingNotificationScreen.kt b/feature/setting/src/main/java/com/boostcamp/dreamteam/dreamdiary/setting/SettingNotificationScreen.kt index 7b723788..d09120e5 100644 --- a/feature/setting/src/main/java/com/boostcamp/dreamteam/dreamdiary/setting/SettingNotificationScreen.kt +++ b/feature/setting/src/main/java/com/boostcamp/dreamteam/dreamdiary/setting/SettingNotificationScreen.kt @@ -73,19 +73,19 @@ internal fun SettingNotificationScreen( onClick = { viewModel.goToLaunchNotificationSetting(activity) }, ) SettingCategory(text = stringResource(R.string.setting_notification_wakeup)) - if (!onTracking) { - SettingOption( - icon = Icons.Default.Bedtime, - text = stringResource(R.string.setting_notification_diary_on), - onClick = { viewModel.startTracking(context) }, - ) - } else { - SettingOption( - icon = Icons.Default.BedtimeOff, - text = stringResource(R.string.setting_notification_diary_off), - onClick = { viewModel.stopTracking(context) }, - ) - } + SettingOption( + icon = if (onTracking) Icons.Default.BedtimeOff else Icons.Default.Bedtime, + text = if (onTracking) { + stringResource( + R.string.setting_notification_diary_off, + ) + } else { + stringResource(R.string.setting_notification_diary_on) + }, + onClick = { if (onTracking) viewModel.stopTracking(context) else viewModel.startTracking(context) }, + switchOption = true, + checked = onTracking, + ) SettingCategory(text = stringResource(R.string.setting_comment_alarm)) SettingOption( icon = Icons.AutoMirrored.Outlined.Comment, diff --git a/feature/setting/src/main/java/com/boostcamp/dreamteam/dreamdiary/setting/component/SettingOption.kt b/feature/setting/src/main/java/com/boostcamp/dreamteam/dreamdiary/setting/component/SettingOption.kt index feb7237c..85e93725 100644 --- a/feature/setting/src/main/java/com/boostcamp/dreamteam/dreamdiary/setting/component/SettingOption.kt +++ b/feature/setting/src/main/java/com/boostcamp/dreamteam/dreamdiary/setting/component/SettingOption.kt @@ -26,6 +26,7 @@ internal fun SettingOption( text: String, helpText: String? = null, switchOption: Boolean = false, + checked: Boolean = false, onClick: () -> Unit = {}, modifier: Modifier = Modifier, ) { @@ -59,8 +60,8 @@ internal fun SettingOption( } if (switchOption) { Switch( - checked = false, - onCheckedChange = { /* TODO */ }, + checked = checked, + onCheckedChange = { onClick() }, ) } }