Updated on 2026-08-14
This commit is contained in:
parent
ef36fbf13e
commit
e4fc013173
10 changed files with 72 additions and 31 deletions
|
|
@ -29,4 +29,13 @@ sealed class PushNotificationAnalyticEvents(
|
|||
data object ButtonCancel : PushNotificationAnalyticEvents(
|
||||
event = "Button - Cancel",
|
||||
)
|
||||
|
||||
data class PermissionStatus(
|
||||
val isAllowed: Boolean,
|
||||
) : PushNotificationAnalyticEvents(
|
||||
event = "Permission Status",
|
||||
params = mapOf(
|
||||
AnalyticsParam.STATE to if (isAllowed) "Allow" else "Cancel",
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -25,9 +25,10 @@ internal class PushNotificationsFragment : ComposeFragment() {
|
|||
BackHandler(onBack = requireActivity()::finish)
|
||||
NavigationBar3ButtonsScrim()
|
||||
PushNotificationsScreen(
|
||||
onShowAllow = viewModel::onAllowPermission,
|
||||
onAllow = viewModel::onAllowedPermission,
|
||||
onLater = viewModel::onAskLater,
|
||||
onRequest = viewModel::onRequest,
|
||||
onRequestLater = viewModel::onRequestLater,
|
||||
onAllowPermission = viewModel::onAllowPermission,
|
||||
onDenyPermission = viewModel::onDenyPermission,
|
||||
onOpenSettings = viewModel::openSettings,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,17 +16,18 @@ import kotlinx.collections.immutable.persistentListOf
|
|||
|
||||
@Composable
|
||||
internal fun PushNotificationsScreen(
|
||||
onShowAllow: () -> Unit,
|
||||
onAllow: () -> Unit,
|
||||
onLater: () -> Unit,
|
||||
onRequest: () -> Unit,
|
||||
onRequestLater: () -> Unit,
|
||||
onAllowPermission: () -> Unit,
|
||||
onDenyPermission: () -> Unit,
|
||||
onOpenSettings: () -> Unit,
|
||||
) {
|
||||
val isClicked = remember { mutableStateOf(false) }
|
||||
val requestPushPermission = requestPushPermission(
|
||||
isFirstTimeAsking = true,
|
||||
isClicked = isClicked,
|
||||
onAllow = onAllow,
|
||||
onDeny = onLater,
|
||||
onAllow = onAllowPermission,
|
||||
onDeny = onDenyPermission,
|
||||
onOpenSettings = onOpenSettings,
|
||||
pushPermission = getPushPermissionOrNull(),
|
||||
)
|
||||
|
|
@ -48,13 +49,13 @@ internal fun PushNotificationsScreen(
|
|||
buttonText = resourceReference(R.string.common_allow),
|
||||
onClick = {
|
||||
isClicked.value = true
|
||||
onShowAllow()
|
||||
onRequest()
|
||||
requestPushPermission()
|
||||
},
|
||||
),
|
||||
secondaryButton = ShowcaseButtonModel(
|
||||
buttonText = resourceReference(R.string.common_later),
|
||||
onClick = onLater,
|
||||
onClick = onRequestLater,
|
||||
),
|
||||
modifier = Modifier.systemBarsPadding(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,16 @@ internal class PushNotificationViewModel @Inject constructor(
|
|||
private val analyticHandler: AnalyticsEventHandler,
|
||||
) : ViewModel(), PushNotificationsClickIntents {
|
||||
|
||||
override fun onAskLater() {
|
||||
override fun onRequest() {
|
||||
analyticHandler.send(
|
||||
PushNotificationAnalyticEvents.ButtonAllow(AnalyticsParam.ScreensSources.Stories),
|
||||
)
|
||||
viewModelScope.launch {
|
||||
setFirstTimeAskingPermissionUseCase(PUSH_PERMISSION)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestLater() {
|
||||
analyticHandler.send(
|
||||
PushNotificationAnalyticEvents.ButtonLater(AnalyticsParam.ScreensSources.Stories),
|
||||
)
|
||||
|
|
@ -36,25 +45,30 @@ internal class PushNotificationViewModel @Inject constructor(
|
|||
delayPermissionRequestUseCase(PUSH_PERMISSION)
|
||||
setFirstTimeAskingPermissionUseCase(PUSH_PERMISSION)
|
||||
neverToInitiallyAskPermissionUseCase(PUSH_PERMISSION)
|
||||
router.openHome()
|
||||
}
|
||||
router.openHome()
|
||||
}
|
||||
|
||||
override fun onAllowPermission() {
|
||||
viewModelScope.launch {
|
||||
setFirstTimeAskingPermissionUseCase(PUSH_PERMISSION)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAllowedPermission() {
|
||||
analyticHandler.send(
|
||||
PushNotificationAnalyticEvents.ButtonAllow(AnalyticsParam.ScreensSources.Stories),
|
||||
PushNotificationAnalyticEvents.PermissionStatus(isAllowed = true),
|
||||
)
|
||||
viewModelScope.launch {
|
||||
neverRequestPermissionUseCase(PUSH_PERMISSION)
|
||||
neverToInitiallyAskPermissionUseCase(PUSH_PERMISSION)
|
||||
router.openHome()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDenyPermission() {
|
||||
analyticHandler.send(
|
||||
PushNotificationAnalyticEvents.PermissionStatus(isAllowed = false),
|
||||
)
|
||||
viewModelScope.launch {
|
||||
delayPermissionRequestUseCase(PUSH_PERMISSION)
|
||||
neverToInitiallyAskPermissionUseCase(PUSH_PERMISSION)
|
||||
router.openHome()
|
||||
}
|
||||
router.openHome()
|
||||
}
|
||||
|
||||
override fun openSettings() = settingsManager.openSettings()
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package com.tangem.features.pushnotifications.impl.presentation.viewmodel
|
||||
|
||||
internal interface PushNotificationsClickIntents {
|
||||
fun onAskLater()
|
||||
fun onRequest()
|
||||
|
||||
fun onRequestLater()
|
||||
|
||||
fun onAllowPermission()
|
||||
|
||||
fun onAllowedPermission()
|
||||
fun onDenyPermission()
|
||||
|
||||
fun openSettings()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue