Updated on 2026-08-14
This commit is contained in:
parent
2357aa509f
commit
c03ab1bfb2
8 changed files with 127 additions and 33 deletions
|
|
@ -93,8 +93,10 @@ fun BigDecimal.formatAmountAsSpannedString(
|
|||
currencySymbol: String,
|
||||
integerPartSizeProportion: Float = 1.4f
|
||||
): SpannedString {
|
||||
val amount = this.scaleToFiat(applyPrecision = true)
|
||||
.stripZeroPlainString()
|
||||
val amount = this.toFormattedString(
|
||||
decimals = 2,
|
||||
roundingMode = RoundingMode.HALF_UP
|
||||
)
|
||||
val integer = amount.substringAfter('.')
|
||||
val reminder = amount.substringBefore('.')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tangem.tap.common.extensions
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
import android.app.Activity
|
||||
import android.content.*
|
||||
import android.content.res.Resources
|
||||
|
|
@ -16,6 +18,7 @@ import androidx.annotation.ColorRes
|
|||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.tangem.common.extensions.VoidCallback
|
||||
|
|
@ -187,4 +190,47 @@ fun Context.safeStartActivity(
|
|||
|
||||
fun View.getString(resId: Int, vararg formatArgs: Any?): String {
|
||||
return context.getString(resId, formatArgs)
|
||||
}
|
||||
|
||||
fun View.showAnimated(durationMillis: Long = 300) {
|
||||
this.animateVisibility(
|
||||
show = true,
|
||||
durationMillis = durationMillis
|
||||
)
|
||||
}
|
||||
|
||||
fun View.hideAnimated(
|
||||
durationMillis: Long = 300,
|
||||
hiddenVisibility: Int = View.GONE
|
||||
) {
|
||||
this.animateVisibility(
|
||||
show = false,
|
||||
durationMillis = durationMillis,
|
||||
hiddenVisibility = hiddenVisibility
|
||||
)
|
||||
}
|
||||
|
||||
private fun View.animateVisibility(
|
||||
show: Boolean,
|
||||
durationMillis: Long = 300,
|
||||
hiddenVisibility: Int = View.GONE
|
||||
) {
|
||||
if (this.isVisible == show) return
|
||||
if (show) {
|
||||
this.alpha = 0f
|
||||
this.isVisible = true
|
||||
this.animate()
|
||||
.alpha(1f)
|
||||
.setDuration(durationMillis)
|
||||
.setListener(null)
|
||||
} else {
|
||||
this.animate()
|
||||
.alpha(0f)
|
||||
.setDuration(durationMillis)
|
||||
.setListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
this@animateVisibility.visibility = hiddenVisibility
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ data class TotalBalance(
|
|||
) {
|
||||
enum class State {
|
||||
Loading,
|
||||
Failed,
|
||||
Success
|
||||
SomeTokensFailed,
|
||||
Success,
|
||||
}
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ class OnWalletLoadedReducer {
|
|||
BalanceStatus.Unreachable,
|
||||
BalanceStatus.NoAccount,
|
||||
BalanceStatus.EmptyCard,
|
||||
BalanceStatus.UnknownBlockchain -> TotalBalance.State.Failed
|
||||
BalanceStatus.UnknownBlockchain -> TotalBalance.State.SomeTokensFailed
|
||||
BalanceStatus.Loading,
|
||||
null -> TotalBalance.State.Loading
|
||||
}
|
||||
|
|
@ -225,13 +225,13 @@ class OnWalletLoadedReducer {
|
|||
return when (this) {
|
||||
TotalBalance.State.Loading -> when (newState) {
|
||||
TotalBalance.State.Loading -> this
|
||||
TotalBalance.State.Failed,
|
||||
TotalBalance.State.SomeTokensFailed,
|
||||
TotalBalance.State.Success -> newState
|
||||
}
|
||||
TotalBalance.State.Success,
|
||||
TotalBalance.State.Failed -> when (newState) {
|
||||
TotalBalance.State.SomeTokensFailed -> when (newState) {
|
||||
TotalBalance.State.Loading,
|
||||
TotalBalance.State.Failed -> newState
|
||||
TotalBalance.State.SomeTokensFailed -> newState
|
||||
TotalBalance.State.Success -> this
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
package com.tangem.tap.features.wallet.ui.wallet
|
||||
|
||||
import android.app.Dialog
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.tangem.common.card.Card
|
||||
import com.tangem.domain.common.TapWorkarounds.derivationStyle
|
||||
import com.tangem.domain.common.TapWorkarounds.isTestCard
|
||||
import com.tangem.tap.common.extensions.formatAmountAsSpannedString
|
||||
import com.tangem.tap.common.extensions.hide
|
||||
import com.tangem.tap.common.extensions.show
|
||||
import com.tangem.tap.common.extensions.*
|
||||
import com.tangem.tap.common.redux.StateDialog
|
||||
import com.tangem.tap.common.redux.navigation.AppScreen
|
||||
import com.tangem.tap.common.redux.navigation.NavigationAction
|
||||
|
|
@ -135,10 +134,29 @@ class MultiWalletView : WalletView {
|
|||
binding: FragmentWalletBinding,
|
||||
totalBalance: TotalBalance,
|
||||
) = with(binding.lCardTotalBalance) {
|
||||
when (totalBalance.state) {
|
||||
TotalBalance.State.Loading -> {
|
||||
pbLoading.showAnimated()
|
||||
tvBalance.hideAnimated(hiddenVisibility = View.INVISIBLE)
|
||||
tvProcessing.hideAnimated()
|
||||
}
|
||||
TotalBalance.State.SomeTokensFailed -> {
|
||||
tvBalance.showAnimated()
|
||||
pbLoading.hideAnimated()
|
||||
tvProcessing.showAnimated()
|
||||
}
|
||||
TotalBalance.State.Success -> {
|
||||
tvBalance.showAnimated()
|
||||
pbLoading.hideAnimated()
|
||||
tvProcessing.hideAnimated()
|
||||
}
|
||||
}
|
||||
|
||||
tvBalance.text = totalBalance.fiatAmount.formatAmountAsSpannedString(
|
||||
currencySymbol = totalBalance.fiatCurrency.symbol
|
||||
)
|
||||
tvCurrencyName.text = totalBalance.fiatCurrency.code
|
||||
|
||||
tvCurrencyName.setOnClickListener {
|
||||
// TODO: Open app currency selector
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,24 +9,24 @@
|
|||
android:minWidth="300dp">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/card_balance"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/white"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:elevation="3dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/card_balance"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="18dp"
|
||||
android:paddingBottom="18dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
>
|
||||
android:background="@android:color/white"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:elevation="3dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="18dp"
|
||||
android:paddingBottom="18dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
|
|
@ -43,28 +43,54 @@
|
|||
<TextView
|
||||
android:id="@+id/tv_balance"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:visibility="gone"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/darkGray6"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:text="$ 22 325.40" />
|
||||
tools:text="$ 22 325.40"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/pb_loading"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:padding="2dp"
|
||||
android:visibility="gone"
|
||||
android:indeterminate="true"
|
||||
android:indeterminateTint="@color/accent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_title"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_processing"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:visibility="gone"
|
||||
android:textColor="@color/warning"
|
||||
android:textSize="12sp"
|
||||
android:text="@string/main_processing_full_amount"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_balance"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_currency_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/darkGray1"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/darkGray1"
|
||||
android:textSize="16sp"
|
||||
app:drawableEndCompat="@drawable/ic_arrow_angle_down"
|
||||
app:drawableTint="@color/darkGray1"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:text="USD"
|
||||
/>
|
||||
tools:text="USD" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
|
|
|||
|
|
@ -383,4 +383,5 @@
|
|||
<string name="feedback_preface_tx_push_failed">Пожалуйста, расскажите нам больше о Вашей проблеме. Каждая деталь может быть полезной.</string>
|
||||
<string name="feedback_data_collection_message">Информация ниже не является обязательной. Вы можете стереть её, если хотите.</string>
|
||||
<string name="main_page_balance">Баланс</string>
|
||||
<string name="main_processing_full_amount">Обработка полной суммы…</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -207,4 +207,5 @@
|
|||
<string name="xtz_withdrawal_message_reduce">Reduce by %s XTZ</string>
|
||||
<string name="xtz_withdrawal_message_ignore">No, send all</string>
|
||||
<string name="main_page_balance">Total balance</string>
|
||||
<string name="main_processing_full_amount">Processing full amount…</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue