Changed way to committing of transactions.

This commit is contained in:
M 2020-01-13 14:34:50 +02:00
parent 465c69c776
commit b7e8abcb95
4 changed files with 66 additions and 21 deletions

View file

@ -296,7 +296,7 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
}), }),
bottomSection: Observer( bottomSection: Observer(
builder: (_) => tradeStore.trade.from == CryptoCurrency.xmr && builder: (_) => tradeStore.trade.from == CryptoCurrency.xmr &&
!(sendStore.state is TransactionCreatedSuccessfully) !(sendStore.state is TransactionCommitted)
? Container( ? Container(
padding: EdgeInsets.only(top: 20.0, bottom: 20.0), padding: EdgeInsets.only(top: 20.0, bottom: 20.0),
child: LoadingPrimaryButton( child: LoadingPrimaryButton(
@ -351,6 +351,33 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
} }
if (state is TransactionCreatedSuccessfully) { if (state is TransactionCreatedSuccessfully) {
WidgetsBinding.instance.addPostFrameCallback((_) {
showDialog<void>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(S.of(context).confirm_sending),
content: Text(S.of(context).commit_transaction_amount_fee(
sendStore.pendingTransaction.amount,
sendStore.pendingTransaction.fee)),
actions: <Widget>[
FlatButton(
child: Text(S.of(context).ok),
onPressed: () {
Navigator.of(context).pop();
sendStore.commitTransaction();
}),
FlatButton(
child: Text(S.of(context).cancel),
onPressed: () => Navigator.of(context).pop(),
)
],
);
});
});
}
if (state is TransactionCommitted) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
showDialog<void>( showDialog<void>(
context: context, context: context,

View file

@ -7,6 +7,7 @@ import 'package:cake_wallet/src/stores/settings/settings_store.dart';
import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
class FaqPage extends BasePage { class FaqPage extends BasePage {
@override
String get title => S.current.faq; String get title => S.current.faq;
@override @override
@ -21,24 +22,18 @@ class FaqPage extends BasePage {
final itemChild = faqItems[index]["answer"].toString(); final itemChild = faqItems[index]["answer"].toString();
return ExpansionTile( return ExpansionTile(
title: Text( title: Text(itemTitle),
itemTitle
),
children: <Widget>[ children: <Widget>[
Row( Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Container( child: Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(left: 15.0, right: 15.0),
left: 15.0, child: Text(
right: 15.0 itemChild,
), ),
child: Text( ))
itemChild,
),
)
)
], ],
) )
], ],
@ -83,4 +78,4 @@ class FaqPage extends BasePage {
return 'assets/faq/faq_en.json'; return 'assets/faq/faq_en.json';
} }
} }
} }

View file

@ -402,7 +402,7 @@ class SendFormState extends State<SendForm> {
borderColor: borderColor:
Theme.of(context).accentTextTheme.button.decorationColor, Theme.of(context).accentTextTheme.button.decorationColor,
isLoading: sendStore.state is CreatingTransaction || isLoading: sendStore.state is CreatingTransaction ||
sendStore.state is TransactionCommitted); sendStore.state is TransactionCommiting);
})); }));
} }
@ -461,6 +461,33 @@ class SendFormState extends State<SendForm> {
} }
if (state is TransactionCreatedSuccessfully) { if (state is TransactionCreatedSuccessfully) {
WidgetsBinding.instance.addPostFrameCallback((_) {
showDialog<void>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(S.of(context).confirm_sending),
content: Text(S.of(context).commit_transaction_amount_fee(
sendStore.pendingTransaction.amount,
sendStore.pendingTransaction.fee)),
actions: <Widget>[
FlatButton(
child: Text(S.of(context).ok),
onPressed: () {
Navigator.of(context).pop();
sendStore.commitTransaction();
}),
FlatButton(
child: Text(S.of(context).cancel),
onPressed: () => Navigator.of(context).pop(),
)
],
);
});
});
}
if (state is TransactionCommitted) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
showDialog<void>( showDialog<void>(
context: context, context: context,

View file

@ -26,12 +26,6 @@ abstract class SendStoreBase with Store {
_pendingTransaction = null; _pendingTransaction = null;
_cryptoNumberFormat = NumberFormat()..maximumFractionDigits = 12; _cryptoNumberFormat = NumberFormat()..maximumFractionDigits = 12;
_fiatNumberFormat = NumberFormat()..maximumFractionDigits = 2; _fiatNumberFormat = NumberFormat()..maximumFractionDigits = 2;
reaction((_) => this.state, (SendingState state) async {
if (state is TransactionCreatedSuccessfully) {
await commitTransaction();
}
});
} }
WalletService walletService; WalletService walletService;
@ -89,7 +83,9 @@ abstract class SendStoreBase with Store {
Future commitTransaction() async { Future commitTransaction() async {
try { try {
final transactionId = _pendingTransaction.hash; final transactionId = _pendingTransaction.hash;
state = TransactionCommiting();
await _pendingTransaction.commit(); await _pendingTransaction.commit();
state = TransactionCommitted();
if (settingsStore.shouldSaveRecipientAddress) { if (settingsStore.shouldSaveRecipientAddress) {
await transactionDescriptions.add(TransactionDescription( await transactionDescriptions.add(TransactionDescription(