Updated on 2026-08-14
This commit is contained in:
parent
38572c0a4e
commit
e323c7cc4a
24 changed files with 27 additions and 134 deletions
|
|
@ -40,7 +40,6 @@ dependencies {
|
|||
|
||||
/** Domain module */
|
||||
implementation(projects.domain.settings)
|
||||
implementation(projects.domain.notifications.toggles)
|
||||
implementation(projects.domain.notifications)
|
||||
|
||||
/** Feature modules */
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package com.tangem.features.pushnotifications.impl
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import com.tangem.core.decompose.context.AppComponentContext
|
||||
import com.tangem.core.decompose.model.getOrCreateModel
|
||||
|
|
@ -38,7 +36,6 @@ internal class DefaultPushNotificationsBottomSheetComponent @AssistedInject cons
|
|||
|
||||
@Composable
|
||||
override fun BottomSheet() {
|
||||
val state by model.state.collectAsState()
|
||||
val bottomSheetConfig = remember(key1 = this) {
|
||||
TangemBottomSheetConfig(
|
||||
isShown = true,
|
||||
|
|
@ -55,7 +52,6 @@ internal class DefaultPushNotificationsBottomSheetComponent @AssistedInject cons
|
|||
onLaterClick = model::onLaterClick,
|
||||
onAllowPermission = model::onAllowPermission,
|
||||
onDenyPermission = model::onDenyPermission,
|
||||
showNotificationsInfo = state.showInfoAboutNotifications,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ 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
|
||||
|
|
@ -28,15 +26,15 @@ 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(
|
||||
onAllowClick = model::onAllowClick,
|
||||
onLaterClick = model::onLaterClick,
|
||||
onAllowPermission = model::onAllowPermission,
|
||||
onDenyPermission = model::onDenyPermission,
|
||||
showNotificationsInfo = state.showInfoAboutNotifications,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,16 +9,12 @@ import com.tangem.core.decompose.di.ModelScoped
|
|||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
import com.tangem.domain.notifications.repository.NotificationsRepository
|
||||
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.PushNotificationsParams
|
||||
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
|
||||
|
||||
|
|
@ -32,7 +28,6 @@ internal class PushNotificationsModel @Inject constructor(
|
|||
private val neverToInitiallyAskPermissionUseCase: NeverToInitiallyAskPermissionUseCase,
|
||||
private val appRouter: AppRouter,
|
||||
private val analyticHandler: AnalyticsEventHandler,
|
||||
private val notificationsFeatureToggles: NotificationsFeatureToggles,
|
||||
private val notificationsRepository: NotificationsRepository,
|
||||
) : Model(), PushNotificationsClickIntents {
|
||||
|
||||
|
|
@ -43,32 +38,21 @@ internal class PushNotificationsModel @Inject constructor(
|
|||
AppRoute.PushNotification.Source.Onboarding -> AnalyticsParam.ScreensSources.Onboarding
|
||||
}
|
||||
|
||||
private val _state = MutableStateFlow(
|
||||
PushNotificationsUM(
|
||||
showInfoAboutNotifications = notificationsFeatureToggles.isNotificationsEnabled,
|
||||
),
|
||||
)
|
||||
|
||||
init {
|
||||
analyticHandler.send(PushNotificationAnalyticEvents.NotificationsScreenOpened(source))
|
||||
}
|
||||
|
||||
val state = _state.asStateFlow()
|
||||
|
||||
override fun onAllowClick() {
|
||||
if (notificationsFeatureToggles.isNotificationsEnabled) {
|
||||
modelScope.launch {
|
||||
notificationsRepository.setUserAllowToSubscribeOnPushNotifications(true)
|
||||
}
|
||||
modelScope.launch {
|
||||
notificationsRepository.setUserAllowToSubscribeOnPushNotifications(true)
|
||||
}
|
||||
|
||||
analyticHandler.send(PushNotificationAnalyticEvents.ButtonAllow(source))
|
||||
}
|
||||
|
||||
override fun onLaterClick() {
|
||||
if (notificationsFeatureToggles.isNotificationsEnabled) {
|
||||
modelScope.launch {
|
||||
notificationsRepository.setUserAllowToSubscribeOnPushNotifications(false)
|
||||
}
|
||||
modelScope.launch {
|
||||
notificationsRepository.setUserAllowToSubscribeOnPushNotifications(false)
|
||||
}
|
||||
analyticHandler.send(PushNotificationAnalyticEvents.ButtonLater(source))
|
||||
modelScope.launch {
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
package com.tangem.features.pushnotifications.impl.presentation.state
|
||||
|
||||
data class PushNotificationsUM(
|
||||
val showInfoAboutNotifications: Boolean = false,
|
||||
)
|
||||
|
|
@ -44,7 +44,6 @@ internal fun PushNotificationsContent(
|
|||
onLaterClick: () -> Unit,
|
||||
onAllowPermission: () -> Unit,
|
||||
onDenyPermission: () -> Unit,
|
||||
showNotificationsInfo: Boolean,
|
||||
) {
|
||||
val requestPushPermission = requestPermission(
|
||||
onAllow = onAllowPermission,
|
||||
|
|
@ -65,18 +64,11 @@ internal fun PushNotificationsContent(
|
|||
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
|
||||
}
|
||||
},
|
||||
ShowcaseItemModel(
|
||||
R.drawable.ic_notifications_24,
|
||||
resourceReference(R.string.user_push_notification_agreement_argument_three),
|
||||
),
|
||||
),
|
||||
modifier = Modifier.padding(top = TangemTheme.dimens.spacing40),
|
||||
)
|
||||
SpacerH28()
|
||||
|
|
@ -111,7 +103,6 @@ private fun Preview_PushNotificationsBottomSheet() {
|
|||
onLaterClick = {},
|
||||
onAllowPermission = {},
|
||||
onDenyPermission = {},
|
||||
showNotificationsInfo = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ internal fun PushNotificationsScreen(
|
|||
onLaterClick: () -> Unit,
|
||||
onAllowPermission: () -> Unit,
|
||||
onDenyPermission: () -> Unit,
|
||||
showNotificationsInfo: Boolean,
|
||||
) {
|
||||
val requestPushPermission = requestPermission(
|
||||
onAllow = onAllowPermission,
|
||||
|
|
@ -38,18 +37,11 @@ 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
|
||||
}
|
||||
},
|
||||
ShowcaseItemModel(
|
||||
R.drawable.ic_notifications_24,
|
||||
resourceReference(R.string.user_push_notification_agreement_argument_three),
|
||||
),
|
||||
),
|
||||
primaryButton = ShowcaseButtonModel(
|
||||
buttonText = resourceReference(R.string.common_allow),
|
||||
onClick = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue