Updated on 2026-08-14
This commit is contained in:
parent
690f6689dc
commit
202aa790c4
17 changed files with 171 additions and 51 deletions
|
|
@ -31,6 +31,7 @@ fun AccountTitle(
|
|||
modifier: Modifier = Modifier,
|
||||
textStyle: TextStyle = TangemTheme.typography.subtitle2,
|
||||
textColor: Color = TangemTheme.colors.text.tertiary,
|
||||
iconSize: AccountIconSize = AccountIconSize.ExtraSmall,
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
|
|
@ -47,7 +48,7 @@ fun AccountTitle(
|
|||
AccountLabel(
|
||||
name = accountTitleUM.name,
|
||||
icon = accountTitleUM.icon,
|
||||
iconSize = AccountIconSize.ExtraSmall,
|
||||
iconSize = iconSize,
|
||||
nameStyle = textStyle,
|
||||
nameColor = textColor,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.walletconnect.transaction.converter
|
||||
|
||||
import com.tangem.common.ui.account.AccountTitleUM
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcAddNetworkUseCase
|
||||
import com.tangem.features.walletconnect.transaction.entity.chain.WcAddEthereumChainItemUM
|
||||
import com.tangem.features.walletconnect.transaction.entity.chain.WcAddEthereumChainUM
|
||||
|
|
@ -24,7 +25,7 @@ internal class WcAddEthereumChainUMConverter @Inject constructor(
|
|||
onShowVerifiedAlert = value.actions.onShowVerifiedAlert,
|
||||
),
|
||||
),
|
||||
walletName = value.useCase.session.wallet.name,
|
||||
portfolioName = value.portfolioName,
|
||||
isLoading = false,
|
||||
),
|
||||
transactionRequestInfo = WcTransactionRequestInfoUM(
|
||||
|
|
@ -36,6 +37,7 @@ internal class WcAddEthereumChainUMConverter @Inject constructor(
|
|||
|
||||
data class Input(
|
||||
val useCase: WcAddNetworkUseCase,
|
||||
val portfolioName: AccountTitleUM?,
|
||||
val actions: WcTransactionActionsUM,
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.tangem.features.walletconnect.transaction.converter
|
||||
|
||||
import com.tangem.common.ui.account.AccountTitleUM
|
||||
import com.tangem.common.ui.account.toUM
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.domain.account.usecase.IsAccountsModeEnabledUseCase
|
||||
import com.tangem.domain.models.account.Account
|
||||
import com.tangem.domain.walletconnect.model.WcSession
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
|
||||
internal class WcPortfolioNameDelegate @AssistedInject constructor(
|
||||
isAccountsModeEnabledUseCase: IsAccountsModeEnabledUseCase,
|
||||
@Assisted private val scope: CoroutineScope,
|
||||
) {
|
||||
val isAccountMode = isAccountsModeEnabledUseCase.invoke()
|
||||
.stateIn(scope = scope, started = SharingStarted.Eagerly, initialValue = false)
|
||||
|
||||
fun createAccountTitleUM(value: WcSession): AccountTitleUM? {
|
||||
val account = when (val account = value.account) {
|
||||
is Account.CryptoPortfolio -> account
|
||||
null -> null
|
||||
}
|
||||
|
||||
return if (account != null && isAccountMode.value) {
|
||||
AccountTitleUM.Account(
|
||||
prefixText = TextReference.EMPTY,
|
||||
name = account.accountName.toUM().value,
|
||||
icon = account.icon.toUM(),
|
||||
)
|
||||
} else {
|
||||
AccountTitleUM.Text(stringReference(value.wallet.name))
|
||||
.takeIf { value.showWalletInfo }
|
||||
}
|
||||
}
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
fun create(scope: CoroutineScope): WcPortfolioNameDelegate
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.walletconnect.transaction.converter
|
||||
|
||||
import com.tangem.common.ui.account.AccountTitleUM
|
||||
import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
||||
import com.tangem.domain.walletconnect.model.WcEthMethod
|
||||
import com.tangem.domain.walletconnect.model.WcSolanaMethod
|
||||
|
|
@ -48,7 +49,7 @@ internal class WcSendTransactionUMConverter @Inject constructor(
|
|||
),
|
||||
),
|
||||
feeState = value.feeState,
|
||||
walletName = value.context.session.wallet.name.takeIf { value.context.session.showWalletInfo },
|
||||
portfolioName = value.portfolioName,
|
||||
networkInfo = networkInfoUMConverter.convert(value.context.network),
|
||||
estimatedWalletChanges = WcSendReceiveTransactionCheckResultsUM(),
|
||||
isLoading = value.signState.domainStep == WcSignStep.Signing,
|
||||
|
|
@ -83,6 +84,7 @@ internal class WcSendTransactionUMConverter @Inject constructor(
|
|||
|
||||
data class Input(
|
||||
val context: WcMethodContext,
|
||||
val portfolioName: AccountTitleUM?,
|
||||
val feeState: WcTransactionFeeState,
|
||||
val signState: WcSignState<*>,
|
||||
val actions: WcTransactionActionsUM,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.walletconnect.transaction.converter
|
||||
|
||||
import com.tangem.common.ui.account.AccountTitleUM
|
||||
import com.tangem.common.ui.userwallet.ext.walletInterationIcon
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcMessageSignUseCase
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcMethodContext
|
||||
|
|
@ -29,7 +30,7 @@ internal class WcSignTransactionUMConverter @Inject constructor(
|
|||
onShowVerifiedAlert = value.actions.onShowVerifiedAlert,
|
||||
),
|
||||
),
|
||||
walletName = value.context.session.wallet.name.takeIf { value.context.session.showWalletInfo },
|
||||
portfolioName = value.portfolioName,
|
||||
networkInfo = networkInfoUMConverter.convert(value.context.network),
|
||||
isLoading = value.signState.domainStep == WcSignStep.Signing,
|
||||
address = WcAddressConverter.convert(value.context.derivationState),
|
||||
|
|
@ -48,5 +49,6 @@ internal class WcSignTransactionUMConverter @Inject constructor(
|
|||
val signState: WcSignState<*>,
|
||||
val signModel: WcMessageSignUseCase.SignModel,
|
||||
val actions: WcTransactionActionsUM,
|
||||
val portfolioName: AccountTitleUM?,
|
||||
)
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.walletconnect.transaction.converter
|
||||
|
||||
import com.tangem.common.ui.account.AccountTitleUM
|
||||
import com.tangem.common.ui.userwallet.ext.walletInterationIcon
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcMessageSignUseCase
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcMethodContext
|
||||
|
|
@ -29,7 +30,7 @@ internal class WcSignTypedDataUMConverter @Inject constructor(
|
|||
onShowVerifiedAlert = value.actions.onShowVerifiedAlert,
|
||||
),
|
||||
),
|
||||
walletName = value.context.session.wallet.name.takeIf { value.context.session.showWalletInfo },
|
||||
portfolioName = value.portfolioName,
|
||||
networkInfo = networkInfoUMConverter.convert(value.context.network),
|
||||
address = WcAddressConverter.convert(value.context.derivationState),
|
||||
isLoading = value.signState.domainStep == WcSignStep.Signing,
|
||||
|
|
@ -52,5 +53,6 @@ internal class WcSignTypedDataUMConverter @Inject constructor(
|
|||
val signState: WcSignState<*>,
|
||||
val signModel: WcMessageSignUseCase.SignModel,
|
||||
val actions: WcTransactionActionsUM,
|
||||
val portfolioName: AccountTitleUM?,
|
||||
)
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.walletconnect.transaction.entity.chain
|
||||
|
||||
import com.tangem.common.ui.account.AccountTitleUM
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
import com.tangem.features.walletconnect.transaction.entity.common.WcCommonTransactionUM
|
||||
import com.tangem.features.walletconnect.transaction.entity.common.WcTransactionAppInfoContentUM
|
||||
|
|
@ -14,6 +15,6 @@ internal data class WcAddEthereumChainItemUM(
|
|||
val onDismiss: () -> Unit,
|
||||
val onSign: () -> Unit,
|
||||
val appInfo: WcTransactionAppInfoContentUM,
|
||||
val walletName: String,
|
||||
val portfolioName: AccountTitleUM?,
|
||||
val isLoading: Boolean = false,
|
||||
) : TangemBottomSheetConfigContent
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.features.walletconnect.transaction.entity.send
|
||||
|
||||
import com.domain.blockaid.models.transaction.ValidationResult
|
||||
import com.tangem.common.ui.account.AccountTitleUM
|
||||
import com.tangem.common.ui.notifications.NotificationUM
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
import com.tangem.features.send.v2.api.entity.FeeSelectorUM
|
||||
|
|
@ -25,7 +26,7 @@ internal data class WcSendTransactionItemUM(
|
|||
val onSend: () -> Unit,
|
||||
val appInfo: WcTransactionAppInfoContentUM,
|
||||
val estimatedWalletChanges: WcSendReceiveTransactionCheckResultsUM?,
|
||||
val walletName: String?,
|
||||
val portfolioName: AccountTitleUM?,
|
||||
val networkInfo: WcNetworkInfoUM,
|
||||
val address: String?,
|
||||
val transactionValidationResult: ValidationResult?,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.walletconnect.transaction.entity.sign
|
||||
|
||||
import com.tangem.common.ui.account.AccountTitleUM
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
import com.tangem.features.walletconnect.transaction.entity.common.WcCommonTransactionUM
|
||||
import com.tangem.features.walletconnect.transaction.entity.common.WcNetworkInfoUM
|
||||
|
|
@ -15,7 +16,7 @@ internal data class WcSignTransactionItemUM(
|
|||
val onDismiss: () -> Unit,
|
||||
val onSign: () -> Unit,
|
||||
val appInfo: WcTransactionAppInfoContentUM,
|
||||
val walletName: String?,
|
||||
val portfolioName: AccountTitleUM?,
|
||||
val networkInfo: WcNetworkInfoUM,
|
||||
val address: String?,
|
||||
val walletInteractionIcon: Int?,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.tangem.domain.walletconnect.usecase.method.WcAddNetworkUseCase
|
|||
import com.tangem.features.walletconnect.transaction.components.common.WcTransactionModelParams
|
||||
import com.tangem.features.walletconnect.transaction.converter.WcAddEthereumChainUMConverter
|
||||
import com.tangem.features.walletconnect.transaction.converter.WcHandleMethodErrorConverter
|
||||
import com.tangem.features.walletconnect.transaction.converter.WcPortfolioNameDelegate
|
||||
import com.tangem.features.walletconnect.transaction.entity.chain.WcAddEthereumChainUM
|
||||
import com.tangem.features.walletconnect.transaction.entity.common.WcCommonTransactionModel
|
||||
import com.tangem.features.walletconnect.transaction.entity.common.WcTransactionActionsUM
|
||||
|
|
@ -34,6 +35,7 @@ import kotlin.properties.Delegates
|
|||
@ModelScoped
|
||||
internal class WcAddNetworkModel @Inject constructor(
|
||||
paramsContainer: ParamsContainer,
|
||||
portfolioNameDelegateFactory: WcPortfolioNameDelegate.Factory,
|
||||
override val messageSender: UiMessageSender,
|
||||
override val dispatchers: CoroutineDispatcherProvider,
|
||||
private val router: Router,
|
||||
|
|
@ -48,6 +50,7 @@ internal class WcAddNetworkModel @Inject constructor(
|
|||
|
||||
val stackNavigation = StackNavigation<WcTransactionRoutes>()
|
||||
|
||||
private val portfolioNameDelegate = portfolioNameDelegateFactory.create(modelScope)
|
||||
private val params = paramsContainer.require<WcTransactionModelParams>()
|
||||
private var useCase by Delegates.notNull<WcAddNetworkUseCase>()
|
||||
private val signatureReceivedAnalyticsSendState = MutableStateFlow(false)
|
||||
|
|
@ -71,6 +74,7 @@ internal class WcAddNetworkModel @Inject constructor(
|
|||
_uiState.value = wcAddEthereumChainUMConverter.convert(
|
||||
WcAddEthereumChainUMConverter.Input(
|
||||
useCase = useCase,
|
||||
portfolioName = portfolioNameDelegate.createAccountTitleUM(useCase.session),
|
||||
actions = WcTransactionActionsUM(
|
||||
onShowVerifiedAlert = ::showVerifiedAlert,
|
||||
onDismiss = { cancel(useCase) },
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import com.tangem.features.walletconnect.connections.routing.WcInnerRoute
|
|||
import com.tangem.features.walletconnect.impl.R
|
||||
import com.tangem.features.walletconnect.transaction.components.common.WcTransactionModelParams
|
||||
import com.tangem.features.walletconnect.transaction.converter.WcHandleMethodErrorConverter
|
||||
import com.tangem.features.walletconnect.transaction.converter.WcPortfolioNameDelegate
|
||||
import com.tangem.features.walletconnect.transaction.converter.WcSendTransactionUMConverter
|
||||
import com.tangem.features.walletconnect.transaction.entity.blockaid.WcSendReceiveTransactionCheckResultsUM
|
||||
import com.tangem.features.walletconnect.transaction.entity.common.WcCommonTransactionModel
|
||||
|
|
@ -69,6 +70,7 @@ import kotlin.properties.Delegates
|
|||
@ModelScoped
|
||||
internal class WcSendTransactionModel @Inject constructor(
|
||||
paramsContainer: ParamsContainer,
|
||||
portfolioNameDelegateFactory: WcPortfolioNameDelegate.Factory,
|
||||
override val messageSender: UiMessageSender,
|
||||
override val dispatchers: CoroutineDispatcherProvider,
|
||||
private val feeSelectorReloadTrigger: FeeSelectorReloadTrigger,
|
||||
|
|
@ -90,6 +92,7 @@ internal class WcSendTransactionModel @Inject constructor(
|
|||
|
||||
val stackNavigation = StackNavigation<WcTransactionRoutes>()
|
||||
|
||||
private val portfolioNameDelegate = portfolioNameDelegateFactory.create(modelScope)
|
||||
internal var cryptoCurrencyStatus: CryptoCurrencyStatus by Delegates.notNull()
|
||||
internal var feeStateConfiguration: FeeStateConfiguration = FeeStateConfiguration.None
|
||||
private var useCase: WcSignUseCase<*> by Delegates.notNull()
|
||||
|
|
@ -276,6 +279,7 @@ internal class WcSendTransactionModel @Inject constructor(
|
|||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
onFeeReload = ::triggerFeeReload,
|
||||
securityCheck = securityCheck.getOrNull(),
|
||||
portfolioName = portfolioNameDelegate.createAccountTitleUM(useCase.session),
|
||||
),
|
||||
)
|
||||
transactionUM = transactionUM?.copy(
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.tangem.domain.walletconnect.usecase.method.WcSignStep
|
|||
import com.tangem.domain.walletconnect.usecase.method.WcSignUseCase
|
||||
import com.tangem.features.walletconnect.transaction.components.common.WcTransactionModelParams
|
||||
import com.tangem.features.walletconnect.transaction.converter.WcHandleMethodErrorConverter
|
||||
import com.tangem.features.walletconnect.transaction.converter.WcPortfolioNameDelegate
|
||||
import com.tangem.features.walletconnect.transaction.converter.WcSignTransactionUMConverter
|
||||
import com.tangem.features.walletconnect.transaction.converter.WcSignTypedDataUMConverter
|
||||
import com.tangem.features.walletconnect.transaction.entity.common.WcCommonTransactionModel
|
||||
|
|
@ -50,6 +51,7 @@ internal class WcSignTransactionModel @Inject constructor(
|
|||
private val useCaseFactory: WcRequestUseCaseFactory,
|
||||
private val signTypedDataUMConverter: WcSignTypedDataUMConverter,
|
||||
private val signTransactionUMConverter: WcSignTransactionUMConverter,
|
||||
portfolioNameDelegateFactory: WcPortfolioNameDelegate.Factory,
|
||||
) : Model(), WcCommonTransactionModel {
|
||||
|
||||
private val params = paramsContainer.require<WcTransactionModelParams>()
|
||||
|
|
@ -61,6 +63,7 @@ internal class WcSignTransactionModel @Inject constructor(
|
|||
|
||||
private var useCase by Delegates.notNull<WcMessageSignUseCase>()
|
||||
private val signatureReceivedAnalyticsSendState = MutableStateFlow(false)
|
||||
private val portfolioNameDelegate = portfolioNameDelegateFactory.create(modelScope)
|
||||
|
||||
init {
|
||||
modelScope.launch {
|
||||
|
|
@ -95,6 +98,7 @@ internal class WcSignTransactionModel @Inject constructor(
|
|||
signState = signState,
|
||||
signModel = signState.signModel,
|
||||
actions = actions,
|
||||
portfolioName = portfolioNameDelegate.createAccountTitleUM(useCase.session),
|
||||
),
|
||||
)
|
||||
is WcEthMethod.MessageSign, is WcSolanaMethod.SignMessage -> signTransactionUMConverter.convert(
|
||||
|
|
@ -103,6 +107,7 @@ internal class WcSignTransactionModel @Inject constructor(
|
|||
signState = signState,
|
||||
signModel = signState.signModel,
|
||||
actions = actions,
|
||||
portfolioName = portfolioNameDelegate.createAccountTitleUM(useCase.session),
|
||||
),
|
||||
)
|
||||
else -> null
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@ import com.tangem.features.walletconnect.transaction.entity.common.WcTransaction
|
|||
import com.tangem.features.walletconnect.transaction.ui.common.WcSimpleConfirmButtons
|
||||
import com.tangem.features.walletconnect.transaction.ui.common.WcSmallTitleItem
|
||||
import com.tangem.features.walletconnect.transaction.ui.common.WcTransactionRequestItem
|
||||
import com.tangem.features.walletconnect.transaction.ui.common.WcWalletItem
|
||||
import com.tangem.features.walletconnect.transaction.ui.common.WcPortfolioItem
|
||||
import com.tangem.features.walletconnect.transaction.ui.sign.accountPortfolioName
|
||||
import com.tangem.features.walletconnect.transaction.ui.sign.walletPortfolioName
|
||||
|
||||
@Composable
|
||||
internal fun WcAddEthereumChainModalBottomSheetContent(
|
||||
|
|
@ -111,14 +113,16 @@ private fun WcAddEthereumChainItems(state: WcAddEthereumChainItemUM) {
|
|||
.fillMaxWidth()
|
||||
.animateContentSize(),
|
||||
) {
|
||||
DividerWithPadding(start = 0.dp, end = 0.dp)
|
||||
WcWalletItem(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(12.dp),
|
||||
walletName = state.walletName,
|
||||
)
|
||||
DividerWithPadding(start = 40.dp, end = 12.dp)
|
||||
if (state.portfolioName != null) {
|
||||
DividerWithPadding(start = 0.dp, end = 0.dp)
|
||||
WcPortfolioItem(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(12.dp),
|
||||
portfolioName = state.portfolioName,
|
||||
)
|
||||
DividerWithPadding(start = 40.dp, end = 12.dp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -163,7 +167,18 @@ private class WcAddEthereumChainStateProvider : CollectionPreviewParameterProvid
|
|||
verifiedState = VerifiedDAppState.Verified {},
|
||||
appSubtitle = "react-app.walletconnect.com",
|
||||
),
|
||||
walletName = "Tangem 2.0",
|
||||
portfolioName = walletPortfolioName,
|
||||
),
|
||||
WcAddEthereumChainItemUM(
|
||||
onDismiss = {},
|
||||
onSign = {},
|
||||
appInfo = WcTransactionAppInfoContentUM(
|
||||
appName = "React App",
|
||||
appIcon = "",
|
||||
verifiedState = VerifiedDAppState.Verified {},
|
||||
appSubtitle = "react-app.walletconnect.com",
|
||||
),
|
||||
portfolioName = accountPortfolioName,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
@ -11,6 +11,7 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.tangem.common.ui.account.AccountTitleUM
|
||||
import com.tangem.core.ui.components.divider.DividerWithPadding
|
||||
import com.tangem.core.ui.extensions.clickableSingle
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
|
|
@ -22,7 +23,7 @@ import com.tangem.features.walletconnect.transaction.entity.common.WcTransaction
|
|||
@Suppress("LongParameterList")
|
||||
@Composable
|
||||
internal fun WcSendTransactionItems(
|
||||
walletName: String?,
|
||||
portfolioName: AccountTitleUM?,
|
||||
networkInfo: WcNetworkInfoUM,
|
||||
feeState: WcTransactionFeeState,
|
||||
feeSelectorBlockComponent: FeeSelectorBlockComponent?,
|
||||
|
|
@ -48,10 +49,10 @@ internal fun WcSendTransactionItems(
|
|||
.fillMaxWidth()
|
||||
.padding(TangemTheme.dimens.spacing12)
|
||||
|
||||
if (walletName != null) {
|
||||
WcWalletItem(
|
||||
if (portfolioName != null) {
|
||||
WcPortfolioItem(
|
||||
modifier = itemsModifier,
|
||||
walletName = walletName,
|
||||
portfolioName = portfolioName,
|
||||
)
|
||||
DividerWithPadding(start = TangemTheme.dimens.spacing40, end = TangemTheme.dimens.spacing12)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,14 +10,18 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import com.tangem.common.ui.account.AccountTitle
|
||||
import com.tangem.common.ui.account.AccountTitleUM
|
||||
import com.tangem.core.ui.components.SpacerWMax
|
||||
import com.tangem.core.ui.components.account.AccountIconSize
|
||||
import com.tangem.core.ui.components.tooltip.TangemTooltip
|
||||
import com.tangem.core.ui.extensions.resolveReference
|
||||
import com.tangem.core.ui.extensions.stringResourceSafe
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.features.walletconnect.impl.R
|
||||
|
||||
@Composable
|
||||
internal fun WcWalletItem(walletName: String, modifier: Modifier = Modifier) {
|
||||
internal fun WcPortfolioItem(portfolioName: AccountTitleUM, modifier: Modifier = Modifier) {
|
||||
Row(modifier = modifier, verticalAlignment = Alignment.CenterVertically) {
|
||||
var isTooltipEnabled by remember { mutableStateOf(false) }
|
||||
Icon(
|
||||
|
|
@ -26,29 +30,42 @@ internal fun WcWalletItem(walletName: String, modifier: Modifier = Modifier) {
|
|||
contentDescription = null,
|
||||
tint = TangemTheme.colors.icon.accent,
|
||||
)
|
||||
val leftText: String = when (portfolioName) {
|
||||
is AccountTitleUM.Account -> stringResourceSafe(R.string.common_account)
|
||||
is AccountTitleUM.Text -> stringResourceSafe(R.string.wc_common_wallet)
|
||||
}
|
||||
Text(
|
||||
modifier = Modifier.padding(start = TangemTheme.dimens.spacing8),
|
||||
text = stringResourceSafe(R.string.manage_tokens_network_selector_wallet),
|
||||
text = leftText,
|
||||
style = TangemTheme.typography.body1,
|
||||
color = TangemTheme.colors.text.primary1,
|
||||
maxLines = 1,
|
||||
)
|
||||
SpacerWMax()
|
||||
TangemTooltip(
|
||||
modifier = Modifier.padding(start = TangemTheme.dimens.spacing16),
|
||||
text = walletName,
|
||||
enabled = isTooltipEnabled,
|
||||
content = { contentModifier ->
|
||||
Text(
|
||||
modifier = contentModifier,
|
||||
text = walletName,
|
||||
style = TangemTheme.typography.body1,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
onTextLayout = { isTooltipEnabled = it.hasVisualOverflow },
|
||||
)
|
||||
},
|
||||
)
|
||||
when (portfolioName) {
|
||||
is AccountTitleUM.Account -> AccountTitle(
|
||||
modifier = Modifier.padding(start = TangemTheme.dimens.spacing16),
|
||||
accountTitleUM = portfolioName,
|
||||
textStyle = TangemTheme.typography.body1,
|
||||
textColor = TangemTheme.colors.text.tertiary,
|
||||
iconSize = AccountIconSize.Small,
|
||||
)
|
||||
is AccountTitleUM.Text -> TangemTooltip(
|
||||
modifier = Modifier.padding(start = TangemTheme.dimens.spacing16),
|
||||
text = portfolioName.title.resolveReference(),
|
||||
enabled = isTooltipEnabled,
|
||||
content = { contentModifier ->
|
||||
Text(
|
||||
modifier = contentModifier,
|
||||
text = portfolioName.title.resolveReference(),
|
||||
style = TangemTheme.typography.body1,
|
||||
color = TangemTheme.colors.text.tertiary,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
onTextLayout = { isTooltipEnabled = it.hasVisualOverflow },
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -51,6 +51,8 @@ import com.tangem.features.walletconnect.transaction.ui.common.WcSendTransaction
|
|||
import com.tangem.features.walletconnect.transaction.ui.common.WcSmallTitleItem
|
||||
import com.tangem.features.walletconnect.transaction.ui.common.WcTransactionRequestButtons
|
||||
import com.tangem.features.walletconnect.transaction.ui.common.WcTransactionRequestItem
|
||||
import com.tangem.features.walletconnect.transaction.ui.sign.accountPortfolioName
|
||||
import com.tangem.features.walletconnect.transaction.ui.sign.walletPortfolioName
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import java.math.BigDecimal
|
||||
|
||||
|
|
@ -114,7 +116,7 @@ internal fun WcSendTransactionModalBottomSheet(
|
|||
}
|
||||
WcSendTransactionItems(
|
||||
modifier = Modifier.padding(top = 16.dp),
|
||||
walletName = state.walletName,
|
||||
portfolioName = state.portfolioName,
|
||||
networkInfo = state.networkInfo,
|
||||
feeState = state.feeState,
|
||||
feeSelectorBlockComponent = feeSelectorBlockComponent,
|
||||
|
|
@ -220,7 +222,7 @@ private class WcSendTransactionStateProvider : CollectionPreviewParameterProvide
|
|||
),
|
||||
isLoading = false,
|
||||
),
|
||||
walletName = "Tangem 2.0 Tangem 2.0 Tangem 2",
|
||||
portfolioName = accountPortfolioName,
|
||||
networkInfo = WcNetworkInfoUM(name = "Optimistic Ethereum Network", iconRes = R.drawable.img_eth_22),
|
||||
feeState = WcTransactionFeeState.Success(dAppFee = null, onClick = {}),
|
||||
address = null,
|
||||
|
|
@ -260,7 +262,7 @@ private class WcSendTransactionStateProvider : CollectionPreviewParameterProvide
|
|||
),
|
||||
),
|
||||
),
|
||||
walletName = "Tangem 2.0",
|
||||
portfolioName = walletPortfolioName,
|
||||
networkInfo = WcNetworkInfoUM(name = "Ethereum", iconRes = R.drawable.img_eth_22),
|
||||
feeState = WcTransactionFeeState.Success(dAppFee = null, onClick = {}),
|
||||
address = "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
||||
|
|
@ -303,7 +305,7 @@ private class WcSendTransactionStateProvider : CollectionPreviewParameterProvide
|
|||
),
|
||||
),
|
||||
),
|
||||
walletName = null,
|
||||
portfolioName = null,
|
||||
networkInfo = WcNetworkInfoUM(name = "Ethereum", iconRes = R.drawable.img_eth_22),
|
||||
feeState = WcTransactionFeeState.None,
|
||||
address = null,
|
||||
|
|
@ -339,7 +341,7 @@ private class WcSendTransactionStateProvider : CollectionPreviewParameterProvide
|
|||
onLearnMoreClicked = {},
|
||||
),
|
||||
),
|
||||
walletName = "Tangem 2.0",
|
||||
portfolioName = accountPortfolioName,
|
||||
networkInfo = WcNetworkInfoUM(name = "Ethereum", iconRes = R.drawable.img_eth_22),
|
||||
feeState = WcTransactionFeeState.None,
|
||||
address = "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
||||
|
|
|
|||
|
|
@ -16,13 +16,17 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.tangem.common.ui.account.AccountIconPreviewData
|
||||
import com.tangem.common.ui.account.AccountTitleUM
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
import com.tangem.core.ui.components.bottomsheets.modal.TangemModalBottomSheet
|
||||
import com.tangem.core.ui.components.bottomsheets.modal.TangemModalBottomSheetTitle
|
||||
import com.tangem.core.ui.components.bottomsheets.modal.TangemModalBottomSheetWithFooter
|
||||
import com.tangem.core.ui.components.divider.DividerWithPadding
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
import com.tangem.features.walletconnect.connections.entity.VerifiedDAppState
|
||||
|
|
@ -115,10 +119,10 @@ private fun WcSignTransactionItems(state: WcSignTransactionItemUM, modifier: Mod
|
|||
.fillMaxWidth()
|
||||
.padding(12.dp)
|
||||
|
||||
if (state.walletName != null) {
|
||||
WcWalletItem(
|
||||
if (state.portfolioName != null) {
|
||||
WcPortfolioItem(
|
||||
modifier = itemsModifier,
|
||||
walletName = state.walletName,
|
||||
portfolioName = state.portfolioName,
|
||||
)
|
||||
DividerWithPadding(start = 40.dp, end = 12.dp)
|
||||
}
|
||||
|
|
@ -182,7 +186,7 @@ private class WcSignTransactionStateProvider : CollectionPreviewParameterProvide
|
|||
verifiedState = VerifiedDAppState.Verified {},
|
||||
appSubtitle = "react-app.walletconnect.com",
|
||||
),
|
||||
walletName = "Tangem 2.0",
|
||||
portfolioName = walletPortfolioName,
|
||||
networkInfo = WcNetworkInfoUM(name = "Ethereum", iconRes = R.drawable.img_eth_22),
|
||||
address = null,
|
||||
walletInteractionIcon = R.drawable.ic_tangem_24,
|
||||
|
|
@ -196,10 +200,20 @@ private class WcSignTransactionStateProvider : CollectionPreviewParameterProvide
|
|||
verifiedState = VerifiedDAppState.Verified {},
|
||||
appSubtitle = "react-app.walletconnect.com",
|
||||
),
|
||||
walletName = null,
|
||||
portfolioName = null,
|
||||
networkInfo = WcNetworkInfoUM(name = "Ethereum", iconRes = R.drawable.img_eth_22),
|
||||
address = "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
||||
walletInteractionIcon = R.drawable.ic_tangem_24,
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
internal val walletPortfolioName
|
||||
get() = AccountTitleUM.Text(title = stringReference("Wallet 1"))
|
||||
|
||||
internal val accountPortfolioName
|
||||
get() = AccountTitleUM.Account(
|
||||
icon = AccountIconPreviewData.randomAccountIcon(),
|
||||
name = stringReference("Main Account"),
|
||||
prefixText = TextReference.EMPTY,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue