Changed way to committing of transactions.
M committed
Jan 13, 2020 at 14:34 UTC
b7e8abcb959acfefd23dad9cc04036d4be61284b
4 files changed
+66
-21
lib/src/screens/exchange_trade/exchange_trade_page.dart
+28
-1
@@ -296,7 +296,7 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
296
}),
297
bottomSection: Observer(
298
builder: (_) => tradeStore.trade.from == CryptoCurrency.xmr &&
299
- !(sendStore.state is TransactionCreatedSuccessfully)
299
+ !(sendStore.state is TransactionCommitted)
300
? Container(
301
padding: EdgeInsets.only(top: 20.0, bottom: 20.0),
302
child: LoadingPrimaryButton(
@@ -351,6 +351,33 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
351
}
352
353
if (state is TransactionCreatedSuccessfully) {
354
+ WidgetsBinding.instance.addPostFrameCallback((_) {
355
+ showDialog<void>(
356
+ context: context,
357
+ builder: (BuildContext context) {
358
+ return AlertDialog(
359
+ title: Text(S.of(context).confirm_sending),
360
+ content: Text(S.of(context).commit_transaction_amount_fee(
361
+ sendStore.pendingTransaction.amount,
362
+ sendStore.pendingTransaction.fee)),
363
+ actions: <Widget>[
364
+ FlatButton(
365
+ child: Text(S.of(context).ok),
366
+ onPressed: () {
367
+ Navigator.of(context).pop();
368
+ sendStore.commitTransaction();
369
+ }),
370
+ FlatButton(
371
+ child: Text(S.of(context).cancel),
372
+ onPressed: () => Navigator.of(context).pop(),
373
+ )
374
+ ],
375
+ );
376
+ });
377
+ });
378
+ }
379
+
380
+ if (state is TransactionCommitted) {
381
WidgetsBinding.instance.addPostFrameCallback((_) {
382
showDialog<void>(
383
context: context,
lib/src/screens/faq/faq_page.dart
+8
-13
@@ -7,6 +7,7 @@ import 'package:cake_wallet/src/stores/settings/settings_store.dart';
7
import 'package:cake_wallet/src/screens/base_page.dart';
8
9
class FaqPage extends BasePage {
10
+ @override
11
String get title => S.current.faq;
12
13
@override
@@ -21,24 +22,18 @@ class FaqPage extends BasePage {
22
final itemChild = faqItems[index]["answer"].toString();
23
24
return ExpansionTile(
24
- title: Text(
25
- itemTitle
26
- ),
25
+ title: Text(itemTitle),
26
children: <Widget>[
27
Row(
28
mainAxisAlignment: MainAxisAlignment.start,
29
children: <Widget>[
30
Expanded(
31
child: Container(
33
- padding: EdgeInsets.only(
34
- left: 15.0,
35
- right: 15.0
36
- ),
37
- child: Text(
38
- itemChild,
39
- ),
40
- )
41
- )
32
+ padding: EdgeInsets.only(left: 15.0, right: 15.0),
33
+ child: Text(
34
+ itemChild,
35
+ ),
36
+ ))
37
],
38
)
39
],
@@ -83,4 +78,4 @@ class FaqPage extends BasePage {
78
return 'assets/faq/faq_en.json';
79
}
80
}
86
-}
\ No newline at end of file
81
+}
lib/src/screens/send/send_page.dart
+28
-1
@@ -402,7 +402,7 @@ class SendFormState extends State<SendForm> {
402
borderColor:
403
Theme.of(context).accentTextTheme.button.decorationColor,
404
isLoading: sendStore.state is CreatingTransaction ||
405
- sendStore.state is TransactionCommitted);
405
+ sendStore.state is TransactionCommiting);
406
}));
407
}
408
@@ -461,6 +461,33 @@ class SendFormState extends State<SendForm> {
461
}
462
463
if (state is TransactionCreatedSuccessfully) {
464
+ WidgetsBinding.instance.addPostFrameCallback((_) {
465
+ showDialog<void>(
466
+ context: context,
467
+ builder: (BuildContext context) {
468
+ return AlertDialog(
469
+ title: Text(S.of(context).confirm_sending),
470
+ content: Text(S.of(context).commit_transaction_amount_fee(
471
+ sendStore.pendingTransaction.amount,
472
+ sendStore.pendingTransaction.fee)),
473
+ actions: <Widget>[
474
+ FlatButton(
475
+ child: Text(S.of(context).ok),
476
+ onPressed: () {
477
+ Navigator.of(context).pop();
478
+ sendStore.commitTransaction();
479
+ }),
480
+ FlatButton(
481
+ child: Text(S.of(context).cancel),
482
+ onPressed: () => Navigator.of(context).pop(),
483
+ )
484
+ ],
485
+ );
486
+ });
487
+ });
488
+ }
489
+
490
+ if (state is TransactionCommitted) {
491
WidgetsBinding.instance.addPostFrameCallback((_) {
492
showDialog<void>(
493
context: context,
lib/src/stores/send/send_store.dart
+2
-6
@@ -26,12 +26,6 @@ abstract class SendStoreBase with Store {
26
_pendingTransaction = null;
27
_cryptoNumberFormat = NumberFormat()..maximumFractionDigits = 12;
28
_fiatNumberFormat = NumberFormat()..maximumFractionDigits = 2;
29
-
30
- reaction((_) => this.state, (SendingState state) async {
31
- if (state is TransactionCreatedSuccessfully) {
32
- await commitTransaction();
33
- }
34
- });
29
}
30
31
WalletService walletService;
@@ -89,7 +83,9 @@ abstract class SendStoreBase with Store {
83
Future commitTransaction() async {
84
try {
85
final transactionId = _pendingTransaction.hash;
86
+ state = TransactionCommiting();
87
await _pendingTransaction.commit();
88
+ state = TransactionCommitted();
89
90
if (settingsStore.shouldSaveRecipientAddress) {
91
await transactionDescriptions.add(TransactionDescription(