Updated on 2026-08-14
This commit is contained in:
parent
c58966bcca
commit
74d04cde07
6 changed files with 45 additions and 16 deletions
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue