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) {
@ -75,305 +78,334 @@ class ExchangePage extends BasePage {
); );
final depositWalletName = final depositWalletName =
exchangeViewModel.depositCurrency == CryptoCurrency.xmr exchangeViewModel.depositCurrency == CryptoCurrency.xmr
? exchangeViewModel.wallet.name ? exchangeViewModel.wallet.name
: null; : null;
final receiveWalletName = final receiveWalletName =
exchangeViewModel.receiveCurrency == CryptoCurrency.xmr exchangeViewModel.receiveCurrency == CryptoCurrency.xmr
? exchangeViewModel.wallet.name ? exchangeViewModel.wallet.name
: null; : null;
WidgetsBinding.instance WidgetsBinding.instance
.addPostFrameCallback((_) => _setReactions(context, exchangeViewModel)); .addPostFrameCallback((_) => _setReactions(context, exchangeViewModel));
return Container( return KeyboardActions(
color: Theme.of(context).backgroundColor, config: KeyboardActionsConfig(
child: Form( keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
key: _formKey, keyboardBarColor: isDarkTheme
child: ScrollableWithBottomSection( ? Color.fromRGBO(48, 51, 60, 1.0)
contentPadding: EdgeInsets.only(bottom: 24), : Color.fromRGBO(98, 98, 98, 1.0),
content: Column( nextFocus: false,
children: <Widget>[ actions: [
Container( KeyboardActionsItem(
padding: EdgeInsets.only(bottom: 32), focusNode: _depositAmountFocus,
decoration: BoxDecoration( toolbarButtons: [(_) => KeyboardDoneButton()]),
borderRadius: BorderRadius.only( KeyboardActionsItem(
bottomLeft: Radius.circular(24), focusNode: _receiveAmountFocus,
bottomRight: Radius.circular(24) toolbarButtons: [(_) => KeyboardDoneButton()])
), ]),
gradient: LinearGradient( child: Container(
colors: [ height: 1,
Theme.of(context).primaryTextTheme.body1.color, color: Theme.of(context).backgroundColor,
Theme.of(context).primaryTextTheme.body1.decorationColor, child: Form(
], key: _formKey,
stops: [0.35, 1.0], child: ScrollableWithBottomSection(
begin: Alignment.topLeft, contentPadding: EdgeInsets.only(bottom: 24),
end: Alignment.bottomRight), content: Column(
), children: <Widget>[
child: Column( Container(
children: <Widget>[ padding: EdgeInsets.only(bottom: 32),
Container( 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(
), colors: [
gradient: LinearGradient( Theme.of(context).primaryTextTheme.body1.color,
colors: [ Theme.of(context)
Theme.of(context)
.primaryTextTheme
.subtitle
.color,
Theme.of(context)
.primaryTextTheme
.subtitle
.decorationColor,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight),
),
padding: EdgeInsets.fromLTRB(24, 90, 24, 32),
child: Observer(
builder: (_) => ExchangeCard(
key: depositKey,
title: S.of(context).you_will_send,
initialCurrency:
exchangeViewModel.depositCurrency,
initialWalletName: depositWalletName,
initialAddress: exchangeViewModel
.depositCurrency ==
exchangeViewModel.wallet.currency
? exchangeViewModel.wallet.address
: exchangeViewModel.depositAddress,
initialIsAmountEditable: true,
initialIsAddressEditable: exchangeViewModel
.isDepositAddressEnabled,
isAmountEstimated: false,
currencies: CryptoCurrency.all,
onCurrencySelected: (currency) =>
exchangeViewModel.changeDepositCurrency(
currency: currency),
imageArrow: arrowBottomPurple,
currencyButtonColor: Colors.transparent,
addressButtonsColor:
Theme.of(context).focusColor,
borderColor: Theme.of(context)
.primaryTextTheme
.body2
.color,
currencyValueValidator: AmountValidator(
type: exchangeViewModel.wallet.type),
addressTextFieldValidator: AddressValidator(
type:
exchangeViewModel.depositCurrency),
),
),
),
Padding(
padding: EdgeInsets.only(top: 29, left: 24, right: 24),
child: Observer(
builder: (_) => ExchangeCard(
key: receiveKey,
title: S.of(context).you_will_get,
initialCurrency:
exchangeViewModel.receiveCurrency,
initialWalletName: receiveWalletName,
initialAddress:
exchangeViewModel.receiveCurrency ==
exchangeViewModel.wallet.currency
? exchangeViewModel.wallet.address
: exchangeViewModel.receiveAddress,
initialIsAmountEditable: exchangeViewModel.provider is XMRTOExchangeProvider ? true : false,
initialIsAddressEditable:
exchangeViewModel.isReceiveAddressEnabled,
isAmountEstimated: true,
currencies: CryptoCurrency.all,
onCurrencySelected: (currency) =>
exchangeViewModel.changeReceiveCurrency(
currency: currency),
imageArrow: arrowBottomCakeGreen,
currencyButtonColor: Colors.transparent,
addressButtonsColor:
Theme.of(context).focusColor,
borderColor: Theme.of(context)
.primaryTextTheme .primaryTextTheme
.body2 .body1
.decorationColor, .decorationColor,
currencyValueValidator: AmountValidator( ],
type: exchangeViewModel.wallet.type), stops: [
addressTextFieldValidator: AddressValidator( 0.35,
type: exchangeViewModel.receiveCurrency), 1.0
)), ],
) begin: Alignment.topLeft,
], end: Alignment.bottomRight),
), ),
), child: Column(
Padding( children: <Widget>[
padding: EdgeInsets.only(top: 30, left: 24, bottom: 24), Container(
child: Row( decoration: BoxDecoration(
mainAxisAlignment: MainAxisAlignment.start, borderRadius: BorderRadius.only(
children: <Widget>[ bottomLeft: Radius.circular(24),
Text( bottomRight: Radius.circular(24)),
S.of(context).send_templates, gradient: LinearGradient(
style: TextStyle( colors: [
fontSize: 18, Theme.of(context)
fontWeight: FontWeight.w600,
color: Theme.of(context)
.primaryTextTheme
.display4
.color),
)
],
),
),
Container(
height: 40,
width: double.infinity,
padding: EdgeInsets.only(left: 24),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: <Widget>[
GestureDetector(
onTap: () => Navigator.of(context)
.pushNamed(Routes.exchangeTemplate),
child: Container(
padding: EdgeInsets.only(left: 1, right: 10),
child: DottedBorder(
borderType: BorderType.RRect,
dashPattern: [6, 4],
color: Theme.of(context)
.primaryTextTheme .primaryTextTheme
.display2 .subtitle
.color,
Theme.of(context)
.primaryTextTheme
.subtitle
.decorationColor, .decorationColor,
strokeWidth: 2, ],
radius: Radius.circular(20), begin: Alignment.topLeft,
child: Container( end: Alignment.bottomRight),
height: 34, ),
width: 75, padding: EdgeInsets.fromLTRB(24, 100, 24, 32),
padding: EdgeInsets.only( child: Observer(
left: 10, right: 10), builder: (_) => ExchangeCard(
alignment: Alignment.center, amountFocusNode: _depositAmountFocus,
decoration: BoxDecoration( key: depositKey,
borderRadius: BorderRadius.all( title: S.of(context).you_will_send,
Radius.circular(20)), initialCurrency:
color: Colors.transparent, exchangeViewModel.depositCurrency,
), initialWalletName: depositWalletName,
child: Text( initialAddress:
S.of(context).send_new, exchangeViewModel.depositCurrency ==
style: TextStyle( exchangeViewModel.wallet.currency
fontSize: 14, ? exchangeViewModel.wallet.address
fontWeight: FontWeight.w600, : exchangeViewModel.depositAddress,
color: Theme.of(context) initialIsAmountEditable: true,
.primaryTextTheme initialIsAddressEditable:
.display3 exchangeViewModel.isDepositAddressEnabled,
.color), isAmountEstimated: false,
), currencies: CryptoCurrency.all,
)), onCurrencySelected: (currency) =>
exchangeViewModel.changeDepositCurrency(
currency: currency),
imageArrow: arrowBottomPurple,
currencyButtonColor: Colors.transparent,
addressButtonsColor:
Theme.of(context).focusColor,
borderColor: Theme.of(context)
.primaryTextTheme
.body2
.color,
currencyValueValidator: AmountValidator(
type: exchangeViewModel.wallet.type),
addressTextFieldValidator: AddressValidator(
type: exchangeViewModel.depositCurrency),
), ),
), ),
Observer(builder: (_) { ),
final templates = exchangeViewModel.templates; Padding(
final itemCount = padding:
exchangeViewModel.templates.length; EdgeInsets.only(top: 29, left: 24, right: 24),
child: Observer(
return ListView.builder( builder: (_) => ExchangeCard(
scrollDirection: Axis.horizontal, amountFocusNode: _receiveAmountFocus,
shrinkWrap: true, key: receiveKey,
physics: NeverScrollableScrollPhysics(), title: S.of(context).you_will_get,
itemCount: itemCount, initialCurrency:
itemBuilder: (context, index) { exchangeViewModel.receiveCurrency,
final template = templates[index]; initialWalletName: receiveWalletName,
initialAddress: exchangeViewModel
return TemplateTile( .receiveCurrency ==
key: UniqueKey(), exchangeViewModel.wallet.currency
amount: template.amount, ? exchangeViewModel.wallet.address
from: template.depositCurrency, : exchangeViewModel.receiveAddress,
to: template.receiveCurrency, initialIsAmountEditable: false,
onTap: () { initialIsAddressEditable:
applyTemplate( exchangeViewModel
exchangeViewModel, template); .isReceiveAddressEnabled,
}, isAmountEstimated: true,
onRemove: () { currencies: CryptoCurrency.all,
showPopUp<void>( onCurrencySelected: (currency) =>
context: context, exchangeViewModel
builder: (dialogContext) { .changeReceiveCurrency(
return AlertWithTwoActions( currency: currency),
alertTitle: imageArrow: arrowBottomCakeGreen,
S.of(context).template, currencyButtonColor: Colors.transparent,
alertContent: S addressButtonsColor:
.of(context) Theme.of(context).focusColor,
.confirm_delete_template, borderColor: Theme.of(context)
leftButtonText: .primaryTextTheme
S.of(context).delete, .body2
rightButtonText: .decorationColor,
S.of(context).cancel, currencyValueValidator: AmountValidator(
actionLeftButton: () { type: exchangeViewModel.wallet.type),
Navigator.of( addressTextFieldValidator:
dialogContext) AddressValidator(
.pop(); type: exchangeViewModel
exchangeViewModel .receiveCurrency),
.exchangeTemplateStore )),
.remove( )
template: ],
template); ),
exchangeViewModel
.exchangeTemplateStore
.update();
},
actionRightButton: () =>
Navigator.of(
dialogContext)
.pop());
});
},
);
});
}),
],
)))
],
),
bottomSectionPadding:
EdgeInsets.only(left: 24, right: 24, bottom: 24),
bottomSection: Column(children: <Widget>[
Padding(
padding: EdgeInsets.only(bottom: 15),
child: Observer(builder: (_) {
final description =
exchangeViewModel.provider is XMRTOExchangeProvider
? S.of(context).amount_is_guaranteed
: S.of(context).amount_is_estimate;
return Center(
child: Text(
description,
style: TextStyle(
color: Theme.of(context)
.primaryTextTheme
.display4
.decorationColor,
fontWeight: FontWeight.w500,
fontSize: 12),
), ),
); Padding(
}), padding: EdgeInsets.only(top: 30, left: 24, bottom: 24),
), child: Row(
Observer( mainAxisAlignment: MainAxisAlignment.start,
builder: (_) => LoadingPrimaryButton( children: <Widget>[
text: S.of(context).exchange, Text(
onPressed: () { S.of(context).send_templates,
if (_formKey.currentState.validate()) { style: TextStyle(
exchangeViewModel.createTrade(); fontSize: 18,
} fontWeight: FontWeight.w600,
}, color: Theme.of(context)
color: Theme.of(context).accentTextTheme.body2.color, .primaryTextTheme
textColor: Colors.white, .display4
isLoading: .color),
false, // FIXME: FIXME exchangeViewModel.tradeState is TradeIsCreating, )
)), ],
]), ),
)), ),
); Container(
height: 40,
width: double.infinity,
padding: EdgeInsets.only(left: 24),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: <Widget>[
GestureDetector(
onTap: () => Navigator.of(context)
.pushNamed(Routes.exchangeTemplate),
child: Container(
padding:
EdgeInsets.only(left: 1, right: 10),
child: DottedBorder(
borderType: BorderType.RRect,
dashPattern: [6, 4],
color: Theme.of(context)
.primaryTextTheme
.display2
.decorationColor,
strokeWidth: 2,
radius: Radius.circular(20),
child: Container(
height: 34,
width: 75,
padding: EdgeInsets.only(
left: 10, right: 10),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(20)),
color: Colors.transparent,
),
child: Text(
S.of(context).send_new,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: Theme.of(context)
.primaryTextTheme
.display3
.color),
),
)),
),
),
Observer(builder: (_) {
final templates = exchangeViewModel.templates;
final itemCount =
exchangeViewModel.templates.length;
return ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: itemCount,
itemBuilder: (context, index) {
final template = templates[index];
return TemplateTile(
key: UniqueKey(),
amount: template.amount,
from: template.depositCurrency,
to: template.receiveCurrency,
onTap: () {
applyTemplate(
exchangeViewModel, template);
},
onRemove: () {
showPopUp<void>(
context: context,
builder: (dialogContext) {
return AlertWithTwoActions(
alertTitle: S
.of(context)
.template,
alertContent: S
.of(context)
.confirm_delete_template,
leftButtonText:
S.of(context).delete,
rightButtonText:
S.of(context).cancel,
actionLeftButton: () {
Navigator.of(
dialogContext)
.pop();
exchangeViewModel
.exchangeTemplateStore
.remove(
template:
template);
exchangeViewModel
.exchangeTemplateStore
.update();
},
actionRightButton: () =>
Navigator.of(
dialogContext)
.pop());
});
},
);
});
}),
],
)))
],
),
bottomSectionPadding:
EdgeInsets.only(left: 24, right: 24, bottom: 24),
bottomSection: Column(children: <Widget>[
Padding(
padding: EdgeInsets.only(bottom: 15),
child: Observer(builder: (_) {
final description =
exchangeViewModel.provider is XMRTOExchangeProvider
? S.of(context).amount_is_guaranteed
: S.of(context).amount_is_estimate;
return Center(
child: Text(
description,
style: TextStyle(
color: Theme.of(context)
.primaryTextTheme
.display4
.decorationColor,
fontWeight: FontWeight.w500,
fontSize: 12),
),
);
}),
),
Observer(
builder: (_) => LoadingPrimaryButton(
text: S.of(context).exchange,
onPressed: () {
if (_formKey.currentState.validate()) {
exchangeViewModel.createTrade();
}
},
color:
Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white,
isLoading: exchangeViewModel.tradeState
is IsExecutingState,
)),
]),
)),
));
} }
void applyTemplate( void applyTemplate(
@ -436,23 +468,23 @@ class ExchangePage extends BasePage {
exchangeViewModel.depositCurrency, exchangeViewModel, depositKey); exchangeViewModel.depositCurrency, exchangeViewModel, depositKey);
reaction( reaction(
(_) => exchangeViewModel.wallet.name, (_) => exchangeViewModel.wallet.name,
(String _) => _onWalletNameChange( (String _) => _onWalletNameChange(
exchangeViewModel, exchangeViewModel.receiveCurrency, receiveKey)); exchangeViewModel, exchangeViewModel.receiveCurrency, receiveKey));
reaction( reaction(
(_) => exchangeViewModel.wallet.name, (_) => exchangeViewModel.wallet.name,
(String _) => _onWalletNameChange( (String _) => _onWalletNameChange(
exchangeViewModel, exchangeViewModel.depositCurrency, depositKey)); exchangeViewModel, exchangeViewModel.depositCurrency, depositKey));
reaction( reaction(
(_) => exchangeViewModel.receiveCurrency, (_) => exchangeViewModel.receiveCurrency,
(CryptoCurrency currency) => (CryptoCurrency currency) =>
_onCurrencyChange(currency, exchangeViewModel, receiveKey)); _onCurrencyChange(currency, exchangeViewModel, receiveKey));
reaction( reaction(
(_) => exchangeViewModel.depositCurrency, (_) => exchangeViewModel.depositCurrency,
(CryptoCurrency currency) => (CryptoCurrency currency) =>
_onCurrencyChange(currency, exchangeViewModel, depositKey)); _onCurrencyChange(currency, exchangeViewModel, depositKey));
reaction((_) => exchangeViewModel.depositAmount, (String amount) { reaction((_) => exchangeViewModel.depositAmount, (String amount) {
@ -468,9 +500,9 @@ class ExchangePage extends BasePage {
}); });
reaction((_) => exchangeViewModel.isDepositAddressEnabled, reaction((_) => exchangeViewModel.isDepositAddressEnabled,
(bool isEnabled) { (bool isEnabled) {
depositKey.currentState.isAddressEditable(isEditable: isEnabled); depositKey.currentState.isAddressEditable(isEditable: isEnabled);
}); });
reaction((_) => exchangeViewModel.receiveAmount, (String amount) { reaction((_) => exchangeViewModel.receiveAmount, (String amount) {
if (receiveKey.currentState.amountController.text != amount) { if (receiveKey.currentState.amountController.text != amount) {
@ -485,9 +517,9 @@ class ExchangePage extends BasePage {
}); });
reaction((_) => exchangeViewModel.isReceiveAddressEnabled, reaction((_) => exchangeViewModel.isReceiveAddressEnabled,
(bool isEnabled) { (bool isEnabled) {
receiveKey.currentState.isAddressEditable(isEditable: isEnabled); receiveKey.currentState.isAddressEditable(isEditable: isEnabled);
}); });
reaction((_) => exchangeViewModel.provider, (ExchangeProvider provider) { reaction((_) => exchangeViewModel.provider, (ExchangeProvider provider) {
provider is XMRTOExchangeProvider provider is XMRTOExchangeProvider
@ -542,7 +574,7 @@ class ExchangePage extends BasePage {
// }); // });
depositAddressController.addListener( depositAddressController.addListener(
() => exchangeViewModel.depositAddress = depositAddressController.text); () => exchangeViewModel.depositAddress = depositAddressController.text);
depositAmountController.addListener(() { depositAmountController.addListener(() {
if (depositAmountController.text != exchangeViewModel.depositAmount) { if (depositAmountController.text != exchangeViewModel.depositAmount) {
@ -553,7 +585,7 @@ class ExchangePage extends BasePage {
}); });
receiveAddressController.addListener( receiveAddressController.addListener(
() => exchangeViewModel.receiveAddress = receiveAddressController.text); () => exchangeViewModel.receiveAddress = receiveAddressController.text);
receiveAmountController.addListener(() { receiveAmountController.addListener(() {
if (receiveAmountController.text != exchangeViewModel.receiveAmount) { if (receiveAmountController.text != exchangeViewModel.receiveAmount) {

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,191 +116,191 @@ 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>[
Text( Text(
_title, _title,
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),
),
) )
], ],
), ),
Padding( Padding(
padding: EdgeInsets.only(top: 20), padding: EdgeInsets.only(top: 20),
child: Stack( child: Stack(
children: <Widget>[ children: <Widget>[
BaseTextFormField( BaseTextFormField(
controller: amountController, focusNode: widget.amountFocusNode,
enabled: _isAmountEditable, controller: amountController,
textAlign: TextAlign.left, enabled: _isAmountEditable,
keyboardType: TextInputType.numberWithOptions( textAlign: TextAlign.left,
signed: false, decimal: true), keyboardType: TextInputType.numberWithOptions(
// inputFormatters: [ signed: false, decimal: true),
// LengthLimitingTextInputFormatter(15), // inputFormatters: [
// BlacklistingTextInputFormatter( // LengthLimitingTextInputFormatter(15),
// RegExp('[\\-|\\ |\\,]')) // BlacklistingTextInputFormatter(
// ], // RegExp('[\\-|\\ |\\,]'))
hintText: '0.0000', // ],
borderColor: widget.borderColor, hintText: '0.0000',
textStyle: TextStyle( borderColor: widget.borderColor,
fontSize: 16, textStyle: TextStyle(
fontWeight: FontWeight.w600, fontSize: 16,
color: Colors.white fontWeight: FontWeight.w600,
color: Colors.white),
placeholderTextStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Theme.of(context)
.textTheme
.subhead
.decorationColor),
validator: _isAmountEditable
? widget.currencyValueValidator
: null),
Positioned(
top: 8,
right: 0,
child: Container(
height: 32,
padding: EdgeInsets.only(left: 10),
color: widget.currencyButtonColor,
child: InkWell(
onTap: () => _presentPicker(context),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(_selectedCurrency.toString(),
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
color: Colors.white)),
Padding(
padding: EdgeInsets.only(left: 5),
child: widget.imageArrow,
)
]),
),
), ),
placeholderTextStyle: TextStyle( )
fontSize: 16, ],
fontWeight: FontWeight.w600, )),
color: Theme.of(context).textTheme.subhead.decorationColor
),
validator: _isAmountEditable
? widget.currencyValueValidator
: null
),
Positioned(
top: 8,
right: 0,
child: Container(
height: 32,
padding: EdgeInsets.only(left: 10),
color: widget.currencyButtonColor,
child: InkWell(
onTap: () => _presentPicker(context),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
_selectedCurrency.toString(),
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
color: Colors.white)),
Padding(
padding: EdgeInsets.only(left: 5),
child: widget.imageArrow,
)
]),
),
),
)
],
)
),
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(
fontSize: 10,
height: 1.2,
color: Theme.of(context).textTheme.subhead.decorationColor),
)
: Offstage(),
_min != null ? SizedBox(width: 10) : Offstage(),
_max != null
? Text(
S.of(context).max_value(
_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(),
]), _min != null ? SizedBox(width: 10) : Offstage(),
_max != null
? Text(
S.of(context).max_value(_max, _selectedCurrency.toString()),
style: TextStyle(
fontSize: 10,
height: 1.2,
color: Theme.of(context)
.textTheme
.subhead
.decorationColor))
: Offstage(),
]),
), ),
_isAddressEditable _isAddressEditable
? Offstage() ? Offstage()
: Padding( : Padding(
padding: EdgeInsets.only(top: 20), padding: EdgeInsets.only(top: 20),
child: Text( child: Text(
S.of(context).refund_address, S.of(context).refund_address,
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),
child: AddressTextField( child: AddressTextField(
controller: addressController, controller: addressController,
options: [ options: [
AddressTextFieldOption.paste, AddressTextFieldOption.paste,
AddressTextFieldOption.qrCode, AddressTextFieldOption.qrCode,
AddressTextFieldOption.addressBook, AddressTextFieldOption.addressBook,
],
isBorderExist: false,
textStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.white),
hintStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Theme.of(context).textTheme.subhead.decorationColor),
buttonColor: widget.addressButtonsColor,
validator: widget.addressTextFieldValidator,
),
)
: Padding(
padding: EdgeInsets.only(top: 10),
child: Builder(
builder: (context) => GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(
text: addressController.text));
Scaffold.of(context).showSnackBar(SnackBar(
content: Text(
S.of(context).copied_to_clipboard,
style: TextStyle(color: Colors.white),
),
backgroundColor: Colors.green,
duration: Duration(milliseconds: 500),
));
},
child: Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
child: Text(
addressController.text,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.white),
),
),
Padding(
padding: EdgeInsets.only(left: 16),
child: copyImage,
)
], ],
isBorderExist: false,
textStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.white),
hintStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color:
Theme.of(context).textTheme.subhead.decorationColor),
buttonColor: widget.addressButtonsColor,
validator: widget.addressTextFieldValidator,
), ),
) )
), : Padding(
), padding: EdgeInsets.only(top: 10),
child: Builder(
builder: (context) => GestureDetector(
onTap: () {
Clipboard.setData(
ClipboardData(text: addressController.text));
Scaffold.of(context).showSnackBar(SnackBar(
content: Text(
S.of(context).copied_to_clipboard,
style: TextStyle(color: Colors.white),
),
backgroundColor: Colors.green,
duration: Duration(milliseconds: 500),
));
},
child: Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
child: Text(
addressController.text,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.white),
),
),
Padding(
padding: EdgeInsets.only(left: 16),
child: copyImage,
)
],
),
)),
),
]), ]),
); );
} }
@ -310,9 +312,9 @@ class ExchangeCardState extends State<ExchangeCard> {
items: widget.currencies, items: widget.currencies,
title: S.of(context).change_currency, title: S.of(context).change_currency,
onItemSelected: (CryptoCurrency item) => onItemSelected: (CryptoCurrency item) =>
widget.onCurrencySelected != null widget.onCurrencySelected != null
? widget.onCurrencySelected(item) ? widget.onCurrencySelected(item)
: null), : null),
context: context); context: context);
} }
} }

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: [
BlockchainHeightWidget(key: _blockchainHeightWidgetKey), Column(
children: <Widget>[
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,180 +58,75 @@ class SendPage 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: Column( ? Color.fromRGBO(48, 51, 60, 1.0)
children: <Widget>[ : Color.fromRGBO(98, 98, 98, 1.0),
Container( nextFocus: false,
decoration: BoxDecoration( actions: [
borderRadius: BorderRadius.only( KeyboardActionsItem(
bottomLeft: Radius.circular(24), focusNode: _cryptoAmountFocus,
bottomRight: Radius.circular(24)), toolbarButtons: [(_) => KeyboardDoneButton()],
gradient: LinearGradient(colors: [ ),
Theme.of(context).primaryTextTheme.subhead.color, KeyboardActionsItem(
Theme.of(context).primaryTextTheme.subhead.decorationColor, focusNode: _fiatAmountFocus,
], begin: Alignment.topLeft, end: Alignment.bottomRight), toolbarButtons: [(_) => KeyboardDoneButton()],
), )
child: Form( ]),
key: _formKey, child: Container(
child: Column(children: <Widget>[ height: 0,
Padding( color: Theme.of(context).backgroundColor,
padding: EdgeInsets.fromLTRB(24, 90, 24, 32), child: ScrollableWithBottomSection(
child: Column( contentPadding: EdgeInsets.only(bottom: 24),
children: <Widget>[ content: Column(
AddressTextField( children: <Widget>[
controller: _addressController, Container(
focusNode: _focusNode, decoration: BoxDecoration(
onURIScanned: (uri) { borderRadius: BorderRadius.only(
var address = ''; bottomLeft: Radius.circular(24),
var amount = ''; bottomRight: Radius.circular(24)),
gradient: LinearGradient(colors: [
Theme.of(context).primaryTextTheme.subhead.color,
Theme.of(context)
.primaryTextTheme
.subhead
.decorationColor,
], begin: Alignment.topLeft, end: Alignment.bottomRight),
),
child: Form(
key: _formKey,
child: Column(children: <Widget>[
Padding(
padding: EdgeInsets.fromLTRB(24, 100, 24, 32),
child: Column(
children: <Widget>[
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: Theme.of(context) buttonColor: Theme.of(context)
.primaryTextTheme
.display1
.color,
borderColor: Theme.of(context)
.primaryTextTheme
.headline
.color,
textStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.white),
hintStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.primaryTextTheme .primaryTextTheme
.headline .display1
.decorationColor), .color,
validator: sendViewModel.addressValidator,
),
Padding(
padding: const EdgeInsets.only(top: 20),
child: BaseTextFormField(
controller: _cryptoAmountController,
keyboardType: TextInputType.numberWithOptions(
signed: false, decimal: true),
prefixIcon: Padding(
padding: EdgeInsets.only(top: 9),
child:
Text(sendViewModel.currency.title + ':',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.white,
)),
),
suffixIcon: Container(
height: 32,
width: 32,
margin: EdgeInsets.only(
left: 14, top: 4, bottom: 10),
decoration: BoxDecoration(
color: Theme.of(context)
.primaryTextTheme
.display1
.color,
borderRadius: BorderRadius.all(
Radius.circular(6))),
child: InkWell(
onTap: () => sendViewModel.setSendAll(),
child: Center(
child: Text(S.of(context).all,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Theme.of(context)
.primaryTextTheme
.display1
.decorationColor)),
),
),
),
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)),
Observer(
builder: (_) => Padding(
padding: EdgeInsets.only(top: 10),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: Text(
S.of(context).available_balance + ':',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Theme.of(context)
.primaryTextTheme
.headline
.decorationColor),
)),
Text(
sendViewModel.balance,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Theme.of(context)
.primaryTextTheme
.headline
.decorationColor),
)
],
),
)),
Padding(
padding: const EdgeInsets.only(top: 20),
child: BaseTextFormField(
controller: _fiatAmountController,
keyboardType: TextInputType.numberWithOptions(
signed: false, decimal: true),
prefixIcon: Padding(
padding: EdgeInsets.only(top: 9),
child: Text(sendViewModel.fiat.title + ':',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.white,
)),
),
hintText: '0.00',
borderColor: Theme.of(context) borderColor: Theme.of(context)
.primaryTextTheme .primaryTextTheme
.headline .headline
@ -244,200 +135,342 @@ class SendPage extends BasePage {
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: Colors.white), color: Colors.white),
placeholderTextStyle: TextStyle( hintStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Theme.of(context) color: Theme.of(context)
.primaryTextTheme .primaryTextTheme
.headline .headline
.decorationColor, .decorationColor),
fontWeight: FontWeight.w500, validator: sendViewModel.addressValidator,
fontSize: 14), ),
)), Padding(
Observer( padding: const EdgeInsets.only(top: 20),
builder: (_) => GestureDetector( child: BaseTextFormField(
onTap: () => focusNode: _cryptoAmountFocus,
_setTransactionPriority(context), controller: _cryptoAmountController,
child: Container( keyboardType:
padding: EdgeInsets.only(top: 24), TextInputType.numberWithOptions(
child: Row( signed: false, decimal: true),
mainAxisAlignment: prefixIcon: Padding(
MainAxisAlignment.spaceBetween, padding: EdgeInsets.only(top: 9),
children: <Widget>[ child: Text(
Text(S.of(context).send_estimated_fee, sendViewModel.currency.title + ':',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.white,
)),
),
suffixIcon: Container(
height: 32,
width: 32,
margin: EdgeInsets.only(
left: 14, top: 4, bottom: 10),
decoration: BoxDecoration(
color: Theme.of(context)
.primaryTextTheme
.display1
.color,
borderRadius: BorderRadius.all(
Radius.circular(6))),
child: InkWell(
onTap: () =>
sendViewModel.setSendAll(),
child: Center(
child: Text(S.of(context).all,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Theme.of(context)
.primaryTextTheme
.display1
.decorationColor)),
),
),
),
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)),
Observer(
builder: (_) => Padding(
padding: EdgeInsets.only(top: 10),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: Text(
S.of(context).available_balance +
':',
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w600,
//color: Theme.of(context).primaryTextTheme.display2.color, color: Theme.of(context)
color: Colors.white)), .primaryTextTheme
Container( .headline
child: Row( .decorationColor),
children: <Widget>[ )),
Text( Text(
sendViewModel.estimatedFee sendViewModel.balance,
.toString() + style: TextStyle(
' ' + fontSize: 12,
sendViewModel fontWeight: FontWeight.w600,
.currency.title, color: Theme.of(context)
style: TextStyle( .primaryTextTheme
fontSize: 12, .headline
fontWeight: .decorationColor),
FontWeight.w600, )
//color: Theme.of(context).primaryTextTheme.display2.color, ],
color: Colors.white)), ),
Padding( )),
padding: Padding(
EdgeInsets.only(left: 5), padding: const EdgeInsets.only(top: 20),
child: Icon( child: BaseTextFormField(
Icons.arrow_forward_ios, focusNode: _fiatAmountFocus,
size: 12, controller: _fiatAmountController,
color: Colors.white, keyboardType:
), TextInputType.numberWithOptions(
) signed: false, decimal: true),
], prefixIcon: Padding(
), padding: EdgeInsets.only(top: 9),
) child:
], Text(sendViewModel.fiat.title + ':',
), style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.white,
)),
), ),
)) hintText: '0.00',
], borderColor: Theme.of(context)
), .primaryTextTheme
) .headline
]), .color,
), textStyle: TextStyle(
), fontSize: 14,
Padding( fontWeight: FontWeight.w500,
padding: EdgeInsets.only(top: 30, left: 24, bottom: 24), color: Colors.white),
child: Row( placeholderTextStyle: TextStyle(
mainAxisAlignment: MainAxisAlignment.start, color: Theme.of(context)
children: <Widget>[ .primaryTextTheme
Text( .headline
S.of(context).send_templates, .decorationColor,
style: TextStyle( fontWeight: FontWeight.w500,
fontSize: 18, fontSize: 14),
fontWeight: FontWeight.w600, )),
color: Theme.of(context) Observer(
.primaryTextTheme builder: (_) => GestureDetector(
.display4 onTap: () =>
.color), _setTransactionPriority(context),
) child: Container(
], padding: EdgeInsets.only(top: 24),
), child: Row(
), mainAxisAlignment:
Container( MainAxisAlignment.spaceBetween,
height: 40, children: <Widget>[
width: double.infinity, Text(
padding: EdgeInsets.only(left: 24), S
child: SingleChildScrollView( .of(context)
scrollDirection: Axis.horizontal, .send_estimated_fee,
child: Row( style: TextStyle(
children: <Widget>[ fontSize: 12,
GestureDetector( fontWeight:
onTap: () => Navigator.of(context) FontWeight.w500,
.pushNamed(Routes.sendTemplate), //color: Theme.of(context).primaryTextTheme.display2.color,
child: Container( color: Colors.white)),
padding: EdgeInsets.only(left: 1, right: 10), Container(
child: DottedBorder( child: Row(
borderType: BorderType.RRect, children: <Widget>[
dashPattern: [6, 4], Text(
sendViewModel
.estimatedFee
.toString() +
' ' +
sendViewModel
.currency.title,
style: TextStyle(
fontSize: 12,
fontWeight:
FontWeight.w600,
//color: Theme.of(context).primaryTextTheme.display2.color,
color:
Colors.white)),
Padding(
padding: EdgeInsets.only(
left: 5),
child: Icon(
Icons.arrow_forward_ios,
size: 12,
color: Colors.white,
),
)
],
),
)
],
),
),
))
],
),
)
]),
),
),
Padding(
padding: EdgeInsets.only(top: 30, left: 24, bottom: 24),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text(
S.of(context).send_templates,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Theme.of(context) color: Theme.of(context)
.primaryTextTheme .primaryTextTheme
.display2 .display4
.decorationColor, .color),
strokeWidth: 2, )
radius: Radius.circular(20), ],
child: Container( ),
height: 34,
width: 75,
padding: EdgeInsets.only(left: 10, right: 10),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(20)),
color: Colors.transparent,
),
child: Text(
S.of(context).send_new,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: Theme.of(context)
.primaryTextTheme
.display3
.color),
),
)),
),
),
// Observer(
// builder: (_) {
// final templates = sendViewModel.templates;
// final itemCount = templates.length;
// return ListView.builder(
// scrollDirection: Axis.horizontal,
// shrinkWrap: true,
// physics: NeverScrollableScrollPhysics(),
// itemCount: itemCount,
// itemBuilder: (context, index) {
// final template = templates[index];
// return TemplateTile(
// key: UniqueKey(),
// to: template.name,
// amount: template.amount,
// from: template.cryptoCurrency,
// onTap: () {
// _addressController.text = template.address;
// _cryptoAmountController.text = template.amount;
// getOpenaliasRecord(context);
// },
// onRemove: () {
// showPopUp<void>(
// context: context,
// builder: (dialogContext) {
// return AlertWithTwoActions(
// alertTitle: S.of(context).template,
// alertContent: S.of(context).confirm_delete_template,
// leftButtonText: S.of(context).delete,
// rightButtonText: S.of(context).cancel,
// actionLeftButton: () {
// Navigator.of(dialogContext).pop();
// sendViewModel.sendTemplateStore.remove(template: template);
// sendViewModel.sendTemplateStore.update();
// },
// actionRightButton: () => Navigator.of(dialogContext).pop()
// );
// }
// );
// },
// );
// }
// );
// }
// )
],
), ),
), Container(
) height: 40,
], width: double.infinity,
), padding: EdgeInsets.only(left: 24),
bottomSectionPadding: child: SingleChildScrollView(
EdgeInsets.only(left: 24, right: 24, bottom: 24), scrollDirection: Axis.horizontal,
bottomSection: Observer(builder: (_) { child: Row(
return LoadingPrimaryButton( children: <Widget>[
onPressed: () { GestureDetector(
if (_formKey.currentState.validate()) {} onTap: () => Navigator.of(context)
}, .pushNamed(Routes.sendTemplate),
text: S.of(context).send, child: Container(
color: Theme.of(context).accentTextTheme.body2.color, padding: EdgeInsets.only(left: 1, right: 10),
textColor: Colors.white, child: DottedBorder(
isLoading: sendViewModel.state is IsExecutingState || borderType: BorderType.RRect,
sendViewModel.state is TransactionCommitting, dashPattern: [6, 4],
isDisabled: color: Theme.of(context)
false // FIXME !(syncStore.status is SyncedSyncStatus), .primaryTextTheme
); .display2
})), .decorationColor,
); strokeWidth: 2,
radius: Radius.circular(20),
child: Container(
height: 34,
width: 75,
padding:
EdgeInsets.only(left: 10, right: 10),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(20)),
color: Colors.transparent,
),
child: Text(
S.of(context).send_new,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: Theme.of(context)
.primaryTextTheme
.display3
.color),
),
)),
),
),
// Observer(
// builder: (_) {
// final templates = sendViewModel.templates;
// final itemCount = templates.length;
// return ListView.builder(
// scrollDirection: Axis.horizontal,
// shrinkWrap: true,
// physics: NeverScrollableScrollPhysics(),
// itemCount: itemCount,
// itemBuilder: (context, index) {
// final template = templates[index];
// return TemplateTile(
// key: UniqueKey(),
// to: template.name,
// amount: template.amount,
// from: template.cryptoCurrency,
// onTap: () {
// _addressController.text = template.address;
// _cryptoAmountController.text = template.amount;
// getOpenaliasRecord(context);
// },
// onRemove: () {
// showPopUp<void>(
// context: context,
// builder: (dialogContext) {
// return AlertWithTwoActions(
// alertTitle: S.of(context).template,
// alertContent: S.of(context).confirm_delete_template,
// leftButtonText: S.of(context).delete,
// rightButtonText: S.of(context).cancel,
// actionLeftButton: () {
// Navigator.of(dialogContext).pop();
// sendViewModel.sendTemplateStore.remove(template: template);
// sendViewModel.sendTemplateStore.update();
// },
// actionRightButton: () => Navigator.of(dialogContext).pop()
// );
// }
// );
// },
// );
// }
// );
// }
// )
],
),
),
)
],
),
bottomSectionPadding:
EdgeInsets.only(left: 24, right: 24, bottom: 24),
bottomSection: Observer(builder: (_) {
return LoadingPrimaryButton(
onPressed: () async {
if (_formKey.currentState.validate()) {
await sendViewModel.createTransaction();
}
},
text: S.of(context).send,
color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white,
isLoading: sendViewModel.state is IsExecutingState ||
sendViewModel.state is TransactionCommitting,
isDisabled:
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,9 +83,10 @@ abstract class SettingsStoreBase with Store {
reaction((_) => currentNode, reaction((_) => currentNode,
(Node node) => _saveCurrentNode(node, WalletType.monero)); (Node node) => _saveCurrentNode(node, WalletType.monero));
reaction((_) => languageCode, reaction(
(String languageCode) => sharedPreferences.setString( (_) => languageCode,
PreferencesKey.currentLanguageCode, languageCode)); (String languageCode) => sharedPreferences.setString(
PreferencesKey.currentLanguageCode, languageCode));
} }
static const defaultPinLength = 4; static const defaultPinLength = 4;
@ -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: