Updated on 2026-08-14

This commit is contained in:
Tangem 2023-09-26 00:36:00 +04:00
parent d1c77b00cf
commit 7805d46f92
48 changed files with 279 additions and 260 deletions

View file

@ -3,6 +3,7 @@ package com.tangem.tap
import android.app.Application
import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.os.Bundle
import android.view.View
import androidx.activity.viewModels
@ -238,6 +239,7 @@ class MainActivity : AppCompatActivity(), SnackbarHandler, ActivityResultCallbac
is GlobalSettingsState.Content -> {
if (isDarkThemeFeatureEnabled(application)) {
MutableAppThemeModeHolder.value = state.appThemeMode
MutableAppThemeModeHolder.isDarkThemeActive = isDarkTheme()
val mode = when (state.appThemeMode) {
AppThemeMode.FORCE_DARK -> AppCompatDelegate.MODE_NIGHT_YES
@ -255,6 +257,18 @@ class MainActivity : AppCompatActivity(), SnackbarHandler, ActivityResultCallbac
.launchIn(lifecycleScope)
}
private fun isDarkTheme(): Boolean {
return when (
resources.configuration.uiMode and
Configuration.UI_MODE_NIGHT_MASK
) {
Configuration.UI_MODE_NIGHT_YES -> true
Configuration.UI_MODE_NIGHT_NO -> false
Configuration.UI_MODE_NIGHT_UNDEFINED -> false
else -> false
}
}
private fun systemActions() {
WindowCompat.setDecorFitsSystemWindows(window, false)

View file

@ -14,4 +14,6 @@ internal object MutableAppThemeModeHolder : AppThemeModeHolder {
appThemeMode.value = value
}
get() = appThemeMode.value
var isDarkThemeActive: Boolean = false
}

View file

@ -7,6 +7,7 @@ import com.tangem.blockchain.common.WalletManager
import com.tangem.common.services.Result
import com.tangem.domain.common.extensions.amountToCreateAccount
import com.tangem.tap.common.TestActions
import com.tangem.tap.common.apptheme.MutableAppThemeModeHolder
import com.tangem.tap.domain.TapError
import com.tangem.tap.domain.getFirstToken
import com.tangem.tap.domain.model.WalletDataModel
@ -71,6 +72,7 @@ fun WalletManager.getTopUpUrl(): String? {
cryptoCurrencyName = wallet.blockchain.currency,
fiatCurrencyName = globalState.appCurrency.code,
walletAddress = defaultAddress,
isDarkTheme = MutableAppThemeModeHolder.isDarkThemeActive,
)
}

View file

@ -2,6 +2,7 @@ package com.tangem.tap.common.ui
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.tap.common.redux.global.GlobalAction
import com.tangem.tap.store
import com.tangem.wallet.R
@ -39,7 +40,7 @@ object SimpleCancelableAlertDialog {
secondaryButtonAction: () -> Unit = {},
context: Context,
): AlertDialog {
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(titleRes?.let { context.getString(it) } ?: title)
setMessage(messageRes?.let { context.getString(it) } ?: message)
setPositiveButton(context.getText(primaryButtonRes)) { _, _ -> primaryButtonAction() }

View file

@ -91,7 +91,7 @@ internal fun AddCustomTokenTestContent(state: AddCustomTokenStateHolder.TestCont
floatingActionButtonPosition = FabPosition.Center,
sheetBackgroundColor = TangemTheme.colors.background.secondary,
sheetPeekHeight = TangemTheme.dimens.size0,
backgroundColor = TangemTheme.colors.background.secondary,
backgroundColor = TangemTheme.colors.background.primary,
) {
Column(
modifier = Modifier

View file

@ -1,11 +1,9 @@
package com.tangem.tap.features.customtoken.impl.presentation.ui.components
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.width
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
@ -25,9 +23,14 @@ import com.tangem.tap.features.details.ui.cardsettings.resolveReference
*/
@Composable
internal fun AddCustomTokenToolbar(title: TextReference, onBackButtonClick: () -> Unit) {
val toolbarElevation = if (isSystemInDarkTheme()) {
TangemTheme.dimens.elevation0
} else {
AppBarDefaults.TopAppBarElevation
}
TopAppBar(
backgroundColor = TangemTheme.colors.background.secondary,
elevation = TangemTheme.dimens.elevation0,
backgroundColor = TangemTheme.colors.background.primary,
elevation = toolbarElevation,
) {
IconButton(onClick = onBackButtonClick) {
Icon(

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.details.ui.walletconnect.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.blockchain.common.Blockchain
import com.tangem.tap.common.redux.global.GlobalAction
import com.tangem.tap.features.details.redux.walletconnect.WalletConnectAction
@ -18,7 +19,7 @@ object ApproveWcSessionDialog {
sessionBlockchain.fullName,
session.peerMeta.url,
)
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(context.getString(R.string.wallet_connect_title))
setMessage(message)
setPositiveButton(context.getText(R.string.common_start)) { _, _ ->

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.details.ui.walletconnect.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.tap.common.redux.global.GlobalAction
import com.tangem.tap.domain.walletconnect2.domain.WcPreparedRequest
import com.tangem.tap.features.details.redux.walletconnect.BinanceMessageData
@ -37,7 +38,7 @@ object BnbTransactionDialog {
)
val positiveButtonTitle = context.getText(R.string.common_sign)
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(context.getString(R.string.wallet_connect_title))
setMessage(fullMessage)
setPositiveButton(positiveButtonTitle) { _, _ ->

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.details.ui.walletconnect.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.blockchain.common.Blockchain
import com.tangem.tap.common.redux.global.GlobalAction
import com.tangem.tap.features.details.redux.walletconnect.WalletConnectAction
@ -11,7 +12,7 @@ import com.tangem.wallet.R
object ChooseNetworkDialog {
fun create(session: WalletConnectSession, networks: List<Blockchain>, context: Context): AlertDialog {
return AlertDialog.Builder(context)
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog)
.setTitle(context.getString(R.string.wallet_connect_select_network))
.setNegativeButton(context.getString(R.string.common_cancel)) { _, _ ->
store.dispatch(WalletConnectAction.FailureEstablishingSession(session.session))

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.details.ui.walletconnect.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.core.navigation.AppScreen
import com.tangem.core.navigation.NavigationAction
import com.tangem.tap.common.redux.global.GlobalAction
@ -11,7 +12,7 @@ import com.tangem.wallet.R
object ClipboardOrScanQrDialog {
fun create(wcUri: String, context: Context): AlertDialog {
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(context.getString(R.string.common_select_action))
setMessage(context.getText(R.string.wallet_connect_clipboard_alert))
setPositiveButton(context.getText(R.string.wallet_connect_paste_from_clipboard)) { _, _ ->

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.details.ui.walletconnect.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.tap.common.redux.global.GlobalAction
import com.tangem.tap.domain.walletconnect2.domain.WcPreparedRequest
import com.tangem.tap.features.details.redux.walletconnect.WalletConnectAction
@ -12,7 +13,7 @@ object PersonalSignDialog {
fun create(preparedData: WcPreparedRequest.EthSign, context: Context): AlertDialog {
val data = preparedData.preparedRequestData.dialogData
val message = context.getString(R.string.wallet_connect_alert_sign_message, data.message)
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(context.getString(R.string.wallet_connect_title))
setMessage(message)
setPositiveButton(context.getText(R.string.common_sign)) { _, _ ->

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.details.ui.walletconnect.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.tap.common.redux.global.GlobalAction
import com.tangem.tap.domain.walletconnect2.domain.models.WalletConnectEvents
import com.tangem.tap.store
@ -21,7 +22,7 @@ object SessionProposalDialog {
networks,
sessionProposal.url,
)
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(context.getString(R.string.wallet_connect_title))
setMessage(message)
setPositiveButton(context.getText(R.string.common_start)) { _, _ ->

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.details.ui.walletconnect.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.tap.common.redux.global.GlobalAction
import com.tangem.tap.domain.walletconnect2.domain.WcPreparedRequest
import com.tangem.tap.features.details.redux.walletconnect.WalletConnectAction
@ -26,7 +27,7 @@ object TransactionDialog {
WcEthTransactionType.EthSignTransaction -> context.getText(R.string.common_sign)
WcEthTransactionType.EthSendTransaction -> context.getText(R.string.common_sign_and_send)
}
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(context.getString(R.string.wallet_connect_title))
setMessage(message)
setPositiveButton(positiveButtonTitle) { _, _ ->

View file

@ -5,7 +5,6 @@ import android.util.TypedValue
import android.view.View
import android.view.animation.OvershootInterpolator
import androidx.annotation.LayoutRes
import androidx.appcompat.content.res.AppCompatResources
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.view.isVisible
import androidx.transition.TransitionManager
@ -194,11 +193,7 @@ class TwinsCardsFragment : BaseOnboardingFragment<TwinCardsState>() {
)
btnMainAction.setText(R.string.common_continue)
btnMainAction.icon = when (state.currentStep) {
is TwinCardsStep.WelcomeOnly -> null
is TwinCardsStep.Welcome -> AppCompatResources.getDrawable(requireContext(), R.drawable.ic_tangem_24)
else -> null
}
btnMainAction.icon = null
btnMainAction.setOnClickListener { onMainButtonClick() }
}
@ -346,7 +341,6 @@ class TwinsCardsFragment : BaseOnboardingFragment<TwinCardsState>() {
btnMainAction.setOnClickListener {
store.dispatch(TwinCardsAction.TopUp)
}
btnAlternativeAction.isVisible = true
btnAlternativeAction.setText(R.string.onboarding_top_up_button_show_wallet_address)
btnAlternativeAction.setOnClickListener {
@ -354,7 +348,6 @@ class TwinsCardsFragment : BaseOnboardingFragment<TwinCardsState>() {
}
} else {
btnMainAction.setText(R.string.onboarding_button_receive_crypto)
btnMainAction.icon = null
btnMainAction.setOnClickListener {
store.dispatch(TwinCardsAction.ShowAddressInfoDialog)
}
@ -364,6 +357,7 @@ class TwinsCardsFragment : BaseOnboardingFragment<TwinCardsState>() {
tvHeader.setText(R.string.onboarding_topup_title)
tvBody.setText(R.string.onboarding_top_up_body)
btnMainAction.icon = null
btnRefreshBalanceWidget.changeState(state.walletBalance.state)
if (btnRefreshBalanceWidget.isShowing != true) {

View file

@ -12,7 +12,7 @@ import com.tangem.wallet.R
*/
object TwinningProcessNotCompletedDialog {
fun create(context: Context): AlertDialog {
return MaterialAlertDialogBuilder(context)
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog)
.setMessage(R.string.onboarding_twin_exit_warning)
.setPositiveButton(R.string.warning_button_ok) { _, _ -> }
.setOnDismissListener { store.dispatchDialogHide() }

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.onboarding.products.wallet.ui.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.tap.common.redux.global.GlobalAction
import com.tangem.tap.features.onboarding.products.wallet.redux.BackupAction
import com.tangem.tap.store
@ -9,7 +10,7 @@ import com.tangem.wallet.R
object AddMoreBackupCardsDialog {
fun create(context: Context): AlertDialog {
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(R.string.common_warning)
setMessage(R.string.onboarding_alert_message_not_max_backup_cards_added)
setPositiveButton(R.string.common_continue) { _, _ ->

View file

@ -2,13 +2,14 @@ package com.tangem.tap.features.onboarding.products.wallet.ui.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.tap.common.redux.global.GlobalAction
import com.tangem.tap.store
import com.tangem.wallet.R
object BackupInProgressDialog {
fun create(context: Context): AlertDialog {
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(R.string.common_warning)
setMessage(R.string.onboarding_backup_exit_warning)
setPositiveButton(R.string.warning_button_ok) { _, _ ->

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.onboarding.products.wallet.ui.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.tap.common.redux.global.GlobalAction
import com.tangem.tap.features.onboarding.products.wallet.redux.BackupAction
import com.tangem.tap.store
@ -9,7 +10,7 @@ import com.tangem.wallet.R
object ConfirmDiscardingBackupDialog {
fun create(context: Context): AlertDialog {
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(R.string.welcome_interrupted_backup_discard_title)
setMessage(R.string.welcome_interrupted_backup_discard_message)
setPositiveButton(R.string.welcome_interrupted_backup_discard_resume) { _, _ ->

View file

@ -2,7 +2,7 @@ package com.tangem.tap.features.onboarding.products.wallet.ui.dialogs
import android.app.Dialog
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.tap.common.extensions.dispatchDialogHide
import com.tangem.tap.features.onboarding.OnboardingDialog
import com.tangem.tap.store
@ -13,7 +13,7 @@ import com.tangem.wallet.R
*/
object InterruptOnboardingDialog {
fun create(context: Context, dialog: OnboardingDialog.InterruptOnboarding): Dialog {
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(context.getString(R.string.onboarding_exit_alert_title))
setMessage(context.getString(R.string.onboarding_exit_alert_message))
setPositiveButton(R.string.common_ok) { _, _ -> dialog.onOk() }

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.onboarding.products.wallet.ui.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.core.analytics.Analytics
import com.tangem.tap.common.analytics.events.Onboarding
import com.tangem.tap.common.redux.global.GlobalAction
@ -11,7 +12,7 @@ import com.tangem.wallet.R
object ResetBackupCardDialog {
fun create(context: Context, cardId: String): AlertDialog {
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(R.string.common_attention)
setMessage(R.string.onboarding_linking_error_card_with_wallets)
setPositiveButton(R.string.common_cancel) { _, _ ->

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.onboarding.products.wallet.ui.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.tap.common.redux.global.GlobalAction
import com.tangem.tap.features.onboarding.products.wallet.redux.BackupAction
import com.tangem.tap.features.onboarding.products.wallet.redux.BackupDialog
@ -10,7 +11,7 @@ import com.tangem.wallet.R
object UnfinishedBackupFoundDialog {
fun create(context: Context): AlertDialog {
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(R.string.common_warning)
setMessage(R.string.welcome_interrupted_backup_alert_message)
setPositiveButton(R.string.welcome_interrupted_backup_alert_resume) { _, _ ->

View file

@ -82,7 +82,7 @@ internal fun BriefNetworkItem(model: NetworkItemState, modifier: Modifier = Modi
.align(Alignment.TopEnd)
.size(TangemTheme.dimens.size7)
.clip(CircleShape)
.background(TangemTheme.colors.background.secondary),
.background(TangemTheme.colors.background.primary),
contentAlignment = Alignment.Center,
) {
Box(

View file

@ -43,7 +43,7 @@ internal fun TokenItem(model: TokenItemState) {
ConstraintLayout(
modifier = Modifier
.fillMaxWidth()
.background(color = TangemTheme.colors.background.secondary)
.background(color = TangemTheme.colors.background.primary)
.padding(top = TangemTheme.dimens.spacing16),
) {
val (icon, title, availableNetworksText) = createRefs()
@ -128,7 +128,7 @@ internal fun TokenItem(model: TokenItemState) {
@Composable
private fun Icon(name: String, iconUrl: String, onContrastCalculate: (Color) -> Unit, modifier: Modifier = Modifier) {
val iconModifier = modifier.size(size = TangemTheme.dimens.size46)
val screenBackgroundColor = TangemTheme.colors.background.secondary.toArgb()
val screenBackgroundColor = TangemTheme.colors.background.primary.toArgb()
val isDarkTheme = isSystemInDarkTheme()
SubcomposeAsyncImage(

View file

@ -72,7 +72,7 @@ internal fun TokensListScreen(stateHolder: TokensListStateHolder, modifier: Modi
}
},
floatingActionButtonPosition = FabPosition.Center,
backgroundColor = TangemTheme.colors.background.secondary,
backgroundColor = TangemTheme.colors.background.primary,
) { scaffoldPadding ->
val tokens = stateHolder.tokens.collectAsLazyPagingItems()
@ -100,7 +100,7 @@ private fun LoadingContent() {
Box(
modifier = Modifier
.fillMaxSize()
.background(color = TangemTheme.colors.background.secondary),
.background(color = TangemTheme.colors.background.primary),
contentAlignment = Alignment.Center,
) {
CircularProgressIndicator(color = TangemTheme.colors.icon.accent)

View file

@ -1,5 +1,6 @@
package com.tangem.tap.features.tokens.impl.presentation.ui
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
@ -7,10 +8,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
@ -38,9 +36,14 @@ import kotlinx.coroutines.delay
*/
@Composable
internal fun TokensListToolbar(state: TokensListToolbarState) {
val toolbarElevation = if (isSystemInDarkTheme()) {
TangemTheme.dimens.elevation0
} else {
AppBarDefaults.TopAppBarElevation
}
TopAppBar(
backgroundColor = TangemTheme.colors.background.secondary,
elevation = TangemTheme.dimens.elevation0,
elevation = toolbarElevation,
) {
IconButton(onClick = state.onBackButtonClick) {
Icon(

View file

@ -17,6 +17,7 @@ import com.tangem.domain.tokens.model.Network
import com.tangem.feature.swap.presentation.SwapFragment
import com.tangem.tap.common.analytics.events.AnalyticsParam
import com.tangem.tap.common.analytics.events.Token
import com.tangem.tap.common.apptheme.MutableAppThemeModeHolder
import com.tangem.tap.common.extensions.dispatchDebugErrorNotification
import com.tangem.tap.common.extensions.dispatchErrorNotification
import com.tangem.tap.common.extensions.dispatchOnMain
@ -112,6 +113,7 @@ class TradeCryptoMiddleware {
cryptoCurrencyName = currency.currencySymbol,
fiatCurrencyName = appCurrency.code,
walletAddress = addresses[0].address,
isDarkTheme = MutableAppThemeModeHolder.isDarkThemeActive,
)?.let {
store.dispatchOpenUrl(it)
Analytics.send(Token.Topup.ScreenOpened())
@ -131,6 +133,7 @@ class TradeCryptoMiddleware {
cryptoCurrencyName = currency.symbol,
fiatCurrencyName = action.appCurrencyCode,
walletAddress = networkAddress,
isDarkTheme = MutableAppThemeModeHolder.isDarkThemeActive,
)
if (action.checkUserLocation && state()?.globalState?.userCountryCode == RUSSIA_COUNTRY_CODE) {
@ -193,6 +196,7 @@ class TradeCryptoMiddleware {
cryptoCurrencyName = currency.currencySymbol,
fiatCurrencyName = appCurrency.code,
walletAddress = addresses[0].address,
isDarkTheme = MutableAppThemeModeHolder.isDarkThemeActive,
)?.let {
store.dispatchOpenUrl(it)
Analytics.send(Token.Withdraw.ScreenOpened())
@ -209,6 +213,7 @@ class TradeCryptoMiddleware {
cryptoCurrencyName = currency.symbol,
fiatCurrencyName = action.appCurrencyCode,
walletAddress = networkAddress,
isDarkTheme = MutableAppThemeModeHolder.isDarkThemeActive,
)?.let {
store.dispatchOpenUrl(it)
Analytics.send(Token.Withdraw.ScreenOpened())

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.wallet.ui.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.core.analytics.Analytics
import com.tangem.tap.common.analytics.events.IntroductionProcess
import com.tangem.tap.common.extensions.dispatchDialogHide
@ -15,7 +16,7 @@ import com.tangem.wallet.R
*/
object ScanFailsDialog {
fun create(context: Context): AlertDialog {
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(context.getString(R.string.common_warning))
setMessage(R.string.alert_troubleshooting_scan_card_title)
setPositiveButton(R.string.alert_button_request_support) { _, _ ->

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.wallet.ui.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.tap.common.redux.global.GlobalAction
import com.tangem.tap.domain.configurable.warningMessage.WarningMessagesManager
import com.tangem.tap.features.wallet.redux.WalletAction
@ -10,7 +11,7 @@ import com.tangem.wallet.R
object SignedHashesWarningDialog {
fun create(context: Context): AlertDialog {
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(context.getString(R.string.warning_important_security_info, "\u26A0"))
setMessage(R.string.alert_signed_hashes_message)
setPositiveButton(R.string.common_understand) { _, _ ->

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.wallet.ui.dialogs
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.tap.common.extensions.dispatchDialogHide
import com.tangem.tap.common.redux.AppDialog
import com.tangem.tap.store
@ -13,7 +14,7 @@ import com.tangem.wallet.R
object SimpleOkDialog {
fun create(dialog: AppDialog.SimpleOkDialog, context: Context): AlertDialog {
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(dialog.header)
setMessage(dialog.message)
setPositiveButton(R.string.common_ok) { _, _ -> }
@ -60,7 +61,7 @@ object SimpleOkDialog {
)
fun create(dialog: AppDialog.OkCancelDialogRes, context: Context): AlertDialog {
return AlertDialog.Builder(context).apply {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(context.getString(dialog.headerId))
setMessage(dialog.messageId)
setPositiveButton(dialog.okButton.title) { _, _ -> dialog.okButton.action?.invoke() }

View file

@ -2,6 +2,7 @@ package com.tangem.tap.features.wallet.ui.wallet
import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tangem.tap.features.wallet.redux.WalletAction
import com.tangem.tap.features.wallet.redux.models.WalletDialog
import com.tangem.tap.store
@ -15,7 +16,7 @@ object CurrencySelectionDialog {
val currentSelection = dialog.currenciesList
.indexOfFirst { it.code == dialog.currentAppCurrency.code }
return AlertDialog.Builder(context)
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog)
.setTitle(context.getString(R.string.details_row_title_currency))
.setNegativeButton(context.getString(R.string.common_cancel)) { _, _ -> /* no-op */ }
.setOnDismissListener {

View file

@ -42,8 +42,16 @@ internal class BuyExchangeService(
cryptoCurrencyName: String,
fiatCurrencyName: String,
walletAddress: String,
isDarkTheme: Boolean,
): String? {
return currentService.getUrl(action, blockchain, cryptoCurrencyName, fiatCurrencyName, walletAddress)
return currentService.getUrl(
action,
blockchain,
cryptoCurrencyName,
fiatCurrencyName,
walletAddress,
isDarkTheme,
)
}
override fun getSellCryptoReceiptUrl(action: CurrencyExchangeManager.Action, transactionId: String): String? {

View file

@ -50,6 +50,7 @@ class CurrencyExchangeManager(
cryptoCurrencyName: CryptoCurrencyName,
fiatCurrencyName: String,
walletAddress: String,
isDarkTheme: Boolean,
): String? {
if (blockchain.isTestnet()) return blockchain.getTestnetTopUpUrl()
@ -60,6 +61,7 @@ class CurrencyExchangeManager(
cryptoCurrencyName,
fiatCurrencyName,
walletAddress,
isDarkTheme,
)
}

View file

@ -28,6 +28,7 @@ interface ExchangeService : Feature, Exchanger, ExchangeUrlBuilder {
cryptoCurrencyName: String,
fiatCurrencyName: String,
walletAddress: String,
isDarkTheme: Boolean,
): String? = null
override fun getSellCryptoReceiptUrl(
@ -52,12 +53,14 @@ interface ExchangeRules : Feature, Exchanger {
}
interface ExchangeUrlBuilder {
@Suppress("LongParameterList")
fun getUrl(
action: CurrencyExchangeManager.Action,
blockchain: Blockchain,
cryptoCurrencyName: String,
fiatCurrencyName: String,
walletAddress: String,
isDarkTheme: Boolean,
): String?
fun getSellCryptoReceiptUrl(action: CurrencyExchangeManager.Action, transactionId: String): String?

View file

@ -79,6 +79,7 @@ internal class MercuryoService(private val environment: MercuryoEnvironment) : E
cryptoCurrencyName: CryptoCurrencyName,
fiatCurrencyName: String,
walletAddress: String,
isDarkTheme: Boolean,
): String {
if (action == CurrencyExchangeManager.Action.Sell) throw UnsupportedOperationException()
@ -92,6 +93,7 @@ internal class MercuryoService(private val environment: MercuryoEnvironment) : E
.appendQueryParameter("signature", signature(walletAddress))
.appendQueryParameter("fix_currency", "true")
.appendQueryParameter("return_url", ExchangeUrlBuilder.SUCCESS_URL)
if (isDarkTheme) builder.appendQueryParameter("theme", "1inch")
return builder.build().toString()
}

View file

@ -102,6 +102,7 @@ class MoonPayService(
cryptoCurrencyName: CryptoCurrencyName,
fatCurrency: String,
walletAddress: String,
isDarkTheme: Boolean,
): String {
if (action == CurrencyExchangeManager.Action.Buy) throw UnsupportedOperationException()
@ -112,6 +113,7 @@ class MoonPayService(
.appendQueryParameter("baseCurrencyCode", cryptoCurrencyName)
.appendQueryParameter("refundWalletAddress", walletAddress)
.appendQueryParameter("redirectURL", "tangem://sell-request.tangem.com")
if (isDarkTheme) uri.appendQueryParameter("theme", "dark")
val originalQuery = uri.build().encodedQuery ?: uri.build().toString()
val signature = createSignature(originalQuery)