CAKE-49 | merged new-world into current branch

This commit is contained in:
OleksandrSobol 2020-09-22 22:26:20 +03:00
parent a0164ec33f
commit 3212f5041f
5 changed files with 174 additions and 128 deletions

View file

@ -75,6 +75,7 @@ abstract class BasePage extends StatelessWidget {
style: TextStyle( style: TextStyle(
fontSize: 18.0, fontSize: 18.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontFamily: 'Poppins',
color: titleColor ?? color: titleColor ??
Theme.of(context).primaryTextTheme.title.color), Theme.of(context).primaryTextTheme.title.color),
); );

View file

@ -1,29 +1,28 @@
import 'dart:ui'; import 'dart:ui';
import 'package:cake_wallet/core/address_validator.dart'; import 'package:cake_wallet/exchange/exchange_template.dart';
import 'package:cake_wallet/core/amount_validator.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
import 'package:cake_wallet/src/domain/exchange/exchange_template.dart';
import 'package:cake_wallet/src/domain/exchange/xmrto/xmrto_exchange_provider.dart';
import 'package:cake_wallet/src/screens/exchange/widgets/exchange_card.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/src/widgets/alert_with_one_action.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
import 'package:cake_wallet/src/widgets/template_tile.dart'; import 'package:cake_wallet/src/widgets/template_tile.dart';
import 'package:cake_wallet/src/widgets/trail_button.dart';
import 'package:dotted_border/dotted_border.dart'; import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:cake_wallet/palette.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/screens/exchange/widgets/present_provider_picker.dart';
import 'package:cake_wallet/src/widgets/trail_button.dart';
import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/generated/i18n.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';
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart';
import 'package:cake_wallet/core/address_validator.dart';
import 'package:cake_wallet/core/amount_validator.dart';
import 'package:cake_wallet/src/screens/exchange/widgets/present_provider_picker.dart';
class ExchangePage extends BasePage { class ExchangePage extends BasePage {
ExchangePage(this.exchangeViewModel); ExchangePage(this.exchangeViewModel);
@ -365,10 +364,10 @@ class ExchangePage extends BasePage {
exchangeViewModel.createTrade(); exchangeViewModel.createTrade();
} }
}, },
color: Palette.blueCraiola, color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white, textColor: Colors.white,
isLoading: isLoading:
exchangeViewModel.tradeState is TradeIsCreating, false, // FIXME: FIXME exchangeViewModel.tradeState is TradeIsCreating,
)), )),
]), ]),
)), )),
@ -414,16 +413,20 @@ class ExchangePage extends BasePage {
final receiveAmountController = receiveKey.currentState.amountController; final receiveAmountController = receiveKey.currentState.amountController;
final limitsState = exchangeViewModel.limitsState; final limitsState = exchangeViewModel.limitsState;
if (limitsState is LimitsLoadedSuccessfully) { // FIXME: FIXME
final min = limitsState.limits.min != null
? limitsState.limits.min.toString() // final limitsState = exchangeViewModel.limitsState;
: null; //
final max = limitsState.limits.max != null // if (limitsState is LimitsLoadedSuccessfully) {
? limitsState.limits.max.toString() // final min = limitsState.limits.min != null
: null; // ? limitsState.limits.min.toString()
final key = depositKey; // : null;
key.currentState.changeLimits(min: min, max: max); // final max = limitsState.limits.max != null
} // ? limitsState.limits.max.toString()
// : null;
// final key = depositKey;
// key.currentState.changeLimits(min: min, max: max);
// }
_onCurrencyChange( _onCurrencyChange(
exchangeViewModel.receiveCurrency, exchangeViewModel, receiveKey); exchangeViewModel.receiveCurrency, exchangeViewModel, receiveKey);
@ -484,47 +487,51 @@ class ExchangePage extends BasePage {
receiveKey.currentState.isAddressEditable(isEditable: isEnabled); receiveKey.currentState.isAddressEditable(isEditable: isEnabled);
}); });
reaction((_) => exchangeViewModel.tradeState, (ExchangeTradeState state) { // FIXME: FIXME
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);
}
});
reaction((_) => exchangeViewModel.limitsState, (LimitsState state) { // reaction((_) => exchangeViewModel.tradeState, (ExchangeTradeState state) {
String min; // if (state is TradeIsCreatedFailure) {
String max; // 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) { // FIXME: FIXME
min = state.limits.min != null ? state.limits.min.toString() : null;
max = state.limits.max != null ? state.limits.max.toString() : null;
}
if (state is LimitsLoadedFailure) { // reaction((_) => exchangeViewModel.limitsState, (LimitsState state) {
min = '0'; // String min;
max = '0'; // String max;
} //
// if (state is LimitsLoadedSuccessfully) {
if (state is LimitsIsLoading) { // min = state.limits.min != null ? state.limits.min.toString() : null;
min = '...'; // max = state.limits.max != null ? state.limits.max.toString() : null;
max = '...'; // }
} //
// if (state is LimitsLoadedFailure) {
depositKey.currentState.changeLimits(min: min, max: max); // min = '0';
receiveKey.currentState.changeLimits(min: null, max: null); // max = '0';
}); // }
//
// if (state is LimitsIsLoading) {
// min = '...';
// max = '...';
// }
//
// depositKey.currentState.changeLimits(min: min, max: max);
// receiveKey.currentState.changeLimits(min: null, max: null);
// });
depositAddressController.addListener( depositAddressController.addListener(
() => exchangeViewModel.depositAddress = depositAddressController.text); () => exchangeViewModel.depositAddress = depositAddressController.text);

View file

@ -1,20 +1,24 @@
import 'dart:ui'; import 'dart:ui';
import 'package:cake_wallet/core/address_validator.dart'; import 'package:cake_wallet/exchange/exchange_template.dart';
import 'package:cake_wallet/core/amount_validator.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/domain/common/crypto_currency.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/src/domain/exchange/xmrto/xmrto_exchange_provider.dart';
import 'package:cake_wallet/src/screens/exchange/widgets/exchange_card.dart';
import 'package:cake_wallet/src/stores/exchange/limits_state.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/screens/exchange/widgets/present_provider_picker.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:cake_wallet/generated/i18n.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';
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
import 'package:cake_wallet/view_model/exchange/exchange_view_model.dart';
import 'package:cake_wallet/core/address_validator.dart';
import 'package:cake_wallet/core/amount_validator.dart';
import 'package:cake_wallet/src/screens/exchange/widgets/present_provider_picker.dart';
class ExchangeTemplatePage extends BasePage { class ExchangeTemplatePage extends BasePage {
ExchangeTemplatePage(this.exchangeViewModel); ExchangeTemplatePage(this.exchangeViewModel);
@ -249,16 +253,20 @@ class ExchangeTemplatePage extends BasePage {
final receiveAmountController = receiveKey.currentState.amountController; final receiveAmountController = receiveKey.currentState.amountController;
final limitsState = exchangeViewModel.limitsState; final limitsState = exchangeViewModel.limitsState;
if (limitsState is LimitsLoadedSuccessfully) { // FIXME: FIXME
final min = limitsState.limits.min != null
? limitsState.limits.min.toString() // final limitsState = exchangeViewModel.limitsState;
: null; //
final max = limitsState.limits.max != null // if (limitsState is LimitsLoadedSuccessfully) {
? limitsState.limits.max.toString() // final min = limitsState.limits.min != null
: null; // ? limitsState.limits.min.toString()
final key = depositKey; // : null;
key.currentState.changeLimits(min: min, max: max); // final max = limitsState.limits.max != null
} // ? limitsState.limits.max.toString()
// : null;
// final key = depositKey;
// key.currentState.changeLimits(min: min, max: max);
// }
_onCurrencyChange( _onCurrencyChange(
exchangeViewModel.receiveCurrency, exchangeViewModel, receiveKey); exchangeViewModel.receiveCurrency, exchangeViewModel, receiveKey);
@ -319,7 +327,7 @@ class ExchangeTemplatePage extends BasePage {
receiveKey.currentState.isAddressEditable(isEditable: isEnabled); receiveKey.currentState.isAddressEditable(isEditable: isEnabled);
}); });
reaction((_) => exchangeViewModel.limitsState, (LimitsState state) { /*reaction((_) => exchangeViewModel.limitsState, (LimitsState state) {
String min; String min;
String max; String max;
@ -340,7 +348,7 @@ class ExchangeTemplatePage extends BasePage {
depositKey.currentState.changeLimits(min: min, max: max); depositKey.currentState.changeLimits(min: min, max: max);
receiveKey.currentState.changeLimits(min: null, max: null); receiveKey.currentState.changeLimits(min: null, max: null);
}); });*/
depositAddressController.addListener( depositAddressController.addListener(
() => exchangeViewModel.depositAddress = depositAddressController.text); () => exchangeViewModel.depositAddress = depositAddressController.text);

View file

@ -1,26 +1,28 @@
import 'dart:ui'; 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/src/widgets/base_text_form_field.dart'; import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/picker.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';
import 'package:cake_wallet/src/widgets/trail_button.dart';
import 'package:cake_wallet/view_model/send/send_view_model_state.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:cake_wallet/view_model/send/send_view_model.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:cake_wallet/palette.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
import 'package:cake_wallet/src/widgets/address_text_field.dart'; import 'package:cake_wallet/src/widgets/address_text_field.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
import 'package:cake_wallet/view_model/send/send_view_model.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:dotted_border/dotted_border.dart';
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/view_model/send/send_view_model_state.dart'; import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart';
import 'package:cake_wallet/src/widgets/trail_button.dart'; // import 'package:cake_wallet/src/screens/send/widgets/sending_alert.dart';
import 'package:dotted_border/dotted_border.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';
class SendPage extends BasePage { class SendPage extends BasePage {
SendPage({@required this.sendViewModel}); SendPage({@required this.sendViewModel});
@ -429,13 +431,13 @@ class SendPage extends BasePage {
return LoadingPrimaryButton( return LoadingPrimaryButton(
onPressed: () { onPressed: () {
if (_formKey.currentState.validate()) { if (_formKey.currentState.validate()) {
print('SENT!!!');
} }
}, },
text: S.of(context).send, text: S.of(context).send,
color: Palette.blueCraiola, color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white, textColor: Colors.white,
isLoading: sendViewModel.state is TransactionIsCreating || isLoading: sendViewModel.state is IsExecutingState ||
sendViewModel.state is TransactionCommitting, sendViewModel.state is TransactionCommitting,
isDisabled: isDisabled:
false // FIXME !(syncStore.status is SyncedSyncStatus), false // FIXME !(syncStore.status is SyncedSyncStatus),
@ -487,8 +489,8 @@ class SendPage extends BasePage {
} }
}); });
reaction((_) => sendViewModel.state, (SendViewModelState state) { reaction((_) => sendViewModel.state, (ExecutionState state) {
if (state is SendingFailed) { if (state is FailureState) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
showDialog<void>( showDialog<void>(
context: context, context: context,
@ -502,7 +504,7 @@ class SendPage extends BasePage {
}); });
} }
if (state is TransactionCreatedSuccessfully) { if (state is ExecutedSuccessfullyState) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
showDialog<void>( showDialog<void>(
context: context, context: context,
@ -562,7 +564,7 @@ class SendPage extends BasePage {
onPressed: () => onPressed: () =>
Navigator.of(context).pop(), Navigator.of(context).pop(),
text: S.of(context).send_got_it, text: S.of(context).send_got_it,
color: Colors.blue, color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white)) textColor: Colors.white))
], ],
); );
@ -648,19 +650,19 @@ class SendPage extends BasePage {
} }
Future<void> _setTransactionPriority(BuildContext context) async { Future<void> _setTransactionPriority(BuildContext context) async {
final items = TransactionPriority.all; // final items = TransactionPriority.all;
final selectedItem = items.indexOf(sendViewModel.transactionPriority); // final selectedItem = items.indexOf(sendViewModel.transactionPriority);
//
await showDialog<void>( // await showDialog<void>(
builder: (_) => Picker( // builder: (_) => Picker(
items: items, // items: items,
selectedAtIndex: selectedItem, // selectedAtIndex: selectedItem,
title: S.of(context).please_select, // title: S.of(context).please_select,
mainAxisAlignment: MainAxisAlignment.center, // mainAxisAlignment: MainAxisAlignment.center,
onItemSelected: (TransactionPriority priority) => null, // onItemSelected: (TransactionPriority priority) => null,
// sendViewModel.setTransactionPriority(priority), // // sendViewModel.setTransactionPriority(priority),
isAlwaysShowScrollThumb: true, // isAlwaysShowScrollThumb: true,
), // ),
context: context); // context: context);
} }
} }

View file

@ -9,7 +9,7 @@ packages:
source: hosted source: hosted
version: "6.0.0" version: "6.0.0"
analyzer: analyzer:
dependency: "direct overridden" dependency: transitive
description: description:
name: analyzer name: analyzer
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
@ -211,6 +211,34 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.14.12" version: "1.14.12"
connectivity:
dependency: "direct main"
description:
name: connectivity
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.9+2"
connectivity_for_web:
dependency: transitive
description:
name: connectivity_for_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.1+2"
connectivity_macos:
dependency: transitive
description:
name: connectivity_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0+5"
connectivity_platform_interface:
dependency: transitive
description:
name: connectivity_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.6"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@ -252,7 +280,7 @@ packages:
name: dart_style name: dart_style
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.9" version: "1.3.6"
dartx: dartx:
dependency: "direct overridden" dependency: "direct overridden"
description: description:
@ -809,7 +837,7 @@ packages:
name: source_gen name: source_gen
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.9.4+4" version: "0.9.7+1"
source_span: source_span:
dependency: transitive dependency: transitive
description: description: