11package com.ninecraft.booket.feature.settings.notification
22
3+ import android.content.Intent
4+ import android.net.Uri
5+ import android.provider.Settings
6+ import androidx.activity.result.contract.ActivityResultContracts
7+ import androidx.activity.compose.rememberLauncherForActivityResult
38import androidx.compose.foundation.background
49import androidx.compose.foundation.layout.Arrangement
510import androidx.compose.foundation.layout.Column
@@ -16,8 +21,10 @@ import androidx.compose.runtime.Composable
1621import androidx.compose.ui.Alignment
1722import androidx.compose.ui.Modifier
1823import androidx.compose.ui.graphics.vector.ImageVector
24+ import androidx.compose.ui.platform.LocalContext
1925import androidx.compose.ui.res.stringResource
2026import androidx.compose.ui.res.vectorResource
27+ import com.ninecraft.booket.core.common.extensions.noRippleClickable
2128import com.ninecraft.booket.core.designsystem.DevicePreview
2229import com.ninecraft.booket.core.designsystem.theme.ReedTheme
2330import com.ninecraft.booket.core.designsystem.theme.White
@@ -53,39 +60,7 @@ internal fun NotificationUi(
5360 },
5461 )
5562 Spacer (modifier = Modifier .height(ReedTheme .spacing.spacing2))
56- Row (
57- modifier = modifier
58- .padding(horizontal = ReedTheme .spacing.spacing5)
59- .fillMaxWidth()
60- .background(
61- color = ReedTheme .colors.baseSecondary,
62- shape = RoundedCornerShape (ReedTheme .radius.md),
63- )
64- .padding(
65- vertical = ReedTheme .spacing.spacing6,
66- horizontal = ReedTheme .spacing.spacing5,
67- ),
68- verticalAlignment = Alignment .CenterVertically ,
69- horizontalArrangement = Arrangement .SpaceBetween ,
70- ) {
71- Column {
72- Text (
73- text = stringResource(R .string.notification_enable_title),
74- color = ReedTheme .colors.contentBrand,
75- style = ReedTheme .typography.body1SemiBold,
76- )
77- Text (
78- text = stringResource(R .string.notification_enable_description),
79- color = ReedTheme .colors.contentTertiary,
80- style = ReedTheme .typography.label2Regular,
81- )
82- }
83- Icon (
84- imageVector = ImageVector .vectorResource(designR.drawable.ic_chevron_right),
85- contentDescription = " Chevron Right Icon" ,
86- tint = ReedTheme .colors.contentBrand,
87- )
88- }
63+ NotificationGuideItem ()
8964 Spacer (modifier = Modifier .height(ReedTheme .spacing.spacing4))
9065 Row (
9166 modifier = modifier
@@ -120,6 +95,54 @@ internal fun NotificationUi(
12095 }
12196}
12297
98+ @Composable
99+ internal fun NotificationGuideItem () {
100+ val context = LocalContext .current
101+ val settingsLauncher = rememberLauncherForActivityResult(
102+ contract = ActivityResultContracts .StartActivityForResult (),
103+ ) { _ -> }
104+
105+ Row (
106+ modifier = Modifier
107+ .padding(horizontal = ReedTheme .spacing.spacing5)
108+ .fillMaxWidth()
109+ .background(
110+ color = ReedTheme .colors.baseSecondary,
111+ shape = RoundedCornerShape (ReedTheme .radius.md),
112+ )
113+ .noRippleClickable {
114+ val intent = Intent (Settings .ACTION_APPLICATION_DETAILS_SETTINGS ).apply {
115+ data = Uri .fromParts(" package" , context.packageName, null )
116+ }
117+ settingsLauncher.launch(intent)
118+ }
119+ .padding(
120+ vertical = ReedTheme .spacing.spacing6,
121+ horizontal = ReedTheme .spacing.spacing5,
122+ ),
123+ verticalAlignment = Alignment .CenterVertically ,
124+ horizontalArrangement = Arrangement .SpaceBetween ,
125+ ) {
126+ Column {
127+ Text (
128+ text = stringResource(R .string.notification_guide_title),
129+ color = ReedTheme .colors.contentBrand,
130+ style = ReedTheme .typography.body1SemiBold,
131+ )
132+ Text (
133+ text = stringResource(R .string.notification_guide_description),
134+ color = ReedTheme .colors.contentTertiary,
135+ style = ReedTheme .typography.label2Regular,
136+ )
137+ }
138+ Icon (
139+ imageVector = ImageVector .vectorResource(designR.drawable.ic_chevron_right),
140+ contentDescription = " Chevron Right Icon" ,
141+ tint = ReedTheme .colors.contentBrand,
142+ )
143+ }
144+ }
145+
123146@DevicePreview
124147@Composable
125148private fun NotificationUiPreview () {
0 commit comments