@@ -4,7 +4,6 @@ import android.content.Intent
44import android.provider.Settings
55import androidx.compose.foundation.Image
66import androidx.compose.foundation.background
7- import androidx.compose.foundation.layout.Arrangement
87import androidx.compose.foundation.layout.Column
98import androidx.compose.foundation.layout.Spacer
109import androidx.compose.foundation.layout.fillMaxSize
@@ -16,6 +15,7 @@ import androidx.compose.material3.Button
1615import androidx.compose.material3.ButtonDefaults
1716import androidx.compose.material3.Text
1817import androidx.compose.runtime.Composable
18+ import androidx.compose.runtime.LaunchedEffect
1919import androidx.compose.runtime.collectAsState
2020import androidx.compose.runtime.getValue
2121import androidx.compose.ui.Modifier
@@ -25,8 +25,10 @@ import androidx.compose.ui.res.painterResource
2525import androidx.compose.ui.unit.dp
2626import androidx.compose.ui.unit.sp
2727import androidx.hilt.navigation.compose.hiltViewModel
28+ import androidx.lifecycle.compose.LifecycleStartEffect
2829import com.plottwist.core.designsystem.component.TukTopAppBar
2930import com.plottwist.core.designsystem.component.TukTopAppBarType
31+ import com.plottwist.core.designsystem.foundation.TukColorTokens.Gray500
3032import com.plottwist.core.designsystem.foundation.type.TukPretendardTypography
3133import com.plottwist.core.designsystem.foundation.type.TukSerifTypography
3234import com.plottwist.feature.mypage.R
@@ -41,6 +43,11 @@ fun NotificationSettingScreen(
4143 val state by viewModel.container.stateFlow.collectAsState()
4244 val context = LocalContext .current
4345
46+ LifecycleStartEffect (Unit ) {
47+ viewModel.checkNotificationStatus()
48+ onStopOrDispose { }
49+ }
50+
4451 viewModel.collectSideEffect { sideEffect ->
4552 when (sideEffect) {
4653 is NotificationSettingSideEffect .OpenNotificationSettings -> {
@@ -69,7 +76,6 @@ fun NotificationSettingScreen(
6976 modifier = Modifier
7077 .fillMaxSize()
7178 .padding(horizontal = 24 .dp),
72- verticalArrangement = Arrangement .Center
7379 ) {
7480 Text (
7581 text = if (state.areNotificationsEnabled) " 기기 알림이\n 켜져있어요" else " 기기 알림이\n 꺼져있어요" ,
@@ -86,24 +92,33 @@ fun NotificationSettingScreen(
8692 color = Color (0xFF888888 ),
8793 lineHeight = 20 .sp
8894 )
89- if (! state.areNotificationsEnabled) {
90- Spacer (modifier = Modifier .height(24 .dp))
91- Button (
92- onClick = { viewModel.onClickNotificationButton() },
93- colors = ButtonDefaults .buttonColors(
94- containerColor = Color (0xFFE74C3C )
95- )
96- ) {
97- Text (" 기기 알림 켜기" ,
98- color = Color .White )
99- Spacer (modifier = Modifier .width(4 .dp))
100- Image (
101- painter = painterResource(id = R .drawable.icon_next),
102- contentDescription = " 화살표 아이콘" ,
103- modifier = Modifier .size(16 .dp)
104- )
105- }
95+ Spacer (modifier = Modifier .height(24 .dp))
96+ Button (
97+ onClick = { viewModel.onClickNotificationButton() },
98+ colors = ButtonDefaults .buttonColors(
99+ containerColor =
100+ if (! state.areNotificationsEnabled) {
101+ Color (0xFFE74C3C )
102+ } else {
103+ Gray500
104+ }
105+ )
106+ ) {
107+ Text (
108+ text = if (! state.areNotificationsEnabled) {
109+ " 기기 알림 켜기"
110+ } else {
111+ " 기기 알림 끄기"
112+ },
113+ color = Color .White )
114+ Spacer (modifier = Modifier .width(4 .dp))
115+ Image (
116+ painter = painterResource(id = R .drawable.icon_next),
117+ contentDescription = " 화살표 아이콘" ,
118+ modifier = Modifier .size(16 .dp)
119+ )
106120 }
121+
107122 }
108123 }
109- }
124+ }
0 commit comments