Merge branch 'main' into CAKE-345-batch-sending

# Conflicts:
#	lib/bitcoin/electrum_wallet.dart
This commit is contained in:
OleksandrSobol
2021-08-04 17:43:03 +03:00
24 changed files with 172 additions and 48 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),
))
)
]
)
],
),
)),
)
)
]
)
),
),
]),
);
@@ -86,9 +86,11 @@ class UnspentCoinsListFormState extends State<UnspentCoinsListForm> {
.pushNamed(Routes.unspentCoinsDetails,
arguments: [item, unspentCoinsListViewModel]),
child: UnspentCoinsListItem(
address: item.address,
note: item.note,
amount: item.amount,
address: item.address,
isSending: item.isSending,
isFrozen: item.isFrozen,
onCheckBoxTap: item.isFrozen
? null
: () async {
@@ -2,12 +2,15 @@ import 'package:auto_size_text/auto_size_text.dart';
import 'package:cake_wallet/palette.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/generated/i18n.dart';
class UnspentCoinsListItem extends StatelessWidget {
UnspentCoinsListItem({
@required this.address,
@required this.note,
@required this.amount,
@required this.address,
@required this.isSending,
@required this.isFrozen,
@required this.onCheckBoxTap,
});
@@ -16,14 +19,17 @@ class UnspentCoinsListItem extends StatelessWidget {
static const selectedItemColor = Palette.paleCornflowerBlue;
static const unselectedItemColor = Palette.moderateLavender;
final String address;
final String note;
final String amount;
final String address;
final bool isSending;
final bool isFrozen;
final Function() onCheckBoxTap;
@override
Widget build(BuildContext context) {
final itemColor = isSending? selectedItemColor : unselectedItemColor;
final _note = (note?.isNotEmpty ?? false) ? note : address;
return Container(
height: 62,
@@ -51,7 +57,7 @@ class UnspentCoinsListItem extends StatelessWidget {
width: 1.0),
borderRadius: BorderRadius.all(
Radius.circular(8.0)),
color: Theme.of(context).backgroundColor),
color: itemColor),
child: isSending
? Icon(
Icons.check,
@@ -67,22 +73,48 @@ class UnspentCoinsListItem extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AutoSizeText(
amount,
style: TextStyle(
color: amountColor,
fontSize: 16,
fontWeight: FontWeight.w600
),
maxLines: 1,
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: AutoSizeText(
amount,
style: TextStyle(
color: amountColor,
fontSize: 16,
fontWeight: FontWeight.w600
),
maxLines: 1,
),
),
if (isFrozen) Container(
height: 17,
padding: EdgeInsets.only(left: 6, right: 6),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8.5)),
color: Colors.white),
alignment: Alignment.center,
child: Text(
S.of(context).frozen,
style: TextStyle(
color: amountColor,
fontSize: 7,
fontWeight: FontWeight.w600
),
)
)
],
),
AutoSizeText(
address,
Text(
_note,
style: TextStyle(
color: addressColor,
fontSize: 12,
),
maxLines: 1,
overflow: TextOverflow.ellipsis
)
]
)