From 05e0f18b457c3ae45615a86838ced5a7bb4fc993 Mon Sep 17 00:00:00 2001 From: Tangem Date: Sat, 28 May 2022 14:13:36 +0300 Subject: [PATCH 1/5] Updated on 2026-08-14 --- app/src/main/res/values-ru/strings_final.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values-ru/strings_final.xml b/app/src/main/res/values-ru/strings_final.xml index 8ce3f1256a..56214ef6e8 100644 --- a/app/src/main/res/values-ru/strings_final.xml +++ b/app/src/main/res/values-ru/strings_final.xml @@ -40,7 +40,7 @@ Доступные сети Внимание! Валюты на разных сетях имеют разные адреса. Убедитесь, что адрес соответствует сети, в которой вы отправляете средства. Токены в сети Solana не поддерживаются этой картой из-за ограничений прошивки. - Не осуществляйте перевод на токены в данной сети иначе это может привести к их безвозвратной утере. + Не осуществляйте перевод на токены в данной сети, иначе это может привести к их безвозвратной утере. Адрес контракта скопирован! Если вы совершили ошибку с выбором сети при переводе средств с биржи, эта инструкция поможет вам восстановить средства From e362149f9e57fce5f798c5932c38cbccfe9bf540 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 23 May 2022 18:50:39 +0300 Subject: [PATCH 2/5] Updated on 2026-08-14 --- .../tap/features/wallet/ui/WalletFragment.kt | 8 +- .../wallet/ui/wallet/MultiWalletView.kt | 8 -- .../wallet/ui/wallet/SingleWalletView.kt | 9 +- .../main/res/drawable/ic_more_vertical_24.xml | 10 ++ app/src/main/res/drawable/ic_scan_card_24.xml | 10 ++ app/src/main/res/layout/fragment_home.xml | 2 +- app/src/main/res/layout/fragment_wallet.xml | 96 ++++++++----------- app/src/main/res/menu/wallet.xml | 11 ++- app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values/dimens.xml | 1 + app/src/main/res/values/strings.xml | 1 + 11 files changed, 81 insertions(+), 76 deletions(-) create mode 100644 app/src/main/res/drawable/ic_more_vertical_24.xml create mode 100644 app/src/main/res/drawable/ic_scan_card_24.xml diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt index 9c4661dbb8..24473568ef 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt @@ -24,7 +24,11 @@ import com.tangem.tap.domain.statePrinter.printScanResponseState import com.tangem.tap.domain.statePrinter.printWalletState import com.tangem.tap.domain.termsOfUse.CardTou import com.tangem.tap.features.details.redux.DetailsAction -import com.tangem.tap.features.wallet.redux.* +import com.tangem.tap.features.wallet.redux.Artwork +import com.tangem.tap.features.wallet.redux.ErrorType +import com.tangem.tap.features.wallet.redux.ProgressState +import com.tangem.tap.features.wallet.redux.WalletAction +import com.tangem.tap.features.wallet.redux.WalletState import com.tangem.tap.features.wallet.ui.adapters.WarningMessagesAdapter import com.tangem.tap.features.wallet.ui.wallet.MultiWalletView import com.tangem.tap.features.wallet.ui.wallet.SingleWalletView @@ -78,7 +82,7 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber + + diff --git a/app/src/main/res/drawable/ic_scan_card_24.xml b/app/src/main/res/drawable/ic_scan_card_24.xml new file mode 100644 index 0000000000..b77d547233 --- /dev/null +++ b/app/src/main/res/drawable/ic_scan_card_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 30dfad0768..7a95116cd8 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -8,4 +8,4 @@ android:layout_width="match_parent" android:layout_height="match_parent"/> - \ No newline at end of file + diff --git a/app/src/main/res/layout/fragment_wallet.xml b/app/src/main/res/layout/fragment_wallet.xml index 829a1f019b..3b962facaf 100644 --- a/app/src/main/res/layout/fragment_wallet.xml +++ b/app/src/main/res/layout/fragment_wallet.xml @@ -18,12 +18,13 @@ app:liftOnScroll="true"> + android:id="@+id/toolbar" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize" + app:menu="@menu/wallet" + app:navigationIcon="@drawable/ic_scan_card_24" + app:navigationIconTint="@color/iconGray" + app:title="@string/wallet_title" /> @@ -41,19 +42,20 @@ android:overScrollMode="never"> - - + + - - - - - - - - - + android:layout_marginTop="30dp" + app:layout_constraintTop_toBottomOf="@id/l_address" + app:layout_constraintVertical_bias="1" + app:layout_constraintBottom_toBottomOf="parent" /> @@ -214,4 +179,19 @@ + + diff --git a/app/src/main/res/menu/wallet.xml b/app/src/main/res/menu/wallet.xml index c4947ea75b..7f6107b331 100644 --- a/app/src/main/res/menu/wallet.xml +++ b/app/src/main/res/menu/wallet.xml @@ -2,8 +2,9 @@ - \ No newline at end of file + android:id="@+id/details_menu" + android:title="@string/details_title" + android:icon="@drawable/ic_more_vertical_24" + app:iconTint="@color/iconGray" + app:showAsAction="ifRoom" /> + diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index bc04e7cf38..0e8fe53b9d 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -384,4 +384,5 @@ Информация ниже не является обязательной. Вы можете стереть её, если хотите. Баланс Обработка полной суммы… + Управление токенами diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index ce2c35b5fb..63924e74c0 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -30,6 +30,7 @@ 135dp 4dp + 8dp 44dp 32sp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c3caa853e1..c87db69e49 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -208,4 +208,5 @@ No, send all Total balance Processing full amount… + Manage tokens From eaa1215307c3a729e6906b92a6f12c4381d30440 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 25 May 2022 12:05:51 +0300 Subject: [PATCH 3/5] Updated on 2026-08-14 --- .../tap/features/wallet/redux/WalletState.kt | 22 +++++++--- .../redux/reducers/MultiWalletReducer.kt | 9 +++- .../redux/reducers/OnWalletLoadedReducer.kt | 11 ++--- .../redux/reducers/TotalBalanceOperations.kt | 28 +++---------- .../wallet/redux/reducers/WalletReducer.kt | 19 ++++++--- .../wallet/ui/wallet/MultiWalletView.kt | 42 +++++++++---------- 6 files changed, 70 insertions(+), 61 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt index c815b4b404..f5b14fe589 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt @@ -32,6 +32,8 @@ import com.tangem.tap.features.wallet.models.WalletRent import com.tangem.tap.features.wallet.models.WalletWarning import com.tangem.tap.features.wallet.models.toPendingTransactions import com.tangem.tap.features.wallet.models.toPendingTransactionsForToken +import com.tangem.tap.features.wallet.redux.reducers.calculateTotalFiatAmount +import com.tangem.tap.features.wallet.redux.reducers.findTotalBalanceState import com.tangem.tap.features.wallet.ui.BalanceStatus import com.tangem.tap.features.wallet.ui.BalanceWidgetData import com.tangem.tap.network.exchangeServices.CurrencyExchangeManager @@ -200,11 +202,11 @@ data class WalletState( .distinct().map { getWalletStore(it) }.mapNotNull { it?.updateWallets(walletsData) } return updateWalletStores(walletStores) - } fun updateWalletStore(walletStore: WalletStore?): WalletState { return copy(wallets = replaceWalletInWallets(walletStore)) + .updateTotalBalance() } private fun updateWalletStores(walletStores: List): WalletState { @@ -221,6 +223,7 @@ data class WalletState( } } return copy(wallets = updatedWallets + walletStoresMutable) + .updateTotalBalance() } fun removeWallet(walletData: WalletData?): WalletState { @@ -282,11 +285,18 @@ data class WalletState( } } - fun updateTotalBalance( - totalBalance: TotalBalance? - ): WalletState { - return this.copy( - totalBalance = totalBalance + private fun updateTotalBalance(): WalletState { + return if (wallets.isNotEmpty()) { + val walletsData = wallets.flatMap(WalletStore::walletsData) + this.copy( + totalBalance = TotalBalance( + state = walletsData.findTotalBalanceState(), + fiatAmount = walletsData.calculateTotalFiatAmount(), + fiatCurrency = store.state.globalState.appCurrency + ) + ) + } else this.copy( + totalBalance = null ) } } diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/MultiWalletReducer.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/MultiWalletReducer.kt index a7437c94eb..f0c7973628 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/MultiWalletReducer.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/MultiWalletReducer.kt @@ -10,7 +10,12 @@ import com.tangem.tap.domain.getFirstToken import com.tangem.tap.domain.tokens.BlockchainNetwork import com.tangem.tap.features.wallet.models.removeUnknownTransactions import com.tangem.tap.features.wallet.models.toPendingTransactions -import com.tangem.tap.features.wallet.redux.* +import com.tangem.tap.features.wallet.redux.Currency +import com.tangem.tap.features.wallet.redux.WalletAction +import com.tangem.tap.features.wallet.redux.WalletData +import com.tangem.tap.features.wallet.redux.WalletMainButton +import com.tangem.tap.features.wallet.redux.WalletState +import com.tangem.tap.features.wallet.redux.WalletStore import com.tangem.tap.features.wallet.ui.BalanceStatus import com.tangem.tap.features.wallet.ui.BalanceWidgetData import com.tangem.tap.features.wallet.ui.TokenData @@ -126,7 +131,7 @@ class MultiWalletReducer { ), fiatAmountFormatted = tokenWalletData.fiatRate?.let { action.amount.value - ?.toFiatString(it, store.state.globalState.appCurrency.code) + ?.toFiatString(it, store.state.globalState.appCurrency.symbol) }, blockchainAmount = wallet.amounts[AmountType.Coin]?.value ?: BigDecimal.ZERO ), diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/OnWalletLoadedReducer.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/OnWalletLoadedReducer.kt index ce9b5cf80a..c44f18e21a 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/OnWalletLoadedReducer.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/OnWalletLoadedReducer.kt @@ -11,7 +11,11 @@ import com.tangem.tap.domain.getFirstToken import com.tangem.tap.domain.tokens.BlockchainNetwork import com.tangem.tap.features.wallet.models.removeUnknownTransactions import com.tangem.tap.features.wallet.models.toPendingTransactions -import com.tangem.tap.features.wallet.redux.* +import com.tangem.tap.features.wallet.redux.Currency +import com.tangem.tap.features.wallet.redux.ProgressState +import com.tangem.tap.features.wallet.redux.TradeCryptoState +import com.tangem.tap.features.wallet.redux.WalletMainButton +import com.tangem.tap.features.wallet.redux.WalletState import com.tangem.tap.features.wallet.ui.BalanceStatus import com.tangem.tap.features.wallet.ui.BalanceWidgetData import com.tangem.tap.features.wallet.ui.TokenData @@ -97,7 +101,7 @@ class OnWalletLoadedReducer { token.symbol ), fiatAmount = tokenFiatAmount, - fiatAmountFormatted = tokenFiatAmount?.toFormattedFiatValue(fiatCurrency.code) + fiatAmountFormatted = tokenFiatAmount?.toFormattedFiatValue(fiatCurrency.symbol) ), pendingTransactions = tokenPendingTransactions.removeUnknownTransactions(), mainButton = WalletMainButton.SendButton(tokenSendButton), @@ -114,9 +118,6 @@ class OnWalletLoadedReducer { } return walletState .updateWalletsData(wallets) - .updateTotalBalance( - totalBalance = obtainTotalBalance(wallets, fiatCurrency) - ) .copy( state = state, error = null diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/TotalBalanceOperations.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/TotalBalanceOperations.kt index b949fe11d9..06d91d7db0 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/TotalBalanceOperations.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/TotalBalanceOperations.kt @@ -1,37 +1,21 @@ package com.tangem.tap.features.wallet.redux.reducers -import com.tangem.tap.common.entities.FiatCurrency import com.tangem.tap.features.wallet.models.TotalBalance import com.tangem.tap.features.wallet.redux.WalletData import com.tangem.tap.features.wallet.ui.BalanceStatus import java.math.BigDecimal -fun obtainTotalBalance( - wallets: List, - appCurrency: FiatCurrency -): TotalBalance? { - return if (wallets.isNotEmpty()) { - TotalBalance( - state = wallets.findTotalBalanceState(), - fiatAmount = wallets.calculateTotalFiatAmount(), - fiatCurrency = appCurrency - ) - } else null -} - -private fun List.findTotalBalanceState(): TotalBalance.State { +fun List.findTotalBalanceState(): TotalBalance.State { return this.mapToTotalBalanceState() - .fold(initial = TotalBalance.State.Loading) { accState, newState -> - accState or newState - } + .reduce(TotalBalance.State::or) } -private fun List.calculateTotalFiatAmount(): BigDecimal { +fun List.calculateTotalFiatAmount(): BigDecimal { return this.map { it.currencyData.fiatAmount ?: BigDecimal.ZERO } .reduce(BigDecimal::plus) } -private fun List.mapToTotalBalanceState(): List { +fun List.mapToTotalBalanceState(): List { return this.map { when (it.currencyData.status) { BalanceStatus.VerifiedOnline, @@ -50,9 +34,9 @@ private fun List.mapToTotalBalanceState(): List infix fun TotalBalance.State.or(newState: TotalBalance.State): TotalBalance.State { return when (this) { TotalBalance.State.Loading -> when (newState) { - TotalBalance.State.Loading -> this + TotalBalance.State.Loading, TotalBalance.State.SomeTokensFailed, - TotalBalance.State.Success -> newState + TotalBalance.State.Success -> this } TotalBalance.State.Success, TotalBalance.State.SomeTokensFailed -> when (newState) { diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/WalletReducer.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/WalletReducer.kt index e4126a3f8c..65e89b0d83 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/WalletReducer.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/reducers/WalletReducer.kt @@ -16,12 +16,24 @@ import com.tangem.tap.domain.extensions.getArtworkUrl import com.tangem.tap.domain.getFirstToken import com.tangem.tap.domain.tokens.BlockchainNetwork import com.tangem.tap.features.wallet.models.WalletRent -import com.tangem.tap.features.wallet.redux.* +import com.tangem.tap.features.wallet.redux.AddressData +import com.tangem.tap.features.wallet.redux.Artwork +import com.tangem.tap.features.wallet.redux.Currency +import com.tangem.tap.features.wallet.redux.ErrorType +import com.tangem.tap.features.wallet.redux.ProgressState +import com.tangem.tap.features.wallet.redux.TradeCryptoState +import com.tangem.tap.features.wallet.redux.WalletAction +import com.tangem.tap.features.wallet.redux.WalletAddresses +import com.tangem.tap.features.wallet.redux.WalletData +import com.tangem.tap.features.wallet.redux.WalletDialog +import com.tangem.tap.features.wallet.redux.WalletMainButton +import com.tangem.tap.features.wallet.redux.WalletState +import com.tangem.tap.features.wallet.redux.WalletStore import com.tangem.tap.features.wallet.ui.BalanceStatus import com.tangem.tap.features.wallet.ui.BalanceWidgetData import com.tangem.tap.store -import org.rekotlin.Action import java.math.BigDecimal +import org.rekotlin.Action class WalletReducer { companion object { @@ -436,9 +448,6 @@ private fun setMultiWalletFiatRate( return state .updateWalletsData(newWalletsData) - .updateTotalBalance( - totalBalance = obtainTotalBalance(newWalletsData, appCurrency) - ) } private fun setSingleWalletFiatRate( diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/MultiWalletView.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/MultiWalletView.kt index 15eb7aedce..66b4a9e664 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/MultiWalletView.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/MultiWalletView.kt @@ -2,6 +2,7 @@ package com.tangem.tap.features.wallet.ui.wallet import android.app.Dialog import android.view.View +import androidx.core.view.isVisible import androidx.recyclerview.widget.LinearLayoutManager import com.tangem.common.card.Card import com.tangem.domain.common.TapWorkarounds.derivationStyle @@ -129,29 +130,28 @@ class MultiWalletView : WalletView { binding: FragmentWalletBinding, totalBalance: TotalBalance?, ) = with(binding.lCardTotalBalance) { - if (totalBalance == null) { - this.root.hide() - return@with - } + root.isVisible = totalBalance != null + if (totalBalance != null) { + tvBalance.animateVisibility( + show = totalBalance.state != TotalBalance.State.Loading, + hiddenVisibility = View.INVISIBLE + ) + pbLoading.animateVisibility( + show = totalBalance.state == TotalBalance.State.Loading + ) + tvProcessing.animateVisibility( + show = totalBalance.state == TotalBalance.State.SomeTokensFailed + ) - tvBalance.animateVisibility( - show = totalBalance.state != TotalBalance.State.Loading, - hiddenVisibility = View.INVISIBLE - ) - pbLoading.animateVisibility( - show = totalBalance.state == TotalBalance.State.Loading - ) - tvProcessing.animateVisibility( - show = totalBalance.state == TotalBalance.State.SomeTokensFailed - ) + tvBalance.text = if (totalBalance.state == TotalBalance.State.SomeTokensFailed) "—" + else totalBalance.fiatAmount.formatAmountAsSpannedString( + currencySymbol = totalBalance.fiatCurrency.symbol + ) + tvCurrencyName.text = totalBalance.fiatCurrency.code - tvBalance.text = totalBalance.fiatAmount.formatAmountAsSpannedString( - currencySymbol = totalBalance.fiatCurrency.symbol - ) - tvCurrencyName.text = totalBalance.fiatCurrency.code - - tvCurrencyName.setOnClickListener { - store.dispatch(WalletAction.AppCurrencyAction.ChooseAppCurrency) + tvCurrencyName.setOnClickListener { + store.dispatch(WalletAction.AppCurrencyAction.ChooseAppCurrency) + } } } From 7b026e8447ad9358acd314556c5f13d5b299c979 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 25 May 2022 15:48:47 +0300 Subject: [PATCH 4/5] Updated on 2026-08-14 --- app/build.gradle | 4 +- .../tangem/tap/common/extensions/Specific.kt | 14 +-- .../wallet/ui/adapters/WalletAdapter.kt | 88 +++++++------ .../wallet/ui/wallet/MultiWalletView.kt | 13 +- .../main/res/layout/card_total_balance.xml | 54 ++++---- .../res/layout/card_total_balance_shimmer.xml | 11 ++ .../main/res/layout/item_currency_wallet.xml | 116 +++--------------- .../layout/item_currency_wallet_content.xml | 90 ++++++++++++++ .../layout/item_currency_wallet_shimmer.xml | 40 ++++++ app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values/strings.xml | 3 +- app/src/main/res/values/styles.xml | 1 - 12 files changed, 249 insertions(+), 186 deletions(-) create mode 100644 app/src/main/res/layout/card_total_balance_shimmer.xml create mode 100644 app/src/main/res/layout/item_currency_wallet_content.xml create mode 100644 app/src/main/res/layout/item_currency_wallet_shimmer.xml diff --git a/app/build.gradle b/app/build.gradle index 446c060d9f..3dcd68f4e8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -170,6 +170,8 @@ dependencies { implementation 'androidx.compose.ui:ui-tooling:1.1.1' implementation "com.google.accompanist:accompanist-appcompat-theme:0.23.0" + implementation "com.github.skydoves:androidveil:1.1.2" + implementation("io.coil-kt:coil:2.0.0-rc01") implementation("io.coil-kt:coil-compose:2.0.0-rc01") @@ -180,4 +182,4 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' -} \ No newline at end of file +} diff --git a/app/src/main/java/com/tangem/tap/common/extensions/Specific.kt b/app/src/main/java/com/tangem/tap/common/extensions/Specific.kt index ea112781c3..b431b780ad 100644 --- a/app/src/main/java/com/tangem/tap/common/extensions/Specific.kt +++ b/app/src/main/java/com/tangem/tap/common/extensions/Specific.kt @@ -108,24 +108,22 @@ fun BigDecimal.isLessThanOrEqual(value: BigDecimal): Boolean { fun BigDecimal.formatAmountAsSpannedString( currencySymbol: String, - integerPartSizeProportion: Float = 1.4f + reminderPartSizeProportion: Float = 0.7f ): SpannedString { val amount = this .setScale(2, RoundingMode.HALF_UP) - .toString() + .formatWithSpaces() val integer = amount.substringBefore('.') val reminder = amount.substringAfter('.') return buildSpannedString { + append(integer) + append('.') append( - integer, - RelativeSizeSpan(integerPartSizeProportion), + "$reminder $currencySymbol", + RelativeSizeSpan(reminderPartSizeProportion), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE ) - append('.') - append(reminder) - append(' ') - append(currencySymbol) } } diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/adapters/WalletAdapter.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/adapters/WalletAdapter.kt index 8328274be6..6230fd27a3 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/adapters/WalletAdapter.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/adapters/WalletAdapter.kt @@ -2,6 +2,7 @@ package com.tangem.tap.features.wallet.ui.adapters import android.view.LayoutInflater import android.view.ViewGroup +import androidx.core.view.isVisible import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView @@ -10,6 +11,7 @@ import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.Token import com.tangem.domain.common.TapWorkarounds.derivationStyle import com.tangem.tap.common.extensions.getString +import com.tangem.tap.common.extensions.hide import com.tangem.tap.common.extensions.loadCurrenciesIcon import com.tangem.tap.common.extensions.show import com.tangem.tap.features.wallet.redux.Currency @@ -61,57 +63,63 @@ class WalletAdapter RecyclerView.ViewHolder(binding.root) { fun bind(wallet: WalletData) = with(binding) { - tvCurrency.text = wallet.currencyData.currency - tvAmount.text = wallet.currencyData.amountFormatted.orEmpty() - tvAmountFiat.text = wallet.currencyData.fiatAmountFormatted - tvExchangeRate.text = wallet.fiatRateString - cardWallet.setOnClickListener { - store.dispatch(WalletAction.MultiWallet.SelectWallet(wallet)) + val status = wallet.currencyData.status + val isCustomCurrency = wallet.currency.isCustomCurrency( + derivationStyle = store.state.globalState + .scanResponse + ?.card + ?.derivationStyle + ) + val statusMessage = when (status) { + BalanceStatus.TransactionInProgress -> { + root.getString(R.string.wallet_balance_tx_in_progress) + } + BalanceStatus.Unreachable -> { + root.getString(R.string.wallet_balance_blockchain_unreachable) + } + BalanceStatus.NoAccount -> { + root.getString(R.string.wallet_error_no_account) + } + BalanceStatus.VerifiedOnline, + BalanceStatus.SameCurrencyTransactionInProgress, + BalanceStatus.EmptyCard, + BalanceStatus.UnknownBlockchain, + BalanceStatus.Loading, + null -> null } - val blockchain = wallet.currency.blockchain - val token = (wallet.currency as? Currency.Token)?.token - val isCustom = wallet.currency - .isCustomCurrency(store.state.globalState.scanResponse?.card?.derivationStyle) - tvExchangeRate.show(!isCustom) - tvCustomCurrency.show(isCustom) + if (status == null || status == BalanceStatus.Loading) { + lContent.root.hide() + lShimmer.root.veil() + } else { + lShimmer.root.unVeil() + lContent.root.show() + } Picasso.get().loadCurrenciesIcon( imageView = ivCurrency, textView = tvTokenLetter, - token = token, blockchain = blockchain, + token = (wallet.currency as? Currency.Token)?.token, + blockchain = wallet.currency.blockchain, ) - when (wallet.currencyData.status) { - BalanceStatus.VerifiedOnline, - BalanceStatus.SameCurrencyTransactionInProgress -> hideMessage() - BalanceStatus.Loading -> if (wallet.currencyData.amountFormatted == null) { - showMessage(root.getString(R.string.wallet_balance_loading)) - } - BalanceStatus.TransactionInProgress -> - showMessage(root.getString(R.string.wallet_balance_tx_in_progress)) - BalanceStatus.Unreachable -> - showMessage(root.getString(R.string.wallet_balance_blockchain_unreachable)) + lContent.tvCurrency.text = wallet.currencyData.currency + lContent.tvAmountFiat.text = wallet.currencyData.fiatAmountFormatted ?: "—" + lContent.tvAmount.text = wallet.currencyData.amountFormatted ?: "—" - BalanceStatus.NoAccount -> - showMessage(root.getString(R.string.wallet_error_no_account)) - else -> { - } + lContent.tvStatus.isVisible = statusMessage != null + lContent.tvStatus.text = statusMessage + + lContent.tvExchangeRate.isVisible = statusMessage == null + lContent.tvExchangeRate.text = if (isCustomCurrency) { + root.getString(id = R.string.token_item_no_rate) + } else { + wallet.fiatRateString } - } - private fun showMessage(message: String) { - toggleMessage(true) - binding.tvStatus.text = message - } - - private fun hideMessage() { - toggleMessage(false) - } - - private fun toggleMessage(show: Boolean) { - binding.tvAmount.show(!show) - binding.tvStatus.show(show) + cardWallet.setOnClickListener { + store.dispatch(WalletAction.MultiWallet.SelectWallet(wallet)) + } } } } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/MultiWalletView.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/MultiWalletView.kt index 66b4a9e664..623f19e85d 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/MultiWalletView.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/wallet/MultiWalletView.kt @@ -1,7 +1,6 @@ package com.tangem.tap.features.wallet.ui.wallet import android.app.Dialog -import android.view.View import androidx.core.view.isVisible import androidx.recyclerview.widget.LinearLayoutManager import com.tangem.common.card.Card @@ -132,13 +131,11 @@ class MultiWalletView : WalletView { ) = with(binding.lCardTotalBalance) { root.isVisible = totalBalance != null if (totalBalance != null) { - tvBalance.animateVisibility( - show = totalBalance.state != TotalBalance.State.Loading, - hiddenVisibility = View.INVISIBLE - ) - pbLoading.animateVisibility( - show = totalBalance.state == TotalBalance.State.Loading - ) + if (totalBalance.state == TotalBalance.State.Loading) { + veilBalance.veil() + } else { + veilBalance.unVeil() + } tvProcessing.animateVisibility( show = totalBalance.state == TotalBalance.State.SomeTokensFailed ) diff --git a/app/src/main/res/layout/card_total_balance.xml b/app/src/main/res/layout/card_total_balance.xml index 0b0d382e71..196dc167e1 100644 --- a/app/src/main/res/layout/card_total_balance.xml +++ b/app/src/main/res/layout/card_total_balance.xml @@ -22,10 +22,10 @@ - + tools:veilLayout_veiled="false"> - + + + + + + + + diff --git a/app/src/main/res/layout/item_currency_wallet.xml b/app/src/main/res/layout/item_currency_wallet.xml index c2d664e182..ddb13e5666 100644 --- a/app/src/main/res/layout/item_currency_wallet.xml +++ b/app/src/main/res/layout/item_currency_wallet.xml @@ -21,7 +21,8 @@ android:layout_marginTop="12dp" android:layout_marginBottom="12dp" android:layout_marginStart="16dp" - android:layout_marginEnd="16dp"> + android:layout_marginEnd="16dp" + android:animateLayoutChanges="true"> - - - - - - - - - - - - + app:layout_constraintEnd_toEndOf="parent" + tools:visibility="visible" /> - - - + app:layout_constraintStart_toEndOf="@id/iv_currency" + app:layout_constraintEnd_toEndOf="parent" /> diff --git a/app/src/main/res/layout/item_currency_wallet_content.xml b/app/src/main/res/layout/item_currency_wallet_content.xml new file mode 100644 index 0000000000..18249f4c63 --- /dev/null +++ b/app/src/main/res/layout/item_currency_wallet_content.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/item_currency_wallet_shimmer.xml b/app/src/main/res/layout/item_currency_wallet_shimmer.xml new file mode 100644 index 0000000000..a37bd8c956 --- /dev/null +++ b/app/src/main/res/layout/item_currency_wallet_shimmer.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 0e8fe53b9d..75c6262e20 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -385,4 +385,5 @@ Баланс Обработка полной суммы… Управление токенами + Нет цены diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c87db69e49..65c053f776 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -207,6 +207,7 @@ Reduce by %s XTZ No, send all Total balance - Processing full amount… + Some networks are unreachable Manage tokens + No rate diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 49c8fefbbb..f36d1cd4bf 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -160,7 +160,6 @@ - From abe140be7b702a50979e34844e2b3dea21333e27 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 30 May 2022 13:28:36 +0300 Subject: [PATCH 5/5] Updated on 2026-08-14 --- app/src/main/res/values-ru/strings.xml | 4 ---- app/src/main/res/values-ru/strings_final.xml | 6 +++++- app/src/main/res/values/strings.xml | 4 ---- app/src/main/res/values/strings_final.xml | 6 +++++- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 75c6262e20..c45da10b0e 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -382,8 +382,4 @@ Привет, команда поддержки, Пожалуйста, расскажите нам больше о Вашей проблеме. Каждая деталь может быть полезной. Информация ниже не является обязательной. Вы можете стереть её, если хотите. - Баланс - Обработка полной суммы… - Управление токенами - Нет цены diff --git a/app/src/main/res/values-ru/strings_final.xml b/app/src/main/res/values-ru/strings_final.xml index 56214ef6e8..ea424b57b6 100644 --- a/app/src/main/res/values-ru/strings_final.xml +++ b/app/src/main/res/values-ru/strings_final.xml @@ -46,4 +46,8 @@ Пользовательский - \ No newline at end of file + Баланс + Обработка полной суммы… + Управление токенами + Нет цены + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 65c053f776..520b7bc183 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -206,8 +206,4 @@ To avoid paying an increased commission the next time you top up your wallet, reduce the amount by %s XTZ Reduce by %s XTZ No, send all - Total balance - Some networks are unreachable - Manage tokens - No rate diff --git a/app/src/main/res/values/strings_final.xml b/app/src/main/res/values/strings_final.xml index de09eb54fd..2478dee488 100644 --- a/app/src/main/res/values/strings_final.xml +++ b/app/src/main/res/values/strings_final.xml @@ -46,4 +46,8 @@ Custom - \ No newline at end of file + Total balance + Some networks are unreachable + Manage tokens + No rate +