CAKE-343 | added address book button to xmr wallet's address text field on exchange_page.dart and exchange_template_page.dart

This commit is contained in:
OleksandrSobol 2021-07-23 14:05:33 +03:00
parent 800376b6b2
commit 1d996c94c8
4 changed files with 99 additions and 27 deletions

View file

@ -188,6 +188,7 @@ class ExchangePage extends BasePage {
exchangeViewModel.isDepositAddressEnabled, exchangeViewModel.isDepositAddressEnabled,
isAmountEstimated: false, isAmountEstimated: false,
hasRefundAddress: true, hasRefundAddress: true,
isMoneroWallet: exchangeViewModel.isMoneroWallet,
currencies: CryptoCurrency.all, currencies: CryptoCurrency.all,
onCurrencySelected: (currency) { onCurrencySelected: (currency) {
// FIXME: need to move it into view model // FIXME: need to move it into view model
@ -260,6 +261,7 @@ class ExchangePage extends BasePage {
exchangeViewModel exchangeViewModel
.isReceiveAddressEnabled, .isReceiveAddressEnabled,
isAmountEstimated: true, isAmountEstimated: true,
isMoneroWallet: exchangeViewModel.isMoneroWallet,
currencies: currencies:
exchangeViewModel.receiveCurrencies, exchangeViewModel.receiveCurrencies,
onCurrencySelected: (currency) => onCurrencySelected: (currency) =>

View file

@ -136,6 +136,7 @@ class ExchangeTemplatePage extends BasePage {
.isDepositAddressEnabled, .isDepositAddressEnabled,
isAmountEstimated: false, isAmountEstimated: false,
hasRefundAddress: true, hasRefundAddress: true,
isMoneroWallet: exchangeViewModel.isMoneroWallet,
currencies: CryptoCurrency.all, currencies: CryptoCurrency.all,
onCurrencySelected: (currency) => onCurrencySelected: (currency) =>
exchangeViewModel.changeDepositCurrency( exchangeViewModel.changeDepositCurrency(
@ -175,6 +176,7 @@ class ExchangeTemplatePage extends BasePage {
initialIsAddressEditable: initialIsAddressEditable:
exchangeViewModel.isReceiveAddressEnabled, exchangeViewModel.isReceiveAddressEnabled,
isAmountEstimated: true, isAmountEstimated: true,
isMoneroWallet: exchangeViewModel.isMoneroWallet,
currencies: exchangeViewModel.receiveCurrencies, currencies: exchangeViewModel.receiveCurrencies,
onCurrencySelected: (currency) => onCurrencySelected: (currency) =>
exchangeViewModel.changeReceiveCurrency( exchangeViewModel.changeReceiveCurrency(

View file

@ -1,3 +1,5 @@
import 'package:cake_wallet/entities/contact_base.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/utils/show_bar.dart'; import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -19,6 +21,7 @@ class ExchangeCard extends StatefulWidget {
this.initialIsAddressEditable, this.initialIsAddressEditable,
this.isAmountEstimated, this.isAmountEstimated,
this.hasRefundAddress = false, this.hasRefundAddress = false,
this.isMoneroWallet = false,
this.currencies, this.currencies,
this.onCurrencySelected, this.onCurrencySelected,
this.imageArrow, this.imageArrow,
@ -44,6 +47,7 @@ class ExchangeCard extends StatefulWidget {
final bool initialIsAddressEditable; final bool initialIsAddressEditable;
final bool isAmountEstimated; final bool isAmountEstimated;
final bool hasRefundAddress; final bool hasRefundAddress;
final bool isMoneroWallet;
final Image imageArrow; final Image imageArrow;
final Color currencyButtonColor; final Color currencyButtonColor;
final Color addressButtonsColor; final Color addressButtonsColor;
@ -72,6 +76,7 @@ class ExchangeCardState extends State<ExchangeCard> {
bool _isAmountEditable; bool _isAmountEditable;
bool _isAddressEditable; bool _isAddressEditable;
bool _isAmountEstimated; bool _isAmountEstimated;
bool _isMoneroWallet;
@override @override
void initState() { void initState() {
@ -81,6 +86,7 @@ class ExchangeCardState extends State<ExchangeCard> {
_walletName = widget.initialWalletName; _walletName = widget.initialWalletName;
_selectedCurrency = widget.initialCurrency; _selectedCurrency = widget.initialCurrency;
_isAmountEstimated = widget.isAmountEstimated; _isAmountEstimated = widget.isAmountEstimated;
_isMoneroWallet = widget.isMoneroWallet;
addressController.text = widget.initialAddress; addressController.text = widget.initialAddress;
super.initState(); super.initState();
} }
@ -322,34 +328,93 @@ class ExchangeCardState extends State<ExchangeCard> {
: Padding( : Padding(
padding: EdgeInsets.only(top: 10), padding: EdgeInsets.only(top: 10),
child: Builder( child: Builder(
builder: (context) => GestureDetector( builder: (context) => Stack(
onTap: () { children: <Widget> [
Clipboard.setData( BaseTextFormField(
ClipboardData(text: addressController.text)); controller: addressController,
showBar<void>( readOnly: true,
context, S.of(context).copied_to_clipboard); borderColor: Colors.transparent,
}, suffixIcon: SizedBox(
child: Row( width: _isMoneroWallet ? 80 : 36
mainAxisSize: MainAxisSize.max, ),
children: <Widget>[ textStyle: TextStyle(
Expanded( fontSize: 16,
child: Text( fontWeight: FontWeight.w600,
addressController.text, color: Colors.white),
maxLines: 1, validator: widget.addressTextFieldValidator
overflow: TextOverflow.ellipsis, ),
style: TextStyle( Positioned(
fontSize: 16, top: 2,
fontWeight: FontWeight.w600, right: 0,
color: Colors.white), child: SizedBox(
), width: _isMoneroWallet ? 80 : 36,
), child: Row(
Padding( children: <Widget>[
padding: EdgeInsets.only(left: 16), if (_isMoneroWallet) Padding(
child: copyImage, padding: EdgeInsets.only(left: 10),
child: Container(
width: 34,
height: 34,
padding: EdgeInsets.only(top: 0),
child: InkWell(
onTap: () async {
final contact = await Navigator
.of(context, rootNavigator: true)
.pushNamed(
Routes.pickerAddressBook);
if (contact is ContactBase &&
contact.address != null) {
setState(() =>
addressController.text =
contact.address);
}
},
child: Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: widget
.addressButtonsColor,
borderRadius: BorderRadius
.all(Radius.circular(6))),
child: Image.asset(
'assets/images/open_book.png',
color: Theme.of(context)
.primaryTextTheme
.display1
.decorationColor,
)),
)),
),
Padding(
padding: EdgeInsets.only(left: 2),
child: Container(
width: 34,
height: 34,
padding: EdgeInsets.only(top: 0),
child: InkWell(
onTap: () {
Clipboard.setData(
ClipboardData(
text: addressController.text));
showBar<void>(
context, S.of(context)
.copied_to_clipboard);
},
child: Container(
padding: EdgeInsets
.fromLTRB(8, 8, 0, 8),
color: Colors.transparent,
child: copyImage),
))
)
]
) )
], )
), )
)), ]
)
),
), ),
]), ]),
); );

View file

@ -9,6 +9,7 @@ import 'package:cake_wallet/exchange/exchange_provider.dart';
import 'package:cake_wallet/exchange/limits.dart'; import 'package:cake_wallet/exchange/limits.dart';
import 'package:cake_wallet/exchange/trade.dart'; import 'package:cake_wallet/exchange/trade.dart';
import 'package:cake_wallet/exchange/limits_state.dart'; import 'package:cake_wallet/exchange/limits_state.dart';
import 'package:cake_wallet/monero/monero_wallet.dart';
import 'package:cake_wallet/store/dashboard/trades_store.dart'; import 'package:cake_wallet/store/dashboard/trades_store.dart';
import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/store/settings_store.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
@ -125,6 +126,8 @@ abstract class ExchangeViewModelBase with Store {
bool get hasAllAmount => bool get hasAllAmount =>
wallet.type == WalletType.bitcoin && depositCurrency == wallet.currency; wallet.type == WalletType.bitcoin && depositCurrency == wallet.currency;
bool get isMoneroWallet => wallet is MoneroWallet;
List<CryptoCurrency> receiveCurrencies; List<CryptoCurrency> receiveCurrencies;
Limits limits; Limits limits;