Updated on 2026-08-14

This commit is contained in:
Tangem 2021-11-03 11:34:53 +03:00
parent c58966bcca
commit 74d04cde07
6 changed files with 45 additions and 16 deletions

View file

@ -84,7 +84,7 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details), StoreS
btn_share.setOnClickListener { store.dispatch(WalletAction.ShowDialog.QrCode) }
btn_top_up.setOnClickListener { store.dispatch(WalletAction.TradeCryptoAction.Buy) }
btn_trade.setOnClickListener { store.dispatch(WalletAction.TradeCryptoAction.Buy) }
btn_sell.setOnClickListener { store.dispatch(WalletAction.TradeCryptoAction.Sell) }
}
@ -138,7 +138,7 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details), StoreS
srl_wallet_details.isRefreshing = false
}
btn_top_up.isEnabled = selectedWallet.tradeCryptoState.buyingAllowed
btn_trade.isEnabled = selectedWallet.tradeCryptoState.buyingAllowed
btn_sell.show(selectedWallet.tradeCryptoState.sellingAllowed)
}
@ -286,7 +286,7 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details), StoreS
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.meny_remove -> {
R.id.menu_remove -> {
store.state.walletState.getSelectedWalletData()?.let { walletData ->
store.dispatch(WalletAction.MultiWallet.RemoveWallet(walletData))
store.dispatch(WalletAction.MultiWallet.SelectWallet(null))

View file

@ -142,12 +142,10 @@ class SingleWalletView : WalletView {
}
btn_show_qr.setOnClickListener { store.dispatch(WalletAction.ShowDialog.QrCode) }
btn_top_up.setOnClickListener {
tradeCryptoAction(state.tradeCryptoState)
}
setupTradeButton(fragment, state.tradeCryptoState)
}
private fun tradeCryptoAction(tradeCryptoState: TradeCryptoState) {
private fun setupTradeButton(fragment: WalletFragment, tradeCryptoState: TradeCryptoState) {
val allowedToBuy = tradeCryptoState.buyingAllowed
val allowedToSell = tradeCryptoState.sellingAllowed
val action = when {
@ -156,7 +154,23 @@ class SingleWalletView : WalletView {
allowedToBuy && allowedToSell -> WalletAction.ShowDialog.ChooseTradeActionDialog
else -> null
}
if (action != null) store.dispatch(action)
val text = when {
allowedToBuy && !allowedToSell -> R.string.wallet_button_buy
!allowedToBuy && allowedToSell -> R.string.wallet_button_sell
allowedToBuy && allowedToSell -> R.string.wallet_button_trade
else -> R.string.wallet_button_trade
}
val icon = when {
allowedToBuy && !allowedToSell -> R.drawable.ic_arrow_up_short_btn
!allowedToBuy && allowedToSell -> R.drawable.ic_arrow_down_short_button
allowedToBuy && allowedToSell -> R.drawable.ic_arrows_up_down_short_btn
else -> R.string.wallet_button_trade
}
with(fragment) {
btn_trade.text = getText(text)
btn_trade.setCompoundDrawablesWithIntrinsicBounds(0, icon, 0, 0)
btn_trade.setOnClickListener { if (action != null) store.dispatch(action) }
}
}
private fun setupButtonsType(state: WalletData, fragment: WalletFragment) = with(fragment) {

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="20dp"
android:viewportWidth="24"
android:viewportHeight="20">
<group>
<path
android:pathData="M5.853,11.6645L9.7814,8.075C10.0495,7.8439 10.0734,7.3871 9.84,7.1191C9.6067,6.8511 9.1615,6.824 8.9084,7.0724L6.0712,9.6665L6.0712,0.8398C6.0712,0.468 5.7781,0.1667 5.4165,0.1667C5.0549,0.1667 4.7618,0.468 4.7618,0.8398L4.7618,9.6665L1.9246,7.0724C1.6715,6.824 1.2271,6.8576 0.9937,7.1256C0.7604,7.3936 0.7835,7.8439 1.0516,8.075L4.98,11.6645C5.2976,11.8989 5.5827,11.8802 5.853,11.6645L5.853,11.6645Z"
android:fillColor="#ffffff"/>
</group>
</vector>

View file

@ -131,7 +131,7 @@
app:constraint_referenced_ids="l_wallet_details,card_pending_transaction_warning" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_top_up"
android:id="@+id/btn_trade"
style="@style/TapButtonWithIcon"
android:layout_width="0dp"
android:layout_marginStart="16dp"
@ -151,7 +151,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="end"
app:constraint_referenced_ids="btn_top_up, btn_sell" />
app:constraint_referenced_ids="btn_trade, btn_sell" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier_right_button"
@ -172,7 +172,7 @@
app:icon="@drawable/ic_arrow_down"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@id/btn_top_up"
app:layout_constraintStart_toEndOf="@id/btn_trade"
app:layout_constraintEnd_toStartOf="@id/btn_confirm"
app:layout_constraintTop_toBottomOf="@id/barrier"
app:layout_constraintVertical_bias="1" />

View file

@ -9,6 +9,7 @@
android:id="@+id/btn_scan_short"
style="@style/TapBlackButton"
android:layout_width="0dp"
android:layout_height="52dp"
android:layout_marginStart="16dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="33dp"
@ -17,14 +18,15 @@
android:paddingTop="7dp"
android:text="@string/wallet_button_scan"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/btn_top_up"
app:layout_constraintEnd_toStartOf="@id/btn_trade"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_bias="1" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_top_up"
android:id="@+id/btn_trade"
style="@style/TapButton"
android:layout_width="0dp"
android:layout_height="52dp"
android:layout_marginStart="8dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="33dp"
@ -42,6 +44,7 @@
android:id="@+id/btn_confirm_short"
style="@style/TapButton"
android:layout_width="0dp"
android:layout_height="52dp"
android:layout_marginStart="8dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="16dp"
@ -52,7 +55,7 @@
android:text="@string/wallet_button_send"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/btn_top_up"
app:layout_constraintStart_toEndOf="@+id/btn_trade"
app:layout_constraintVertical_bias="1" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -2,7 +2,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/meny_remove"
android:title="@string/common_remove"
android:id="@+id/menu_remove"
android:title="@string/remove_token"
app:showAsAction="always" />
</menu>