CAKE-134. CAKE-139. FIXES.

This commit is contained in:
M 2020-10-30 18:32:21 +02:00
parent ed72cee3f4
commit 9f498f30a2
8 changed files with 357 additions and 234 deletions

View file

@ -1,3 +1,4 @@
import 'package:cake_wallet/bitcoin/bitcoin_wallet_service.dart'; import 'package:cake_wallet/bitcoin/bitcoin_wallet_service.dart';
import 'package:cake_wallet/core/wallet_service.dart'; import 'package:cake_wallet/core/wallet_service.dart';
import 'package:cake_wallet/entities/biometric_auth.dart'; import 'package:cake_wallet/entities/biometric_auth.dart';
@ -332,7 +333,8 @@ Future setup(
getIt.registerFactory(() => ExchangeTradeViewModel( getIt.registerFactory(() => ExchangeTradeViewModel(
wallet: getIt.get<AppStore>().wallet, wallet: getIt.get<AppStore>().wallet,
trades: tradesSource, trades: tradesSource,
tradesStore: getIt.get<TradesStore>())); tradesStore: getIt.get<TradesStore>(),
sendViewModel: getIt.get<SendViewModel>()));
getIt.registerFactory(() => ExchangePage(getIt.get<ExchangeViewModel>())); getIt.registerFactory(() => ExchangePage(getIt.get<ExchangeViewModel>()));

View file

@ -95,6 +95,7 @@ class CurrencyPickerState extends State<CurrencyPicker> {
alignment: Alignment.center, alignment: Alignment.center,
children: <Widget>[ children: <Widget>[
GridView.count( GridView.count(
padding: EdgeInsets.all(0),
controller: controller, controller: controller,
crossAxisCount: crossAxisCount, crossAxisCount: crossAxisCount,
childAspectRatio: 1.25, childAspectRatio: 1.25,

View file

@ -1,31 +1,26 @@
import 'package:cake_wallet/palette.dart'; import 'dart:ui';
import 'package:cake_wallet/entities/crypto_currency.dart';
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_item.dart';
import 'package:cake_wallet/src/screens/exchange_trade/information_page.dart';
import 'package:cake_wallet/src/widgets/standart_list_row.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/exchange/exchange_trade_view_model.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:provider/provider.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/core/execution_state.dart';
// import 'package:cake_wallet/src/stores/exchange_trade/exchange_trade_store.dart'; import 'package:cake_wallet/entities/crypto_currency.dart';
// import 'package:cake_wallet/src/stores/send/send_store.dart'; import 'package:cake_wallet/exchange/exchange_provider_description.dart';
// import 'package:cake_wallet/src/stores/send/sending_state.dart'; import 'package:cake_wallet/src/screens/exchange_trade/information_page.dart';
// import 'package:cake_wallet/src/stores/wallet/wallet_store.dart'; import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart';
import 'package:cake_wallet/src/widgets/standart_list_row.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/exchange/exchange_trade_view_model.dart';
import 'package:cake_wallet/view_model/send/send_view_model_state.dart';
import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart'; import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart';
import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/screens/exchange_trade/widgets/timer_widget.dart'; import 'package:cake_wallet/src/screens/exchange_trade/widgets/timer_widget.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart'; import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart'; import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
void showInformation( void showInformation(
ExchangeTradeViewModel exchangeTradeViewModel, BuildContext context) { ExchangeTradeViewModel exchangeTradeViewModel, BuildContext context) {
@ -110,7 +105,7 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
width: 16, width: 16,
color: Theme.of(context).primaryTextTheme.overline.color); color: Theme.of(context).primaryTextTheme.overline.color);
//_setEffects(context); _setEffects(context);
return Container( return Container(
child: ScrollableWithBottomSection( child: ScrollableWithBottomSection(
@ -227,44 +222,25 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
); );
}), }),
bottomSectionPadding: EdgeInsets.fromLTRB(24, 0, 24, 24), bottomSectionPadding: EdgeInsets.fromLTRB(24, 0, 24, 24),
bottomSection: bottomSection: Observer(builder: (_) {
/*Observer( final trade = widget.exchangeTradeViewModel.trade;
builder: (_) => tradeStore.trade.from == CryptoCurrency.xmr && final sendingState =
!(sendStore.state is TransactionCommitted) widget.exchangeTradeViewModel.sendViewModel.state;
? LoadingPrimaryButton(
isDisabled: tradeStore.trade.inputAddress == null ||
tradeStore.trade.inputAddress.isEmpty,
isLoading: sendStore.state is CreatingTransaction ||
sendStore.state is TransactionCommitted,
onPressed: () => sendStore.createTransaction(
address: tradeStore.trade.inputAddress,
amount: tradeStore.trade.amount),
text: tradeStore.trade.provider ==
ExchangeProviderDescription.xmrto
? S.of(context).confirm
: S.of(context).send_xmr,
color: Colors.blue,
textColor: Colors.white)
: Offstage()),*/
Observer(
builder: (_) {
final trade = widget.exchangeTradeViewModel.trade;
return trade.from == CryptoCurrency.xmr return trade.from == CryptoCurrency.xmr && !(sendingState is TransactionCommitted)
? LoadingPrimaryButton( ? LoadingPrimaryButton(
isDisabled: trade.inputAddress == null || isDisabled: trade.inputAddress == null ||
trade.inputAddress.isEmpty, trade.inputAddress.isEmpty,
isLoading: false, // FIXME isLoading: sendingState is IsExecutingState,
onPressed: () {}, // FIXME onPressed: () =>
text: trade.provider == widget.exchangeTradeViewModel.confirmSending(),
ExchangeProviderDescription.xmrto text: trade.provider == ExchangeProviderDescription.xmrto
? S.of(context).confirm ? S.of(context).confirm
: S.of(context).send_xmr, : S.of(context).send_xmr,
color: Theme.of(context).accentTextTheme.body2.color, color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white) textColor: Colors.white)
: Offstage(); : Offstage();
}) })),
),
); );
} }
@ -273,10 +249,9 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
return; return;
} }
/*final sendStore = Provider.of<SendStore>(context); reaction((_) => this.widget.exchangeTradeViewModel.sendViewModel.state,
(ExecutionState state) {
reaction((_) => sendStore.state, (SendingState state) { if (state is FailureState) {
if (state is SendingFailed) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
showPopUp<void>( showPopUp<void>(
context: context, context: context,
@ -285,30 +260,126 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
alertTitle: S.of(context).error, alertTitle: S.of(context).error,
alertContent: state.error, alertContent: state.error,
buttonText: S.of(context).ok, buttonText: S.of(context).ok,
buttonAction: () => Navigator.of(context).pop() buttonAction: () => Navigator.of(context).pop());
);
}); });
}); });
} }
if (state is TransactionCreatedSuccessfully) { if (state is ExecutedSuccessfullyState) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
showPopUp<void>( showPopUp<void>(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertWithTwoActions( return ConfirmSendingAlert(
alertTitle: S.of(context).confirm_sending, alertTitle: S.of(context).confirm_sending,
alertContent: S.of(context).commit_transaction_amount_fee( amount: S.of(context).send_amount,
sendStore.pendingTransaction.amount, amountValue: widget.exchangeTradeViewModel.sendViewModel
sendStore.pendingTransaction.fee), .pendingTransaction.amountFormatted,
leftButtonText: S.of(context).ok, fee: S.of(context).send_fee,
rightButtonText: S.of(context).cancel, feeValue: widget.exchangeTradeViewModel.sendViewModel
actionLeftButton: () { .pendingTransaction.feeFormatted,
rightButtonText: S.of(context).ok,
leftButtonText: S.of(context).cancel,
actionRightButton: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
sendStore.commitTransaction(); widget.exchangeTradeViewModel.sendViewModel
.commitTransaction();
showPopUp<void>(
context: context,
builder: (BuildContext context) {
return Observer(builder: (_) {
final state = widget
.exchangeTradeViewModel.sendViewModel.state;
if (state is TransactionCommitted) {
return Stack(
children: <Widget>[
Container(
color: Theme.of(context).backgroundColor,
child: Center(
child: Image.asset(
'assets/images/birthday_cake.png'),
),
),
Center(
child: Padding(
padding: EdgeInsets.only(
top: 220, left: 24, right: 24),
child: Text(
S.of(context).send_success,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Theme.of(context)
.primaryTextTheme
.title
.color,
decoration: TextDecoration.none,
),
),
),
),
Positioned(
left: 24,
right: 24,
bottom: 24,
child: PrimaryButton(
onPressed: () =>
Navigator.of(context).pop(),
text: S.of(context).send_got_it,
color: Theme.of(context)
.accentTextTheme
.body2
.color,
textColor: Colors.white))
],
);
}
return Stack(
children: <Widget>[
Container(
color: Theme.of(context).backgroundColor,
child: Center(
child: Image.asset(
'assets/images/birthday_cake.png'),
),
),
BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 3.0, sigmaY: 3.0),
child: Container(
decoration: BoxDecoration(
color: Theme.of(context)
.backgroundColor
.withOpacity(0.25)),
child: Center(
child: Padding(
padding: EdgeInsets.only(top: 220),
child: Text(
S.of(context).send_sending,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Theme.of(context)
.primaryTextTheme
.title
.color,
decoration: TextDecoration.none,
),
),
),
),
),
)
],
);
});
});
}, },
actionRightButton: () => Navigator.of(context).pop() actionLeftButton: () => Navigator.of(context).pop());
);
}); });
}); });
} }
@ -322,12 +393,11 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
alertTitle: S.of(context).sending, alertTitle: S.of(context).sending,
alertContent: S.of(context).transaction_sent, alertContent: S.of(context).transaction_sent,
buttonText: S.of(context).ok, buttonText: S.of(context).ok,
buttonAction: () => Navigator.of(context).pop() buttonAction: () => Navigator.of(context).pop());
);
}); });
}); });
} }
});*/ });
_effectsInstalled = true; _effectsInstalled = true;
} }

View file

@ -483,8 +483,16 @@ class SendPage extends BasePage {
} }
}, },
text: S.of(context).send, text: S.of(context).send,
color: Theme.of(context).accentTextTheme.body2.color, color: Theme
textColor: Colors.white, .of(context)
.accentTextTheme
.subtitle
.decorationColor,
textColor: Theme
.of(context)
.accentTextTheme
.headline
.decorationColor,
isLoading: sendViewModel.state is IsExecutingState || isLoading: sendViewModel.state is IsExecutingState ||
sendViewModel.state is TransactionCommitting, sendViewModel.state is TransactionCommitting,
isDisabled: isDisabled:

View file

@ -1,15 +1,17 @@
import 'package:cake_wallet/src/widgets/address_text_field.dart'; import 'package:mobx/mobx.dart';
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:keyboard_actions/keyboard_actions.dart';
import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/view_model/send/send_view_model.dart'; import 'package:cake_wallet/view_model/send/send_view_model.dart';
import 'package:flutter/services.dart'; import 'package:cake_wallet/src/widgets/address_text_field.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
import 'package:mobx/mobx.dart'; import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
class SendTemplatePage extends BasePage { class SendTemplatePage extends BasePage {
SendTemplatePage({@required this.sendViewModel}); SendTemplatePage({@required this.sendViewModel});
@ -20,6 +22,8 @@ class SendTemplatePage extends BasePage {
final _fiatAmountController = TextEditingController(); final _fiatAmountController = TextEditingController();
final _nameController = TextEditingController(); final _nameController = TextEditingController();
final _formKey = GlobalKey<FormState>(); final _formKey = GlobalKey<FormState>();
final FocusNode _cryptoAmountFocus = FocusNode();
final FocusNode _fiatAmountFocus = FocusNode();
bool _effectsInstalled = false; bool _effectsInstalled = false;
@ -42,94 +46,153 @@ class SendTemplatePage extends BasePage {
Widget body(BuildContext context) { Widget body(BuildContext context) {
_setEffects(context); _setEffects(context);
return Container( return KeyboardActions(
color: Theme.of(context).backgroundColor, config: KeyboardActionsConfig(
child: ScrollableWithBottomSection( keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
contentPadding: EdgeInsets.only(bottom: 24), keyboardBarColor: isDarkTheme
content: Container( ? Color.fromRGBO(48, 51, 60, 1.0)
decoration: BoxDecoration( : Color.fromRGBO(98, 98, 98, 1.0),
borderRadius: BorderRadius.only( nextFocus: false,
bottomLeft: Radius.circular(24), actions: [
bottomRight: Radius.circular(24) KeyboardActionsItem(
), focusNode: _cryptoAmountFocus,
gradient: LinearGradient(colors: [ toolbarButtons: [(_) => KeyboardDoneButton()],
Theme.of(context).primaryTextTheme.subhead.color, ),
Theme.of(context).primaryTextTheme.subhead.decorationColor, KeyboardActionsItem(
], begin: Alignment.topLeft, end: Alignment.bottomRight), focusNode: _fiatAmountFocus,
), toolbarButtons: [(_) => KeyboardDoneButton()],
child: Form( )
key: _formKey, ]),
child: Column(children: <Widget>[ child: Container(
Padding( height: 0,
padding: EdgeInsets.fromLTRB(24, 90, 24, 32), color: Theme.of(context).backgroundColor,
child: Column( child: ScrollableWithBottomSection(
children: <Widget>[ contentPadding: EdgeInsets.only(bottom: 24),
BaseTextFormField( content: Container(
controller: _nameController, decoration: BoxDecoration(
hintText: S.of(context).send_name, borderRadius: BorderRadius.only(
borderColor: Theme.of(context) bottomLeft: Radius.circular(24),
.primaryTextTheme bottomRight: Radius.circular(24)),
.headline gradient: LinearGradient(colors: [
.color, Theme.of(context).primaryTextTheme.subhead.color,
textStyle: TextStyle( Theme.of(context).primaryTextTheme.subhead.decorationColor,
fontSize: 14, ], begin: Alignment.topLeft, end: Alignment.bottomRight),
fontWeight: FontWeight.w500, ),
color: Colors.white), child: Form(
placeholderTextStyle: TextStyle( key: _formKey,
color: Theme.of(context) child: Column(children: <Widget>[
.primaryTextTheme Padding(
.headline padding: EdgeInsets.fromLTRB(24, 90, 24, 32),
.decorationColor, child: Column(
fontWeight: FontWeight.w500, children: <Widget>[
fontSize: 14), BaseTextFormField(
validator: sendViewModel.templateValidator, controller: _nameController,
), hintText: S.of(context).send_name,
Padding( borderColor:
padding: EdgeInsets.only(top: 20), Theme.of(context).primaryTextTheme.headline.color,
child: AddressTextField( textStyle: TextStyle(
controller: _addressController, fontSize: 14,
onURIScanned: (uri) { fontWeight: FontWeight.w500,
var address = ''; color: Colors.white),
var amount = ''; placeholderTextStyle: TextStyle(
color: Theme.of(context)
.primaryTextTheme
.headline
.decorationColor,
fontWeight: FontWeight.w500,
fontSize: 14),
validator: sendViewModel.templateValidator,
),
Padding(
padding: EdgeInsets.only(top: 20),
child: AddressTextField(
controller: _addressController,
onURIScanned: (uri) {
var address = '';
var amount = '';
if (uri != null) { if (uri != null) {
address = uri.path; address = uri.path;
amount = uri.queryParameters['tx_amount']; amount = uri.queryParameters['tx_amount'];
} else { } else {
address = uri.toString(); address = uri.toString();
} }
_addressController.text = address; _addressController.text = address;
_cryptoAmountController.text = amount; _cryptoAmountController.text = amount;
}, },
options: [ options: [
AddressTextFieldOption.paste, AddressTextFieldOption.paste,
AddressTextFieldOption.qrCode, AddressTextFieldOption.qrCode,
AddressTextFieldOption.addressBook AddressTextFieldOption.addressBook
], ],
buttonColor: buttonColor: Theme.of(context)
Theme.of(context).primaryTextTheme.display1.color, .primaryTextTheme
borderColor: .display1
Theme.of(context).primaryTextTheme.headline.color, .color,
textStyle: TextStyle( borderColor: Theme.of(context)
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.white),
hintStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.primaryTextTheme .primaryTextTheme
.headline .headline
.decorationColor), .color,
validator: sendViewModel.addressValidator, textStyle: TextStyle(
), fontSize: 14,
), fontWeight: FontWeight.w500,
Observer(builder: (_) { color: Colors.white),
return Padding( hintStyle: TextStyle(
padding: const EdgeInsets.only(top: 20), fontSize: 14,
child: BaseTextFormField( fontWeight: FontWeight.w500,
controller: _cryptoAmountController, color: Theme.of(context)
.primaryTextTheme
.headline
.decorationColor),
validator: sendViewModel.addressValidator,
),
),
Observer(builder: (_) {
return Padding(
padding: const EdgeInsets.only(top: 20),
child: BaseTextFormField(
focusNode: _cryptoAmountFocus,
controller: _cryptoAmountController,
keyboardType: TextInputType.numberWithOptions(
signed: false, decimal: true),
inputFormatters: [
BlacklistingTextInputFormatter(
RegExp('[\\-|\\ ]'))
],
prefixIcon: Padding(
padding: EdgeInsets.only(top: 9),
child:
Text(sendViewModel.currency.title + ':',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.white,
)),
),
hintText: '0.0000',
borderColor: Theme.of(context)
.primaryTextTheme
.headline
.color,
textStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.white),
placeholderTextStyle: TextStyle(
color: Theme.of(context)
.primaryTextTheme
.headline
.decorationColor,
fontWeight: FontWeight.w500,
fontSize: 14),
validator: sendViewModel.amountValidator));
}),
Padding(
padding: const EdgeInsets.only(top: 20),
child: BaseTextFormField(
focusNode: _fiatAmountFocus,
controller: _fiatAmountController,
keyboardType: TextInputType.numberWithOptions( keyboardType: TextInputType.numberWithOptions(
signed: false, decimal: true), signed: false, decimal: true),
inputFormatters: [ inputFormatters: [
@ -138,15 +201,14 @@ class SendTemplatePage extends BasePage {
], ],
prefixIcon: Padding( prefixIcon: Padding(
padding: EdgeInsets.only(top: 9), padding: EdgeInsets.only(top: 9),
child: child: Text(sendViewModel.fiat.title + ':',
Text(sendViewModel.currency.title + ':',
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: Colors.white, color: Colors.white,
)), )),
), ),
hintText: '0.0000', hintText: '0.00',
borderColor: Theme.of(context) borderColor: Theme.of(context)
.primaryTextTheme .primaryTextTheme
.headline .headline
@ -162,68 +224,34 @@ class SendTemplatePage extends BasePage {
.decorationColor, .decorationColor,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
fontSize: 14), fontSize: 14),
validator: sendViewModel.amountValidator)); )),
}), ],
Padding( ),
padding: const EdgeInsets.only(top: 20), )
child: BaseTextFormField( ]),
controller: _fiatAmountController, ),
keyboardType: TextInputType.numberWithOptions( ),
signed: false, decimal: true), bottomSectionPadding:
inputFormatters: [ EdgeInsets.only(left: 24, right: 24, bottom: 24),
BlacklistingTextInputFormatter( bottomSection: PrimaryButton(
RegExp('[\\-|\\ ]')) onPressed: () {
], if (_formKey.currentState.validate()) {
prefixIcon: Padding( sendViewModel.addTemplate(
padding: EdgeInsets.only(top: 9), name: _nameController.text,
child: Text(sendViewModel.fiat.title + ':', address: _addressController.text,
style: TextStyle( cryptoCurrency: sendViewModel.currency.title,
fontSize: 16, amount: _cryptoAmountController.text);
fontWeight: FontWeight.w600, sendViewModel.updateTemplate();
color: Colors.white, Navigator.of(context).pop();
)), }
), },
hintText: '0.00', text: S.of(context).save,
borderColor: Theme.of(context) color: Theme.of(context).accentTextTheme.subtitle.decorationColor,
.primaryTextTheme textColor:
.headline Theme.of(context).accentTextTheme.headline.decorationColor,
.color, ),
textStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.white),
placeholderTextStyle: TextStyle(
color: Theme.of(context)
.primaryTextTheme
.headline
.decorationColor,
fontWeight: FontWeight.w500,
fontSize: 14),
)),
],
),
)
]),
), ),
), ));
bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24),
bottomSection: PrimaryButton(
onPressed: () {
if (_formKey.currentState.validate()) {
sendViewModel.addTemplate(
name: _nameController.text,
address: _addressController.text,
cryptoCurrency: sendViewModel.currency.title,
amount: _cryptoAmountController.text);
sendViewModel.updateTemplate();
Navigator.of(context).pop();
}
},
text: S.of(context).save,
color: Colors.green,
textColor: Colors.white),
),
);
} }
void _setEffects(BuildContext context) { void _setEffects(BuildContext context) {

View file

@ -13,29 +13,29 @@ import 'package:cake_wallet/src/widgets/standart_list_row.dart';
class TradeDetailsPage extends BasePage { class TradeDetailsPage extends BasePage {
TradeDetailsPage(this.trade) : _items = [] { TradeDetailsPage(this.trade) : _items = [] {
final dateFormat = DateFormatter.withCurrentLocal(); final dateFormat = DateFormatter.withCurrentLocal();
final items = [ _items.addAll([
StandartListItem(title: S.current.trade_details_id, value: trade.id), StandartListItem(title: S.current.trade_details_id, value: trade.id),
StandartListItem( StandartListItem(
title: S.current.trade_details_state, title: S.current.trade_details_state,
value: trade.state != null value: trade.state != null
? trade.state.toString() ? trade.state.toString()
: S.current.trade_details_fetching) : S.current.trade_details_fetching)
]; ]);
if (trade.provider != null) { if (trade.provider != null) {
items.add(StandartListItem( _items.add(StandartListItem(
title: S.current.trade_details_provider, title: S.current.trade_details_provider,
value: trade.provider.toString())); value: trade.provider.toString()));
} }
if (trade.createdAt != null) { if (trade.createdAt != null) {
items.add(StandartListItem( _items.add(StandartListItem(
title: S.current.trade_details_created_at, title: S.current.trade_details_created_at,
value: dateFormat.format(trade.createdAt).toString())); value: dateFormat.format(trade.createdAt).toString()));
} }
if (trade.from != null && trade.to != null) { if (trade.from != null && trade.to != null) {
items.add(StandartListItem( _items.add(StandartListItem(
title: S.current.trade_details_pair, title: S.current.trade_details_pair,
value: '${trade.from.toString()}${trade.to.toString()}')); value: '${trade.from.toString()}${trade.to.toString()}'));
} }

View file

@ -7,6 +7,7 @@ import 'package:cake_wallet/exchange/morphtoken/morphtoken_exchange_provider.dar
import 'package:cake_wallet/exchange/trade.dart'; import 'package:cake_wallet/exchange/trade.dart';
import 'package:cake_wallet/exchange/xmrto/xmrto_exchange_provider.dart'; import 'package:cake_wallet/exchange/xmrto/xmrto_exchange_provider.dart';
import 'package:cake_wallet/store/dashboard/trades_store.dart'; import 'package:cake_wallet/store/dashboard/trades_store.dart';
import 'package:cake_wallet/view_model/send/send_view_model.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_item.dart'; import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_item.dart';
@ -18,7 +19,8 @@ class ExchangeTradeViewModel = ExchangeTradeViewModelBase
with _$ExchangeTradeViewModel; with _$ExchangeTradeViewModel;
abstract class ExchangeTradeViewModelBase with Store { abstract class ExchangeTradeViewModelBase with Store {
ExchangeTradeViewModelBase({this.wallet, this.trades, this.tradesStore}) { ExchangeTradeViewModelBase(
{this.wallet, this.trades, this.tradesStore, this.sendViewModel}) {
trade = tradesStore.trade; trade = tradesStore.trade;
isSendable = trade.from == wallet.currency || isSendable = trade.from == wallet.currency ||
@ -57,6 +59,7 @@ abstract class ExchangeTradeViewModelBase with Store {
final WalletBase wallet; final WalletBase wallet;
final Box<Trade> trades; final Box<Trade> trades;
final TradesStore tradesStore; final TradesStore tradesStore;
final SendViewModel sendViewModel;
@observable @observable
Trade trade; Trade trade;
@ -71,6 +74,17 @@ abstract class ExchangeTradeViewModelBase with Store {
Timer _timer; Timer _timer;
@action
Future confirmSending() async {
if (!isSendable) {
return;
}
sendViewModel.address = trade.inputAddress;
sendViewModel.setCryptoAmount(trade.amount);
await sendViewModel.createTransaction();
}
@action @action
Future<void> _updateTrade() async { Future<void> _updateTrade() async {
try { try {

View file

@ -1,8 +1,8 @@
import 'package:intl/intl.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/entities/openalias_record.dart'; import 'package:cake_wallet/entities/openalias_record.dart';
import 'package:cake_wallet/entities/template.dart'; import 'package:cake_wallet/entities/template.dart';
import 'package:cake_wallet/store/templates/send_template_store.dart'; import 'package:cake_wallet/store/templates/send_template_store.dart';
import 'package:intl/intl.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/core/template_validator.dart'; import 'package:cake_wallet/core/template_validator.dart';
import 'package:cake_wallet/core/address_validator.dart'; import 'package:cake_wallet/core/address_validator.dart';
import 'package:cake_wallet/core/amount_validator.dart'; import 'package:cake_wallet/core/amount_validator.dart';