Updated on 2026-08-14
This commit is contained in:
parent
74e286f57b
commit
c55274f40f
7 changed files with 68 additions and 1 deletions
|
|
@ -38,6 +38,7 @@ dependencies {
|
|||
|
||||
/** Domain module */
|
||||
implementation(projects.domain.settings)
|
||||
implementation(projects.domain.notifications.toggles)
|
||||
|
||||
/** Feature modules */
|
||||
implementation(projects.features.pushNotifications.api)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.tangem.features.pushnotifications.impl
|
|||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import com.tangem.core.decompose.context.AppComponentContext
|
||||
|
|
@ -25,6 +27,7 @@ internal class DefaultPushNotificationsComponent @AssistedInject constructor(
|
|||
@Composable
|
||||
override fun Content(modifier: Modifier) {
|
||||
val activity = LocalContext.current.findActivity()
|
||||
val state by model.state.collectAsState()
|
||||
BackHandler(onBack = { activity.finish() })
|
||||
NavigationBar3ButtonsScrim()
|
||||
PushNotificationsScreen(
|
||||
|
|
@ -32,6 +35,7 @@ internal class DefaultPushNotificationsComponent @AssistedInject constructor(
|
|||
onNeverRequest = model::onNeverRequest,
|
||||
onAllowPermission = model::onAllowPermission,
|
||||
onDenyPermission = model::onDenyPermission,
|
||||
showNotificationsInfo = state.showInfoAboutNotifications,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,15 @@ import com.tangem.core.analytics.api.AnalyticsEventHandler
|
|||
import com.tangem.core.analytics.models.AnalyticsParam
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.domain.notifications.toggles.NotificationsFeatureToggles
|
||||
import com.tangem.domain.settings.NeverRequestPermissionUseCase
|
||||
import com.tangem.domain.settings.NeverToInitiallyAskPermissionUseCase
|
||||
import com.tangem.features.pushnotifications.api.analytics.PushNotificationAnalyticEvents
|
||||
import com.tangem.features.pushnotifications.api.utils.PUSH_PERMISSION
|
||||
import com.tangem.features.pushnotifications.impl.presentation.state.PushNotificationsUM
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
@ -23,8 +27,17 @@ internal class PushNotificationsModel @Inject constructor(
|
|||
private val neverToInitiallyAskPermissionUseCase: NeverToInitiallyAskPermissionUseCase,
|
||||
private val appRouter: AppRouter,
|
||||
private val analyticHandler: AnalyticsEventHandler,
|
||||
private val notificationsFeatureToggles: NotificationsFeatureToggles,
|
||||
) : Model(), PushNotificationsClickIntents {
|
||||
|
||||
private val _state = MutableStateFlow(
|
||||
PushNotificationsUM(
|
||||
showInfoAboutNotifications = notificationsFeatureToggles.isNotificationsEnabled,
|
||||
),
|
||||
)
|
||||
|
||||
val state = _state.asStateFlow()
|
||||
|
||||
override fun onRequest() {
|
||||
analyticHandler.send(
|
||||
PushNotificationAnalyticEvents.ButtonAllow(AnalyticsParam.ScreensSources.Stories),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package com.tangem.features.pushnotifications.impl.presentation.state
|
||||
|
||||
data class PushNotificationsUM(
|
||||
val showInfoAboutNotifications: Boolean = false,
|
||||
)
|
||||
|
|
@ -18,6 +18,7 @@ internal fun PushNotificationsScreen(
|
|||
onNeverRequest: () -> Unit,
|
||||
onAllowPermission: () -> Unit,
|
||||
onDenyPermission: () -> Unit,
|
||||
showNotificationsInfo: Boolean,
|
||||
) {
|
||||
val requestPushPermission = requestPushPermission(
|
||||
onAllow = onAllowPermission,
|
||||
|
|
@ -37,7 +38,18 @@ internal fun PushNotificationsScreen(
|
|||
R.drawable.ic_storefront_24,
|
||||
resourceReference(R.string.user_push_notification_agreement_argument_two),
|
||||
),
|
||||
),
|
||||
).let { baseItems ->
|
||||
if (showNotificationsInfo) {
|
||||
baseItems.add(
|
||||
ShowcaseItemModel(
|
||||
R.drawable.ic_notifications_24,
|
||||
resourceReference(R.string.user_push_notification_agreement_argument_three),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
baseItems
|
||||
}
|
||||
},
|
||||
primaryButton = ShowcaseButtonModel(
|
||||
buttonText = resourceReference(R.string.common_allow),
|
||||
onClick = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue