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(
fontSize: 18.0,
fontWeight: FontWeight.bold,
fontFamily: 'Poppins',
color: titleColor ??
Theme.of(context).primaryTextTheme.title.color),
);

View file

@ -1,29 +1,28 @@
import 'dart:ui';
import 'package:cake_wallet/core/address_validator.dart';
import 'package:cake_wallet/core/amount_validator.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/exchange/exchange_template.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/src/widgets/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/trail_button.dart';
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/cupertino.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: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 {
ExchangePage(this.exchangeViewModel);
@ -365,10 +364,10 @@ class ExchangePage extends BasePage {
exchangeViewModel.createTrade();
}
},
color: Palette.blueCraiola,
color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white,
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 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);
@ -484,47 +487,51 @@ class ExchangePage extends BasePage {
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);

View file

@ -1,20 +1,24 @@
import 'dart:ui';
import 'package:cake_wallet/core/address_validator.dart';
import 'package:cake_wallet/core/amount_validator.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/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:cake_wallet/exchange/exchange_template.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:flutter/cupertino.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: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 {
ExchangeTemplatePage(this.exchangeViewModel);
@ -249,16 +253,20 @@ class ExchangeTemplatePage extends BasePage {
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);
@ -319,7 +327,7 @@ class ExchangeTemplatePage extends BasePage {
receiveKey.currentState.isAddressEditable(isEditable: isEnabled);
});
reaction((_) => exchangeViewModel.limitsState, (LimitsState state) {
/*reaction((_) => exchangeViewModel.limitsState, (LimitsState state) {
String min;
String max;
@ -340,7 +348,7 @@ class ExchangeTemplatePage extends BasePage {
depositKey.currentState.changeLimits(min: min, max: max);
receiveKey.currentState.changeLimits(min: null, max: null);
});
});*/
depositAddressController.addListener(
() => exchangeViewModel.depositAddress = depositAddressController.text);

View file

@ -1,26 +1,28 @@
import 'dart:ui';
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/src/domain/common/transaction_priority.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/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/material.dart';
import 'package:cake_wallet/view_model/send/send_view_model.dart';
import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/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/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: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/view_model/send/send_view_model_state.dart';
import 'package:cake_wallet/src/widgets/trail_button.dart';
import 'package:dotted_border/dotted_border.dart';
import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart';
// import 'package:cake_wallet/src/screens/send/widgets/sending_alert.dart';
import 'package:cake_wallet/src/widgets/template_tile.dart';
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
import 'package:cake_wallet/routes.dart';
class SendPage extends BasePage {
SendPage({@required this.sendViewModel});
@ -429,13 +431,13 @@ class SendPage extends BasePage {
return LoadingPrimaryButton(
onPressed: () {
if (_formKey.currentState.validate()) {
print('SENT!!!');
}
},
text: S.of(context).send,
color: Palette.blueCraiola,
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),
@ -487,8 +489,8 @@ class SendPage extends BasePage {
}
});
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,
@ -502,7 +504,7 @@ class SendPage extends BasePage {
});
}
if (state is TransactionCreatedSuccessfully) {
if (state is ExecutedSuccessfullyState) {
WidgetsBinding.instance.addPostFrameCallback((_) {
showDialog<void>(
context: context,
@ -562,7 +564,7 @@ class SendPage extends BasePage {
onPressed: () =>
Navigator.of(context).pop(),
text: S.of(context).send_got_it,
color: Colors.blue,
color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white))
],
);
@ -648,19 +650,19 @@ class SendPage extends BasePage {
}
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);
}
}

View file

@ -9,7 +9,7 @@ packages:
source: hosted
version: "6.0.0"
analyzer:
dependency: "direct overridden"
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
@ -211,6 +211,34 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
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:
dependency: transitive
description:
@ -252,7 +280,7 @@ packages:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.9"
version: "1.3.6"
dartx:
dependency: "direct overridden"
description:
@ -809,7 +837,7 @@ packages:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.4+4"
version: "0.9.7+1"
source_span:
dependency: transitive
description: