Updated on 2026-08-14
This commit is contained in:
commit
9713eef560
9 changed files with 71 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()
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ data class PushNotificationsBottomSheetConfig(
|
|||
val isFirstTimeRequested: Boolean,
|
||||
val wasInitiallyAsk: Boolean,
|
||||
val onRequest: () -> Unit,
|
||||
val onRequestLater: () -> Unit,
|
||||
val onAllow: () -> Unit,
|
||||
val onDeny: () -> Unit,
|
||||
val openSettings: () -> Unit,
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ private fun PushNotificationsSheetContent(content: PushNotificationsBottomSheetC
|
|||
stringResource(R.string.common_cancel)
|
||||
},
|
||||
onClick = {
|
||||
content.onDeny()
|
||||
content.onRequestLater()
|
||||
onDismiss()
|
||||
},
|
||||
modifier = Modifier.weight(1f),
|
||||
|
|
@ -113,6 +113,7 @@ private fun PushNotificationsSheetContent_Preview() {
|
|||
isFirstTimeRequested = false,
|
||||
wasInitiallyAsk = false,
|
||||
onRequest = {},
|
||||
onRequestLater = {},
|
||||
onAllow = {},
|
||||
onDeny = {},
|
||||
openSettings = {},
|
||||
|
|
|
|||
|
|
@ -159,21 +159,22 @@ internal class WalletViewModel @Inject constructor(
|
|||
|
||||
val isFirstTimeRequested = isFirstTimeAskingPermissionUseCase(PUSH_PERMISSION).getOrElse { true }
|
||||
val wasInitiallyAsk = shouldInitiallyAskPermissionUseCase(PUSH_PERMISSION).getOrElse { true }
|
||||
val onDenyClick: () -> Unit = if (wasInitiallyAsk) {
|
||||
val onRequestLater: () -> Unit = if (wasInitiallyAsk) {
|
||||
clickIntents::onDelayAskPushPermission
|
||||
} else {
|
||||
clickIntents::onDenyPushPermission
|
||||
clickIntents::onNeverAskPushPermission
|
||||
}
|
||||
stateHolder.showBottomSheet(
|
||||
content = PushNotificationsBottomSheetConfig(
|
||||
isFirstTimeRequested = isFirstTimeRequested,
|
||||
wasInitiallyAsk = wasInitiallyAsk,
|
||||
onRequest = clickIntents::onRequestPushPermission,
|
||||
onRequestLater = onRequestLater,
|
||||
onAllow = clickIntents::onAllowPushPermission,
|
||||
onDeny = onDenyClick,
|
||||
onDeny = clickIntents::onDenyPushPermission,
|
||||
openSettings = settingsManager::openSettings,
|
||||
),
|
||||
onDismiss = onDenyClick,
|
||||
onDismiss = onRequestLater,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ internal interface WalletPushPermissionClickIntents {
|
|||
|
||||
fun onDelayAskPushPermission()
|
||||
|
||||
fun onNeverAskPushPermission()
|
||||
|
||||
fun onDenyPushPermission()
|
||||
|
||||
fun onAllowPushPermission()
|
||||
|
|
@ -31,6 +33,9 @@ internal class WalletPushPermissionClickIntentsImplementor @Inject constructor(
|
|||
) : BaseWalletClickIntents(), WalletPushPermissionClickIntents {
|
||||
|
||||
override fun onRequestPushPermission() {
|
||||
analyticsEventHandler.send(
|
||||
PushNotificationAnalyticEvents.ButtonAllow(AnalyticsParam.ScreensSources.Main),
|
||||
)
|
||||
viewModelScope.launch {
|
||||
setFirstTimeAskingPermissionUseCase(PUSH_PERMISSION)
|
||||
}
|
||||
|
|
@ -45,17 +50,22 @@ internal class WalletPushPermissionClickIntentsImplementor @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onNeverAskPushPermission() {
|
||||
viewModelScope.launch {
|
||||
analyticsEventHandler.send(PushNotificationAnalyticEvents.ButtonCancel)
|
||||
neverRequestPermissionUseCase(PUSH_PERMISSION)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDenyPushPermission() {
|
||||
analyticsEventHandler.send(PushNotificationAnalyticEvents.ButtonCancel)
|
||||
analyticsEventHandler.send(PushNotificationAnalyticEvents.PermissionStatus(isAllowed = false))
|
||||
viewModelScope.launch {
|
||||
neverRequestPermissionUseCase(PUSH_PERMISSION)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAllowPushPermission() {
|
||||
analyticsEventHandler.send(
|
||||
PushNotificationAnalyticEvents.ButtonAllow(AnalyticsParam.ScreensSources.Main),
|
||||
)
|
||||
analyticsEventHandler.send(PushNotificationAnalyticEvents.PermissionStatus(isAllowed = true))
|
||||
viewModelScope.launch {
|
||||
neverRequestPermissionUseCase(PUSH_PERMISSION)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue