diff --git a/core/res/src/main/res/values-de/strings.xml b/core/res/src/main/res/values-de/strings.xml index d3c9f55037..12d2744c43 100644 --- a/core/res/src/main/res/values-de/strings.xml +++ b/core/res/src/main/res/values-de/strings.xml @@ -534,13 +534,13 @@ Basisinformationen Netzwerk Vertragsadresse - Kontrollabschnitt - Kontrollabschnitt - Kontrollabschnitt - Kontrollabschnitt - Kontrollabschnitt - Kontrollabschnitt - Kontrollabschnitt + Chain ist die Blockchain, in der das NFT existiert. + Die Vertragsadresse ist eine eindeutige Kennung für den Smart Contract, der die Token auf der Blockchain verwaltet. + Eine Bezeichnung, die beschreibt, wie selten das NFT ist. Je niedriger der Wert, desto einzigartiger das NFT. + Die Position eines NFT im Seltenheitsranking unter anderen Token. Je höher der Rang, desto seltener und wertvoller ist das NFT. + Die Token-Adresse ist eine eindeutige Kennung für das Token in der Blockchain und ermöglicht die Verfolgung von Transaktionen und Eigentumsverhältnissen + Die Token-ID ist eine eindeutige Kennung, die jedem Token zugewiesen wird und es von anderen in der Sammlung unterscheidet. + Der Token-Standard definiert, um welche Art von Token es sich handelt und wie es mit verschiedenen Wallets und Plattformen funktioniert Letzter Verkaufspreis Raritätsetikett Seltenheitsgrad @@ -553,7 +553,7 @@ Verfügbar Netzwerk auswählen NFT erhalten - Du hast dieses Netzwerk noch nicht hinzugefügt. Um NFTs zu empfangen, füge es zum Hauptbildschirm hinzu! + Du hast dieses Netzwerk noch nicht hinzugefügt. Um NFTs zu erhalten, füge es Deinem Portfolio hinzu. Netzwerk nicht hinzugefügt Nicht hinzugefügt NFT senden @@ -1250,7 +1250,7 @@ Zeitüberschreitungsfehler. Bitte versuche es später erneut. WalletConnect konnte nicht hergestellt werden Diese Domäne kann nicht verifiziert werden. Überprüfe die Anfrage sorgfältig und bestätige diese dann. - Geh zurück zu Deinem Browser und stell erneut eine Verbindung über WalletConnect her. + Bitte kehre zu Deinem Browser zurück und stellen die Verbindung über WalletConnect erneut her. WalletConnect-Sitzung wurde getrennt Fehlercode: %s. Wenn das Problem weiterhin besteht, wende Dich bitte an unseren Support. Wir haben einen unbekannten Fehler festgestellt. @@ -1258,8 +1258,9 @@ Nicht unterstützte Netzwerke Tangem unterstützt ein erforderliches Netzwerk um %s. Verifizierte Domain - Falsche Karte oder falscher Ring in der Tangem-App ausgewählt + Falsche Karte oder falscher Ring in der App ausgewählt Wir haben eine Art Problem + Vertragsadresse Verbinden Netzwerk Netzwerke @@ -1286,6 +1287,7 @@ Bekanntes Sicherheitsrisiko Anfrage von Art der Signatur + An Transaktionsanfrage Transaktionsanfrage Wallet verbinden diff --git a/core/res/src/main/res/values-ja/strings.xml b/core/res/src/main/res/values-ja/strings.xml index 06e907a6d2..3dde89a4c9 100644 --- a/core/res/src/main/res/values-ja/strings.xml +++ b/core/res/src/main/res/values-ja/strings.xml @@ -527,13 +527,13 @@ 基本情報 チェーン コントラクトアドレス - スタブ - スタブ - スタブ - スタブ - スタブ - スタブ - スタブ + チェーンは、NFTが存在するブロックチェーンです。 + コントラクトアドレスは、ブロックチェーン上のトークンを管理するスマートコントラクトの識別子です。 + NFTの希少性を示すラベル。数値が低いほどユニークなNFTであることを示します。 + 他のトークンの中での希少性ランキングにおけるNFTの位置。ランクが高ければ高いほど、NFTの希少性と価値は高くなります。 + トークンアドレスは、ブロックチェーン上のトークンの識別子であり、取引と所有権の追跡を可能にします + トークンIDは、各トークンに割り当てられる識別子であり、コレクション内の他のトークンと区別されます + トークン標準は、トークンの種類と、さまざまなウォレットやプラットフォームでどのように機能するかを定義します 最終販売価格 レアリティ・ラベル レアリティ・ランク @@ -546,7 +546,7 @@ 利用可能 ネットワークを選択 NFTを受け取る - このネットワークはまだ追加されていません。NFTの受け取りを開始するには、メイン画面に追加してください。 + このネットワークはまだ追加されていません。NFTを受け取るには、ポートフォリオに追加してください。 ネットワークが追加されていません 未追加 NFTを送信する @@ -1234,7 +1234,7 @@ タイムアウトエラーが発生しました。しばらくしてからもう一度お試しください。 WalletConnectを確立できませんでした このドメインは検証できません。承認前にリクエスト内容をよく確認してください。 - ブラウザに戻り、WalletConnect経由で再度接続してください。 + ブラウザに戻り、WalletConnect経由で再接続してください。 WalletConnectセッションが接続解除されました エラーコード: %s 。問題が解決しない場合は、お気軽にサポートまでお問い合わせください。 不明なエラーが発生しました @@ -1242,7 +1242,7 @@ サポートされていないネットワーク Tangemは%sで必要なネットワークをサポートします。 検証済みドメイン - Tangemアプリで誤ったカードまたはリングが選択されました + アプリで間違ったカードまたはリングが選択されました 問題が起きています アドレス 接続する diff --git a/core/res/src/main/res/values-ru/strings.xml b/core/res/src/main/res/values-ru/strings.xml index a4e05ae190..930c417497 100644 --- a/core/res/src/main/res/values-ru/strings.xml +++ b/core/res/src/main/res/values-ru/strings.xml @@ -167,6 +167,7 @@ Сетевая комиссия Сумма отправки будет уменьшена на %1$s (%2$s) для покрытия выбранного уровня комиссии Далее + NFT Нет Нет адреса Сейчас @@ -189,6 +190,7 @@ Поиск Поиск токенов сек + Показать всё Seed-фраза Выберите действие Продать @@ -311,6 +313,7 @@ Ожидание депозита Ожидаем пополнения... Возвращено + Возврат средств Отправляем Отправка средств... Отправлено @@ -450,6 +453,9 @@ Лидеры роста Лидеры падения В тренде + Стейкинг — простой способ получать доход с вашей криптовалюты. %s + Показать больше + Получайте до %s APY О %s %d биржа @@ -521,6 +527,51 @@ Потяните вверх или коснитесь поисковой строки, чтобы добавить токены напрямую из рынка Добавить токены Функция NFC недоступна на вашем устройстве + Об NFT + NFT + + NFT + NFT + NFT + NFT + + Здесь будут отображаться NFT, полученные на ваш кошелёк + У вас ещё нет коллекций + Получить NFT + NFT коллекции + Часть данных может не отобразиться + Не удалось загрузить данные + Базовая информация + Сеть + Адрес контракта + Сеть — это блокчейн, на котором существует NFT. + Адрес контракта — уникальный код, который идентифицирует смарт-контракт, управляющий токенами в блокчейне + Метка, которая описывает, насколько редким является NFT. Чем ниже значение, тем уникальнее NFT. + Позиция NFT в рейтинге редкости среди других токенов. Чем выше ранг, тем реже и ценнее NFT. + Адрес токена — это уникальный идентификатор токена в блокчейне, который позволяет отслеживать транзакции и владение им. + ID токена — уникальный идентификатор, присваиваемый каждому токену, который отличает его от других в коллекции + Стандарт токена определяет его тип и как он работает с различными кошельками и платформами + Последняя цена продажи + Метка уникальности + Ранг редкости + Адрес токена + ID токена + Стандарт токена + Черты + Нет результатов. Пожалуйста, попробуйте другой запрос. + Нет коллекции + Доступно + Выберите сеть + Получить NFT + Вы ещё не добавили эту сеть. Чтобы получать NFT, добавьте её в ваш портфель. + Сеть не добавлена + Не добавлено + Отправить NFT + Черты + %1$d NFTs в %2$d коллекциях + Нажмите здесь, чтобы получить первую NFT + NFT коллекции + Невозможно загрузить данные Чтобы использовать сеть %1$s, вы должны оплатить резерв аккаунта (%2$s %3$s), который блокируется и не используется в вашем балансе Аккаунт получателя не активирован. Отправьте %s или более для активации аккаунта. Для создания аккаунта отправьте средства на этот адрес @@ -1024,6 +1075,8 @@ валидатор: %s Минимум %s Минимальная сумма транзакции равна %1$s. + Комиссии сети Tron для популярных токенов могут быть выше. Стейкинг TRX может помочь снизить расходы на транзакции. + Экономьте на Tron комиссиях Попробовать снова Вы отсканировали ту же карту. Для создания twin-кошелька вам необходимо отсканировать карту с номером %d Вы отсканировали не ту twin-карту. Пожалуйста, попробуйте отсканировать другую @@ -1184,6 +1237,20 @@ Это Testnet карта. Он не может обрабатывать транзакции и используется только в целях тестирования и разработки. Только для целей тестирования Возможно, баланс устарел. Обновите страницу. + Пожалуйста, вернитесь в браузер и выполните повторное подключение через WalletConnect. + Выбрана не верная карта или кольцо + Адрес + Подключение + Посмотреть баланс кошелька и его активность + Запрос на подключение + Вложение + Копировать данные + Запрос от + Тип подписи + На + Запрос транзакции + Запрос транзакции + Подключение кошелька Отказаться Вы не закончили резервное копирование. Хотите продолжить? Да, возобновить diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml index 2081101d9d..869cf9bf8b 100644 --- a/core/res/src/main/res/values/strings.xml +++ b/core/res/src/main/res/values/strings.xml @@ -535,13 +535,13 @@ Base information Chain Contract Address - stub - stub - stub - stub - stub - stub - stub + Chain is the blockchain where the NFT exists. + The contract address is a unique identifier for the smart contract that governs the tokens on the blockchain + A label that describes how rare the NFT is. The lower the value, the more unique the NFT. + The position of an NFT in the rarity ranking among other tokens. The higher the rank, the rarer and more valuable the NFT. + The token address is a unique identifier for the token on the blockchain, allowing tracking of transactions and ownership + The token ID is a unique identifier assigned to each token, distinguishing it from others in the collection + Token standard defines what type of token it is and how it works with different wallets and platforms Last sale price Rarity label Rarity rank @@ -554,7 +554,7 @@ Available Choose network Receive NFT - You haven\'t added this network yet. To start receiving NFTs, add it to the main screen! + You haven\'t added this network yet. To receive NFTs, add it to your portfolio. Network not added Not Added Send NFT @@ -1121,7 +1121,7 @@ This won’t take long. We’re completing the activation. Getting everything ready! Other wallet - Set up a 4-digit code. 
It will be used for payments. + Set up a 4-digit code.\nIt will be used for payments. PIN code Create PIN Code PIN was not accepted. Try again or use a different code. @@ -1295,7 +1295,7 @@ Timeout error. Please, try again later. Failed to establish WalletConnect This domain cannot be verified. Check the request carefully approving. - Go back to your browser and connect via WalletConnect again. + Please return to your browser and reconnect via WalletConnect. WalletConnect session was disconnected Error code: %s. If the problem persists — feel free to contact our support. We\'ve encountered unknown error @@ -1303,8 +1303,9 @@ Unsuported networks Tangem support a required network by %s. Verified domain - Wrong card or ring selected in Tangem App + Wrong card or ring selected in the App We\'ve got some kind of problem + Allow to spend Address Connect Network @@ -1320,6 +1321,7 @@ Connections Contents Copy data + Custom allowance Disconnect all Text about discnected all dApps Disconect All dApps diff --git a/core/ui/src/main/res/drawable/ic_edit_new_24.xml b/core/ui/src/main/res/drawable/ic_edit_new_24.xml new file mode 100644 index 0000000000..438006f6fa --- /dev/null +++ b/core/ui/src/main/res/drawable/ic_edit_new_24.xml @@ -0,0 +1,12 @@ + + + + diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/WcSignTransactionComponent.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/WcSignTransactionComponent.kt index 9ffe0a28d5..8f18c4327c 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/WcSignTransactionComponent.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/WcSignTransactionComponent.kt @@ -20,7 +20,7 @@ internal class WcSignTransactionComponent( if (content != null) { WcSignTransactionModalBottomSheetContent( - state = content, + state = content.transaction, onClickTransactionRequest = transactionInfoOnClick, ) } diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/WcSignTransactionRequestInfoComponent.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/WcSignTransactionRequestInfoComponent.kt index 7563b8a646..d78b56b14a 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/WcSignTransactionRequestInfoComponent.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/WcSignTransactionRequestInfoComponent.kt @@ -18,7 +18,7 @@ internal class WcSignTransactionRequestInfoComponent( val content = model.uiState.collectAsStateWithLifecycle().value if (content != null) { - TransactionRequestInfoContent(content) + TransactionRequestInfoContent(content.transactionRequestInfo) } } } \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/WcSignTransactionUM.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/WcSignTransactionUM.kt deleted file mode 100644 index 77379d44e1..0000000000 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/WcSignTransactionUM.kt +++ /dev/null @@ -1,56 +0,0 @@ -package com.tangem.features.walletconnect.transaction.entity - -import androidx.annotation.DrawableRes -import androidx.compose.runtime.Immutable -import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent -import com.tangem.core.ui.extensions.TextReference -import kotlinx.collections.immutable.ImmutableList - -@Immutable -internal data class WcSignTransactionUM( - val actions: WcTransactionActionsUM, - val transaction: WcTransactionUM, - val transactionRequestInfo: WcTransactionRequestInfoUM, -) : TangemBottomSheetConfigContent - -@Immutable -internal data class WcTransactionUM( - val appName: String, - val appIcon: String, - val isVerified: Boolean, - val appSubtitle: String, - val walletName: String, - val networkInfo: WcNetworkInfoUM, - val addressText: String? = null, - val networkFee: String? = null, - val isLoading: Boolean = false, -) - -@Immutable -internal data class WcTransactionRequestInfoUM( - val blocks: ImmutableList, -) - -@Immutable -internal data class WcTransactionRequestBlockUM( - val info: ImmutableList, -) - -@Immutable -internal data class WcTransactionRequestInfoItemUM( - val title: TextReference, - val description: String = "", -) - -@Immutable -internal data class WcTransactionActionsUM( - val onDismiss: () -> Unit, - val onSign: () -> Unit, - val onCopy: () -> Unit, -) - -@Immutable -internal data class WcNetworkInfoUM( - val name: String, - @DrawableRes val iconRes: Int, -) \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/approve/WcApproveTransactionUM.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/approve/WcApproveTransactionUM.kt new file mode 100644 index 0000000000..42c283e2e1 --- /dev/null +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/approve/WcApproveTransactionUM.kt @@ -0,0 +1,31 @@ +package com.tangem.features.walletconnect.transaction.entity.approve + +import androidx.annotation.DrawableRes +import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent +import com.tangem.features.walletconnect.transaction.entity.common.WcNetworkInfoUM +import com.tangem.features.walletconnect.transaction.entity.common.WcTransactionAppInfoContentUM +import com.tangem.features.walletconnect.transaction.entity.common.WcTransactionRequestInfoUM + +internal data class WcApproveTransactionUM( + val transaction: WcApproveTransactionItemUM, + val transactionRequestInfo: WcTransactionRequestInfoUM, + val customAllowance: WcCustomAllowanceUM, +) + +internal data class WcApproveTransactionItemUM( + val onDismiss: () -> Unit, + val onSend: () -> Unit, + val appInfo: WcTransactionAppInfoContentUM, + val spendAllowance: WcSpendAllowanceUM? = null, + val walletName: String, + val networkInfo: WcNetworkInfoUM, + val networkFee: String? = null, + val isLoading: Boolean = false, +) : TangemBottomSheetConfigContent + +internal data class WcCustomAllowanceUM( + @DrawableRes val networkIconRes: Int, + val tokenIconUrl: String, + val amountText: String, + val isUnlimited: Boolean, +) \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/approve/WcSpendAllowanceUM.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/approve/WcSpendAllowanceUM.kt new file mode 100644 index 0000000000..d3609afa63 --- /dev/null +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/approve/WcSpendAllowanceUM.kt @@ -0,0 +1,6 @@ +package com.tangem.features.walletconnect.transaction.entity.approve + +internal data class WcSpendAllowanceUM( + val amountText: String, + val tokenImageUrl: String, +) \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/common/WcNetworkInfoUM.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/common/WcNetworkInfoUM.kt new file mode 100644 index 0000000000..788036d8fd --- /dev/null +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/common/WcNetworkInfoUM.kt @@ -0,0 +1,8 @@ +package com.tangem.features.walletconnect.transaction.entity.common + +import androidx.annotation.DrawableRes + +internal data class WcNetworkInfoUM( + val name: String, + @DrawableRes val iconRes: Int, +) \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/common/WcTransactionActionsUM.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/common/WcTransactionActionsUM.kt new file mode 100644 index 0000000000..58a4ac9b7a --- /dev/null +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/common/WcTransactionActionsUM.kt @@ -0,0 +1,10 @@ +package com.tangem.features.walletconnect.transaction.entity.common + +import androidx.compose.runtime.Immutable + +@Immutable +internal data class WcTransactionActionsUM( + val onDismiss: () -> Unit, + val onSign: () -> Unit, + val onCopy: () -> Unit, +) \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/common/WcTransactionAppInfoContentUM.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/common/WcTransactionAppInfoContentUM.kt new file mode 100644 index 0000000000..3d84687afa --- /dev/null +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/common/WcTransactionAppInfoContentUM.kt @@ -0,0 +1,8 @@ +package com.tangem.features.walletconnect.transaction.entity.common + +internal data class WcTransactionAppInfoContentUM( + val appName: String, + val appIcon: String, + val isVerified: Boolean, + val appSubtitle: String, +) \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/common/WcTransactionRequestInfoUM.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/common/WcTransactionRequestInfoUM.kt new file mode 100644 index 0000000000..37bf3b7fde --- /dev/null +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/common/WcTransactionRequestInfoUM.kt @@ -0,0 +1,19 @@ +package com.tangem.features.walletconnect.transaction.entity.common + +import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent +import com.tangem.core.ui.extensions.TextReference +import kotlinx.collections.immutable.ImmutableList + +internal data class WcTransactionRequestInfoUM( + val blocks: ImmutableList, + val onCopy: () -> Unit, +) : TangemBottomSheetConfigContent + +internal data class WcTransactionRequestBlockUM( + val info: ImmutableList, +) + +internal data class WcTransactionRequestInfoItemUM( + val title: TextReference, + val description: String = "", +) \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/sign/WcSignTransactionUM.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/sign/WcSignTransactionUM.kt new file mode 100644 index 0000000000..48a1bc062e --- /dev/null +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/entity/sign/WcSignTransactionUM.kt @@ -0,0 +1,21 @@ +package com.tangem.features.walletconnect.transaction.entity.sign + +import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent +import com.tangem.features.walletconnect.transaction.entity.common.WcNetworkInfoUM +import com.tangem.features.walletconnect.transaction.entity.common.WcTransactionAppInfoContentUM +import com.tangem.features.walletconnect.transaction.entity.common.WcTransactionRequestInfoUM + +internal data class WcSignTransactionUM( + val transaction: WcSignTransactionItemUM, + val transactionRequestInfo: WcTransactionRequestInfoUM, +) + +internal data class WcSignTransactionItemUM( + val onDismiss: () -> Unit, + val onSign: () -> Unit, + val appInfo: WcTransactionAppInfoContentUM, + val walletName: String, + val networkInfo: WcNetworkInfoUM, + val addressText: String? = null, + val isLoading: Boolean = false, +) : TangemBottomSheetConfigContent \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSignTransactionModel.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSignTransactionModel.kt index ed6ea36064..f906dbd0de 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSignTransactionModel.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSignTransactionModel.kt @@ -11,8 +11,8 @@ import com.tangem.domain.walletconnect.usecase.method.WcSignState import com.tangem.domain.walletconnect.usecase.method.WcSignStep import com.tangem.domain.walletconnect.usecase.method.WcSignUseCase import com.tangem.features.walletconnect.transaction.components.WcSignTransactionContainerComponent -import com.tangem.features.walletconnect.transaction.entity.WcSignTransactionUM -import com.tangem.features.walletconnect.transaction.entity.WcTransactionActionsUM +import com.tangem.features.walletconnect.transaction.entity.common.WcTransactionActionsUM +import com.tangem.features.walletconnect.transaction.entity.sign.WcSignTransactionUM import com.tangem.features.walletconnect.transaction.utils.toUM import com.tangem.utils.coroutines.CoroutineDispatcherProvider import kotlinx.coroutines.flow.MutableStateFlow @@ -58,7 +58,7 @@ internal class WcSignTransactionModel @Inject constructor( } fun dismiss() { - _uiState.value?.actions?.onDismiss?.invoke() ?: router.pop() + _uiState.value?.transaction?.onDismiss?.invoke() ?: router.pop() } private fun signingIsDone(signState: WcSignState<*>): Boolean { diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/approve/WcApproveTransactionModalBottomSheet.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/approve/WcApproveTransactionModalBottomSheet.kt new file mode 100644 index 0000000000..a64be58984 --- /dev/null +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/approve/WcApproveTransactionModalBottomSheet.kt @@ -0,0 +1,174 @@ +package com.tangem.features.walletconnect.transaction.ui.approve + +import android.content.res.Configuration +import androidx.compose.animation.animateContentSize +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.HorizontalDivider +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.tooling.preview.Devices +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 androidx.compose.ui.unit.dp +import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig +import com.tangem.core.ui.components.bottomsheets.modal.TangemModalBottomSheet +import com.tangem.core.ui.components.bottomsheets.modal.TangemModalBottomSheetTitle +import com.tangem.core.ui.extensions.resourceReference +import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview +import com.tangem.features.walletconnect.connections.ui.WcAppInfoItem +import com.tangem.features.walletconnect.impl.R +import com.tangem.features.walletconnect.transaction.entity.approve.WcApproveTransactionItemUM +import com.tangem.features.walletconnect.transaction.entity.approve.WcSpendAllowanceUM +import com.tangem.features.walletconnect.transaction.entity.common.WcNetworkInfoUM +import com.tangem.features.walletconnect.transaction.entity.common.WcTransactionAppInfoContentUM +import com.tangem.features.walletconnect.transaction.ui.common.* + +@Composable +internal fun WcApproveTransactionModalBottomSheetContent( + state: WcApproveTransactionItemUM, + onClickTransactionRequest: () -> Unit, +) { + Column( + modifier = Modifier + .padding(horizontal = TangemTheme.dimens.spacing16), + ) { + Column( + modifier = Modifier + .clip(RoundedCornerShape(TangemTheme.dimens.radius14)) + .background(color = TangemTheme.colors.background.action) + .fillMaxWidth() + .animateContentSize(), + ) { + WcSmallTitleItem(R.string.wc_request_from) + WcAppInfoItem( + iconUrl = state.appInfo.appIcon, + title = state.appInfo.appName, + subtitle = state.appInfo.appSubtitle, + isVerified = state.appInfo.isVerified, + ) + DividerWithPadding(start = 0.dp, end = 0.dp) + WcTransactionRequestItem( + iconRes = R.drawable.ic_doc_new_24, + modifier = Modifier + .fillMaxWidth() + .clickable { onClickTransactionRequest() } + .padding(TangemTheme.dimens.spacing12), + ) + } + Column(modifier = Modifier.padding(top = TangemTheme.dimens.spacing16)) { + if (state.spendAllowance != null) { + WcSpendAllowanceItem(state.spendAllowance) + Spacer(Modifier.height(TangemTheme.dimens.spacing16)) + } + WcApproveTransactionItems(state) + WcTransactionRequestButtons( + modifier = Modifier.padding(vertical = TangemTheme.dimens.spacing16), + onDismiss = state.onDismiss, + onClickActiveButton = state.onSend, + activeButtonText = resourceReference(R.string.common_send), + isLoading = state.isLoading, + ) + } + } +} + +@Composable +private fun WcApproveTransactionItems(state: WcApproveTransactionItemUM) { + Column( + modifier = Modifier + .clip(RoundedCornerShape(TangemTheme.dimens.radius14)) + .background(color = TangemTheme.colors.background.action) + .fillMaxWidth() + .animateContentSize(), + ) { + val itemsModifier = Modifier + .fillMaxWidth() + .padding(TangemTheme.dimens.spacing12) + + DividerWithPadding(start = 0.dp, end = 0.dp) + WcWalletItem( + modifier = itemsModifier, + walletName = state.walletName, + ) + DividerWithPadding(start = TangemTheme.dimens.spacing40, end = TangemTheme.dimens.spacing12) + WcNetworkItem( + modifier = itemsModifier, + networkInfo = state.networkInfo, + ) + if (!state.networkFee.isNullOrEmpty()) { + DividerWithPadding(start = TangemTheme.dimens.spacing40, end = TangemTheme.dimens.spacing12) + WcNetworkFeeItem( + modifier = itemsModifier, + networkFeeText = state.networkFee, + ) + } + } +} + +@Composable +internal fun DividerWithPadding(start: Dp, end: Dp) { + HorizontalDivider( + modifier = Modifier.padding( + start = start, + end = end, + ), + thickness = TangemTheme.dimens.size1, + color = TangemTheme.colors.stroke.primary, + ) +} + +@Composable +@Preview(showBackground = true, device = Devices.PIXEL_7_PRO) +@Preview(showBackground = true, device = Devices.PIXEL_7_PRO, uiMode = Configuration.UI_MODE_NIGHT_YES) +private fun WcApproveTransactionBottomSheetPreview( + @PreviewParameter(WcApproveTransactionStateProvider::class) state: WcApproveTransactionItemUM, +) { + TangemThemePreview { + TangemModalBottomSheet( + config = TangemBottomSheetConfig( + isShown = true, + onDismissRequest = {}, + content = state, + ), + containerColor = TangemTheme.colors.background.tertiary, + title = { + TangemModalBottomSheetTitle( + title = resourceReference(R.string.wallet_connect_title), + endIconRes = R.drawable.ic_close_24, + onEndClick = {}, + startIconRes = null, + onStartClick = {}, + ) + }, + content = { + WcApproveTransactionModalBottomSheetContent(state = state, onClickTransactionRequest = {}) + }, + ) + } +} + +private class WcApproveTransactionStateProvider : CollectionPreviewParameterProvider( + listOf( + WcApproveTransactionItemUM( + onDismiss = {}, + onSend = {}, + appInfo = WcTransactionAppInfoContentUM( + appName = "React App", + appIcon = "", + isVerified = true, + appSubtitle = "react-app.walletconnect.com", + ), + spendAllowance = WcSpendAllowanceUM(amountText = "Unlimited USDT", tokenImageUrl = ""), + walletName = "Tangem 2.0", + networkInfo = WcNetworkInfoUM(name = "Ethereum", iconRes = R.drawable.img_eth_22), + networkFee = "~ 0.22 $", + ), + ), +) \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/approve/WcSpendAllowanceItem.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/approve/WcSpendAllowanceItem.kt new file mode 100644 index 0000000000..329402c6cd --- /dev/null +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/approve/WcSpendAllowanceItem.kt @@ -0,0 +1,88 @@ +package com.tangem.features.walletconnect.transaction.ui.approve + +import androidx.compose.animation.AnimatedContent +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Icon +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import com.tangem.features.walletconnect.impl.R +import androidx.compose.ui.res.painterResource +import coil.compose.AsyncImage +import com.tangem.core.ui.extensions.stringResourceSafe +import com.tangem.core.ui.res.TangemTheme +import com.tangem.features.walletconnect.transaction.entity.approve.WcSpendAllowanceUM +import com.tangem.features.walletconnect.transaction.ui.common.WcSmallTitleItem + +@Composable +internal fun WcSpendAllowanceItem(spendAllowance: WcSpendAllowanceUM, modifier: Modifier = Modifier) { + Column( + modifier = modifier + .clip(RoundedCornerShape(TangemTheme.dimens.radius14)) + .background(TangemTheme.colors.background.action) + .fillMaxWidth() + .padding( + end = TangemTheme.dimens.spacing12, + bottom = TangemTheme.dimens.spacing12, + ), + ) { + WcSmallTitleItem(R.string.wc_allow_to_spend) + + Spacer(modifier = Modifier.height(TangemTheme.dimens.spacing8)) + + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.fillMaxWidth(), + ) { + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.weight(1f), + ) { + AsyncImage( + model = spendAllowance.tokenImageUrl, + modifier = Modifier + .size(TangemTheme.dimens.size24) + .clip(CircleShape), + contentDescription = null, + ) + + Spacer(modifier = Modifier.width(TangemTheme.dimens.spacing12)) + + AnimatedContent( + targetState = spendAllowance.amountText, + label = "Animate Spend allowance text", + ) { amount -> + Text( + text = amount, + style = TangemTheme.typography.body1, + color = TangemTheme.colors.text.primary1, + ) + } + } + + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.End, + ) { + Text( + text = stringResourceSafe(R.string.manage_tokens_edit), + style = TangemTheme.typography.body1, + color = TangemTheme.colors.text.tertiary, + ) + + Spacer(modifier = Modifier.width(TangemTheme.dimens.spacing8)) + + Icon( + painter = painterResource(id = R.drawable.ic_edit_new_24), + contentDescription = null, + tint = TangemTheme.colors.icon.informative, + ) + } + } + } +} \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/TransactionRequestInfoContent.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/TransactionRequestInfoContent.kt index 382da28e98..46051412fe 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/TransactionRequestInfoContent.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/TransactionRequestInfoContent.kt @@ -27,19 +27,16 @@ import com.tangem.core.ui.extensions.stringResourceSafe import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreview import com.tangem.features.walletconnect.impl.R -import com.tangem.features.walletconnect.transaction.entity.* -import com.tangem.features.walletconnect.transaction.entity.WcNetworkInfoUM -import com.tangem.features.walletconnect.transaction.entity.WcSignTransactionUM -import com.tangem.features.walletconnect.transaction.entity.WcTransactionActionsUM -import com.tangem.features.walletconnect.transaction.entity.WcTransactionRequestInfoUM -import com.tangem.features.walletconnect.transaction.entity.WcTransactionUM +import com.tangem.features.walletconnect.transaction.entity.common.WcTransactionRequestBlockUM +import com.tangem.features.walletconnect.transaction.entity.common.WcTransactionRequestInfoItemUM +import com.tangem.features.walletconnect.transaction.entity.common.WcTransactionRequestInfoUM import kotlinx.collections.immutable.persistentListOf private const val MIN_HEIGHT_SCREEN_PERCENT = 0.35f private const val MAX_HEIGHT_SCREEN_PERCENT = 0.75f @Composable -internal fun TransactionRequestInfoContent(state: WcSignTransactionUM) { +internal fun TransactionRequestInfoContent(state: WcTransactionRequestInfoUM) { val screenHeight = LocalConfiguration.current.screenHeightDp val minHeight = (screenHeight * MIN_HEIGHT_SCREEN_PERCENT).dp val maxHeight = (screenHeight * MAX_HEIGHT_SCREEN_PERCENT).dp @@ -55,7 +52,7 @@ internal fun TransactionRequestInfoContent(state: WcSignTransactionUM) { .fillMaxWidth(), contentPadding = PaddingValues(top = TangemTheme.dimens.spacing8, bottom = TangemTheme.dimens.spacing70), ) { - items(state.transactionRequestInfo.blocks) { block -> + items(state.blocks) { block -> Column( modifier = Modifier .fillMaxWidth() @@ -98,7 +95,7 @@ internal fun TransactionRequestInfoContent(state: WcSignTransactionUM) { .padding(bottom = TangemTheme.dimens.spacing20) .fillMaxWidth(), text = stringResourceSafe(R.string.wc_copy_data_button_text), - onClick = state.actions.onCopy, + onClick = state.onCopy, iconResId = R.drawable.ic_copy_24, ) } @@ -108,10 +105,10 @@ internal fun TransactionRequestInfoContent(state: WcSignTransactionUM) { @Preview(showBackground = true, device = Devices.PIXEL_7_PRO) @Preview(showBackground = true, device = Devices.PIXEL_7_PRO, uiMode = Configuration.UI_MODE_NIGHT_YES) private fun WcSignTransactionRequestInfoBottomSheetPreview( - @PreviewParameter(WcSignTransactionStateProvider::class) state: WcSignTransactionUM, + @PreviewParameter(WcSignTransactionStateProvider::class) state: WcTransactionRequestInfoUM, ) { TangemThemePreview { - TangemModalBottomSheet( + TangemModalBottomSheet( config = TangemBottomSheetConfig( isShown = true, onDismissRequest = {}, @@ -134,86 +131,56 @@ private fun WcSignTransactionRequestInfoBottomSheetPreview( } } -private class WcSignTransactionStateProvider : CollectionPreviewParameterProvider( +private class WcSignTransactionStateProvider : CollectionPreviewParameterProvider( listOf( - WcSignTransactionUM( - transaction = WcTransactionUM( - appName = "React App", - appIcon = "", - isVerified = true, - appSubtitle = "react-app.walletconnect.com", - walletName = "Tangem 2.0", - networkInfo = WcNetworkInfoUM(name = "Ethereum", iconRes = R.drawable.img_eth_22), - ), - transactionRequestInfo = WcTransactionRequestInfoUM( - blocks = persistentListOf( - WcTransactionRequestBlockUM( - persistentListOf( - WcTransactionRequestInfoItemUM( - title = resourceReference(R.string.wc_signature_type), - description = "personal_sign", - ), - WcTransactionRequestInfoItemUM( - title = resourceReference(R.string.wc_contents), - description = "Hello! My name is John Dow. test@tange.com", - ), + WcTransactionRequestInfoUM( + blocks = persistentListOf( + WcTransactionRequestBlockUM( + persistentListOf( + WcTransactionRequestInfoItemUM( + title = resourceReference(R.string.wc_signature_type), + description = "personal_sign", + ), + WcTransactionRequestInfoItemUM( + title = resourceReference(R.string.wc_contents), + description = "Hello! My name is John Dow. test@tange.com", ), ), ), ), - actions = WcTransactionActionsUM( - onDismiss = {}, - onSign = {}, - onCopy = {}, - ), + onCopy = {}, ), - WcSignTransactionUM( - transaction = WcTransactionUM( - appName = "React App", - appIcon = "", - isVerified = true, - appSubtitle = "react-app.walletconnect.com", - walletName = "Tangem 2.0", - networkInfo = WcNetworkInfoUM(name = "Ethereum", iconRes = R.drawable.img_eth_22), - addressText = "0x345FF...34FA", - networkFee = "~ 0.22 $", - ), - transactionRequestInfo = WcTransactionRequestInfoUM( - blocks = persistentListOf( - WcTransactionRequestBlockUM( - persistentListOf( - WcTransactionRequestInfoItemUM( - title = resourceReference(R.string.wc_signature_type), - description = "personal_sign", - ), - WcTransactionRequestInfoItemUM( - title = resourceReference(R.string.wc_contents), - description = "Hello! My name is John Dow. test@tange.com", - ), + WcTransactionRequestInfoUM( + blocks = persistentListOf( + WcTransactionRequestBlockUM( + persistentListOf( + WcTransactionRequestInfoItemUM( + title = resourceReference(R.string.wc_signature_type), + description = "personal_sign", + ), + WcTransactionRequestInfoItemUM( + title = resourceReference(R.string.wc_contents), + description = "Hello! My name is John Dow. test@tange.com", ), ), - WcTransactionRequestBlockUM( - persistentListOf( - WcTransactionRequestInfoItemUM( - title = resourceReference(R.string.wc_transaction_info_to_title), - ), - WcTransactionRequestInfoItemUM( - title = resourceReference(R.string.settings_wallet_name_title), - description = "Bob", - ), - WcTransactionRequestInfoItemUM( - title = resourceReference(R.string.wc_common_wallet), - description = "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826", - ), + ), + WcTransactionRequestBlockUM( + persistentListOf( + WcTransactionRequestInfoItemUM( + title = resourceReference(R.string.wc_transaction_info_to_title), + ), + WcTransactionRequestInfoItemUM( + title = resourceReference(R.string.settings_wallet_name_title), + description = "Bob", + ), + WcTransactionRequestInfoItemUM( + title = resourceReference(R.string.wc_common_wallet), + description = "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826", ), ), ), ), - actions = WcTransactionActionsUM( - onDismiss = {}, - onSign = {}, - onCopy = {}, - ), + onCopy = {}, ), ), ) \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcNetworkFeeItem.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcNetworkFeeItem.kt index bb4c1867c5..df6080b3e4 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcNetworkFeeItem.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcNetworkFeeItem.kt @@ -1,5 +1,6 @@ package com.tangem.features.walletconnect.transaction.ui.common +import androidx.compose.animation.AnimatedContent import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.Icon @@ -48,11 +49,16 @@ internal fun WcNetworkFeeItem(networkFeeText: String, modifier: Modifier = Modif verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.End, ) { - Text( - text = networkFeeText, - style = TangemTheme.typography.body1, - color = TangemTheme.colors.text.tertiary, - ) + AnimatedContent( + targetState = networkFeeText, + label = "Animate Network fee text", + ) { fee -> + Text( + text = fee, + style = TangemTheme.typography.body1, + color = TangemTheme.colors.text.tertiary, + ) + } Spacer(modifier = Modifier.width(TangemTheme.dimens.spacing6)) Icon( modifier = Modifier diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcNetworkItem.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcNetworkItem.kt index 58c62d0366..fe95a18f69 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcNetworkItem.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcNetworkItem.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.res.painterResource import com.tangem.core.ui.extensions.stringResourceSafe import com.tangem.core.ui.res.TangemTheme import com.tangem.features.walletconnect.impl.R -import com.tangem.features.walletconnect.transaction.entity.WcNetworkInfoUM +import com.tangem.features.walletconnect.transaction.entity.common.WcNetworkInfoUM @Composable internal fun WcNetworkItem(networkInfo: WcNetworkInfoUM, modifier: Modifier = Modifier) { diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcRequestFromItem.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcSmallTitleItem.kt similarity index 80% rename from features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcRequestFromItem.kt rename to features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcSmallTitleItem.kt index a36d7b2365..e6d70ced09 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcRequestFromItem.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcSmallTitleItem.kt @@ -1,5 +1,6 @@ package com.tangem.features.walletconnect.transaction.ui.common +import androidx.annotation.StringRes import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material3.Text @@ -7,15 +8,14 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.tangem.core.ui.extensions.stringResourceSafe import com.tangem.core.ui.res.TangemTheme -import com.tangem.features.walletconnect.impl.R @Composable -fun RequestFromItem(modifier: Modifier = Modifier) { +fun WcSmallTitleItem(@StringRes textRex: Int, modifier: Modifier = Modifier) { Text( modifier = modifier .fillMaxWidth() .padding(top = TangemTheme.dimens.spacing12, start = TangemTheme.dimens.spacing12), - text = stringResourceSafe(R.string.wc_request_from), + text = stringResourceSafe(textRex), color = TangemTheme.colors.text.tertiary, style = TangemTheme.typography.subtitle2, ) diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcTransactionRequestButtons.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcTransactionRequestButtons.kt index 8451c004cb..9d8ec8d0fb 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcTransactionRequestButtons.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/common/WcTransactionRequestButtons.kt @@ -7,15 +7,18 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.tangem.core.ui.components.PrimaryButtonIconEnd import com.tangem.core.ui.components.SecondaryButton +import com.tangem.core.ui.extensions.TextReference +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 WcTransactionRequestButtons( + activeButtonText: TextReference, isLoading: Boolean, onDismiss: () -> Unit, - onSign: () -> Unit, + onClickActiveButton: () -> Unit, modifier: Modifier = Modifier, ) { Row(modifier = modifier, horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing8)) { @@ -30,8 +33,8 @@ internal fun WcTransactionRequestButtons( modifier = Modifier .fillMaxWidth() .weight(1f), - text = stringResourceSafe(R.string.common_sign), - onClick = onSign, + text = activeButtonText.resolveReference(), + onClick = onClickActiveButton, iconResId = R.drawable.ic_tangem_24, showProgress = isLoading, ) diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/sign/WcSignTransactionModalBottomSheetContent.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/sign/WcSignTransactionModalBottomSheetContent.kt index 398d71924e..4596bcc2b6 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/sign/WcSignTransactionModalBottomSheetContent.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/ui/sign/WcSignTransactionModalBottomSheetContent.kt @@ -26,32 +26,33 @@ import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreview import com.tangem.features.walletconnect.connections.ui.WcAppInfoItem import com.tangem.features.walletconnect.impl.R -import com.tangem.features.walletconnect.transaction.entity.* +import com.tangem.features.walletconnect.transaction.entity.common.WcNetworkInfoUM +import com.tangem.features.walletconnect.transaction.entity.common.WcTransactionAppInfoContentUM +import com.tangem.features.walletconnect.transaction.entity.sign.WcSignTransactionItemUM import com.tangem.features.walletconnect.transaction.ui.common.* -import kotlinx.collections.immutable.persistentListOf @Composable internal fun WcSignTransactionModalBottomSheetContent( - state: WcSignTransactionUM, + state: WcSignTransactionItemUM, onClickTransactionRequest: () -> Unit, ) { Column( modifier = Modifier - .padding(horizontal = TangemTheme.dimens.spacing16), + .padding(horizontal = 16.dp), ) { Column( modifier = Modifier - .clip(RoundedCornerShape(TangemTheme.dimens.radius14)) + .clip(RoundedCornerShape(14.dp)) .background(color = TangemTheme.colors.background.action) .fillMaxWidth() .animateContentSize(), ) { - RequestFromItem() + WcSmallTitleItem(R.string.wc_request_from) WcAppInfoItem( - iconUrl = state.transaction.appIcon, - title = state.transaction.appName, - subtitle = state.transaction.appSubtitle, - isVerified = state.transaction.isVerified, + iconUrl = state.appInfo.appIcon, + title = state.appInfo.appName, + subtitle = state.appInfo.appSubtitle, + isVerified = state.appInfo.isVerified, ) DividerWithPadding(start = 0.dp, end = 0.dp) WcTransactionRequestItem( @@ -59,69 +60,63 @@ internal fun WcSignTransactionModalBottomSheetContent( modifier = Modifier .fillMaxWidth() .clickable { onClickTransactionRequest() } - .padding(TangemTheme.dimens.spacing12), + .padding(12.dp), ) } - Column(modifier = Modifier.padding(top = TangemTheme.dimens.spacing16)) { + Column(modifier = Modifier.padding(top = 16.dp)) { WcSignTransactionItems(state) WcTransactionRequestButtons( - modifier = Modifier.padding(vertical = TangemTheme.dimens.spacing16), - onDismiss = state.actions.onDismiss, - onSign = state.actions.onSign, - isLoading = state.transaction.isLoading, + modifier = Modifier.padding(vertical = 16.dp), + onDismiss = state.onDismiss, + onClickActiveButton = state.onSign, + activeButtonText = resourceReference(R.string.common_sign), + isLoading = state.isLoading, ) } } } @Composable -private fun WcSignTransactionItems(state: WcSignTransactionUM) { +private fun WcSignTransactionItems(state: WcSignTransactionItemUM) { Column( modifier = Modifier - .clip(RoundedCornerShape(TangemTheme.dimens.radius14)) + .clip(RoundedCornerShape(14.dp)) .background(color = TangemTheme.colors.background.action) .fillMaxWidth() .animateContentSize(), ) { val itemsModifier = Modifier .fillMaxWidth() - .padding(TangemTheme.dimens.spacing12) + .padding(12.dp) DividerWithPadding(start = 0.dp, end = 0.dp) WcWalletItem( modifier = itemsModifier, - walletName = state.transaction.walletName, + walletName = state.walletName, ) - DividerWithPadding(start = TangemTheme.dimens.spacing40, end = TangemTheme.dimens.spacing12) + DividerWithPadding(start = 40.dp, end = 12.dp) WcNetworkItem( modifier = itemsModifier, - networkInfo = state.transaction.networkInfo, + networkInfo = state.networkInfo, ) - if (!state.transaction.addressText.isNullOrEmpty()) { - DividerWithPadding(start = TangemTheme.dimens.spacing40, end = TangemTheme.dimens.spacing12) + if (!state.addressText.isNullOrEmpty()) { + DividerWithPadding(start = 40.dp, end = 12.dp) WcAddressItem( modifier = itemsModifier, - addressText = state.transaction.addressText, - ) - } - if (!state.transaction.networkFee.isNullOrEmpty()) { - DividerWithPadding(start = TangemTheme.dimens.spacing40, end = TangemTheme.dimens.spacing12) - WcNetworkFeeItem( - modifier = itemsModifier, - networkFeeText = state.transaction.networkFee, + addressText = state.addressText, ) } } } @Composable -private fun DividerWithPadding(start: Dp, end: Dp) { +internal fun DividerWithPadding(start: Dp, end: Dp) { HorizontalDivider( modifier = Modifier.padding( start = start, end = end, ), - thickness = TangemTheme.dimens.size1, + thickness = 1.dp, color = TangemTheme.colors.stroke.primary, ) } @@ -130,10 +125,10 @@ private fun DividerWithPadding(start: Dp, end: Dp) { @Preview(showBackground = true, device = Devices.PIXEL_7_PRO) @Preview(showBackground = true, device = Devices.PIXEL_7_PRO, uiMode = Configuration.UI_MODE_NIGHT_YES) private fun WcSignTransactionBottomSheetPreview( - @PreviewParameter(WcSignTransactionStateProvider::class) state: WcSignTransactionUM, + @PreviewParameter(WcSignTransactionStateProvider::class) state: WcSignTransactionItemUM, ) { TangemThemePreview { - TangemModalBottomSheet( + TangemModalBottomSheet( config = TangemBottomSheetConfig( isShown = true, onDismissRequest = {}, @@ -156,41 +151,32 @@ private fun WcSignTransactionBottomSheetPreview( } } -private class WcSignTransactionStateProvider : CollectionPreviewParameterProvider( +private class WcSignTransactionStateProvider : CollectionPreviewParameterProvider( listOf( - WcSignTransactionUM( - transaction = WcTransactionUM( + WcSignTransactionItemUM( + onDismiss = {}, + onSign = {}, + appInfo = WcTransactionAppInfoContentUM( appName = "React App", appIcon = "", isVerified = true, appSubtitle = "react-app.walletconnect.com", - walletName = "Tangem 2.0", - networkInfo = WcNetworkInfoUM(name = "Ethereum", iconRes = R.drawable.img_eth_22), - ), - transactionRequestInfo = WcTransactionRequestInfoUM(persistentListOf()), - actions = WcTransactionActionsUM( - onDismiss = {}, - onSign = {}, - onCopy = {}, ), + walletName = "Tangem 2.0", + networkInfo = WcNetworkInfoUM(name = "Ethereum", iconRes = R.drawable.img_eth_22), ), - WcSignTransactionUM( - transaction = WcTransactionUM( + WcSignTransactionItemUM( + onDismiss = {}, + onSign = {}, + appInfo = WcTransactionAppInfoContentUM( appName = "React App", appIcon = "", isVerified = true, appSubtitle = "react-app.walletconnect.com", - walletName = "Tangem 2.0", - networkInfo = WcNetworkInfoUM(name = "Ethereum", iconRes = R.drawable.img_eth_22), - addressText = "0x345FF...34FA", - networkFee = "~ 0.22 $", - ), - transactionRequestInfo = WcTransactionRequestInfoUM(persistentListOf()), - actions = WcTransactionActionsUM( - onDismiss = {}, - onSign = {}, - onCopy = {}, ), + walletName = "Tangem 2.0", + addressText = "0x345FF...34FA", + networkInfo = WcNetworkInfoUM(name = "Ethereum", iconRes = R.drawable.img_eth_22), ), ), ) \ No newline at end of file diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/utils/WcSignTransactionUtils.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/utils/WcSignTransactionUtils.kt index 0442435782..986355b6cf 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/utils/WcSignTransactionUtils.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/utils/WcSignTransactionUtils.kt @@ -11,13 +11,9 @@ import com.tangem.domain.walletconnect.usecase.method.WcSignState import com.tangem.domain.walletconnect.usecase.method.WcSignStep import com.tangem.domain.walletconnect.usecase.method.WcSignUseCase import com.tangem.features.walletconnect.impl.R -import com.tangem.features.walletconnect.transaction.entity.WcNetworkInfoUM -import com.tangem.features.walletconnect.transaction.entity.WcSignTransactionUM -import com.tangem.features.walletconnect.transaction.entity.WcTransactionActionsUM -import com.tangem.features.walletconnect.transaction.entity.WcTransactionRequestBlockUM -import com.tangem.features.walletconnect.transaction.entity.WcTransactionRequestInfoItemUM -import com.tangem.features.walletconnect.transaction.entity.WcTransactionRequestInfoUM -import com.tangem.features.walletconnect.transaction.entity.WcTransactionUM +import com.tangem.features.walletconnect.transaction.entity.common.* +import com.tangem.features.walletconnect.transaction.entity.sign.WcSignTransactionItemUM +import com.tangem.features.walletconnect.transaction.entity.sign.WcSignTransactionUM import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList @@ -47,12 +43,15 @@ private fun WcMessageSignUseCase.signTypedDataToUM( signModel: WcMessageSignUseCase.SignModel, actions: WcTransactionActionsUM, ) = WcSignTransactionUM( - actions = actions, - transaction = WcTransactionUM( - appName = session.sdkModel.appMetaData.name, - appIcon = session.sdkModel.appMetaData.url, - isVerified = session.securityStatus == CheckDAppResult.SAFE, - appSubtitle = session.sdkModel.appMetaData.description, + transaction = WcSignTransactionItemUM( + onDismiss = actions.onDismiss, + onSign = actions.onSign, + appInfo = WcTransactionAppInfoContentUM( + appName = session.sdkModel.appMetaData.name, + appIcon = session.sdkModel.appMetaData.url, + isVerified = session.securityStatus == CheckDAppResult.SAFE, + appSubtitle = session.sdkModel.appMetaData.description, + ), walletName = session.wallet.name, networkInfo = WcNetworkInfoUM( name = network.name, @@ -62,7 +61,7 @@ private fun WcMessageSignUseCase.signTypedDataToUM( isLoading = signState.domainStep == WcSignStep.Signing, ), transactionRequestInfo = WcTransactionRequestInfoUM( - buildList { + blocks = buildList { add(createInfoBlockUM(rawSdkRequest, signModel)) (method as? WcEthMethod.SignTypedData)?.params?.message?.to?.let { to -> add( @@ -84,6 +83,7 @@ private fun WcMessageSignUseCase.signTypedDataToUM( ) } }.toImmutableList(), + onCopy = actions.onCopy, ), ) @@ -92,12 +92,15 @@ private fun WcMessageSignUseCase.messageSignToUM( signModel: WcMessageSignUseCase.SignModel, actions: WcTransactionActionsUM, ) = WcSignTransactionUM( - actions = actions, - transaction = WcTransactionUM( - appName = session.sdkModel.appMetaData.name, - appIcon = session.sdkModel.appMetaData.url, - isVerified = session.securityStatus == CheckDAppResult.SAFE, - appSubtitle = session.sdkModel.appMetaData.description, + transaction = WcSignTransactionItemUM( + onDismiss = actions.onDismiss, + onSign = actions.onSign, + appInfo = WcTransactionAppInfoContentUM( + appName = session.sdkModel.appMetaData.name, + appIcon = session.sdkModel.appMetaData.url, + isVerified = session.securityStatus == CheckDAppResult.SAFE, + appSubtitle = session.sdkModel.appMetaData.description, + ), walletName = session.wallet.name, networkInfo = WcNetworkInfoUM( name = network.name, @@ -107,6 +110,7 @@ private fun WcMessageSignUseCase.messageSignToUM( ), transactionRequestInfo = WcTransactionRequestInfoUM( persistentListOf(createInfoBlockUM(rawSdkRequest, signModel)), + onCopy = actions.onCopy, ), )