mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 01:37:40 +00:00
Merge pull request #163 from cake-tech/CAKE-343-subaddresses-for-contact-book
CAKE-343 | added address book button to xmr wallet's address text fie…
This commit is contained in:
commit
4418532896
4 changed files with 99 additions and 27 deletions
|
@ -188,6 +188,7 @@ class ExchangePage extends BasePage {
|
|||
exchangeViewModel.isDepositAddressEnabled,
|
||||
isAmountEstimated: false,
|
||||
hasRefundAddress: true,
|
||||
isMoneroWallet: exchangeViewModel.isMoneroWallet,
|
||||
currencies: CryptoCurrency.all,
|
||||
onCurrencySelected: (currency) {
|
||||
// FIXME: need to move it into view model
|
||||
|
@ -260,6 +261,7 @@ class ExchangePage extends BasePage {
|
|||
exchangeViewModel
|
||||
.isReceiveAddressEnabled,
|
||||
isAmountEstimated: true,
|
||||
isMoneroWallet: exchangeViewModel.isMoneroWallet,
|
||||
currencies:
|
||||
exchangeViewModel.receiveCurrencies,
|
||||
onCurrencySelected: (currency) =>
|
||||
|
|
|
@ -136,6 +136,7 @@ class ExchangeTemplatePage extends BasePage {
|
|||
.isDepositAddressEnabled,
|
||||
isAmountEstimated: false,
|
||||
hasRefundAddress: true,
|
||||
isMoneroWallet: exchangeViewModel.isMoneroWallet,
|
||||
currencies: CryptoCurrency.all,
|
||||
onCurrencySelected: (currency) =>
|
||||
exchangeViewModel.changeDepositCurrency(
|
||||
|
@ -175,6 +176,7 @@ class ExchangeTemplatePage extends BasePage {
|
|||
initialIsAddressEditable:
|
||||
exchangeViewModel.isReceiveAddressEnabled,
|
||||
isAmountEstimated: true,
|
||||
isMoneroWallet: exchangeViewModel.isMoneroWallet,
|
||||
currencies: exchangeViewModel.receiveCurrencies,
|
||||
onCurrencySelected: (currency) =>
|
||||
exchangeViewModel.changeReceiveCurrency(
|
||||
|
|
|
@ -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_pop_up.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
@ -19,6 +21,7 @@ class ExchangeCard extends StatefulWidget {
|
|||
this.initialIsAddressEditable,
|
||||
this.isAmountEstimated,
|
||||
this.hasRefundAddress = false,
|
||||
this.isMoneroWallet = false,
|
||||
this.currencies,
|
||||
this.onCurrencySelected,
|
||||
this.imageArrow,
|
||||
|
@ -44,6 +47,7 @@ class ExchangeCard extends StatefulWidget {
|
|||
final bool initialIsAddressEditable;
|
||||
final bool isAmountEstimated;
|
||||
final bool hasRefundAddress;
|
||||
final bool isMoneroWallet;
|
||||
final Image imageArrow;
|
||||
final Color currencyButtonColor;
|
||||
final Color addressButtonsColor;
|
||||
|
@ -72,6 +76,7 @@ class ExchangeCardState extends State<ExchangeCard> {
|
|||
bool _isAmountEditable;
|
||||
bool _isAddressEditable;
|
||||
bool _isAmountEstimated;
|
||||
bool _isMoneroWallet;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -81,6 +86,7 @@ class ExchangeCardState extends State<ExchangeCard> {
|
|||
_walletName = widget.initialWalletName;
|
||||
_selectedCurrency = widget.initialCurrency;
|
||||
_isAmountEstimated = widget.isAmountEstimated;
|
||||
_isMoneroWallet = widget.isMoneroWallet;
|
||||
addressController.text = widget.initialAddress;
|
||||
super.initState();
|
||||
}
|
||||
|
@ -322,34 +328,93 @@ class ExchangeCardState extends State<ExchangeCard> {
|
|||
: Padding(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
child: Builder(
|
||||
builder: (context) => GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(
|
||||
ClipboardData(text: addressController.text));
|
||||
showBar<void>(
|
||||
context, S.of(context).copied_to_clipboard);
|
||||
},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Text(
|
||||
addressController.text,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 16),
|
||||
child: copyImage,
|
||||
builder: (context) => Stack(
|
||||
children: <Widget> [
|
||||
BaseTextFormField(
|
||||
controller: addressController,
|
||||
readOnly: true,
|
||||
borderColor: Colors.transparent,
|
||||
suffixIcon: SizedBox(
|
||||
width: _isMoneroWallet ? 80 : 36
|
||||
),
|
||||
textStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white),
|
||||
validator: widget.addressTextFieldValidator
|
||||
),
|
||||
Positioned(
|
||||
top: 2,
|
||||
right: 0,
|
||||
child: SizedBox(
|
||||
width: _isMoneroWallet ? 80 : 36,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
if (_isMoneroWallet) Padding(
|
||||
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),
|
||||
))
|
||||
)
|
||||
]
|
||||
)
|
||||
],
|
||||
),
|
||||
)),
|
||||
)
|
||||
)
|
||||
]
|
||||
)
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
|
|
|
@ -9,6 +9,7 @@ import 'package:cake_wallet/exchange/exchange_provider.dart';
|
|||
import 'package:cake_wallet/exchange/limits.dart';
|
||||
import 'package:cake_wallet/exchange/trade.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/settings_store.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
@ -125,6 +126,8 @@ abstract class ExchangeViewModelBase with Store {
|
|||
bool get hasAllAmount =>
|
||||
wallet.type == WalletType.bitcoin && depositCurrency == wallet.currency;
|
||||
|
||||
bool get isMoneroWallet => wallet is MoneroWallet;
|
||||
|
||||
List<CryptoCurrency> receiveCurrencies;
|
||||
|
||||
Limits limits;
|
||||
|
|
Loading…
Reference in a new issue