Updated on 2026-08-14
This commit is contained in:
parent
7af70694ca
commit
b0d9d81348
11 changed files with 93 additions and 20 deletions
|
|
@ -65,12 +65,19 @@ internal class WalletStateController @Inject constructor() {
|
|||
return with(value) { wallets[selectedWalletIndex].walletCardState.id }
|
||||
}
|
||||
|
||||
fun showBottomSheet(content: TangemBottomSheetConfigContent, userWalletId: UserWalletId = getSelectedWalletId()) {
|
||||
fun showBottomSheet(
|
||||
content: TangemBottomSheetConfigContent,
|
||||
userWalletId: UserWalletId = getSelectedWalletId(),
|
||||
onDismiss: (() -> Unit)? = null,
|
||||
) {
|
||||
update(
|
||||
OpenBottomSheetTransformer(
|
||||
userWalletId = userWalletId,
|
||||
content = content,
|
||||
onDismissBottomSheet = { update(CloseBottomSheetTransformer(userWalletId)) },
|
||||
onDismissBottomSheet = {
|
||||
onDismiss?.invoke()
|
||||
update(CloseBottomSheetTransformer(userWalletId))
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ package com.tangem.feature.wallet.presentation.wallet.state.model
|
|||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
|
||||
data class PushNotificationsBottomSheetConfig(
|
||||
val isFirstTimeAsking: Boolean,
|
||||
val isFirstTimeRequested: Boolean,
|
||||
val wasInitiallyAsk: Boolean,
|
||||
val onRequest: () -> Unit,
|
||||
val onAllow: () -> Unit,
|
||||
val onDeny: () -> Unit,
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ private fun PushNotificationsSheetContent(content: PushNotificationsBottomSheetC
|
|||
val isClicked = remember { mutableStateOf(false) }
|
||||
val requestPushPermission = requestPushPermission(
|
||||
pushPermission = getPushPermissionOrNull(),
|
||||
isFirstTimeAsking = content.isFirstTimeAsking,
|
||||
isFirstTimeAsking = content.isFirstTimeRequested,
|
||||
isClicked = isClicked,
|
||||
onAllow = {
|
||||
content.onAllow()
|
||||
|
|
@ -78,7 +78,11 @@ private fun PushNotificationsSheetContent(content: PushNotificationsBottomSheetC
|
|||
),
|
||||
) {
|
||||
SecondaryButton(
|
||||
text = stringResource(R.string.common_later),
|
||||
text = if (content.wasInitiallyAsk) {
|
||||
stringResource(R.string.common_later)
|
||||
} else {
|
||||
stringResource(R.string.common_cancel)
|
||||
},
|
||||
onClick = {
|
||||
content.onDeny()
|
||||
onDismiss()
|
||||
|
|
@ -106,7 +110,8 @@ private fun PushNotificationsSheetContent_Preview() {
|
|||
TangemThemePreview {
|
||||
PushNotificationsSheetContent(
|
||||
PushNotificationsBottomSheetConfig(
|
||||
isFirstTimeAsking = false,
|
||||
isFirstTimeRequested = false,
|
||||
wasInitiallyAsk = false,
|
||||
onRequest = {},
|
||||
onAllow = {},
|
||||
onDeny = {},
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import kotlinx.coroutines.withContext
|
|||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@Suppress("LongParameterList", "LargeClass")
|
||||
@HiltViewModel
|
||||
internal class WalletViewModel @Inject constructor(
|
||||
private val stateHolder: WalletStateController,
|
||||
|
|
@ -157,21 +157,23 @@ internal class WalletViewModel @Inject constructor(
|
|||
|
||||
delay(timeMillis = 1_800)
|
||||
|
||||
val isFirstTimeAsking = isFirstTimeAskingPermissionUseCase(PUSH_PERMISSION).getOrElse { true }
|
||||
val isFirstTimeRequested = isFirstTimeAskingPermissionUseCase(PUSH_PERMISSION).getOrElse { true }
|
||||
val wasInitiallyAsk = shouldInitiallyAskPermissionUseCase(PUSH_PERMISSION).getOrElse { true }
|
||||
val onDenyClick: () -> Unit = if (wasInitiallyAsk) {
|
||||
clickIntents::onDelayAskPushPermission
|
||||
} else {
|
||||
clickIntents::onNeverAskPushPermission
|
||||
clickIntents::onDenyPushPermission
|
||||
}
|
||||
stateHolder.showBottomSheet(
|
||||
PushNotificationsBottomSheetConfig(
|
||||
isFirstTimeAsking = isFirstTimeAsking,
|
||||
content = PushNotificationsBottomSheetConfig(
|
||||
isFirstTimeRequested = isFirstTimeRequested,
|
||||
wasInitiallyAsk = wasInitiallyAsk,
|
||||
onRequest = clickIntents::onRequestPushPermission,
|
||||
onAllow = clickIntents::onNeverAskPushPermission,
|
||||
onAllow = clickIntents::onAllowPushPermission,
|
||||
onDeny = onDenyClick,
|
||||
openSettings = settingsManager::openSettings,
|
||||
),
|
||||
onDismiss = onDenyClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ internal interface WalletPushPermissionClickIntents {
|
|||
|
||||
fun onDelayAskPushPermission()
|
||||
|
||||
fun onNeverAskPushPermission()
|
||||
fun onDenyPushPermission()
|
||||
|
||||
fun onAllowPushPermission()
|
||||
}
|
||||
|
||||
@ViewModelScoped
|
||||
|
|
@ -36,7 +38,13 @@ internal class WalletPushPermissionClickIntentsImplementor @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onNeverAskPushPermission() {
|
||||
override fun onDenyPushPermission() {
|
||||
viewModelScope.launch {
|
||||
neverRequestPermissionUseCase(PUSH_PERMISSION)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAllowPushPermission() {
|
||||
viewModelScope.launch {
|
||||
neverRequestPermissionUseCase(PUSH_PERMISSION)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue