This commit is contained in:
M 2020-09-29 20:56:11 +03:00
parent e08e10bc35
commit 696b808698
10 changed files with 950 additions and 848 deletions

View file

@ -131,6 +131,7 @@ class App extends StatelessWidget {
return Observer(builder: (BuildContext context) { return Observer(builder: (BuildContext context) {
return Root( return Root(
authenticationStore: authenticationStore, authenticationStore: authenticationStore,
navigatorKey: navigatorKey,
child: MaterialApp( child: MaterialApp(
navigatorKey: navigatorKey, navigatorKey: navigatorKey,
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,

View file

@ -37,7 +37,7 @@ abstract class BasePage extends StatelessWidget {
Widget Function(BuildContext, Widget) get rootWrapper => null; Widget Function(BuildContext, Widget) get rootWrapper => null;
bool get _isDarkTheme => getIt.get<SettingsStore>().isDarkTheme; bool get isDarkTheme => getIt.get<SettingsStore>().isDarkTheme;
void onOpenEndDrawer() => _scaffoldKey.currentState.openEndDrawer(); void onOpenEndDrawer() => _scaffoldKey.currentState.openEndDrawer();
@ -51,7 +51,7 @@ abstract class BasePage extends StatelessWidget {
final _backButton = Image.asset('assets/images/back_arrow.png', final _backButton = Image.asset('assets/images/back_arrow.png',
color: titleColor ?? Theme.of(context).primaryTextTheme.title.color); color: titleColor ?? Theme.of(context).primaryTextTheme.title.color);
final _closeButton = final _closeButton =
_isDarkTheme ? _closeButtonImageDarkTheme : _closeButtonImage; isDarkTheme ? _closeButtonImageDarkTheme : _closeButtonImage;
return SizedBox( return SizedBox(
height: 37, height: 37,
@ -88,7 +88,7 @@ abstract class BasePage extends StatelessWidget {
ObstructingPreferredSizeWidget appBar(BuildContext context) { ObstructingPreferredSizeWidget appBar(BuildContext context) {
final appBarColor = final appBarColor =
_isDarkTheme ? backgroundDarkColor : backgroundLightColor; isDarkTheme ? backgroundDarkColor : backgroundLightColor;
switch (appBarStyle) { switch (appBarStyle) {
case AppBarStyle.regular: case AppBarStyle.regular:
@ -133,7 +133,7 @@ abstract class BasePage extends StatelessWidget {
final root = Scaffold( final root = Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
backgroundColor: backgroundColor:
_isDarkTheme ? backgroundDarkColor : backgroundLightColor, isDarkTheme ? backgroundDarkColor : backgroundLightColor,
resizeToAvoidBottomPadding: resizeToAvoidBottomPadding, resizeToAvoidBottomPadding: resizeToAvoidBottomPadding,
extendBodyBehindAppBar: extendBodyBehindAppBar, extendBodyBehindAppBar: extendBodyBehindAppBar,
endDrawer: endDrawer, endDrawer: endDrawer,

View file

@ -1,7 +1,9 @@
import 'dart:ui'; import 'dart:ui';
import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/exchange/exchange_template.dart'; import 'package:cake_wallet/exchange/exchange_template.dart';
import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
import 'package:cake_wallet/src/widgets/template_tile.dart'; import 'package:cake_wallet/src/widgets/template_tile.dart';
import 'package:cake_wallet/src/widgets/trail_button.dart'; import 'package:cake_wallet/src/widgets/trail_button.dart';
import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/utils/show_pop_up.dart';
@ -9,11 +11,13 @@ import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:keyboard_actions/keyboard_actions.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/entities/crypto_currency.dart'; import 'package:cake_wallet/entities/crypto_currency.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/exchange/exchange_trade_state.dart'; // import 'package:cake_wallet/exchange/exchange_trade_state.dart';
// import 'package:cake_wallet/exchange/limits_state.dart'; // import 'package:cake_wallet/exchange/limits_state.dart';
import 'package:cake_wallet/src/screens/exchange/widgets/exchange_card.dart'; import 'package:cake_wallet/src/screens/exchange/widgets/exchange_card.dart';
@ -32,6 +36,8 @@ class ExchangePage extends BasePage {
final depositKey = GlobalKey<ExchangeCardState>(); final depositKey = GlobalKey<ExchangeCardState>();
final receiveKey = GlobalKey<ExchangeCardState>(); final receiveKey = GlobalKey<ExchangeCardState>();
final _formKey = GlobalKey<FormState>(); final _formKey = GlobalKey<FormState>();
final _depositAmountFocus = FocusNode();
final _receiveAmountFocus = FocusNode();
var _isReactionsSet = false; var _isReactionsSet = false;
@override @override
@ -54,11 +60,8 @@ class ExchangePage extends BasePage {
PresentProviderPicker(exchangeViewModel: exchangeViewModel); PresentProviderPicker(exchangeViewModel: exchangeViewModel);
@override @override
Widget trailing(BuildContext context) => Widget trailing(BuildContext context) => TrailButton(
TrailButton( caption: S.of(context).reset, onPressed: () => exchangeViewModel.reset());
caption: S.of(context).reset,
onPressed: () => exchangeViewModel.reset()
);
@override @override
Widget body(BuildContext context) { Widget body(BuildContext context) {
@ -85,7 +88,23 @@ class ExchangePage extends BasePage {
WidgetsBinding.instance WidgetsBinding.instance
.addPostFrameCallback((_) => _setReactions(context, exchangeViewModel)); .addPostFrameCallback((_) => _setReactions(context, exchangeViewModel));
return Container( return KeyboardActions(
config: KeyboardActionsConfig(
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
keyboardBarColor: isDarkTheme
? Color.fromRGBO(48, 51, 60, 1.0)
: Color.fromRGBO(98, 98, 98, 1.0),
nextFocus: false,
actions: [
KeyboardActionsItem(
focusNode: _depositAmountFocus,
toolbarButtons: [(_) => KeyboardDoneButton()]),
KeyboardActionsItem(
focusNode: _receiveAmountFocus,
toolbarButtons: [(_) => KeyboardDoneButton()])
]),
child: Container(
height: 1,
color: Theme.of(context).backgroundColor, color: Theme.of(context).backgroundColor,
child: Form( child: Form(
key: _formKey, key: _formKey,
@ -98,14 +117,19 @@ class ExchangePage extends BasePage {
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(24), bottomLeft: Radius.circular(24),
bottomRight: Radius.circular(24) bottomRight: Radius.circular(24)),
),
gradient: LinearGradient( gradient: LinearGradient(
colors: [ colors: [
Theme.of(context).primaryTextTheme.body1.color, Theme.of(context).primaryTextTheme.body1.color,
Theme.of(context).primaryTextTheme.body1.decorationColor, Theme.of(context)
.primaryTextTheme
.body1
.decorationColor,
],
stops: [
0.35,
1.0
], ],
stops: [0.35, 1.0],
begin: Alignment.topLeft, begin: Alignment.topLeft,
end: Alignment.bottomRight), end: Alignment.bottomRight),
), ),
@ -115,8 +139,7 @@ class ExchangePage extends BasePage {
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(24), bottomLeft: Radius.circular(24),
bottomRight: Radius.circular(24) bottomRight: Radius.circular(24)),
),
gradient: LinearGradient( gradient: LinearGradient(
colors: [ colors: [
Theme.of(context) Theme.of(context)
@ -131,22 +154,23 @@ class ExchangePage extends BasePage {
begin: Alignment.topLeft, begin: Alignment.topLeft,
end: Alignment.bottomRight), end: Alignment.bottomRight),
), ),
padding: EdgeInsets.fromLTRB(24, 90, 24, 32), padding: EdgeInsets.fromLTRB(24, 100, 24, 32),
child: Observer( child: Observer(
builder: (_) => ExchangeCard( builder: (_) => ExchangeCard(
amountFocusNode: _depositAmountFocus,
key: depositKey, key: depositKey,
title: S.of(context).you_will_send, title: S.of(context).you_will_send,
initialCurrency: initialCurrency:
exchangeViewModel.depositCurrency, exchangeViewModel.depositCurrency,
initialWalletName: depositWalletName, initialWalletName: depositWalletName,
initialAddress: exchangeViewModel initialAddress:
.depositCurrency == exchangeViewModel.depositCurrency ==
exchangeViewModel.wallet.currency exchangeViewModel.wallet.currency
? exchangeViewModel.wallet.address ? exchangeViewModel.wallet.address
: exchangeViewModel.depositAddress, : exchangeViewModel.depositAddress,
initialIsAmountEditable: true, initialIsAmountEditable: true,
initialIsAddressEditable: exchangeViewModel initialIsAddressEditable:
.isDepositAddressEnabled, exchangeViewModel.isDepositAddressEnabled,
isAmountEstimated: false, isAmountEstimated: false,
currencies: CryptoCurrency.all, currencies: CryptoCurrency.all,
onCurrencySelected: (currency) => onCurrencySelected: (currency) =>
@ -163,32 +187,35 @@ class ExchangePage extends BasePage {
currencyValueValidator: AmountValidator( currencyValueValidator: AmountValidator(
type: exchangeViewModel.wallet.type), type: exchangeViewModel.wallet.type),
addressTextFieldValidator: AddressValidator( addressTextFieldValidator: AddressValidator(
type: type: exchangeViewModel.depositCurrency),
exchangeViewModel.depositCurrency),
), ),
), ),
), ),
Padding( Padding(
padding: EdgeInsets.only(top: 29, left: 24, right: 24), padding:
EdgeInsets.only(top: 29, left: 24, right: 24),
child: Observer( child: Observer(
builder: (_) => ExchangeCard( builder: (_) => ExchangeCard(
amountFocusNode: _receiveAmountFocus,
key: receiveKey, key: receiveKey,
title: S.of(context).you_will_get, title: S.of(context).you_will_get,
initialCurrency: initialCurrency:
exchangeViewModel.receiveCurrency, exchangeViewModel.receiveCurrency,
initialWalletName: receiveWalletName, initialWalletName: receiveWalletName,
initialAddress: initialAddress: exchangeViewModel
exchangeViewModel.receiveCurrency == .receiveCurrency ==
exchangeViewModel.wallet.currency exchangeViewModel.wallet.currency
? exchangeViewModel.wallet.address ? exchangeViewModel.wallet.address
: exchangeViewModel.receiveAddress, : exchangeViewModel.receiveAddress,
initialIsAmountEditable: false, initialIsAmountEditable: false,
initialIsAddressEditable: initialIsAddressEditable:
exchangeViewModel.isReceiveAddressEnabled, exchangeViewModel
.isReceiveAddressEnabled,
isAmountEstimated: true, isAmountEstimated: true,
currencies: CryptoCurrency.all, currencies: CryptoCurrency.all,
onCurrencySelected: (currency) => onCurrencySelected: (currency) =>
exchangeViewModel.changeReceiveCurrency( exchangeViewModel
.changeReceiveCurrency(
currency: currency), currency: currency),
imageArrow: arrowBottomCakeGreen, imageArrow: arrowBottomCakeGreen,
currencyButtonColor: Colors.transparent, currencyButtonColor: Colors.transparent,
@ -200,8 +227,10 @@ class ExchangePage extends BasePage {
.decorationColor, .decorationColor,
currencyValueValidator: AmountValidator( currencyValueValidator: AmountValidator(
type: exchangeViewModel.wallet.type), type: exchangeViewModel.wallet.type),
addressTextFieldValidator: AddressValidator( addressTextFieldValidator:
type: exchangeViewModel.receiveCurrency), AddressValidator(
type: exchangeViewModel
.receiveCurrency),
)), )),
) )
], ],
@ -237,7 +266,8 @@ class ExchangePage extends BasePage {
onTap: () => Navigator.of(context) onTap: () => Navigator.of(context)
.pushNamed(Routes.exchangeTemplate), .pushNamed(Routes.exchangeTemplate),
child: Container( child: Container(
padding: EdgeInsets.only(left: 1, right: 10), padding:
EdgeInsets.only(left: 1, right: 10),
child: DottedBorder( child: DottedBorder(
borderType: BorderType.RRect, borderType: BorderType.RRect,
dashPattern: [6, 4], dashPattern: [6, 4],
@ -298,8 +328,9 @@ class ExchangePage extends BasePage {
context: context, context: context,
builder: (dialogContext) { builder: (dialogContext) {
return AlertWithTwoActions( return AlertWithTwoActions(
alertTitle: alertTitle: S
S.of(context).template, .of(context)
.template,
alertContent: S alertContent: S
.of(context) .of(context)
.confirm_delete_template, .confirm_delete_template,
@ -365,14 +396,15 @@ class ExchangePage extends BasePage {
exchangeViewModel.createTrade(); exchangeViewModel.createTrade();
} }
}, },
color: Theme.of(context).accentTextTheme.body2.color, color:
Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white, textColor: Colors.white,
isLoading: isLoading: exchangeViewModel.tradeState
false, // FIXME: FIXME exchangeViewModel.tradeState is TradeIsCreating, is IsExecutingState,
)), )),
]), ]),
)), )),
); ));
} }
void applyTemplate( void applyTemplate(

View file

@ -24,7 +24,8 @@ class ExchangeCard extends StatefulWidget {
this.addressButtonsColor = Colors.transparent, this.addressButtonsColor = Colors.transparent,
this.borderColor = Colors.transparent, this.borderColor = Colors.transparent,
this.currencyValueValidator, this.currencyValueValidator,
this.addressTextFieldValidator}) this.addressTextFieldValidator,
this.amountFocusNode})
: super(key: key); : super(key: key);
final List<CryptoCurrency> currencies; final List<CryptoCurrency> currencies;
@ -42,6 +43,7 @@ class ExchangeCard extends StatefulWidget {
final Color borderColor; final Color borderColor;
final FormFieldValidator<String> currencyValueValidator; final FormFieldValidator<String> currencyValueValidator;
final FormFieldValidator<String> addressTextFieldValidator; final FormFieldValidator<String> addressTextFieldValidator;
final FocusNode amountFocusNode;
@override @override
ExchangeCardState createState() => ExchangeCardState(); ExchangeCardState createState() => ExchangeCardState();
@ -114,15 +116,15 @@ class ExchangeCardState extends State<ExchangeCard> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final copyImage = Image.asset('assets/images/copy_content.png', final copyImage = Image.asset('assets/images/copy_content.png',
height: 16, width: 16, height: 16,
width: 16,
color: Theme.of(context).primaryTextTheme.display2.color); color: Theme.of(context).primaryTextTheme.display2.color);
return Container( return Container(
width: double.infinity, width: double.infinity,
color: Colors.transparent, color: Colors.transparent,
child: Column( child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: <
crossAxisAlignment: CrossAxisAlignment.start, Widget>[
children: <Widget>[
Row( Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
@ -131,8 +133,7 @@ class ExchangeCardState extends State<ExchangeCard> {
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 18,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: Theme.of(context).textTheme.headline.color color: Theme.of(context).textTheme.headline.color),
),
) )
], ],
), ),
@ -141,6 +142,7 @@ class ExchangeCardState extends State<ExchangeCard> {
child: Stack( child: Stack(
children: <Widget>[ children: <Widget>[
BaseTextFormField( BaseTextFormField(
focusNode: widget.amountFocusNode,
controller: amountController, controller: amountController,
enabled: _isAmountEditable, enabled: _isAmountEditable,
textAlign: TextAlign.left, textAlign: TextAlign.left,
@ -156,17 +158,17 @@ class ExchangeCardState extends State<ExchangeCard> {
textStyle: TextStyle( textStyle: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: Colors.white color: Colors.white),
),
placeholderTextStyle: TextStyle( placeholderTextStyle: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: Theme.of(context).textTheme.subhead.decorationColor color: Theme.of(context)
), .textTheme
.subhead
.decorationColor),
validator: _isAmountEditable validator: _isAmountEditable
? widget.currencyValueValidator ? widget.currencyValueValidator
: null : null),
),
Positioned( Positioned(
top: 8, top: 8,
right: 0, right: 0,
@ -180,8 +182,7 @@ class ExchangeCardState extends State<ExchangeCard> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
Text( Text(_selectedCurrency.toString(),
_selectedCurrency.toString(),
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
fontSize: 16, fontSize: 16,
@ -195,32 +196,34 @@ class ExchangeCardState extends State<ExchangeCard> {
), ),
) )
], ],
) )),
),
Padding( Padding(
padding: EdgeInsets.only(top: 5), padding: EdgeInsets.only(top: 5),
child: Row( child: Row(mainAxisAlignment: MainAxisAlignment.start, children: <
mainAxisAlignment: MainAxisAlignment.start, Widget>[
children: <Widget>[
_min != null _min != null
? Text( ? Text(
S.of(context).min_value( S.of(context).min_value(_min, _selectedCurrency.toString()),
_min, _selectedCurrency.toString()),
style: TextStyle( style: TextStyle(
fontSize: 10, fontSize: 10,
height: 1.2, height: 1.2,
color: Theme.of(context).textTheme.subhead.decorationColor), color: Theme.of(context)
.textTheme
.subhead
.decorationColor),
) )
: Offstage(), : Offstage(),
_min != null ? SizedBox(width: 10) : Offstage(), _min != null ? SizedBox(width: 10) : Offstage(),
_max != null _max != null
? Text( ? Text(
S.of(context).max_value( S.of(context).max_value(_max, _selectedCurrency.toString()),
_max, _selectedCurrency.toString()),
style: TextStyle( style: TextStyle(
fontSize: 10, fontSize: 10,
height: 1.2, height: 1.2,
color: Theme.of(context).textTheme.subhead.decorationColor)) color: Theme.of(context)
.textTheme
.subhead
.decorationColor))
: Offstage(), : Offstage(),
]), ]),
), ),
@ -233,10 +236,9 @@ class ExchangeCardState extends State<ExchangeCard> {
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: Theme.of(context).textTheme.subhead.decorationColor color:
), Theme.of(context).textTheme.subhead.decorationColor),
) )),
),
_isAddressEditable _isAddressEditable
? Padding( ? Padding(
padding: EdgeInsets.only(top: 20), padding: EdgeInsets.only(top: 20),
@ -255,7 +257,8 @@ class ExchangeCardState extends State<ExchangeCard> {
hintStyle: TextStyle( hintStyle: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: Theme.of(context).textTheme.subhead.decorationColor), color:
Theme.of(context).textTheme.subhead.decorationColor),
buttonColor: widget.addressButtonsColor, buttonColor: widget.addressButtonsColor,
validator: widget.addressTextFieldValidator, validator: widget.addressTextFieldValidator,
), ),
@ -265,8 +268,8 @@ class ExchangeCardState extends State<ExchangeCard> {
child: Builder( child: Builder(
builder: (context) => GestureDetector( builder: (context) => GestureDetector(
onTap: () { onTap: () {
Clipboard.setData(ClipboardData( Clipboard.setData(
text: addressController.text)); ClipboardData(text: addressController.text));
Scaffold.of(context).showSnackBar(SnackBar( Scaffold.of(context).showSnackBar(SnackBar(
content: Text( content: Text(
S.of(context).copied_to_clipboard, S.of(context).copied_to_clipboard,
@ -296,8 +299,7 @@ class ExchangeCardState extends State<ExchangeCard> {
) )
], ],
), ),
) )),
),
), ),
]), ]),
); );

View file

@ -6,11 +6,17 @@ import 'package:cake_wallet/store/authentication_store.dart';
import 'package:cake_wallet/entities/qr_scanner.dart'; import 'package:cake_wallet/entities/qr_scanner.dart';
class Root extends StatefulWidget { class Root extends StatefulWidget {
Root({Key key, this.authenticationStore, this.appStore, this.child}) Root(
{Key key,
this.authenticationStore,
this.appStore,
this.child,
this.navigatorKey})
: super(key: key); : super(key: key);
final AuthenticationStore authenticationStore; final AuthenticationStore authenticationStore;
final AppStore appStore; final AppStore appStore;
final GlobalKey<NavigatorState> navigatorKey;
final Widget child; final Widget child;
@override @override
@ -53,7 +59,7 @@ class RootState extends State<Root> with WidgetsBindingObserver {
if (_isInactive && !_postFrameCallback) { if (_isInactive && !_postFrameCallback) {
_postFrameCallback = true; _postFrameCallback = true;
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.of(context).pushNamed(Routes.unlock, widget.navigatorKey.currentState.pushNamed(Routes.unlock,
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) { arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
if (!isAuthenticatedSuccessfully) { if (!isAuthenticatedSuccessfully) {
return; return;

View file

@ -1,31 +1,26 @@
import 'dart:ui'; import 'dart:ui';
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
// import 'package:cake_wallet/src/domain/common/transaction_priority.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart';
import 'package:keyboard_actions/keyboard_actions.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/view_model/send/send_view_model.dart';
import 'package:cake_wallet/core/execution_state.dart'; import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/picker.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/trail_button.dart'; import 'package:cake_wallet/src/widgets/trail_button.dart';
import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/send/send_view_model_state.dart'; import 'package:cake_wallet/view_model/send/send_view_model_state.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/view_model/send/send_view_model.dart';
import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/src/widgets/address_text_field.dart'; import 'package:cake_wallet/src/widgets/address_text_field.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:dotted_border/dotted_border.dart'; import 'package:dotted_border/dotted_border.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';
import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart'; import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart';
// import 'package:cake_wallet/src/screens/send/widgets/sending_alert.dart';
import 'package:cake_wallet/src/widgets/template_tile.dart';
import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
import 'package:cake_wallet/routes.dart';
class SendPage extends BasePage { class SendPage extends BasePage {
SendPage({@required this.sendViewModel}); SendPage({@required this.sendViewModel});
@ -34,8 +29,9 @@ class SendPage extends BasePage {
final _addressController = TextEditingController(); final _addressController = TextEditingController();
final _cryptoAmountController = TextEditingController(); final _cryptoAmountController = TextEditingController();
final _fiatAmountController = TextEditingController(); final _fiatAmountController = TextEditingController();
final _focusNode = FocusNode();
final _formKey = GlobalKey<FormState>(); final _formKey = GlobalKey<FormState>();
final _cryptoAmountFocus = FocusNode();
final _fiatAmountFocus = FocusNode();
bool _effectsInstalled = false; bool _effectsInstalled = false;
@ -62,7 +58,25 @@ class SendPage extends BasePage {
Widget body(BuildContext context) { Widget body(BuildContext context) {
_setEffects(context); _setEffects(context);
return Container( return KeyboardActions(
config: KeyboardActionsConfig(
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
keyboardBarColor: isDarkTheme
? Color.fromRGBO(48, 51, 60, 1.0)
: Color.fromRGBO(98, 98, 98, 1.0),
nextFocus: false,
actions: [
KeyboardActionsItem(
focusNode: _cryptoAmountFocus,
toolbarButtons: [(_) => KeyboardDoneButton()],
),
KeyboardActionsItem(
focusNode: _fiatAmountFocus,
toolbarButtons: [(_) => KeyboardDoneButton()],
)
]),
child: Container(
height: 0,
color: Theme.of(context).backgroundColor, color: Theme.of(context).backgroundColor,
child: ScrollableWithBottomSection( child: ScrollableWithBottomSection(
contentPadding: EdgeInsets.only(bottom: 24), contentPadding: EdgeInsets.only(bottom: 24),
@ -75,19 +89,21 @@ class SendPage extends BasePage {
bottomRight: Radius.circular(24)), bottomRight: Radius.circular(24)),
gradient: LinearGradient(colors: [ gradient: LinearGradient(colors: [
Theme.of(context).primaryTextTheme.subhead.color, Theme.of(context).primaryTextTheme.subhead.color,
Theme.of(context).primaryTextTheme.subhead.decorationColor, Theme.of(context)
.primaryTextTheme
.subhead
.decorationColor,
], begin: Alignment.topLeft, end: Alignment.bottomRight), ], begin: Alignment.topLeft, end: Alignment.bottomRight),
), ),
child: Form( child: Form(
key: _formKey, key: _formKey,
child: Column(children: <Widget>[ child: Column(children: <Widget>[
Padding( Padding(
padding: EdgeInsets.fromLTRB(24, 90, 24, 32), padding: EdgeInsets.fromLTRB(24, 100, 24, 32),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
AddressTextField( AddressTextField(
controller: _addressController, controller: _addressController,
focusNode: _focusNode,
onURIScanned: (uri) { onURIScanned: (uri) {
var address = ''; var address = '';
var amount = ''; var amount = '';
@ -131,13 +147,15 @@ class SendPage extends BasePage {
Padding( Padding(
padding: const EdgeInsets.only(top: 20), padding: const EdgeInsets.only(top: 20),
child: BaseTextFormField( child: BaseTextFormField(
focusNode: _cryptoAmountFocus,
controller: _cryptoAmountController, controller: _cryptoAmountController,
keyboardType: TextInputType.numberWithOptions( keyboardType:
TextInputType.numberWithOptions(
signed: false, decimal: true), signed: false, decimal: true),
prefixIcon: Padding( prefixIcon: Padding(
padding: EdgeInsets.only(top: 9), padding: EdgeInsets.only(top: 9),
child: child: Text(
Text(sendViewModel.currency.title + ':', sendViewModel.currency.title + ':',
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
@ -157,7 +175,8 @@ class SendPage extends BasePage {
borderRadius: BorderRadius.all( borderRadius: BorderRadius.all(
Radius.circular(6))), Radius.circular(6))),
child: InkWell( child: InkWell(
onTap: () => sendViewModel.setSendAll(), onTap: () =>
sendViewModel.setSendAll(),
child: Center( child: Center(
child: Text(S.of(context).all, child: Text(S.of(context).all,
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -187,7 +206,8 @@ class SendPage extends BasePage {
.decorationColor, .decorationColor,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
fontSize: 14), fontSize: 14),
validator: sendViewModel.amountValidator)), validator:
sendViewModel.amountValidator)),
Observer( Observer(
builder: (_) => Padding( builder: (_) => Padding(
padding: EdgeInsets.only(top: 10), padding: EdgeInsets.only(top: 10),
@ -198,7 +218,8 @@ class SendPage extends BasePage {
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Text( child: Text(
S.of(context).available_balance + ':', S.of(context).available_balance +
':',
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
@ -223,12 +244,15 @@ class SendPage extends BasePage {
Padding( Padding(
padding: const EdgeInsets.only(top: 20), padding: const EdgeInsets.only(top: 20),
child: BaseTextFormField( child: BaseTextFormField(
focusNode: _fiatAmountFocus,
controller: _fiatAmountController, controller: _fiatAmountController,
keyboardType: TextInputType.numberWithOptions( keyboardType:
TextInputType.numberWithOptions(
signed: false, decimal: true), signed: false, decimal: true),
prefixIcon: Padding( prefixIcon: Padding(
padding: EdgeInsets.only(top: 9), padding: EdgeInsets.only(top: 9),
child: Text(sendViewModel.fiat.title + ':', child:
Text(sendViewModel.fiat.title + ':',
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
@ -262,17 +286,22 @@ class SendPage extends BasePage {
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.spaceBetween, MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
Text(S.of(context).send_estimated_fee, Text(
S
.of(context)
.send_estimated_fee,
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w500, fontWeight:
FontWeight.w500,
//color: Theme.of(context).primaryTextTheme.display2.color, //color: Theme.of(context).primaryTextTheme.display2.color,
color: Colors.white)), color: Colors.white)),
Container( Container(
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
Text( Text(
sendViewModel.estimatedFee sendViewModel
.estimatedFee
.toString() + .toString() +
' ' + ' ' +
sendViewModel sendViewModel
@ -282,10 +311,11 @@ class SendPage extends BasePage {
fontWeight: fontWeight:
FontWeight.w600, FontWeight.w600,
//color: Theme.of(context).primaryTextTheme.display2.color, //color: Theme.of(context).primaryTextTheme.display2.color,
color: Colors.white)), color:
Colors.white)),
Padding( Padding(
padding: padding: EdgeInsets.only(
EdgeInsets.only(left: 5), left: 5),
child: Icon( child: Icon(
Icons.arrow_forward_ios, Icons.arrow_forward_ios,
size: 12, size: 12,
@ -348,7 +378,8 @@ class SendPage extends BasePage {
child: Container( child: Container(
height: 34, height: 34,
width: 75, width: 75,
padding: EdgeInsets.only(left: 10, right: 10), padding:
EdgeInsets.only(left: 10, right: 10),
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: borderRadius:
@ -439,7 +470,7 @@ class SendPage extends BasePage {
false // FIXME !(syncStore.status is SyncedSyncStatus), false // FIXME !(syncStore.status is SyncedSyncStatus),
); );
})), })),
); ));
} }
void _setEffects(BuildContext context) { void _setEffects(BuildContext context) {

View file

@ -22,7 +22,8 @@ class BaseTextFormField extends StatelessWidget {
this.validator, this.validator,
this.textStyle, this.textStyle,
this.placeholderTextStyle, this.placeholderTextStyle,
this.maxLength}); this.maxLength,
this.focusNode});
final TextEditingController controller; final TextEditingController controller;
final TextInputType keyboardType; final TextInputType keyboardType;
@ -44,10 +45,12 @@ class BaseTextFormField extends StatelessWidget {
final TextStyle placeholderTextStyle; final TextStyle placeholderTextStyle;
final TextStyle textStyle; final TextStyle textStyle;
final int maxLength; final int maxLength;
final FocusNode focusNode;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return TextFormField( return TextFormField(
focusNode: focusNode,
controller: controller, controller: controller,
keyboardType: keyboardType, keyboardType: keyboardType,
textInputAction: textInputAction, textInputAction: textInputAction,

View file

@ -0,0 +1,19 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class KeyboardDoneButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
// FIXME: Add translation
return CupertinoButton(
padding: EdgeInsets.only(right: 24.0, top: 8.0, bottom: 8.0),
onPressed: () {
FocusScope.of(context).requestFocus(FocusNode());
},
child: Text(
'Done',
style: TextStyle(color: Colors.blueAccent,fontWeight: FontWeight.bold)
),
);
}
}

View file

@ -534,6 +534,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.1.0" version: "3.1.0"
keyboard_actions:
dependency: "direct main"
description:
name: keyboard_actions
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.0+1"
local_auth: local_auth:
dependency: "direct main" dependency: "direct main"
description: description:

View file

@ -64,6 +64,7 @@ dependencies:
bitcoin_flutter: ^2.0.0 bitcoin_flutter: ^2.0.0
get_it: ^4.0.2 get_it: ^4.0.2
connectivity: ^0.4.9+2 connectivity: ^0.4.9+2
keyboard_actions: ^3.3.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: