Updated on 2026-08-14
This commit is contained in:
parent
20f7a7ab0c
commit
5c2dc3f50a
3 changed files with 92 additions and 23 deletions
|
|
@ -52,7 +52,10 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
|
|||
addressData = addressData,
|
||||
currencyData = BalanceWidgetData(
|
||||
status = BalanceStatus.Unreachable,
|
||||
currency = wallet?.blockchain?.fullName),
|
||||
currency = wallet?.blockchain?.fullName,
|
||||
token = wallet?.token?.symbol?.let {
|
||||
TokenData("", tokenSymbol = it)
|
||||
}),
|
||||
mainButton = WalletMainButton.SendButton(false)
|
||||
)
|
||||
}
|
||||
|
|
@ -83,7 +86,10 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
|
|||
cardImage = cardImage,
|
||||
currencyData = BalanceWidgetData(
|
||||
BalanceStatus.Loading,
|
||||
wallet?.blockchain?.fullName
|
||||
wallet?.blockchain?.fullName,
|
||||
token = wallet?.token?.symbol?.let {
|
||||
TokenData("", tokenSymbol = it)
|
||||
}
|
||||
),
|
||||
addressData = addressData,
|
||||
mainButton = WalletMainButton.SendButton(false)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import com.tangem.wallet.R
|
|||
import kotlinx.android.synthetic.main.card_balance.*
|
||||
import kotlinx.android.synthetic.main.layout_balance.*
|
||||
import kotlinx.android.synthetic.main.layout_balance_error.*
|
||||
import kotlinx.android.synthetic.main.layout_token.view.*
|
||||
|
||||
enum class BalanceStatus {
|
||||
VerifiedOnline,
|
||||
|
|
@ -50,20 +49,21 @@ class BalanceWidget(
|
|||
fragment.l_balance.show()
|
||||
fragment.l_balance_error.hide()
|
||||
fragment.tv_fiat_amount.hide()
|
||||
fragment.l_token.hide()
|
||||
|
||||
fragment.tv_currency.text = data.currency
|
||||
fragment.tv_amount.text = ""
|
||||
|
||||
showStatus(R.id.tv_status_loading)
|
||||
|
||||
if (data.token != null) {
|
||||
showBalanceWithToken(data, false)
|
||||
} else {
|
||||
showBalanceWithoutToken(data, false)
|
||||
}
|
||||
}
|
||||
BalanceStatus.VerifiedOnline, BalanceStatus.TransactionInProgress -> {
|
||||
fragment.l_balance.show()
|
||||
fragment.l_balance_error.hide()
|
||||
fragment.tv_currency.text = data.currency
|
||||
fragment.tv_amount.text = data.amount
|
||||
fragment.tv_fiat_amount.show()
|
||||
fragment.tv_fiat_amount.text = data.fiatAmount
|
||||
val statusView = if (data.status == BalanceStatus.VerifiedOnline) {
|
||||
R.id.tv_status_verified
|
||||
} else {
|
||||
|
|
@ -75,22 +75,21 @@ class BalanceWidget(
|
|||
fragment.tv_status_error_message.hide()
|
||||
|
||||
if (data.token != null) {
|
||||
fragment.l_token.show()
|
||||
fragment.l_token.tv_token_symbol.text = data.token.tokenSymbol
|
||||
fragment.l_token.tv_token_amount.text = data.token.amount
|
||||
fragment.l_token.tv_token_fiat_amount.text = data.token.fiatAmount
|
||||
showBalanceWithToken(data, true)
|
||||
} else {
|
||||
fragment.l_token.hide()
|
||||
showBalanceWithoutToken(data, true)
|
||||
}
|
||||
}
|
||||
BalanceStatus.Unreachable -> {
|
||||
fragment.l_balance.show()
|
||||
fragment.l_balance_error.hide()
|
||||
fragment.l_token.hide()
|
||||
fragment.tv_fiat_amount.hide()
|
||||
fragment.group_base_currency.hide()
|
||||
|
||||
fragment.tv_currency.text = data.currency
|
||||
val currency = if (data.token != null) data.token.tokenSymbol else data.currency
|
||||
fragment.tv_currency.text = currency
|
||||
fragment.tv_amount.text = ""
|
||||
|
||||
fragment.tv_status_error_message.text = data.errorMessage
|
||||
fragment.tv_status_error.text =
|
||||
fragment.getString(R.string.wallet_balance_blockchain_unreachable)
|
||||
|
|
@ -129,4 +128,26 @@ class BalanceWidget(
|
|||
fragment.tv_status_loading.show(viewRes == R.id.tv_status_loading)
|
||||
fragment.tv_status_verified.show(viewRes == R.id.tv_status_verified)
|
||||
}
|
||||
|
||||
private fun showBalanceWithToken(data: BalanceWidgetData, showAmount: Boolean) {
|
||||
fragment.group_base_currency.show()
|
||||
fragment.tv_currency.text = data.token?.tokenSymbol
|
||||
fragment.tv_base_currency.text = data.currency
|
||||
fragment.tv_amount.text = if (showAmount) data.token?.amount else ""
|
||||
fragment.tv_base_amount.text = if (showAmount) data.amount else ""
|
||||
if (showAmount) {
|
||||
fragment.tv_fiat_amount.show()
|
||||
fragment.tv_fiat_amount.text = data.token?.fiatAmount
|
||||
}
|
||||
}
|
||||
|
||||
private fun showBalanceWithoutToken(data: BalanceWidgetData, showAmount: Boolean) {
|
||||
fragment.group_base_currency.hide()
|
||||
fragment.tv_currency.text = data.currency
|
||||
fragment.tv_amount.text = if (showAmount) data.amount else ""
|
||||
if (showAmount) {
|
||||
fragment.tv_fiat_amount.show()
|
||||
fragment.tv_fiat_amount.text = data.fiatAmount
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -103,10 +103,10 @@
|
|||
app:autoSizeMinTextSize="12sp"
|
||||
app:autoSizeStepGranularity="1sp"
|
||||
app:autoSizeTextType="uniform"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_currency"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_weight="1"
|
||||
app:layout_constraintStart_toEndOf="@id/tv_currency"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_currency"
|
||||
tools:text="0.43 BTC" />
|
||||
|
||||
<TextView
|
||||
|
|
@ -130,22 +130,64 @@
|
|||
android:paddingTop="4dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:textSize="14sp"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_amount"
|
||||
tools:text="USD 3 588"
|
||||
android:visibility="invisible"/>
|
||||
tools:text="USD 3 588" />
|
||||
|
||||
|
||||
<include
|
||||
android:id="@+id/l_token"
|
||||
layout="@layout/layout_token"
|
||||
<View
|
||||
android:id="@+id/v_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="@color/lightGray5"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_placeholder" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_base_currency"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="35dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:textColor="@color/darkGray6"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/v_divider"
|
||||
tools:text="Ethereum" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_base_amount"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="end"
|
||||
android:maxLines="1"
|
||||
android:textAlignment="textEnd"
|
||||
android:textColor="@color/darkGray6"
|
||||
android:textSize="14sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_currency" />
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1"
|
||||
app:layout_constraintStart_toEndOf="@id/tv_base_currency"
|
||||
app:layout_constraintTop_toBottomOf="@id/v_divider"
|
||||
tools:text="0.00434143 ETH"
|
||||
/>
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/group_base_currency"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:constraint_referenced_ids="v_divider, tv_base_currency, tv_base_amount" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Loading…
Add table
Add a link
Reference in a new issue