mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-04 12:34:14 +01:00
Part 1
This commit is contained in:
@@ -5,20 +5,18 @@ import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/view_model/auth_state.dart';
|
||||
import 'package:cake_wallet/view_model/auth_view_model.dart';
|
||||
import 'package:cake_wallet/src/screens/pin_code/pin_code.dart';
|
||||
import 'package:cake_wallet/src/domain/common/biometric_auth.dart';
|
||||
import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart';
|
||||
import 'package:cake_wallet/entities/biometric_auth.dart';
|
||||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
|
||||
typedef OnAuthenticationFinished = void Function(bool, AuthPageState);
|
||||
|
||||
class AuthPage extends StatefulWidget {
|
||||
AuthPage(
|
||||
{@required this.allowBiometricalAuthentication,
|
||||
this.onAuthenticationFinished,
|
||||
this.authViewModel,
|
||||
this.closable = true});
|
||||
AuthPage(this.authViewModel,
|
||||
{this.onAuthenticationFinished, this.closable = true});
|
||||
|
||||
final AuthViewModel authViewModel;
|
||||
final OnAuthenticationFinished onAuthenticationFinished;
|
||||
final bool allowBiometricalAuthentication;
|
||||
final bool closable;
|
||||
|
||||
@override
|
||||
@@ -35,8 +33,8 @@ class AuthPageState extends State<AuthPage> {
|
||||
@override
|
||||
void initState() {
|
||||
_reaction ??=
|
||||
reaction((_) => widget.authViewModel.state, (AuthState state) {
|
||||
if (state is AuthenticatedSuccessfully) {
|
||||
reaction((_) => widget.authViewModel.state, (ExecutionState state) {
|
||||
if (state is ExecutedSuccessfullyState) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (widget.onAuthenticationFinished != null) {
|
||||
widget.onAuthenticationFinished(true, this);
|
||||
@@ -51,7 +49,7 @@ class AuthPageState extends State<AuthPage> {
|
||||
});
|
||||
}
|
||||
|
||||
if (state is AuthenticationInProgress) {
|
||||
if (state is IsExecutingState) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_key.currentState.showSnackBar(
|
||||
SnackBar(
|
||||
@@ -62,7 +60,7 @@ class AuthPageState extends State<AuthPage> {
|
||||
});
|
||||
}
|
||||
|
||||
if (state is AuthenticationFailure) {
|
||||
if (state is FailureState) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_pinCodeKey.currentState.clear();
|
||||
_key.currentState.hideCurrentSnackBar();
|
||||
@@ -97,23 +95,10 @@ class AuthPageState extends State<AuthPage> {
|
||||
}
|
||||
});
|
||||
|
||||
if (widget.allowBiometricalAuthentication) {
|
||||
if (widget.authViewModel.isBiometricalAuthenticationAllowed) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
print('post');
|
||||
await Future<void>.delayed(Duration(milliseconds: 100));
|
||||
print('after timeout');
|
||||
final biometricAuth = BiometricAuth();
|
||||
final isAuth = await biometricAuth.isAuthenticated();
|
||||
|
||||
if (isAuth) {
|
||||
widget.authViewModel.biometricAuth();
|
||||
_key.currentState.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(S.of(context).authenticated),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
);
|
||||
}
|
||||
await widget.authViewModel.biometricAuth();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -133,34 +118,28 @@ class AuthPageState extends State<AuthPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('start');
|
||||
|
||||
return Scaffold(
|
||||
key: _key,
|
||||
appBar: CupertinoNavigationBar(
|
||||
leading: widget.closable
|
||||
? SizedBox(
|
||||
height: 37,
|
||||
width: 20,
|
||||
child: ButtonTheme(
|
||||
minWidth: double.minPositive,
|
||||
child: FlatButton(
|
||||
highlightColor: Colors.transparent,
|
||||
splashColor: Colors.transparent,
|
||||
padding: EdgeInsets.all(0),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: _backArrowImageDarkTheme),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
backgroundColor: Theme.of(context).backgroundColor,
|
||||
border: null,
|
||||
),
|
||||
leading: widget.closable
|
||||
? SizedBox(
|
||||
height: 37,
|
||||
width: 20,
|
||||
child: ButtonTheme(
|
||||
minWidth: double.minPositive,
|
||||
child: FlatButton(
|
||||
highlightColor: Colors.transparent,
|
||||
splashColor: Colors.transparent,
|
||||
padding: EdgeInsets.all(0),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: _backArrowImageDarkTheme),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
backgroundColor: Theme.of(context).backgroundColor,
|
||||
border: null),
|
||||
resizeToAvoidBottomPadding: false,
|
||||
body: PinCode(
|
||||
(pin, _) => widget.authViewModel
|
||||
.auth(password: pin.fold('', (ac, val) => ac + '$val')),
|
||||
false,
|
||||
_pinCodeKey));
|
||||
body: PinCode((pin, _) => widget.authViewModel.auth(password: pin),
|
||||
(_) => null, widget.authViewModel.pinLength, false, _pinCodeKey));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:cake_wallet/src/domain/services/user_service.dart';
|
||||
import 'package:cake_wallet/src/domain/services/wallet_list_service.dart';
|
||||
import 'package:cake_wallet/src/domain/services/wallet_service.dart';
|
||||
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
||||
import 'package:cake_wallet/src/stores/auth/auth_store.dart';
|
||||
import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
|
||||
|
||||
Widget createLoginPage(
|
||||
{@required SharedPreferences sharedPreferences,
|
||||
@required UserService userService,
|
||||
@required WalletService walletService,
|
||||
@required WalletListService walletListService,
|
||||
@required AuthenticationStore authenticationStore}) =>
|
||||
null;
|
||||
// Provider(
|
||||
// create: (_) => AuthStore(
|
||||
// sharedPreferences: sharedPreferences,
|
||||
// userService: userService,
|
||||
// walletService: walletService),
|
||||
// child: AuthPage(
|
||||
// onAuthenticationFinished: (isAuthenticated, state) {
|
||||
// if (isAuthenticated) {
|
||||
// authenticationStore.loggedIn();
|
||||
// }
|
||||
// },
|
||||
// closable: false));
|
||||
@@ -1,24 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:cake_wallet/src/domain/services/user_service.dart';
|
||||
import 'package:cake_wallet/src/domain/services/wallet_service.dart';
|
||||
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
||||
import 'package:cake_wallet/src/stores/auth/auth_store.dart';
|
||||
|
||||
Widget createUnlockPage(
|
||||
{@required SharedPreferences sharedPreferences,
|
||||
@required UserService userService,
|
||||
@required WalletService walletService,
|
||||
@required Function(bool, AuthPageState) onAuthenticationFinished}) =>
|
||||
null;
|
||||
// WillPopScope(
|
||||
// onWillPop: () async => false,
|
||||
// child: Provider(
|
||||
// create: (_) => AuthStore(
|
||||
// sharedPreferences: sharedPreferences,
|
||||
// userService: userService,
|
||||
// walletService: walletService),
|
||||
// child: AuthPage(
|
||||
// onAuthenticationFinished: onAuthenticationFinished,
|
||||
// closable: false)));
|
||||
@@ -94,8 +94,8 @@ abstract class BasePage extends StatelessWidget {
|
||||
leading: leading(context),
|
||||
middle: middle(context),
|
||||
trailing: trailing(context),
|
||||
backgroundColor:
|
||||
_isDarkTheme ? backgroundDarkColor : backgroundLightColor);
|
||||
backgroundColor: Colors.transparent);
|
||||
// _isDarkTheme ? backgroundDarkColor : backgroundLightColor);
|
||||
|
||||
case AppBarStyle.withShadow:
|
||||
return NavBar.withShadow(
|
||||
@@ -131,7 +131,7 @@ abstract class BasePage extends StatelessWidget {
|
||||
resizeToAvoidBottomPadding: resizeToAvoidBottomPadding,
|
||||
endDrawer: endDrawer,
|
||||
appBar: appBar(context),
|
||||
body: body(context), //SafeArea(child: ),
|
||||
body: body(context),
|
||||
floatingActionButton: floatingActionButton(context));
|
||||
|
||||
return rootWrapper?.call(context, root) ?? root;
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.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/view_model/contact_list/contact_list_view_model.dart';
|
||||
|
||||
@@ -6,9 +6,9 @@ import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/core/address_validator.dart';
|
||||
import 'package:cake_wallet/core/contact_name_validator.dart';
|
||||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
import 'package:cake_wallet/view_model/contact_list/contact_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/contact_list/contact_view_model_state.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
@@ -48,12 +48,12 @@ class ContactPage extends BasePage {
|
||||
final downArrow = Image.asset('assets/images/arrow_bottom_purple_icon.png',
|
||||
color: Theme.of(context).primaryTextTheme.overline.color, height: 8);
|
||||
|
||||
reaction((_) => contactViewModel.state, (ContactViewModelState state) {
|
||||
if (state is ContactCreationFailure) {
|
||||
reaction((_) => contactViewModel.state, (ExecutionState state) {
|
||||
if (state is FailureState) {
|
||||
_onContactSavingFailure(context, state.error);
|
||||
}
|
||||
|
||||
if (state is ContactSavingSuccessfully) {
|
||||
if (state is ExecutedSuccessfullyState) {
|
||||
_onContactSavedSuccessfully(context);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,31 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/transaction_description.dart';
|
||||
import 'package:cake_wallet/src/domain/services/wallet_service.dart';
|
||||
import 'package:cake_wallet/src/screens/dashboard/dashboard_page.dart';
|
||||
import 'package:cake_wallet/src/stores/action_list/action_list_store.dart';
|
||||
import 'package:cake_wallet/src/stores/action_list/trade_filter_store.dart';
|
||||
import 'package:cake_wallet/src/stores/action_list/transaction_filter_store.dart';
|
||||
import 'package:cake_wallet/src/stores/price/price_store.dart';
|
||||
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:cake_wallet/exchange/trade.dart';
|
||||
// import 'package:cake_wallet/monero/transaction_description.dart';
|
||||
// import 'package:cake_wallet/src/domain/services/wallet_service.dart';
|
||||
// import 'package:cake_wallet/src/screens/dashboard/dashboard_page.dart';
|
||||
// import 'package:cake_wallet/src/stores/action_list/action_list_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/action_list/trade_filter_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/action_list/transaction_filter_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/price/price_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
|
||||
Widget createDashboardPage(
|
||||
{@required WalletService walletService,
|
||||
@required PriceStore priceStore,
|
||||
@required Box<TransactionDescription> transactionDescriptions,
|
||||
@required SettingsStore settingsStore,
|
||||
@required Box<Trade> trades,
|
||||
@required WalletStore walletStore}) =>
|
||||
Provider(
|
||||
create: (_) => ActionListStore(
|
||||
walletService: walletService,
|
||||
settingsStore: settingsStore,
|
||||
priceStore: priceStore,
|
||||
tradesSource: trades,
|
||||
transactionFilterStore: TransactionFilterStore(),
|
||||
tradeFilterStore: TradeFilterStore(walletStore: walletStore),
|
||||
transactionDescriptions: transactionDescriptions),
|
||||
child: DashboardPage());
|
||||
// FIXME: Remove me.
|
||||
|
||||
// Widget createDashboardPage(
|
||||
// {@required WalletService walletService,
|
||||
// @required PriceStore priceStore,
|
||||
// @required Box<TransactionDescription> transactionDescriptions,
|
||||
// @required SettingsStore settingsStore,
|
||||
// @required Box<Trade> trades,
|
||||
// @required WalletStore walletStore}) =>
|
||||
// Provider(
|
||||
// create: (_) => ActionListStore(
|
||||
// walletService: walletService,
|
||||
// settingsStore: settingsStore,
|
||||
// priceStore: priceStore,
|
||||
// tradesSource: trades,
|
||||
// transactionFilterStore: TransactionFilterStore(),
|
||||
// tradeFilterStore: TradeFilterStore(walletStore: walletStore),
|
||||
// transactionDescriptions: transactionDescriptions),
|
||||
// child: DashboardPage());
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||
|
||||
|
||||
@@ -1,26 +1,21 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:cake_wallet/utils/date_formatter.dart';
|
||||
|
||||
class DateSectionRaw extends StatelessWidget {
|
||||
DateSectionRaw({this.date});
|
||||
|
||||
static final nowDate = DateTime.now();
|
||||
final DateTime date;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final nowDate = DateTime.now();
|
||||
final diffDays = date.difference(nowDate).inDays;
|
||||
final isToday = nowDate.day == date.day &&
|
||||
nowDate.month == date.month &&
|
||||
nowDate.year == date.year;
|
||||
final settingsStore = Provider.of<SettingsStore>(context);
|
||||
final currentLanguage = settingsStore.languageCode;
|
||||
final dateSectionDateFormat = settingsStore.getCurrentDateFormat(
|
||||
formatUSA: "yyyy MMM d",
|
||||
formatDefault: "d MMM yyyy");
|
||||
final dateSectionDateFormat = DateFormatter.withCurrentLocal();
|
||||
var title = "";
|
||||
|
||||
if (isToday) {
|
||||
@@ -28,21 +23,19 @@ class DateSectionRaw extends StatelessWidget {
|
||||
} else if (diffDays == 0) {
|
||||
title = S.of(context).yesterday;
|
||||
} else if (diffDays > -7 && diffDays < 0) {
|
||||
final dateFormat = DateFormat.EEEE(currentLanguage);
|
||||
final dateFormat = DateFormat.EEEE();
|
||||
title = dateFormat.format(date);
|
||||
} else {
|
||||
title = dateSectionDateFormat.format(date);
|
||||
}
|
||||
|
||||
return Container(
|
||||
height: 35,
|
||||
alignment: Alignment.center,
|
||||
color: Colors.transparent,
|
||||
child: Text(title,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).textTheme.overline.backgroundColor
|
||||
))
|
||||
);
|
||||
height: 35,
|
||||
alignment: Alignment.center,
|
||||
color: Colors.transparent,
|
||||
child: Text(title,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).textTheme.overline.backgroundColor)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'dart:ui';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/src/screens/dashboard/wallet_menu.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:cake_wallet/src/domain/common/sync_status.dart';
|
||||
import 'package:cake_wallet/entities/sync_status.dart';
|
||||
|
||||
class SyncIndicator extends StatelessWidget {
|
||||
SyncIndicator({@required this.dashboardViewModel});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
||||
|
||||
class TradeRow extends StatelessWidget {
|
||||
TradeRow({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_direction.dart';
|
||||
import 'package:cake_wallet/entities/transaction_direction.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
|
||||
class TransactionRow extends StatelessWidget {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'dart:ui';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_template.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_template.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||
import 'package:cake_wallet/src/widgets/template_tile.dart';
|
||||
import 'package:dotted_border/dotted_border.dart';
|
||||
@@ -9,10 +9,10 @@ import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/xmrto/xmrto_exchange_provider.dart';
|
||||
import 'package:cake_wallet/src/stores/exchange/exchange_trade_state.dart';
|
||||
import 'package:cake_wallet/src/stores/exchange/limits_state.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.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/limits_state.dart';
|
||||
import 'package:cake_wallet/src/screens/exchange/widgets/exchange_card.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||
@@ -376,7 +376,7 @@ class BaseExchangeWidgetState extends State<BaseExchangeWidget> {
|
||||
},
|
||||
color: Theme.of(context).accentTextTheme.body2.color,
|
||||
textColor: Colors.white,
|
||||
isLoading: exchangeViewModel.tradeState is TradeIsCreating,
|
||||
isLoading: false, // FIXME: FIXME exchangeViewModel.tradeState is TradeIsCreating,
|
||||
)),
|
||||
]),
|
||||
));
|
||||
@@ -419,18 +419,21 @@ class BaseExchangeWidgetState extends State<BaseExchangeWidget> {
|
||||
final depositAmountController = depositKey.currentState.amountController;
|
||||
final receiveAddressController = receiveKey.currentState.addressController;
|
||||
final receiveAmountController = receiveKey.currentState.amountController;
|
||||
final limitsState = exchangeViewModel.limitsState;
|
||||
|
||||
if (limitsState is LimitsLoadedSuccessfully) {
|
||||
final min = limitsState.limits.min != null
|
||||
? limitsState.limits.min.toString()
|
||||
: null;
|
||||
final max = limitsState.limits.max != null
|
||||
? limitsState.limits.max.toString()
|
||||
: null;
|
||||
final key = depositKey;
|
||||
key.currentState.changeLimits(min: min, max: max);
|
||||
}
|
||||
// FIXME: FIXME
|
||||
|
||||
// final limitsState = exchangeViewModel.limitsState;
|
||||
//
|
||||
// if (limitsState is LimitsLoadedSuccessfully) {
|
||||
// final min = limitsState.limits.min != null
|
||||
// ? limitsState.limits.min.toString()
|
||||
// : null;
|
||||
// final max = limitsState.limits.max != null
|
||||
// ? limitsState.limits.max.toString()
|
||||
// : null;
|
||||
// final key = depositKey;
|
||||
// key.currentState.changeLimits(min: min, max: max);
|
||||
// }
|
||||
|
||||
_onCurrencyChange(
|
||||
exchangeViewModel.receiveCurrency, exchangeViewModel, receiveKey);
|
||||
@@ -491,47 +494,51 @@ class BaseExchangeWidgetState extends State<BaseExchangeWidget> {
|
||||
receiveKey.currentState.isAddressEditable(isEditable: isEnabled);
|
||||
});
|
||||
|
||||
reaction((_) => exchangeViewModel.tradeState, (ExchangeTradeState state) {
|
||||
if (state is TradeIsCreatedFailure) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithOneAction(
|
||||
alertTitle: S.of(context).error,
|
||||
alertContent: state.error,
|
||||
buttonText: S.of(context).ok,
|
||||
buttonAction: () => Navigator.of(context).pop());
|
||||
});
|
||||
});
|
||||
}
|
||||
if (state is TradeIsCreatedSuccessfully) {
|
||||
Navigator.of(context).pushNamed(Routes.exchangeConfirm);
|
||||
}
|
||||
});
|
||||
// FIXME: FIXME
|
||||
|
||||
reaction((_) => exchangeViewModel.limitsState, (LimitsState state) {
|
||||
String min;
|
||||
String max;
|
||||
// reaction((_) => exchangeViewModel.tradeState, (ExchangeTradeState state) {
|
||||
// if (state is TradeIsCreatedFailure) {
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// showDialog<void>(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) {
|
||||
// return AlertWithOneAction(
|
||||
// alertTitle: S.of(context).error,
|
||||
// alertContent: state.error,
|
||||
// buttonText: S.of(context).ok,
|
||||
// buttonAction: () => Navigator.of(context).pop());
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// if (state is TradeIsCreatedSuccessfully) {
|
||||
// Navigator.of(context).pushNamed(Routes.exchangeConfirm);
|
||||
// }
|
||||
// });
|
||||
|
||||
if (state is LimitsLoadedSuccessfully) {
|
||||
min = state.limits.min != null ? state.limits.min.toString() : null;
|
||||
max = state.limits.max != null ? state.limits.max.toString() : null;
|
||||
}
|
||||
// FIXME: FIXME
|
||||
|
||||
if (state is LimitsLoadedFailure) {
|
||||
min = '0';
|
||||
max = '0';
|
||||
}
|
||||
|
||||
if (state is LimitsIsLoading) {
|
||||
min = '...';
|
||||
max = '...';
|
||||
}
|
||||
|
||||
depositKey.currentState.changeLimits(min: min, max: max);
|
||||
receiveKey.currentState.changeLimits(min: null, max: null);
|
||||
});
|
||||
// reaction((_) => exchangeViewModel.limitsState, (LimitsState state) {
|
||||
// String min;
|
||||
// String max;
|
||||
//
|
||||
// if (state is LimitsLoadedSuccessfully) {
|
||||
// min = state.limits.min != null ? state.limits.min.toString() : null;
|
||||
// max = state.limits.max != null ? state.limits.max.toString() : null;
|
||||
// }
|
||||
//
|
||||
// if (state is LimitsLoadedFailure) {
|
||||
// min = '0';
|
||||
// max = '0';
|
||||
// }
|
||||
//
|
||||
// if (state is LimitsIsLoading) {
|
||||
// min = '...';
|
||||
// max = '...';
|
||||
// }
|
||||
//
|
||||
// depositKey.currentState.changeLimits(min: min, max: max);
|
||||
// receiveKey.currentState.changeLimits(min: null, max: null);
|
||||
// });
|
||||
|
||||
depositAddressController.addListener(
|
||||
() => exchangeViewModel.depositAddress = depositAddressController.text);
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'dart:ui';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_background.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_close_button.dart';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/widgets/address_text_field.dart';
|
||||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||
import 'package:cake_wallet/src/screens/exchange/widgets/currency_picker.dart';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_provider.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/widgets/picker.dart';
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:cake_wallet/exchange/trade.dart';
|
||||
|
||||
class ExchangeConfirmPage extends BasePage {
|
||||
ExchangeConfirmPage({@required this.tradesStore}) : trade = tradesStore.trade;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
||||
import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_item.dart';
|
||||
import 'package:cake_wallet/src/screens/exchange_trade/information_page.dart';
|
||||
import 'package:cake_wallet/src/widgets/standart_list_row.dart';
|
||||
@@ -12,10 +12,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/stores/exchange_trade/exchange_trade_store.dart';
|
||||
import 'package:cake_wallet/src/stores/send/send_store.dart';
|
||||
import 'package:cake_wallet/src/stores/send/sending_state.dart';
|
||||
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/exchange_trade/exchange_trade_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/send/send_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/send/sending_state.dart';
|
||||
// import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/screens/exchange_trade/widgets/timer_widget.dart';
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
|
||||
class FaqPage extends BasePage {
|
||||
@@ -124,35 +124,37 @@ class FaqFormState extends State<FaqForm> {
|
||||
}
|
||||
|
||||
String getFaqPath(BuildContext context) {
|
||||
final settingsStore = Provider.of<SettingsStore>(context);
|
||||
|
||||
switch (settingsStore.languageCode) {
|
||||
case 'en':
|
||||
return 'assets/faq/faq_en.json';
|
||||
case 'uk':
|
||||
return 'assets/faq/faq_uk.json';
|
||||
case 'ru':
|
||||
return 'assets/faq/faq_ru.json';
|
||||
case 'es':
|
||||
return 'assets/faq/faq_es.json';
|
||||
case 'ja':
|
||||
return 'assets/faq/faq_ja.json';
|
||||
case 'ko':
|
||||
return 'assets/faq/faq_ko.json';
|
||||
case 'hi':
|
||||
return 'assets/faq/faq_hi.json';
|
||||
case 'de':
|
||||
return 'assets/faq/faq_de.json';
|
||||
case 'zh':
|
||||
return 'assets/faq/faq_zh.json';
|
||||
case 'pt':
|
||||
return 'assets/faq/faq_pt.json';
|
||||
case 'pl':
|
||||
return 'assets/faq/faq_pl.json';
|
||||
case 'nl':
|
||||
return 'assets/faq/faq_nl.json';
|
||||
default:
|
||||
return 'assets/faq/faq_en.json';
|
||||
}
|
||||
// FIXME: FIXME
|
||||
// final settingsStore = Provider.of<SettingsStore>(context);
|
||||
//
|
||||
// switch (settingsStore.languageCode) {
|
||||
// case 'en':
|
||||
// return 'assets/faq/faq_en.json';
|
||||
// case 'uk':
|
||||
// return 'assets/faq/faq_uk.json';
|
||||
// case 'ru':
|
||||
// return 'assets/faq/faq_ru.json';
|
||||
// case 'es':
|
||||
// return 'assets/faq/faq_es.json';
|
||||
// case 'ja':
|
||||
// return 'assets/faq/faq_ja.json';
|
||||
// case 'ko':
|
||||
// return 'assets/faq/faq_ko.json';
|
||||
// case 'hi':
|
||||
// return 'assets/faq/faq_hi.json';
|
||||
// case 'de':
|
||||
// return 'assets/faq/faq_de.json';
|
||||
// case 'zh':
|
||||
// return 'assets/faq/faq_zh.json';
|
||||
// case 'pt':
|
||||
// return 'assets/faq/faq_pt.json';
|
||||
// case 'pl':
|
||||
// return 'assets/faq/faq_pl.json';
|
||||
// case 'nl':
|
||||
// return 'assets/faq/faq_nl.json';
|
||||
// default:
|
||||
// return 'assets/faq/faq_en.json';
|
||||
// }
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/core/monero_account_label_validator.dart';
|
||||
import 'package:cake_wallet/view_model/monero_account_list/monero_account_edit_or_create_state.dart';
|
||||
import 'package:cake_wallet/view_model/monero_account_list/monero_account_edit_or_create_view_model.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
@@ -59,7 +59,7 @@ class MoneroAccountEditOrCreatePage extends BasePage {
|
||||
color: Colors.green,
|
||||
textColor: Colors.white,
|
||||
isLoading: moneroAccountCreationViewModel.state
|
||||
is AccountIsCreating,
|
||||
is IsExecutingState,
|
||||
isDisabled:
|
||||
moneroAccountCreationViewModel.label?.isEmpty ?? true,
|
||||
))
|
||||
|
||||
@@ -13,7 +13,7 @@ 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/screens/seed_language/widgets/seed_language_picker.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_creation_state.dart';
|
||||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_new_vm.dart';
|
||||
|
||||
class NewWalletPage extends BasePage {
|
||||
@@ -43,7 +43,8 @@ class _WalletNameFormState extends State<WalletNameForm> {
|
||||
static const aspectRatioImage = 1.22;
|
||||
|
||||
final walletNameImage = Image.asset('assets/images/wallet_name.png');
|
||||
final walletNameLightImage = Image.asset('assets/images/wallet_name_light.png');
|
||||
final walletNameLightImage =
|
||||
Image.asset('assets/images/wallet_name_light.png');
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _languageSelectorKey = GlobalKey<SeedLanguageSelectorState>();
|
||||
ReactionDisposer _stateReaction;
|
||||
@@ -52,12 +53,12 @@ class _WalletNameFormState extends State<WalletNameForm> {
|
||||
@override
|
||||
void initState() {
|
||||
_stateReaction ??=
|
||||
reaction((_) => _walletNewVM.state, (WalletCreationState state) {
|
||||
if (state is WalletCreatedSuccessfully) {
|
||||
Navigator.of(context).popAndPushNamed(Routes.seed, arguments: true);
|
||||
reaction((_) => _walletNewVM.state, (ExecutionState state) {
|
||||
if (state is ExecutedSuccessfullyState) {
|
||||
Navigator.of(context).pushNamed(Routes.seed, arguments: true);
|
||||
}
|
||||
|
||||
if (state is WalletCreationFailure) {
|
||||
if (state is FailureState) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
@@ -77,7 +78,8 @@ class _WalletNameFormState extends State<WalletNameForm> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final walletImage = getIt.get<SettingsStore>().isDarkTheme
|
||||
? walletNameImage : walletNameLightImage;
|
||||
? walletNameImage
|
||||
: walletNameLightImage;
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 24),
|
||||
@@ -158,7 +160,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
|
||||
text: S.of(context).seed_language_next,
|
||||
color: Colors.green,
|
||||
textColor: Colors.white,
|
||||
isLoading: _walletNewVM.state is WalletCreatedSuccessfully,
|
||||
isLoading: _walletNewVM.state is IsExecutingState,
|
||||
isDisabled: _walletNewVM.name.isEmpty,
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
@@ -1,301 +1,20 @@
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/biometric_auth.dart';
|
||||
|
||||
abstract class PinCodeWidget extends StatefulWidget {
|
||||
PinCodeWidget({Key key, this.onPinCodeEntered, this.hasLengthSwitcher})
|
||||
: super(key: key);
|
||||
|
||||
final Function(List<int> pin, PinCodeState state) onPinCodeEntered;
|
||||
final bool hasLengthSwitcher;
|
||||
}
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart';
|
||||
|
||||
class PinCode extends PinCodeWidget {
|
||||
PinCode(Function(List<int> pin, PinCodeState state) onPinCodeEntered,
|
||||
bool hasLengthSwitcher, Key key)
|
||||
PinCode(
|
||||
void Function(String pin, PinCodeState state) onFullPin,
|
||||
void Function(String pin) onChangedPin,
|
||||
int initialPinLength,
|
||||
bool hasLengthSwitcher,
|
||||
Key key)
|
||||
: super(
|
||||
key: key,
|
||||
onPinCodeEntered: onPinCodeEntered,
|
||||
hasLengthSwitcher: hasLengthSwitcher);
|
||||
onFullPin: onFullPin,
|
||||
onChangedPin: onChangedPin,
|
||||
hasLengthSwitcher: hasLengthSwitcher,
|
||||
initialPinLength: initialPinLength);
|
||||
|
||||
@override
|
||||
PinCodeState createState() => PinCodeState();
|
||||
}
|
||||
|
||||
class PinCodeState<T extends PinCodeWidget> extends State<T> {
|
||||
static const defaultPinLength = 4;
|
||||
static const sixPinLength = 6;
|
||||
static const fourPinLength = 4;
|
||||
final _gridViewKey = GlobalKey();
|
||||
final _key = GlobalKey<ScaffoldState>();
|
||||
|
||||
int pinLength = defaultPinLength;
|
||||
List<int> pin = List<int>.filled(defaultPinLength, null);
|
||||
String title = S.current.enter_your_pin;
|
||||
double _aspectRatio = 0;
|
||||
|
||||
void setTitle(String title) => setState(() => this.title = title);
|
||||
|
||||
void clear() => setState(() => pin = List<int>.filled(pinLength, null));
|
||||
|
||||
void onPinCodeEntered(PinCodeState state) =>
|
||||
widget.onPinCodeEntered(state.pin, this);
|
||||
|
||||
void changePinLength(int length) {
|
||||
final newPin = List<int>.filled(length, null);
|
||||
|
||||
setState(() {
|
||||
pinLength = length;
|
||||
pin = newPin;
|
||||
});
|
||||
}
|
||||
|
||||
void setDefaultPinLength() {
|
||||
final settingsStore = Provider.of<SettingsStore>(context);
|
||||
|
||||
pinLength = settingsStore.defaultPinLength;
|
||||
changePinLength(pinLength);
|
||||
}
|
||||
|
||||
void calculateAspectRatio() {
|
||||
final renderBox =
|
||||
_gridViewKey.currentContext.findRenderObject() as RenderBox;
|
||||
final cellWidth = renderBox.size.width / 3;
|
||||
final cellHeight = renderBox.size.height / 4;
|
||||
|
||||
if (cellWidth > 0 && cellHeight > 0) {
|
||||
_aspectRatio = cellWidth / cellHeight;
|
||||
}
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback(afterLayout);
|
||||
}
|
||||
|
||||
void afterLayout(dynamic _) {
|
||||
setDefaultPinLength();
|
||||
calculateAspectRatio();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) =>
|
||||
Scaffold(key: _key, body: body(context));
|
||||
|
||||
Widget body(BuildContext context) {
|
||||
final settingsStore = Provider.of<SettingsStore>(context);
|
||||
|
||||
final deleteIconImage = Image.asset(
|
||||
'assets/images/delete_icon.png',
|
||||
color: Theme.of(context).primaryTextTheme.title.color,
|
||||
);
|
||||
final faceImage = Image.asset(
|
||||
'assets/images/face.png',
|
||||
color: Theme.of(context).primaryTextTheme.title.color,
|
||||
);
|
||||
|
||||
return Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
padding: EdgeInsets.only(left: 40.0, right: 40.0, bottom: 40.0),
|
||||
child: Column(children: <Widget>[
|
||||
Spacer(flex: 2),
|
||||
Text(title,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).primaryTextTheme.title.color)),
|
||||
Spacer(flex: 3),
|
||||
Container(
|
||||
width: 180,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: List.generate(pinLength, (index) {
|
||||
const size = 10.0;
|
||||
final isFilled = pin[index] != null;
|
||||
|
||||
return Container(
|
||||
width: size,
|
||||
height: size,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: isFilled
|
||||
? Theme.of(context).primaryTextTheme.title.color
|
||||
: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.body1
|
||||
.color
|
||||
.withOpacity(0.25),
|
||||
));
|
||||
}),
|
||||
),
|
||||
),
|
||||
Spacer(flex: 2),
|
||||
if (widget.hasLengthSwitcher) ...[
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
changePinLength(pinLength == PinCodeState.fourPinLength
|
||||
? PinCodeState.sixPinLength
|
||||
: PinCodeState.fourPinLength);
|
||||
},
|
||||
child: Text(
|
||||
_changePinLengthText(),
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.body1
|
||||
.decorationColor),
|
||||
))
|
||||
],
|
||||
Spacer(flex: 1),
|
||||
Flexible(
|
||||
flex: 24,
|
||||
child: Container(
|
||||
key: _gridViewKey,
|
||||
child: _aspectRatio > 0
|
||||
? GridView.count(
|
||||
shrinkWrap: true,
|
||||
crossAxisCount: 3,
|
||||
childAspectRatio: _aspectRatio,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: List.generate(12, (index) {
|
||||
const double marginRight = 15;
|
||||
const double marginLeft = 15;
|
||||
|
||||
if (index == 9) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: marginLeft, right: marginRight),
|
||||
child: FlatButton(
|
||||
onPressed: (widget.hasLengthSwitcher ||
|
||||
!settingsStore
|
||||
.allowBiometricalAuthentication)
|
||||
? null
|
||||
: () {
|
||||
// FIXME
|
||||
// if (authStore != null) {
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// final biometricAuth = BiometricAuth();
|
||||
// biometricAuth.isAuthenticated().then(
|
||||
// (isAuth) {
|
||||
// if (isAuth) {
|
||||
// authStore.biometricAuth();
|
||||
// _key.currentState.showSnackBar(
|
||||
// SnackBar(
|
||||
// content: Text(S.of(context).authenticated),
|
||||
// backgroundColor: Colors.green,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
},
|
||||
color: Theme.of(context).backgroundColor,
|
||||
shape: CircleBorder(),
|
||||
child: (widget.hasLengthSwitcher ||
|
||||
!settingsStore
|
||||
.allowBiometricalAuthentication)
|
||||
? Offstage()
|
||||
: faceImage,
|
||||
),
|
||||
);
|
||||
} else if (index == 10) {
|
||||
index = 0;
|
||||
} else if (index == 11) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: marginLeft, right: marginRight),
|
||||
child: FlatButton(
|
||||
onPressed: () => _pop(),
|
||||
color: Theme.of(context).backgroundColor,
|
||||
shape: CircleBorder(),
|
||||
child: deleteIconImage,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
|
||||
return Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: marginLeft, right: marginRight),
|
||||
child: FlatButton(
|
||||
onPressed: () => _push(index),
|
||||
color: Theme.of(context).backgroundColor,
|
||||
shape: CircleBorder(),
|
||||
child: Text('$index',
|
||||
style: TextStyle(
|
||||
fontSize: 30.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.title
|
||||
.color)),
|
||||
),
|
||||
);
|
||||
}),
|
||||
)
|
||||
: null))
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
void _push(int num) {
|
||||
if (currentPinLength() >= pinLength) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < pin.length; i++) {
|
||||
if (pin[i] == null) {
|
||||
setState(() => pin[i] = num);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final _currentPinLength = currentPinLength();
|
||||
|
||||
if (_currentPinLength == pinLength) {
|
||||
onPinCodeEntered(this);
|
||||
}
|
||||
}
|
||||
|
||||
void _pop() {
|
||||
if (currentPinLength() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = pin.length - 1; i >= 0; i--) {
|
||||
if (pin[i] != null) {
|
||||
setState(() => pin[i] = null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int currentPinLength() {
|
||||
return pin.fold(0, (v, e) {
|
||||
if (e != null) {
|
||||
return v + 1;
|
||||
}
|
||||
|
||||
return v;
|
||||
});
|
||||
}
|
||||
|
||||
String _changePinLengthText() {
|
||||
return S.current.use +
|
||||
(pinLength == PinCodeState.fourPinLength
|
||||
? '${PinCodeState.sixPinLength}'
|
||||
: '${PinCodeState.fourPinLength}') +
|
||||
S.current.digit_pin;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,284 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
|
||||
class PinCodeWidget extends StatefulWidget {
|
||||
PinCodeWidget(
|
||||
{Key key,
|
||||
@required this.onFullPin,
|
||||
@required this.initialPinLength,
|
||||
this.onChangedPin,
|
||||
this.onChangedPinLength,
|
||||
this.hasLengthSwitcher})
|
||||
: super(key: key);
|
||||
|
||||
final void Function(String pin, PinCodeState state) onFullPin;
|
||||
final void Function(String pin) onChangedPin;
|
||||
final void Function(int length) onChangedPinLength;
|
||||
final bool hasLengthSwitcher;
|
||||
final int initialPinLength;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => PinCodeState();
|
||||
}
|
||||
|
||||
class PinCodeState<T extends PinCodeWidget> extends State<T> {
|
||||
static const defaultPinLength = fourPinLength;
|
||||
static const sixPinLength = 6;
|
||||
static const fourPinLength = 4;
|
||||
final _gridViewKey = GlobalKey();
|
||||
final _key = GlobalKey<ScaffoldState>();
|
||||
|
||||
int pinLength;
|
||||
String pin;
|
||||
String title;
|
||||
double _aspectRatio;
|
||||
|
||||
int currentPinLength() => pin.length;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
pinLength = widget.initialPinLength;
|
||||
pin = '';
|
||||
title = S.current.enter_your_pin;
|
||||
_aspectRatio = 0;
|
||||
WidgetsBinding.instance.addPostFrameCallback(_afterLayout);
|
||||
}
|
||||
|
||||
void setTitle(String title) => setState(() => this.title = title);
|
||||
|
||||
void clear() => setState(() => pin = '');
|
||||
|
||||
void reset() => setState(() {
|
||||
pin = '';
|
||||
pinLength = widget.initialPinLength;
|
||||
title = S.current.enter_your_pin;
|
||||
});
|
||||
|
||||
void changePinLength(int length) {
|
||||
setState(() {
|
||||
pinLength = length;
|
||||
pin = '';
|
||||
});
|
||||
|
||||
widget.onChangedPinLength?.call(length);
|
||||
}
|
||||
|
||||
void setDefaultPinLength() => changePinLength(widget.initialPinLength);
|
||||
|
||||
void calculateAspectRatio() {
|
||||
final renderBox =
|
||||
_gridViewKey.currentContext.findRenderObject() as RenderBox;
|
||||
final cellWidth = renderBox.size.width / 3;
|
||||
final cellHeight = renderBox.size.height / 4;
|
||||
|
||||
if (cellWidth > 0 && cellHeight > 0) {
|
||||
_aspectRatio = cellWidth / cellHeight;
|
||||
}
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) =>
|
||||
Scaffold(key: _key, body: body(context));
|
||||
|
||||
Widget body(BuildContext context) {
|
||||
final deleteIconImage = Image.asset(
|
||||
'assets/images/delete_icon.png',
|
||||
color: Theme.of(context).primaryTextTheme.title.color,
|
||||
);
|
||||
final faceImage = Image.asset(
|
||||
'assets/images/face.png',
|
||||
color: Theme.of(context).primaryTextTheme.title.color,
|
||||
);
|
||||
|
||||
return Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
padding: EdgeInsets.only(left: 40.0, right: 40.0, bottom: 40.0),
|
||||
child: Column(children: <Widget>[
|
||||
Spacer(flex: 2),
|
||||
Text(title,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).primaryTextTheme.title.color)),
|
||||
Spacer(flex: 3),
|
||||
Container(
|
||||
width: 180,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: List.generate(pinLength, (index) {
|
||||
const size = 10.0;
|
||||
final isFilled = pin.length > index ? pin[index] != null : false;
|
||||
|
||||
return Container(
|
||||
width: size,
|
||||
height: size,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: isFilled
|
||||
? Theme.of(context).primaryTextTheme.title.color
|
||||
: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.body1
|
||||
.color
|
||||
.withOpacity(0.25),
|
||||
));
|
||||
}),
|
||||
),
|
||||
),
|
||||
Spacer(flex: 2),
|
||||
if (widget.hasLengthSwitcher) ...[
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
changePinLength(pinLength == PinCodeState.fourPinLength
|
||||
? PinCodeState.sixPinLength
|
||||
: PinCodeState.fourPinLength);
|
||||
},
|
||||
child: Text(
|
||||
_changePinLengthText(),
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.body1
|
||||
.decorationColor),
|
||||
))
|
||||
],
|
||||
Spacer(flex: 1),
|
||||
Flexible(
|
||||
flex: 24,
|
||||
child: Container(
|
||||
key: _gridViewKey,
|
||||
child: _aspectRatio > 0
|
||||
? GridView.count(
|
||||
shrinkWrap: true,
|
||||
crossAxisCount: 3,
|
||||
childAspectRatio: _aspectRatio,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: List.generate(12, (index) {
|
||||
const double marginRight = 15;
|
||||
const double marginLeft = 15;
|
||||
|
||||
if (index == 9) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: marginLeft, right: marginRight),
|
||||
child: FlatButton(
|
||||
onPressed: () => null,
|
||||
// (widget.hasLengthSwitcher ||
|
||||
// !settingsStore
|
||||
// .allowBiometricalAuthentication)
|
||||
// ? null
|
||||
// : () {
|
||||
// FIXME
|
||||
// if (authStore != null) {
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// final biometricAuth = BiometricAuth();
|
||||
// biometricAuth.isAuthenticated().then(
|
||||
// (isAuth) {
|
||||
// if (isAuth) {
|
||||
// authStore.biometricAuth();
|
||||
// _key.currentState.showSnackBar(
|
||||
// SnackBar(
|
||||
// content: Text(S.of(context).authenticated),
|
||||
// backgroundColor: Colors.green,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
color: Theme.of(context).backgroundColor,
|
||||
shape: CircleBorder(),
|
||||
child: null
|
||||
// (widget.hasLengthSwitcher ||
|
||||
// !settingsStore
|
||||
// .allowBiometricalAuthentication)
|
||||
// ? Offstage()
|
||||
// : faceImage,
|
||||
),
|
||||
);
|
||||
} else if (index == 10) {
|
||||
index = 0;
|
||||
} else if (index == 11) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: marginLeft, right: marginRight),
|
||||
child: FlatButton(
|
||||
onPressed: () => _pop(),
|
||||
color: Theme.of(context).backgroundColor,
|
||||
shape: CircleBorder(),
|
||||
child: deleteIconImage,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
|
||||
return Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: marginLeft, right: marginRight),
|
||||
child: FlatButton(
|
||||
onPressed: () => _push(index),
|
||||
color: Theme.of(context).backgroundColor,
|
||||
shape: CircleBorder(),
|
||||
child: Text('$index',
|
||||
style: TextStyle(
|
||||
fontSize: 30.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.title
|
||||
.color)),
|
||||
),
|
||||
);
|
||||
}),
|
||||
)
|
||||
: null))
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
void _push(int num) {
|
||||
setState(() {
|
||||
if (currentPinLength() >= pinLength) {
|
||||
return;
|
||||
}
|
||||
|
||||
pin += num.toString();
|
||||
|
||||
widget.onChangedPin(pin);
|
||||
|
||||
if (pin.length == pinLength) {
|
||||
widget.onFullPin(pin, this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _pop() {
|
||||
if (currentPinLength() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
pin.substring(0, pin.length - 1);
|
||||
}
|
||||
|
||||
String _changePinLengthText() {
|
||||
return S.current.use +
|
||||
(pinLength == PinCodeState.fourPinLength
|
||||
? '${PinCodeState.sixPinLength}'
|
||||
: '${PinCodeState.fourPinLength}') +
|
||||
S.current.digit_pin;
|
||||
}
|
||||
|
||||
void _afterLayout(dynamic _) {
|
||||
setDefaultPinLength();
|
||||
calculateAspectRatio();
|
||||
}
|
||||
}
|
||||
@@ -1,38 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:cake_wallet/view_model/rescan_view_model.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/widgets/blockchain_height_widget.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/stores/rescan/rescan_wallet_store.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
|
||||
class RescanPage extends BasePage {
|
||||
final blockchainKey = GlobalKey<BlockchainHeightState>();
|
||||
RescanPage(this._rescanViewModel)
|
||||
: _blockchainHeightWidgetKey = GlobalKey<BlockchainHeightState>();
|
||||
|
||||
@override
|
||||
String get title => S.current.rescan;
|
||||
final GlobalKey<BlockchainHeightState> _blockchainHeightWidgetKey;
|
||||
final RescanViewModel _rescanViewModel;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
final rescanWalletStore = Provider.of<RescanWalletStore>(context);
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
||||
child:
|
||||
Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
BlockchainHeightWidget(key: blockchainKey),
|
||||
BlockchainHeightWidget(key: _blockchainHeightWidgetKey),
|
||||
Observer(
|
||||
builder: (_) => LoadingPrimaryButton(
|
||||
isLoading:
|
||||
rescanWalletStore.state == RescanWalletState.rescaning,
|
||||
text: S.of(context).rescan,
|
||||
onPressed: () async {
|
||||
await rescanWalletStore.rescanCurrentWallet(
|
||||
restoreHeight: blockchainKey.currentState.height);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white,))
|
||||
isLoading:
|
||||
_rescanViewModel.state == RescanWalletState.rescaning,
|
||||
text: S.of(context).rescan,
|
||||
onPressed: () async {
|
||||
await _rescanViewModel.rescanCurrentWallet(
|
||||
restoreHeight:
|
||||
_blockchainHeightWidgetKey.currentState.height);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white,
|
||||
))
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/core/validator.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_creation_state.dart';
|
||||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/widgets/blockchain_height_widget.dart';
|
||||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||
@@ -46,12 +46,12 @@ class _RestoreFromSeedDetailsFormState
|
||||
@override
|
||||
void initState() {
|
||||
_stateReaction = reaction((_) => widget.walletRestorationFromSeedVM.state,
|
||||
(WalletCreationState state) {
|
||||
if (state is WalletCreatedSuccessfully) {
|
||||
(ExecutionState state) {
|
||||
if (state is ExecutedSuccessfullyState) {
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
}
|
||||
|
||||
if (state is WalletCreationFailure) {
|
||||
if (state is FailureState) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
@@ -131,7 +131,7 @@ class _RestoreFromSeedDetailsFormState
|
||||
}
|
||||
},
|
||||
isLoading:
|
||||
widget.walletRestorationFromSeedVM.state is WalletCreating,
|
||||
widget.walletRestorationFromSeedVM.state is IsExecutingState,
|
||||
text: S.of(context).restore_recover,
|
||||
color: Theme.of(context).accentTextTheme.body2.color,
|
||||
textColor: Colors.white,
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/widgets/seed_widget.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/core/seed_validator.dart';
|
||||
import 'package:cake_wallet/core/mnemonic_length.dart';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/src/screens/restore/widgets/restore_button.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
|
||||
class RestoreWalletOptionsPage extends BasePage {
|
||||
|
||||
+28
-135
@@ -1,28 +1,9 @@
|
||||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/src/screens/dashboard/dashboard_page.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/store/authentication_store.dart';
|
||||
|
||||
//import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
|
||||
import 'package:cake_wallet/src/stores/price/price_store.dart';
|
||||
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:cake_wallet/src/domain/common/qr_scanner.dart';
|
||||
import 'package:cake_wallet/src/domain/services/user_service.dart';
|
||||
import 'package:cake_wallet/src/domain/services/wallet_list_service.dart';
|
||||
import 'package:cake_wallet/src/domain/services/wallet_service.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/trade.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/transaction_description.dart';
|
||||
import 'package:cake_wallet/src/screens/auth/create_login_page.dart';
|
||||
import 'package:cake_wallet/src/screens/dashboard/create_dashboard_page.dart';
|
||||
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
||||
import 'package:cake_wallet/src/screens/welcome/create_welcome_page.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:cake_wallet/store/authentication_store.dart';
|
||||
import 'package:cake_wallet/entities/qr_scanner.dart';
|
||||
|
||||
class Root extends StatefulWidget {
|
||||
Root({Key key, this.authenticationStore, this.appStore, this.child})
|
||||
@@ -39,18 +20,12 @@ class Root extends StatefulWidget {
|
||||
class RootState extends State<Root> with WidgetsBindingObserver {
|
||||
bool _isInactive;
|
||||
bool _postFrameCallback;
|
||||
// GlobalKey<NavigatorState> _navKey;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_isInactive = false;
|
||||
_postFrameCallback = false;
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// _navKey.currentState.pushNamed(Routes.login);
|
||||
// });
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -62,12 +37,10 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
||||
return;
|
||||
}
|
||||
|
||||
// if (!_isInactive &&
|
||||
// widget.authenticationStore.state ==
|
||||
// AuthenticationState.authenticated ||
|
||||
// widget.authenticationStore.state == AuthenticationState.active) {
|
||||
// setState(() => _isInactive = true);
|
||||
// }
|
||||
if (!_isInactive &&
|
||||
widget.authenticationStore.state == AuthenticationState.allowed) {
|
||||
setState(() => _isInactive = true);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
@@ -77,108 +50,28 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_isInactive && !_postFrameCallback) {
|
||||
_postFrameCallback = true;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
Navigator.of(context).pushNamed(Routes.unlock,
|
||||
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
|
||||
if (!isAuthenticatedSuccessfully) {
|
||||
return;
|
||||
}
|
||||
|
||||
_reset();
|
||||
auth.close();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return widget.child;
|
||||
}
|
||||
|
||||
// _authenticationStore = Provider.of<AuthenticationStore>(context);
|
||||
// final sharedPreferences = Provider.of<SharedPreferences>(context);
|
||||
// final walletListService = Provider.of<WalletListService>(context);
|
||||
// final walletService = Provider.of<WalletService>(context);
|
||||
// final userService = Provider.of<UserService>(context);
|
||||
// final priceStore = Provider.of<PriceStore>(context);
|
||||
// final authenticationStore = Provider.of<AuthenticationStore>(context);
|
||||
// final trades = Provider.of<Box<Trade>>(context);
|
||||
// final transactionDescriptions =
|
||||
// Provider.of<Box<TransactionDescription>>(context);
|
||||
// final walletStore = Provider.of<WalletStore>(context);
|
||||
// final settingsStore = Provider.of<SettingsStore>(context);
|
||||
|
||||
// if (_isInactive && !_postFrameCallback) {
|
||||
// _postFrameCallback = true;
|
||||
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// Navigator.of(context).pushNamed(Routes.unlock,
|
||||
// arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
|
||||
// if (!isAuthenticatedSuccessfully) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// setState(() {
|
||||
// _postFrameCallback = false;
|
||||
// _isInactive = false;
|
||||
// });
|
||||
// auth.close();
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
|
||||
// return Navigator(
|
||||
// key: _navKey,
|
||||
// initialRoute: Routes.welcome,
|
||||
// onGenerateRoute: Router.generateRoute(
|
||||
// sharedPreferences: sharedPreferences,
|
||||
// walletListService: walletListService,
|
||||
// walletService: walletService,
|
||||
// userService: userService,
|
||||
// settings: settings,
|
||||
// priceStore: priceStore,
|
||||
// walletStore: walletStore,
|
||||
// syncStore: syncStore,
|
||||
// balanceStore: balanceStore,
|
||||
// settingsStore: settingsStore,
|
||||
// contacts: contacts,
|
||||
// nodes: nodes,
|
||||
// trades: trades,
|
||||
// transactionDescriptions: transactionDescriptions),
|
||||
// );
|
||||
|
||||
// return Observer(builder: (_) {
|
||||
// final state = widget.authenticationStore.state;
|
||||
|
||||
// if (state == AuthenticationState.denied) {
|
||||
// return createWelcomePage();
|
||||
// }
|
||||
|
||||
// if (state == AuthenticationState.installed) {
|
||||
// return getIt.get<AuthPage>(instanceName: 'login');
|
||||
// }
|
||||
|
||||
// if (state == AuthenticationState.allowed) {
|
||||
// return getIt.get<DashboardPage>();
|
||||
// }
|
||||
|
||||
// if (state == AuthenticationState.denied) {
|
||||
// return createWelcomePage();
|
||||
// }
|
||||
|
||||
// if (state == AuthenticationState.readyToLogin) {
|
||||
// return createLoginPage(
|
||||
// sharedPreferences: sharedPreferences,
|
||||
// userService: userService,
|
||||
// walletService: walletService,
|
||||
// walletListService: walletListService,
|
||||
// authenticationStore: authenticationStore);
|
||||
// }
|
||||
|
||||
// if (state == AuthenticationState.authenticated ||
|
||||
// state == AuthenticationState.restored) {
|
||||
// return createDashboardPage(
|
||||
// walletService: walletService,
|
||||
// priceStore: priceStore,
|
||||
// trades: trades,
|
||||
// transactionDescriptions: transactionDescriptions,
|
||||
// walletStore: walletStore,
|
||||
// settingsStore: settingsStore);
|
||||
// }
|
||||
|
||||
// if (state == AuthenticationState.created) {
|
||||
// return createSeedPage(
|
||||
// settingsStore: settingsStore,
|
||||
// walletService: walletService,
|
||||
// callback: () =>
|
||||
// _authenticationStore.state = AuthenticationState.authenticated);
|
||||
// }
|
||||
|
||||
// return Container(color: Colors.white);
|
||||
// });
|
||||
void _reset() {
|
||||
setState(() {
|
||||
_postFrameCallback = false;
|
||||
_isInactive = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,9 @@ class WalletSeedPage extends BasePage {
|
||||
final WalletSeedViewModel walletSeedViewModel;
|
||||
|
||||
@override
|
||||
void onClose(BuildContext context) =>
|
||||
isNewWalletCreated
|
||||
? Navigator.of(context).popUntil((route) => route.isFirst)
|
||||
: Navigator.of(context).pop();
|
||||
void onClose(BuildContext context) => isNewWalletCreated
|
||||
? Navigator.of(context).popUntil((route) => route.isFirst)
|
||||
: Navigator.of(context).pop();
|
||||
|
||||
@override
|
||||
Widget leading(BuildContext context) =>
|
||||
@@ -60,7 +59,8 @@ class WalletSeedPage extends BasePage {
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
final image = getIt.get<SettingsStore>().isDarkTheme ? imageDark : imageLight;
|
||||
final image =
|
||||
getIt.get<SettingsStore>().isDarkTheme ? imageDark : imageLight;
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.all(24),
|
||||
@@ -93,7 +93,8 @@ class WalletSeedPage extends BasePage {
|
||||
.color),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 20, left: 16, right: 16),
|
||||
padding:
|
||||
EdgeInsets.only(top: 20, left: 16, right: 16),
|
||||
child: Text(
|
||||
walletSeedViewModel.seed,
|
||||
textAlign: TextAlign.center,
|
||||
@@ -113,58 +114,63 @@ class WalletSeedPage extends BasePage {
|
||||
Column(
|
||||
children: <Widget>[
|
||||
isNewWalletCreated
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(bottom: 52, left: 43, right: 43),
|
||||
child: Text(
|
||||
S.of(context).seed_reminder,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.overline
|
||||
.color
|
||||
),
|
||||
),
|
||||
)
|
||||
: Offstage(),
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: 52, left: 43, right: 43),
|
||||
child: Text(
|
||||
S.of(context).seed_reminder,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.overline
|
||||
.color),
|
||||
),
|
||||
)
|
||||
: Offstage(),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(right: 8.0),
|
||||
child: PrimaryButton(
|
||||
onPressed: () => Share.text(
|
||||
S.of(context).seed_share,
|
||||
walletSeedViewModel.seed,
|
||||
'text/plain'),
|
||||
text: S.of(context).save,
|
||||
color: Colors.green,
|
||||
textColor: Colors.white),
|
||||
)),
|
||||
padding: EdgeInsets.only(right: 8.0),
|
||||
child: PrimaryButton(
|
||||
onPressed: () => Share.text(
|
||||
S.of(context).seed_share,
|
||||
walletSeedViewModel.seed,
|
||||
'text/plain'),
|
||||
text: S.of(context).save,
|
||||
color: Colors.green,
|
||||
textColor: Colors.white),
|
||||
)),
|
||||
Flexible(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(left: 8.0),
|
||||
child: Builder(
|
||||
builder: (context) => PrimaryButton(
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(
|
||||
text: walletSeedViewModel.seed));
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
S.of(context).copied_to_clipboard),
|
||||
backgroundColor: Colors.green,
|
||||
duration: Duration(milliseconds: 1500),
|
||||
),
|
||||
);
|
||||
},
|
||||
text: S.of(context).copy,
|
||||
color: Theme.of(context).accentTextTheme.body2.color,
|
||||
textColor: Colors.white)),
|
||||
))
|
||||
padding: EdgeInsets.only(left: 8.0),
|
||||
child: Builder(
|
||||
builder: (context) => PrimaryButton(
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(
|
||||
text: walletSeedViewModel.seed));
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(S
|
||||
.of(context)
|
||||
.copied_to_clipboard),
|
||||
backgroundColor: Colors.green,
|
||||
duration:
|
||||
Duration(milliseconds: 1500),
|
||||
),
|
||||
);
|
||||
},
|
||||
text: S.of(context).copy,
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.body2
|
||||
.color,
|
||||
textColor: Colors.white)),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
|
||||
@@ -16,7 +16,6 @@ import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/widgets/top_panel.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/view_model/send/send_view_model_state.dart';
|
||||
import 'package:cake_wallet/src/widgets/trail_button.dart';
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:ui';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
|
||||
// import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
|
||||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
import 'package:cake_wallet/src/widgets/picker.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||
@@ -18,7 +19,7 @@ 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_two_actions.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/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/routes.dart';
|
||||
@@ -473,13 +474,13 @@ class BaseSendWidget extends StatelessWidget {
|
||||
return LoadingPrimaryButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState.validate()) {
|
||||
print('SENT!!!');
|
||||
|
||||
}
|
||||
},
|
||||
text: S.of(context).send,
|
||||
color: Theme.of(context).accentTextTheme.body2.color,
|
||||
textColor: Colors.white,
|
||||
isLoading: sendViewModel.state is TransactionIsCreating ||
|
||||
isLoading: sendViewModel.state is IsExecutingState ||
|
||||
sendViewModel.state is TransactionCommitting,
|
||||
isDisabled:
|
||||
false // FIXME !(syncStore.status is SyncedSyncStatus),
|
||||
@@ -530,8 +531,8 @@ class BaseSendWidget extends StatelessWidget {
|
||||
}
|
||||
});
|
||||
|
||||
reaction((_) => sendViewModel.state, (SendViewModelState state) {
|
||||
if (state is SendingFailed) {
|
||||
reaction((_) => sendViewModel.state, (ExecutionState state) {
|
||||
if (state is FailureState) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
@@ -545,7 +546,7 @@ class BaseSendWidget extends StatelessWidget {
|
||||
});
|
||||
}
|
||||
|
||||
if (state is TransactionCreatedSuccessfully) {
|
||||
if (state is ExecutedSuccessfullyState) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
@@ -691,19 +692,19 @@ class BaseSendWidget extends StatelessWidget {
|
||||
}
|
||||
|
||||
Future<void> _setTransactionPriority(BuildContext context) async {
|
||||
final items = TransactionPriority.all;
|
||||
final selectedItem = items.indexOf(sendViewModel.transactionPriority);
|
||||
|
||||
await showDialog<void>(
|
||||
builder: (_) => Picker(
|
||||
items: items,
|
||||
selectedAtIndex: selectedItem,
|
||||
title: S.of(context).please_select,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
onItemSelected: (TransactionPriority priority) => null,
|
||||
// sendViewModel.setTransactionPriority(priority),
|
||||
isAlwaysShowScrollThumb: true,
|
||||
),
|
||||
context: context);
|
||||
// final items = TransactionPriority.all;
|
||||
// final selectedItem = items.indexOf(sendViewModel.transactionPriority);
|
||||
//
|
||||
// await showDialog<void>(
|
||||
// builder: (_) => Picker(
|
||||
// items: items,
|
||||
// selectedAtIndex: selectedItem,
|
||||
// title: S.of(context).please_select,
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// onItemSelected: (TransactionPriority priority) => null,
|
||||
// // sendViewModel.setTransactionPriority(priority),
|
||||
// isAlwaysShowScrollThumb: true,
|
||||
// ),
|
||||
// context: context);
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
import 'dart:ui';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/src/stores/send/sending_state.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/stores/send/send_store.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
|
||||
class SendingAlert extends StatefulWidget {
|
||||
SendingAlert({@required this.sendStore});
|
||||
|
||||
final SendStore sendStore;
|
||||
|
||||
@override
|
||||
SendingAlertState createState() => SendingAlertState(sendStore);
|
||||
}
|
||||
|
||||
class SendingAlertState extends State<SendingAlert> {
|
||||
SendingAlertState(this.sendStore);
|
||||
|
||||
final SendStore sendStore;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Observer(
|
||||
builder: (_) {
|
||||
final state = sendStore.state;
|
||||
|
||||
if (state is TransactionCommitted) {
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
'assets/images/birthday_cake.png'),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 220, left: 24, right: 24),
|
||||
child: Text(
|
||||
S.of(context).send_success,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).primaryTextTheme.title.color,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 24,
|
||||
right: 24,
|
||||
bottom: 24,
|
||||
child: PrimaryButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
text: S.of(context).send_got_it,
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white
|
||||
)
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
'assets/images/birthday_cake.png'),
|
||||
),
|
||||
),
|
||||
BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 3.0, sigmaY: 3.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(color: Theme.of(context).backgroundColor.withOpacity(0.25)),
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 220),
|
||||
child: Text(
|
||||
S.of(context).send_sending,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).primaryTextTheme.title.color,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,61 +4,65 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/language.dart';
|
||||
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:cake_wallet/entities/language.dart';
|
||||
// import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||
|
||||
// FIXME: FIXME
|
||||
|
||||
class ChangeLanguage extends BasePage {
|
||||
@override
|
||||
String get title => S.current.settings_change_language;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
final settingsStore = Provider.of<SettingsStore>(context);
|
||||
final currentLanguage = Provider.of<Language>(context);
|
||||
// final settingsStore = Provider.of<SettingsStore>(context);
|
||||
// final currentLanguage = Provider.of<Language>(context);
|
||||
//
|
||||
// return Container(
|
||||
// padding: EdgeInsets.only(top: 10.0),
|
||||
// child: SectionStandardList(
|
||||
// sectionCount: 1,
|
||||
// context: context,
|
||||
// itemCounter: (int sectionIndex) => languages.values.length,
|
||||
// itemBuilder: (_, sectionIndex, index) {
|
||||
// final item = languages.values.elementAt(index);
|
||||
// final code = languages.keys.elementAt(index);
|
||||
//
|
||||
// final isCurrent = settingsStore.languageCode == null
|
||||
// ? false
|
||||
// : code == settingsStore.languageCode;
|
||||
//
|
||||
// return LanguageRow(
|
||||
// title: item,
|
||||
// isSelected: isCurrent,
|
||||
// handler: (context) async {
|
||||
// if (!isCurrent) {
|
||||
// await showDialog<void>(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) {
|
||||
// return AlertWithTwoActions(
|
||||
// alertTitle: S.of(context).change_language,
|
||||
// alertContent: S.of(context).change_language_to(item),
|
||||
// rightButtonText: S.of(context).change,
|
||||
// leftButtonText: S.of(context).cancel,
|
||||
// actionRightButton: () {
|
||||
// settingsStore.saveLanguageCode(
|
||||
// languageCode: code);
|
||||
// currentLanguage.setCurrentLanguage(code);
|
||||
// Navigator.of(context).pop();
|
||||
// },
|
||||
// actionLeftButton: () => Navigator.of(context).pop()
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// );
|
||||
// },
|
||||
// )
|
||||
// );
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 10.0),
|
||||
child: SectionStandardList(
|
||||
sectionCount: 1,
|
||||
context: context,
|
||||
itemCounter: (int sectionIndex) => languages.values.length,
|
||||
itemBuilder: (_, sectionIndex, index) {
|
||||
final item = languages.values.elementAt(index);
|
||||
final code = languages.keys.elementAt(index);
|
||||
|
||||
final isCurrent = settingsStore.languageCode == null
|
||||
? false
|
||||
: code == settingsStore.languageCode;
|
||||
|
||||
return LanguageRow(
|
||||
title: item,
|
||||
isSelected: isCurrent,
|
||||
handler: (context) async {
|
||||
if (!isCurrent) {
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithTwoActions(
|
||||
alertTitle: S.of(context).change_language,
|
||||
alertContent: S.of(context).change_language_to(item),
|
||||
rightButtonText: S.of(context).change,
|
||||
leftButtonText: S.of(context).cancel,
|
||||
actionRightButton: () {
|
||||
settingsStore.saveLanguageCode(
|
||||
languageCode: code);
|
||||
currentLanguage.setCurrentLanguage(code);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
actionLeftButton: () => Navigator.of(context).pop()
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,105 +1,81 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:cake_wallet/src/stores/user/user_store.dart';
|
||||
import 'package:cake_wallet/src/screens/pin_code/pin_code.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart';
|
||||
import 'package:cake_wallet/view_model/setup_pin_code_view_model.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||
|
||||
class SetupPinCodePage extends BasePage {
|
||||
SetupPinCodePage({this.onPinCodeSetup});
|
||||
SetupPinCodePage(this.pinCodeViewModel, {this.onSuccessfulPinSetup});
|
||||
|
||||
final Function(BuildContext, String) onPinCodeSetup;
|
||||
final SetupPinCodeViewModel pinCodeViewModel;
|
||||
final void Function(BuildContext, String) onSuccessfulPinSetup;
|
||||
|
||||
@override
|
||||
String get title => S.current.setup_pin;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) =>
|
||||
SetupPinCodeForm(onPinCodeSetup: onPinCodeSetup, hasLengthSwitcher: true);
|
||||
}
|
||||
Widget body(BuildContext context) => PinCodeWidget(
|
||||
hasLengthSwitcher: true,
|
||||
onFullPin: (String pin, PinCodeState<PinCodeWidget> state) async {
|
||||
if (pinCodeViewModel.isOriginalPinCodeFull && !pinCodeViewModel.isRepeatedPinCodeFull) {
|
||||
state.title = S.current.enter_your_pin_again;
|
||||
state.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
class SetupPinCodeForm extends PinCodeWidget {
|
||||
SetupPinCodeForm(
|
||||
{@required this.onPinCodeSetup, @required bool hasLengthSwitcher})
|
||||
: super(hasLengthSwitcher: hasLengthSwitcher);
|
||||
if (!pinCodeViewModel.isPinCodeCorrect) {
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithOneAction(
|
||||
alertTitle: S.current.setup_pin,
|
||||
alertContent: S.of(context).pin_is_incorrect,
|
||||
buttonText: S.of(context).ok,
|
||||
buttonAction: () => Navigator.of(context).pop());
|
||||
});
|
||||
pinCodeViewModel.reset();
|
||||
state.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
final Function(BuildContext, String) onPinCodeSetup;
|
||||
try {
|
||||
await pinCodeViewModel.setupPinCode();
|
||||
|
||||
@override
|
||||
_SetupPinCodeFormState createState() => _SetupPinCodeFormState();
|
||||
}
|
||||
|
||||
class _SetupPinCodeFormState<WidgetType extends SetupPinCodeForm>
|
||||
extends PinCodeState<WidgetType> {
|
||||
_SetupPinCodeFormState() {
|
||||
title = S.current.enter_your_pin;
|
||||
}
|
||||
|
||||
bool isEnteredOriginalPin() => _originalPin.isNotEmpty;
|
||||
Function(BuildContext) onPinCodeSetup;
|
||||
List<int> _originalPin = [];
|
||||
UserStore _userStore;
|
||||
SettingsStore _settingsStore;
|
||||
|
||||
@override
|
||||
void onPinCodeEntered(PinCodeState state) {
|
||||
if (!isEnteredOriginalPin()) {
|
||||
_originalPin = state.pin;
|
||||
state.title = S.current.enter_your_pin_again;
|
||||
state.clear();
|
||||
} else {
|
||||
if (listEquals<int>(state.pin, _originalPin)) {
|
||||
final String pin = state.pin.fold('', (ac, val) => ac + '$val');
|
||||
_userStore.set(password: pin);
|
||||
_settingsStore.setDefaultPinLength(pinLength: state.pinLength);
|
||||
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithOneAction(
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithOneAction(
|
||||
alertTitle: S.current.setup_pin,
|
||||
alertContent: S.of(context).setup_successful,
|
||||
buttonText: S.of(context).ok,
|
||||
buttonAction: () {
|
||||
Navigator.of(context).pop();
|
||||
widget.onPinCodeSetup(context, pin);
|
||||
reset();
|
||||
onSuccessfulPinSetup(context, pin);
|
||||
state.reset();
|
||||
},
|
||||
alertBarrierDismissible: false,
|
||||
);
|
||||
});
|
||||
} else {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithOneAction(
|
||||
);
|
||||
});
|
||||
} catch (e) {
|
||||
// FIXME: Add translation for alert content text.
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithOneAction(
|
||||
alertTitle: S.current.setup_pin,
|
||||
alertContent: S.of(context).pin_is_incorrect,
|
||||
alertContent:
|
||||
'Setup pin is failed with error: ${e.toString()}',
|
||||
buttonText: S.of(context).ok,
|
||||
buttonAction: () => Navigator.of(context).pop()
|
||||
);
|
||||
});
|
||||
|
||||
reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void reset() {
|
||||
clear();
|
||||
setTitle(S.current.enter_your_pin);
|
||||
_originalPin = [];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_userStore = Provider.of<UserStore>(context);
|
||||
_settingsStore = Provider.of<SettingsStore>(context);
|
||||
|
||||
return body(context);
|
||||
}
|
||||
buttonAction: () => Navigator.of(context).pop(),
|
||||
alertBarrierDismissible: false,
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
onChangedPin: (String pin) => pinCodeViewModel.pinCode = pin,
|
||||
onChangedPinLength: (int length) =>
|
||||
pinCodeViewModel.pinCodeLength = length,
|
||||
initialPinLength: pinCodeViewModel.pinCodeLength);
|
||||
}
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/stores/subaddress_list/subaddress_list_store.dart';
|
||||
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
|
||||
class SubaddressListPage extends BasePage {
|
||||
SubaddressListPage();
|
||||
|
||||
@override
|
||||
bool get isModalBackButton => true;
|
||||
|
||||
@override
|
||||
String get title => S.current.subaddress_title;
|
||||
|
||||
@override
|
||||
AppBarStyle get appBarStyle => AppBarStyle.withShadow;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
final walletStore = Provider.of<WalletStore>(context);
|
||||
final subaddressListStore = Provider.of<SubaddressListStore>(context);
|
||||
|
||||
final currentColor = Theme.of(context).selectedRowColor;
|
||||
final notCurrentColor = Theme.of(context).backgroundColor;
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 20.0, bottom: 20.0),
|
||||
child: Observer(
|
||||
builder: (_) => ListView.separated(
|
||||
separatorBuilder: (_, __) => Divider(
|
||||
color: Theme.of(context).dividerTheme.color, height: 1.0),
|
||||
itemCount: subaddressListStore.subaddresses == null
|
||||
? 0
|
||||
: subaddressListStore.subaddresses.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final subaddress = subaddressListStore.subaddresses[index];
|
||||
final isCurrent =
|
||||
walletStore.subaddress.address == subaddress.address;
|
||||
final label = subaddress.label ?? subaddress.address;
|
||||
|
||||
return InkWell(
|
||||
onTap: () => Navigator.of(context).pop(subaddress),
|
||||
child: Container(
|
||||
color: isCurrent ? currentColor : notCurrentColor,
|
||||
child: Column(children: <Widget>[
|
||||
ListTile(
|
||||
title: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.headline
|
||||
.color),
|
||||
),
|
||||
)
|
||||
]),
|
||||
),
|
||||
);
|
||||
}),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,92 +1,88 @@
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:cake_wallet/exchange/trade.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/stores/exchange_trade/exchange_trade_store.dart';
|
||||
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:cake_wallet/utils/date_formatter.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
|
||||
import 'package:cake_wallet/src/widgets/standart_list_row.dart';
|
||||
|
||||
class TradeDetailsPage extends BasePage {
|
||||
TradeDetailsPage(this.trade) : _items = [] {
|
||||
final dateFormat = DateFormatter.withCurrentLocal();
|
||||
final items = [
|
||||
StandartListItem(title: S.current.trade_details_id, value: trade.id),
|
||||
StandartListItem(
|
||||
title: S.current.trade_details_state,
|
||||
value: trade.state != null
|
||||
? trade.state.toString()
|
||||
: S.current.trade_details_fetching)
|
||||
];
|
||||
|
||||
if (trade.provider != null) {
|
||||
items.add(StandartListItem(
|
||||
title: S.current.trade_details_provider,
|
||||
value: trade.provider.toString()));
|
||||
}
|
||||
|
||||
if (trade.createdAt != null) {
|
||||
items.add(StandartListItem(
|
||||
title: S.current.trade_details_created_at,
|
||||
value: dateFormat.format(trade.createdAt).toString()));
|
||||
}
|
||||
|
||||
if (trade.from != null && trade.to != null) {
|
||||
items.add(StandartListItem(
|
||||
title: S.current.trade_details_pair,
|
||||
value: '${trade.from.toString()} → ${trade.to.toString()}'));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String get title => S.current.trade_details_title;
|
||||
|
||||
final Trade trade;
|
||||
final List<StandartListItem> _items;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
final exchangeStore = Provider.of<ExchangeTradeStore>(context);
|
||||
final settingsStore = Provider.of<SettingsStore>(context);
|
||||
final createdAtFormat = settingsStore.getCurrentDateFormat(
|
||||
formatUSA: "yyyy.MM.dd, HH:mm",
|
||||
formatDefault: "dd.MM.yyyy, HH:mm");
|
||||
|
||||
return Container(
|
||||
child: Observer(builder: (_) {
|
||||
final trade = exchangeStore.trade;
|
||||
final items = [
|
||||
StandartListItem(
|
||||
title: S.of(context).trade_details_id, value: trade.id),
|
||||
StandartListItem(
|
||||
title: S.of(context).trade_details_state,
|
||||
value: trade.state != null
|
||||
? trade.state.toString()
|
||||
: S.of(context).trade_details_fetching)
|
||||
];
|
||||
|
||||
if (trade.provider != null) {
|
||||
items.add(StandartListItem(
|
||||
title: S.of(context).trade_details_provider,
|
||||
value: trade.provider.toString()));
|
||||
}
|
||||
|
||||
if (trade.createdAt != null) {
|
||||
items.add(StandartListItem(
|
||||
title: S.of(context).trade_details_created_at,
|
||||
value: createdAtFormat.format(trade.createdAt).toString()));
|
||||
}
|
||||
|
||||
if (trade.from != null && trade.to != null) {
|
||||
items.add(StandartListItem(
|
||||
title: S.of(context).trade_details_pair,
|
||||
value: '${trade.from.toString()} → ${trade.to.toString()}'));
|
||||
}
|
||||
|
||||
return ListView.separated(
|
||||
separatorBuilder: (_, __) => Container(
|
||||
height: 1,
|
||||
padding: EdgeInsets.only(left: 24),
|
||||
color: Theme.of(context).backgroundColor,
|
||||
child: Container(
|
||||
return Container(child: Observer(builder: (_) {
|
||||
return ListView.separated(
|
||||
separatorBuilder: (_, __) => Container(
|
||||
height: 1,
|
||||
padding: EdgeInsets.only(left: 24),
|
||||
color: Theme.of(context).backgroundColor,
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: Theme.of(context).primaryTextTheme.title.backgroundColor,
|
||||
),
|
||||
),
|
||||
itemCount: items.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final item = items[index];
|
||||
final isDrawBottom = index == items.length - 1 ? true : false;
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.title
|
||||
.backgroundColor)),
|
||||
itemCount: _items.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final item = _items[index];
|
||||
final isDrawBottom = index == _items.length - 1 ? true : false;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(text: '${item.value}'));
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
S.of(context).trade_details_copied(item.title)),
|
||||
backgroundColor: Colors.green,
|
||||
duration: Duration(milliseconds: 1500),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: StandartListRow(
|
||||
title: '${item.title}',
|
||||
value: '${item.value}',
|
||||
isDrawBottom: isDrawBottom,
|
||||
));
|
||||
});
|
||||
}));
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(text: '${item.value}'));
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content:
|
||||
Text(S.of(context).trade_details_copied(item.title)),
|
||||
backgroundColor: Colors.green,
|
||||
duration: Duration(milliseconds: 1500),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: StandartListRow(
|
||||
title: '${item.title}',
|
||||
value: '${item.value}',
|
||||
isDrawBottom: isDrawBottom,
|
||||
));
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_transaction_info.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/monero_transaction_info.dart';
|
||||
import 'package:cake_wallet/src/domain/common/transaction_info.dart';
|
||||
import 'package:cake_wallet/monero/monero_transaction_info.dart';
|
||||
import 'package:cake_wallet/entities/transaction_info.dart';
|
||||
import 'package:cake_wallet/src/widgets/standart_list_row.dart';
|
||||
import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/utils/date_formatter.dart';
|
||||
|
||||
class TransactionDetailsPage extends BasePage {
|
||||
TransactionDetailsPage({this.transactionInfo}) : _items = [] {
|
||||
// FIXME
|
||||
// final _dateFormat = widget.settingsStore.getCurrentDateFormat(
|
||||
// formatUSA: "yyyy.MM.dd, HH:mm", formatDefault: "dd.MM.yyyy, HH:mm");
|
||||
final dateFormat = DateFormat('dd.MM.yyyy, HH:mm');
|
||||
TransactionDetailsPage(this.transactionInfo) : _items = [] {
|
||||
final dateFormat = DateFormatter.withCurrentLocal();
|
||||
final tx = transactionInfo;
|
||||
|
||||
if (tx is MoneroTransactionInfo) {
|
||||
@@ -50,8 +46,7 @@ class TransactionDetailsPage extends BasePage {
|
||||
title: S.current.transaction_details_date,
|
||||
value: dateFormat.format(tx.date)),
|
||||
StandartListItem(
|
||||
title: 'Confirmations',
|
||||
value: tx.confirmations?.toString()),
|
||||
title: 'Confirmations', value: tx.confirmations?.toString()),
|
||||
StandartListItem(
|
||||
title: S.current.transaction_details_height, value: '${tx.height}'),
|
||||
StandartListItem(
|
||||
@@ -80,7 +75,8 @@ class TransactionDetailsPage extends BasePage {
|
||||
color: Theme.of(context).backgroundColor,
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: Theme.of(context).primaryTextTheme.title.backgroundColor,
|
||||
color:
|
||||
Theme.of(context).primaryTextTheme.title.backgroundColor,
|
||||
),
|
||||
),
|
||||
itemCount: _items.length,
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/stores/wallet_list/wallet_list_store.dart';
|
||||
// import 'package:cake_wallet/src/stores/wallet_list/wallet_list_store.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart';
|
||||
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
|
||||
Reference in New Issue
Block a user