Merge branch 'new-world' into CAKE-43-xmr_to-amount-entering

# Conflicts:
#	lib/src/screens/exchange/exchange_page.dart
This commit is contained in:
OleksandrSobol 2020-09-30 20:21:57 +03:00
commit 0c65c8d04d
16 changed files with 1023 additions and 860 deletions

View file

@ -354,7 +354,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 32J6BB6VUS; DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
@ -493,7 +493,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 32J6BB6VUS; DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
@ -526,7 +526,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 32J6BB6VUS; DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (

View file

@ -19,6 +19,10 @@ abstract class TransactionHistoryBase<TransactionType extends TransactionInfo> {
try { try {
_isUpdating = true; _isUpdating = true;
final _transactions = await fetchTransactions(); final _transactions = await fetchTransactions();
transactions.keys
.toSet()
.difference(_transactions.keys.toSet())
.forEach((k) => transactions.remove(k));
_transactions.forEach((key, value) => transactions[key] = value); _transactions.forEach((key, value) => transactions[key] = value);
_isUpdating = false; _isUpdating = false;
} catch (e) { } catch (e) {

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

@ -191,7 +191,12 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
@override @override
Future<void> rescan({int height}) async { Future<void> rescan({int height}) async {
monero_wallet.setRefreshFromBlockHeight(height: height);
monero_wallet.rescanBlockchainAsync(); monero_wallet.rescanBlockchainAsync();
await startSync();
_askForUpdateBalance();
await _askForUpdateTransactionHistory();
await save();
} }
void _setListeners() { void _setListeners() {
@ -247,9 +252,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
} }
Future<void> _askForUpdateTransactionHistory() async { Future<void> _askForUpdateTransactionHistory() async {
print('start');
await transactionHistory.update(); await transactionHistory.update();
print('end');
} }
int _getFullBalance() => int _getFullBalance() =>
@ -270,6 +273,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
if (walletInfo.isRecovery) { if (walletInfo.isRecovery) {
_askForUpdateTransactionHistory(); _askForUpdateTransactionHistory();
_askForUpdateBalance();
} }
final currentHeight = getCurrentHeight(); final currentHeight = getCurrentHeight();

View file

@ -236,7 +236,8 @@ class Router {
case Routes.login: case Routes.login:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
builder: (context) => getIt.get<AuthPage>(instanceName: 'login')); builder: (context) => getIt.get<AuthPage>(instanceName: 'login'),
fullscreenDialog: true);
case Routes.accountCreation: case Routes.accountCreation:
return CupertinoPageRoute<String>( return CupertinoPageRoute<String>(

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,8 +1,10 @@
import 'dart:ui'; import 'dart:ui';
import 'package:cake_wallet/exchange/exchange_provider.dart'; import 'package:cake_wallet/exchange/exchange_provider.dart';
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';
@ -10,11 +12,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';
@ -33,6 +37,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
@ -55,11 +61,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) {
@ -86,7 +89,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,
@ -99,14 +118,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),
), ),
@ -116,8 +140,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)
@ -132,22 +155,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) =>
@ -164,32 +188,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: exchangeViewModel.provider is XMRTOExchangeProvider ? true : 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,
@ -201,8 +228,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),
)), )),
) )
], ],
@ -238,7 +267,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],
@ -299,8 +329,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,
@ -366,14 +397,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

@ -21,7 +21,23 @@ class RescanPage extends BasePage {
padding: EdgeInsets.only(left: 24, right: 24, bottom: 24), padding: EdgeInsets.only(left: 24, right: 24, bottom: 24),
child: child:
Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Column(
children: <Widget>[
BlockchainHeightWidget(key: _blockchainHeightWidgetKey), BlockchainHeightWidget(key: _blockchainHeightWidgetKey),
Padding(
padding: EdgeInsets.only(left: 40, right: 40, top: 24),
child: Text(
S.of(context).restore_from_date_or_blockheight,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.normal,
color: Theme.of(context).hintColor
),
),
)
],
),
Observer( Observer(
builder: (_) => LoadingPrimaryButton( builder: (_) => LoadingPrimaryButton(
isLoading: isLoading:
@ -33,7 +49,7 @@ class RescanPage extends BasePage {
_blockchainHeightWidgetKey.currentState.height); _blockchainHeightWidgetKey.currentState.height);
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
color: Colors.blue, color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white, textColor: Colors.white,
)) ))
]), ]),

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;
@ -65,7 +71,7 @@ class RootState extends State<Root> with WidgetsBindingObserver {
}); });
} }
return widget.child; return WillPopScope(onWillPop: () async => false, child: widget.child);
} }
void _reset() { void _reset() {

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:
@ -425,8 +456,10 @@ class SendPage extends BasePage {
EdgeInsets.only(left: 24, right: 24, bottom: 24), EdgeInsets.only(left: 24, right: 24, bottom: 24),
bottomSection: Observer(builder: (_) { bottomSection: Observer(builder: (_) {
return LoadingPrimaryButton( return LoadingPrimaryButton(
onPressed: () { onPressed: () async {
if (_formKey.currentState.validate()) {} if (_formKey.currentState.validate()) {
await sendViewModel.createTransaction();
}
}, },
text: S.of(context).send, text: S.of(context).send,
color: Theme.of(context).accentTextTheme.body2.color, color: Theme.of(context).accentTextTheme.body2.color,
@ -437,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) {
@ -445,6 +478,18 @@ class SendPage extends BasePage {
return; return;
} }
_cryptoAmountController.addListener(() {
final amount = _cryptoAmountController.text;
if (sendViewModel.sendAll && amount != S.current.all) {
sendViewModel.sendAll = false;
}
if (amount != sendViewModel.cryptoAmount) {
sendViewModel.setCryptoAmount(amount);
}
});
reaction((_) => sendViewModel.sendAll, (bool all) { reaction((_) => sendViewModel.sendAll, (bool all) {
if (all) { if (all) {
_cryptoAmountController.text = S.current.all; _cryptoAmountController.text = S.current.all;

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

@ -47,6 +47,28 @@ abstract class SettingsStoreBase with Store {
this.nodes = ObservableMap<WalletType, Node>.of(nodes); this.nodes = ObservableMap<WalletType, Node>.of(nodes);
_sharedPreferences = sharedPreferences; _sharedPreferences = sharedPreferences;
reaction(
(_) => fiatCurrency,
(FiatCurrency fiatCurrency) => sharedPreferences.setString(
PreferencesKey.currentFiatCurrencyKey, fiatCurrency.serialize()));
reaction(
(_) => transactionPriority,
(TransactionPriority priority) => sharedPreferences.setInt(
PreferencesKey.currentTransactionPriorityKey,
priority.serialize()));
reaction(
(_) => shouldSaveRecipientAddress,
(bool shouldSaveRecipientAddress) => sharedPreferences.setBool(
PreferencesKey.shouldSaveRecipientAddressKey,
shouldSaveRecipientAddress));
reaction(
(_) => isDarkTheme,
(bool isDarkTheme) => sharedPreferences.setBool(
PreferencesKey.currentDarkTheme, isDarkTheme));
reaction( reaction(
(_) => allowBiometricalAuthentication, (_) => allowBiometricalAuthentication,
(bool biometricalAuthentication) => sharedPreferences.setBool( (bool biometricalAuthentication) => sharedPreferences.setBool(
@ -61,7 +83,8 @@ abstract class SettingsStoreBase with Store {
reaction((_) => currentNode, reaction((_) => currentNode,
(Node node) => _saveCurrentNode(node, WalletType.monero)); (Node node) => _saveCurrentNode(node, WalletType.monero));
reaction((_) => languageCode, reaction(
(_) => languageCode,
(String languageCode) => sharedPreferences.setString( (String languageCode) => sharedPreferences.setString(
PreferencesKey.currentLanguageCode, languageCode)); PreferencesKey.currentLanguageCode, languageCode));
} }
@ -165,8 +188,7 @@ abstract class SettingsStoreBase with Store {
initialDarkTheme: savedDarkTheme, initialDarkTheme: savedDarkTheme,
actionlistDisplayMode: actionListDisplayMode, actionlistDisplayMode: actionListDisplayMode,
initialPinLength: pinLength, initialPinLength: pinLength,
initialLanguageCode: savedLanguageCode initialLanguageCode: savedLanguageCode);
);
} }
Future<void> _saveCurrentNode(Node node, WalletType walletType) async { Future<void> _saveCurrentNode(Node node, WalletType walletType) async {

View file

@ -527,6 +527,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: