CAKE-345 | changed bitcoin transaction credentials; reworked createTransaction() method in the electrum_wallet.dart for batch sending; fixed exchange_trade_page.dart and send_page.dart; reworked confirm_sending_alert.dart; fixed _credenials() and commitTransaction() methods in the send_view_model.dart

This commit is contained in:
OleksandrSobol
2021-07-20 18:03:49 +03:00
parent e6cfa2b636
commit 7b2d89f96f
20 changed files with 378 additions and 235 deletions
@@ -262,9 +262,6 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
if (state is ExecutedSuccessfullyState) {
WidgetsBinding.instance.addPostFrameCallback((_) {
final item = widget.exchangeTradeViewModel.sendViewModel
.sendItemList.first;
showPopUp<void>(
context: context,
builder: (BuildContext context) {
@@ -388,8 +385,8 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
.pendingTransactionFiatAmount +
' ' +
widget.exchangeTradeViewModel.sendViewModel.fiat.title,
recipientTitle: S.of(context).recipient_address,
recipientAddress: item.address);
sendItemList: widget.exchangeTradeViewModel.sendViewModel
.sendItemList);
});
});
}
+56 -51
View File
@@ -266,56 +266,49 @@ class SendPage extends BasePage {
EdgeInsets.only(left: 24, right: 24, bottom: 24),
bottomSection: Column(
children: [
PrimaryButton(
onPressed: () {
sendViewModel.addSendItem();
},
text: 'Add receiver',
color: Colors.green,
textColor: Colors.white,
),
Padding(
padding: EdgeInsets.only(top: 12),
child: Observer(builder: (_) {
return LoadingPrimaryButton(
onPressed: () async {
if (_formKey.currentState.validate()) {
//await sendViewModel.createTransaction();
// FIXME: for test only
sendViewModel.clearSendItemList();
await showPopUp<void>(
context: context,
builder: (BuildContext context) {
return AlertWithOneAction(
alertTitle: S.of(context).send,
alertContent: S.of(context).send_success(
sendViewModel.currency
.toString()),
buttonText: S.of(context).ok,
buttonAction: () => Navigator.of(context).pop());
});
} else {
await showPopUp<void>(
context: context,
builder: (BuildContext context) {
return AlertWithOneAction(
alertTitle: S.of(context).error,
alertContent: 'Please, check your receivers forms',
buttonText: S.of(context).ok,
buttonAction: () =>
Navigator.of(context).pop());
});
}
},
text: S.of(context).send,
color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white,
isLoading: sendViewModel.state is IsExecutingState ||
sendViewModel.state is TransactionCommitting,
isDisabled: !sendViewModel.isReadyForSend,
);
if (sendViewModel.isAddReceiverButtonEnabled) Padding(
padding: EdgeInsets.only(bottom: 12),
child: PrimaryButton(
onPressed: () {
sendViewModel.addSendItem();
},
))
text: S.of(context).add_receiver,
color: Colors.green,
textColor: Colors.white,
)
),
Observer(builder: (_) {
return LoadingPrimaryButton(
onPressed: () async {
if (!_formKey.currentState.validate()) {
if (sendViewModel.sendItemList.length > 1) {
showErrorValidationAlert(context);
}
return;
}
final notValidItems = sendViewModel.sendItemList
.where((item) =>
item.address.isEmpty || item.cryptoAmount.isEmpty)
.toList();
if (notValidItems?.isNotEmpty ?? false) {
showErrorValidationAlert(context);
return;
}
await sendViewModel.createTransaction();
},
text: S.of(context).send,
color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white,
isLoading: sendViewModel.state is IsExecutingState ||
sendViewModel.state is TransactionCommitting,
isDisabled: !sendViewModel.isReadyForSend,
);
},
)
],
)),
);
@@ -357,8 +350,7 @@ class SendPage extends BasePage {
feeValue: sendViewModel.pendingTransaction.feeFormatted,
feeFiatAmount: sendViewModel.pendingTransactionFeeFiatAmount
+ ' ' + sendViewModel.fiat.title,
recipientTitle: S.of(context).recipient_address,
recipientAddress: '', // FIXME: sendViewModel.address,
sendItemList: sendViewModel.sendItemList,
rightButtonText: S.of(context).ok,
leftButtonText: S.of(context).cancel,
actionRightButton: () {
@@ -408,4 +400,17 @@ class SendPage extends BasePage {
final itemCount = controller.page.round();
return sendViewModel.sendItemList[itemCount];
}
void showErrorValidationAlert(BuildContext context) async {
await showPopUp<void>(
context: context,
builder: (BuildContext context) {
return AlertWithOneAction(
alertTitle: S.of(context).error,
alertContent: 'Please, check receiver forms',
buttonText: S.of(context).ok,
buttonAction: () =>
Navigator.of(context).pop());
});
}
}
@@ -1,6 +1,8 @@
import 'package:cake_wallet/palette.dart';
import 'package:cake_wallet/view_model/send/send_item.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/src/widgets/base_alert_dialog.dart';
import 'package:cake_wallet/generated/i18n.dart';
class ConfirmSendingAlert extends BaseAlertDialog {
ConfirmSendingAlert({
@@ -11,14 +13,18 @@ class ConfirmSendingAlert extends BaseAlertDialog {
@required this.fee,
@required this.feeValue,
@required this.feeFiatAmount,
@required this.recipientTitle,
@required this.recipientAddress,
@required this.sendItemList,
@required this.leftButtonText,
@required this.rightButtonText,
@required this.actionLeftButton,
@required this.actionRightButton,
this.alertBarrierDismissible = true
});
}) {
itemCount = sendItemList.length;
recipientTitle = itemCount > 1
? S.current.transaction_details_recipient_address
: S.current.recipient_address;
}
final String alertTitle;
final String amount;
@@ -27,14 +33,16 @@ class ConfirmSendingAlert extends BaseAlertDialog {
final String fee;
final String feeValue;
final String feeFiatAmount;
final String recipientTitle;
final String recipientAddress;
final List<SendItem> sendItemList;
final String leftButtonText;
final String rightButtonText;
final VoidCallback actionLeftButton;
final VoidCallback actionRightButton;
final bool alertBarrierDismissible;
String recipientTitle;
int itemCount;
@override
String get titleText => alertTitle;
@@ -58,127 +66,181 @@ class ConfirmSendingAlert extends BaseAlertDialog {
@override
Widget content(BuildContext context) {
return Column(
children: <Widget>[
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
return Container(
height: 200,
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Text(
amount,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.color,
decoration: TextDecoration.none,
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
amountValue,
amount,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
fontSize: 16,
fontWeight: FontWeight.normal,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.color,
decoration: TextDecoration.none,
),
),
Text(
fiatAmountValue,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
fontFamily: 'Lato',
color: PaletteDark.pigeonBlue,
decoration: TextDecoration.none,
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
amountValue,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.color,
decoration: TextDecoration.none,
),
),
Text(
fiatAmountValue,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
fontFamily: 'Lato',
color: PaletteDark.pigeonBlue,
decoration: TextDecoration.none,
),
)
],
)
],
)
],
),
Padding(
padding: EdgeInsets.only(top: 16),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
fee,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.color,
decoration: TextDecoration.none,
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
),
Padding(
padding: EdgeInsets.only(top: 16),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
fee,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.color,
decoration: TextDecoration.none,
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
feeValue,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.color,
decoration: TextDecoration.none,
),
),
Text(
feeFiatAmount,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
fontFamily: 'Lato',
color: PaletteDark.pigeonBlue,
decoration: TextDecoration.none,
),
)
],
)
],
)
),
Padding(
padding: EdgeInsets.only(top: 16),
child: Column(
children: [
Text(
feeValue,
'$recipientTitle:',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
fontSize: 16,
fontWeight: FontWeight.normal,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.color,
decoration: TextDecoration.none,
),
),
Text(
feeFiatAmount,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
fontFamily: 'Lato',
color: PaletteDark.pigeonBlue,
decoration: TextDecoration.none,
itemCount > 1
? ListView.builder(
padding: EdgeInsets.only(top: 0),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: itemCount,
itemBuilder: (context, index) {
final item = sendItemList[index];
final _address = item.address;
final _amount =
item.cryptoAmount.replaceAll(',', '.');
return Column(
children: [
Padding(
padding: EdgeInsets.only(top: 8),
child: Text(
_address,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
fontFamily: 'Lato',
color: PaletteDark.pigeonBlue,
decoration: TextDecoration.none,
),
)
),
Padding(
padding: EdgeInsets.only(top: 8),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
_amount,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
fontFamily: 'Lato',
color: PaletteDark.pigeonBlue,
decoration: TextDecoration.none,
),
)
],
)
)
],
);
}
)
: Padding(
padding: EdgeInsets.only(top: 8),
child: Text(
sendItemList.first.address,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
fontFamily: 'Lato',
color: PaletteDark.pigeonBlue,
decoration: TextDecoration.none,
),
),
)
],
)
],
)
),
Padding(
padding: EdgeInsets.fromLTRB(0, 16, 0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'$recipientTitle:',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal,
fontFamily: 'Lato',
color: Theme.of(context).primaryTextTheme.title.color,
decoration: TextDecoration.none,
),
),
Padding(
padding: EdgeInsets.only(top: 8),
child: Text(
recipientAddress,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
fontFamily: 'Lato',
color: PaletteDark.pigeonBlue,
decoration: TextDecoration.none,
),
)
)
],
),
)
],
)
],
)
);
}
}