Updated on 2026-08-14
This commit is contained in:
parent
189ffd9927
commit
d327640e9f
10 changed files with 64 additions and 10 deletions
|
|
@ -16,4 +16,7 @@ dependencies {
|
|||
implementation(projects.core.decompose)
|
||||
implementation(projects.core.ui)
|
||||
implementation(projects.core.analytics.models)
|
||||
|
||||
/** Common */
|
||||
implementation(projects.common.routing)
|
||||
}
|
||||
|
|
@ -1,9 +1,19 @@
|
|||
package com.tangem.features.pushnotifications.api
|
||||
|
||||
import com.tangem.common.routing.AppRoute
|
||||
import com.tangem.core.decompose.factory.ComponentFactory
|
||||
import com.tangem.core.ui.decompose.ComposableContentComponent
|
||||
|
||||
interface PushNotificationsComponent : ComposableContentComponent {
|
||||
|
||||
interface Factory : ComponentFactory<Unit, PushNotificationsComponent>
|
||||
interface Factory : ComponentFactory<Params, PushNotificationsComponent>
|
||||
|
||||
interface ModelCallbacks {
|
||||
fun onResult()
|
||||
}
|
||||
|
||||
sealed class Params {
|
||||
data class Callbacks(val callbacks: ModelCallbacks) : Params()
|
||||
data class Route(val route: AppRoute) : Params()
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ import dagger.assisted.AssistedInject
|
|||
|
||||
internal class DefaultPushNotificationsComponent @AssistedInject constructor(
|
||||
@Assisted appComponentContext: AppComponentContext,
|
||||
@Assisted params: Unit,
|
||||
@Assisted params: PushNotificationsComponent.Params,
|
||||
) : PushNotificationsComponent, AppComponentContext by appComponentContext {
|
||||
|
||||
private val model: PushNotificationsModel = getOrCreateModel(params)
|
||||
|
|
@ -41,6 +41,9 @@ internal class DefaultPushNotificationsComponent @AssistedInject constructor(
|
|||
|
||||
@AssistedFactory
|
||||
interface Factory : PushNotificationsComponent.Factory {
|
||||
override fun create(context: AppComponentContext, params: Unit): DefaultPushNotificationsComponent
|
||||
override fun create(
|
||||
context: AppComponentContext,
|
||||
params: PushNotificationsComponent.Params,
|
||||
): DefaultPushNotificationsComponent
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,16 @@
|
|||
package com.tangem.features.pushnotifications.impl.model
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import com.tangem.common.routing.AppRoute
|
||||
import com.tangem.common.routing.AppRouter
|
||||
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.core.decompose.model.ParamsContainer
|
||||
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.PushNotificationsComponent
|
||||
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
|
||||
|
|
@ -21,15 +22,19 @@ import javax.inject.Inject
|
|||
|
||||
@Stable
|
||||
@ModelScoped
|
||||
@Suppress("LongParameterList")
|
||||
internal class PushNotificationsModel @Inject constructor(
|
||||
paramsContainer: ParamsContainer,
|
||||
override val dispatchers: CoroutineDispatcherProvider,
|
||||
private val neverRequestPermissionUseCase: NeverRequestPermissionUseCase,
|
||||
private val neverToInitiallyAskPermissionUseCase: NeverToInitiallyAskPermissionUseCase,
|
||||
private val appRouter: AppRouter,
|
||||
private val analyticHandler: AnalyticsEventHandler,
|
||||
private val notificationsFeatureToggles: NotificationsFeatureToggles,
|
||||
notificationsFeatureToggles: NotificationsFeatureToggles,
|
||||
) : Model(), PushNotificationsClickIntents {
|
||||
|
||||
private val params: PushNotificationsComponent.Params = paramsContainer.require()
|
||||
|
||||
private val _state = MutableStateFlow(
|
||||
PushNotificationsUM(
|
||||
showInfoAboutNotifications = notificationsFeatureToggles.isNotificationsEnabled,
|
||||
|
|
@ -51,7 +56,7 @@ internal class PushNotificationsModel @Inject constructor(
|
|||
modelScope.launch {
|
||||
neverRequestPermissionUseCase(PUSH_PERMISSION)
|
||||
neverToInitiallyAskPermissionUseCase(PUSH_PERMISSION)
|
||||
appRouter.push(AppRoute.Home)
|
||||
onResult()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +67,7 @@ internal class PushNotificationsModel @Inject constructor(
|
|||
modelScope.launch {
|
||||
neverRequestPermissionUseCase(PUSH_PERMISSION)
|
||||
neverToInitiallyAskPermissionUseCase(PUSH_PERMISSION)
|
||||
appRouter.push(AppRoute.Home)
|
||||
onResult()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +78,18 @@ internal class PushNotificationsModel @Inject constructor(
|
|||
modelScope.launch {
|
||||
neverRequestPermissionUseCase(PUSH_PERMISSION)
|
||||
neverToInitiallyAskPermissionUseCase(PUSH_PERMISSION)
|
||||
appRouter.push(AppRoute.Home)
|
||||
onResult()
|
||||
}
|
||||
}
|
||||
|
||||
private fun onResult() {
|
||||
when (params) {
|
||||
is PushNotificationsComponent.Params.Callbacks -> {
|
||||
params.callbacks.onResult()
|
||||
}
|
||||
is PushNotificationsComponent.Params.Route -> {
|
||||
appRouter.push(params.route)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue