Fixes

M committed Oct 24, 2020 at 15:55 UTC 588d93c1a442df6e4868d0ff18901398bd3cfaaa
6 files changed +82 -85
ios/Runner.xcodeproj/project.pbxproj
+3 -3
@@ -354,7 +354,7 @@
354 buildSettings = {
355 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
356 CLANG_ENABLE_MODULES = YES;
357 - CURRENT_PROJECT_VERSION = 8;
357 + CURRENT_PROJECT_VERSION = 10;
358 DEVELOPMENT_TEAM = 32J6BB6VUS;
359 ENABLE_BITCODE = NO;
360 FRAMEWORK_SEARCH_PATHS = (
@@ -493,7 +493,7 @@
493 buildSettings = {
494 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
495 CLANG_ENABLE_MODULES = YES;
496 - CURRENT_PROJECT_VERSION = 8;
496 + CURRENT_PROJECT_VERSION = 10;
497 DEVELOPMENT_TEAM = 32J6BB6VUS;
498 ENABLE_BITCODE = NO;
499 FRAMEWORK_SEARCH_PATHS = (
@@ -526,7 +526,7 @@
526 buildSettings = {
527 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
528 CLANG_ENABLE_MODULES = YES;
529 - CURRENT_PROJECT_VERSION = 8;
529 + CURRENT_PROJECT_VERSION = 10;
530 DEVELOPMENT_TEAM = 32J6BB6VUS;
531 ENABLE_BITCODE = NO;
532 FRAMEWORK_SEARCH_PATHS = (
lib/exchange/xmrto/xmrto_exchange_provider.dart
+4 -4
@@ -89,8 +89,8 @@ class XMRTOExchangeProvider extends ExchangeProvider {
89 final url = await getApiUri() + _orderCreateUriSufix;
90 final body = {
91 'amount': _request.isBTCRequest
92 - ? _request.receiveAmount
93 - : _request.amount,
92 + ? _request.receiveAmount.replaceAll(',', '.')
93 + : _request.amount.replaceAll(',', '.'),
94 'amount_currency': _request.isBTCRequest
95 ? _request.to.toString()
96 : _request.from.toString(),
@@ -146,9 +146,9 @@ class XMRTOExchangeProvider extends ExchangeProvider {
146 }
147
148 final responseJSON = json.decode(response.body) as Map<String, dynamic>;
149 - final address = responseJSON['xmr_receiving_integrated_address'] as String;
149 + final address = responseJSON['receiving_subaddress'] as String;
150 final paymentId = responseJSON['xmr_required_payment_id_short'] as String;
151 - final amount = responseJSON['xmr_amount_total'].toString();
151 + final amount = responseJSON['incoming_amount_total'].toString();
152 final stateRaw = responseJSON['state'] as String;
153 final expiredAtRaw = responseJSON['expires_at'] as String;
154 final expiredAt = DateTime.parse(expiredAtRaw).toLocal();
lib/src/screens/exchange/exchange_page.dart
+66 -74
@@ -1,26 +1,25 @@
1 import 'dart:ui';
2 +import 'package:dotted_border/dotted_border.dart';
3 +import 'package:flutter/cupertino.dart';
4 +import 'package:flutter/material.dart';
5 +import 'package:flutter_mobx/flutter_mobx.dart';
6 +import 'package:keyboard_actions/keyboard_actions.dart';
7 +import 'package:mobx/mobx.dart';
8 import 'package:cake_wallet/exchange/exchange_provider.dart';
9 import 'package:cake_wallet/core/execution_state.dart';
10 import 'package:cake_wallet/exchange/exchange_template.dart';
11 +import 'package:cake_wallet/exchange/exchange_trade_state.dart';
12 +import 'package:cake_wallet/exchange/limits_state.dart';
13 import 'package:cake_wallet/src/screens/base_page.dart';
14 import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
15 import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
16 import 'package:cake_wallet/src/widgets/template_tile.dart';
17 import 'package:cake_wallet/src/widgets/trail_button.dart';
18 import 'package:cake_wallet/utils/show_pop_up.dart';
11 -import 'package:dotted_border/dotted_border.dart';
12 -import 'package:flutter/cupertino.dart';
13 -import 'package:flutter/material.dart';
14 -import 'package:flutter_mobx/flutter_mobx.dart';
15 -import 'package:keyboard_actions/keyboard_actions.dart';
16 -import 'package:mobx/mobx.dart';
19 import 'package:cake_wallet/routes.dart';
20 import 'package:cake_wallet/generated/i18n.dart';
21 import 'package:cake_wallet/entities/crypto_currency.dart';
22 import 'package:cake_wallet/exchange/xmrto/xmrto_exchange_provider.dart';
21 -
22 -// import 'package:cake_wallet/exchange/exchange_trade_state.dart';
23 -// import 'package:cake_wallet/exchange/limits_state.dart';
23 import 'package:cake_wallet/src/screens/exchange/widgets/exchange_card.dart';
24 import 'package:cake_wallet/src/widgets/primary_button.dart';
25 import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
@@ -209,9 +208,10 @@ class ExchangePage extends BasePage {
208 exchangeViewModel.wallet.currency
209 ? exchangeViewModel.wallet.address
210 : exchangeViewModel.receiveAddress,
212 - initialIsAmountEditable:
213 - exchangeViewModel.provider is
214 - XMRTOExchangeProvider ? true : false,
211 + initialIsAmountEditable: exchangeViewModel
212 + .provider is XMRTOExchangeProvider
213 + ? true
214 + : false,
215 initialIsAddressEditable:
216 exchangeViewModel
217 .isReceiveAddressEnabled,
@@ -401,7 +401,7 @@ class ExchangePage extends BasePage {
401 Theme.of(context).accentTextTheme.body2.color,
402 textColor: Colors.white,
403 isLoading: exchangeViewModel.tradeState
404 - is IsExecutingState,
404 + is TradeIsCreating,
405 )),
406 ]),
407 )),
@@ -447,20 +447,16 @@ class ExchangePage extends BasePage {
447 final receiveAmountController = receiveKey.currentState.amountController;
448 final limitsState = exchangeViewModel.limitsState;
449
450 - // FIXME: FIXME
451 -
452 - // final limitsState = exchangeViewModel.limitsState;
453 - //
454 - // if (limitsState is LimitsLoadedSuccessfully) {
455 - // final min = limitsState.limits.min != null
456 - // ? limitsState.limits.min.toString()
457 - // : null;
458 - // final max = limitsState.limits.max != null
459 - // ? limitsState.limits.max.toString()
460 - // : null;
461 - // final key = depositKey;
462 - // key.currentState.changeLimits(min: min, max: max);
463 - // }
450 + if (limitsState is LimitsLoadedSuccessfully) {
451 + final min = limitsState.limits.min != null
452 + ? limitsState.limits.min.toString()
453 + : null;
454 + final max = limitsState.limits.max != null
455 + ? limitsState.limits.max.toString()
456 + : null;
457 + final key = depositKey;
458 + key.currentState.changeLimits(min: min, max: max);
459 + }
460
461 _onCurrencyChange(
462 exchangeViewModel.receiveCurrency, exchangeViewModel, receiveKey);
@@ -523,55 +519,51 @@ class ExchangePage extends BasePage {
519
520 reaction((_) => exchangeViewModel.provider, (ExchangeProvider provider) {
521 provider is XMRTOExchangeProvider
526 - ? receiveKey.currentState.isAmountEditable(isEditable: true)
527 - : receiveKey.currentState.isAmountEditable(isEditable: false);
522 + ? receiveKey.currentState.isAmountEditable(isEditable: true)
523 + : receiveKey.currentState.isAmountEditable(isEditable: false);
524 });
525
530 - // FIXME: FIXME
531 -
532 - // reaction((_) => exchangeViewModel.tradeState, (ExchangeTradeState state) {
533 - // if (state is TradeIsCreatedFailure) {
534 - // WidgetsBinding.instance.addPostFrameCallback((_) {
535 - // showPopUp<void>(
536 - // context: context,
537 - // builder: (BuildContext context) {
538 - // return AlertWithOneAction(
539 - // alertTitle: S.of(context).error,
540 - // alertContent: state.error,
541 - // buttonText: S.of(context).ok,
542 - // buttonAction: () => Navigator.of(context).pop());
543 - // });
544 - // });
545 - // }
546 - // if (state is TradeIsCreatedSuccessfully) {
547 - // Navigator.of(context).pushNamed(Routes.exchangeConfirm);
548 - // }
549 - // });
550 -
551 - // FIXME: FIXME
552 -
553 - // reaction((_) => exchangeViewModel.limitsState, (LimitsState state) {
554 - // String min;
555 - // String max;
556 - //
557 - // if (state is LimitsLoadedSuccessfully) {
558 - // min = state.limits.min != null ? state.limits.min.toString() : null;
559 - // max = state.limits.max != null ? state.limits.max.toString() : null;
560 - // }
561 - //
562 - // if (state is LimitsLoadedFailure) {
563 - // min = '0';
564 - // max = '0';
565 - // }
566 - //
567 - // if (state is LimitsIsLoading) {
568 - // min = '...';
569 - // max = '...';
570 - // }
571 - //
572 - // depositKey.currentState.changeLimits(min: min, max: max);
573 - // receiveKey.currentState.changeLimits(min: null, max: null);
574 - // });
526 + reaction((_) => exchangeViewModel.tradeState, (ExchangeTradeState state) {
527 + if (state is TradeIsCreatedFailure) {
528 + WidgetsBinding.instance.addPostFrameCallback((_) {
529 + showPopUp<void>(
530 + context: context,
531 + builder: (BuildContext context) {
532 + return AlertWithOneAction(
533 + alertTitle: S.of(context).error,
534 + alertContent: state.error,
535 + buttonText: S.of(context).ok,
536 + buttonAction: () => Navigator.of(context).pop());
537 + });
538 + });
539 + }
540 + if (state is TradeIsCreatedSuccessfully) {
541 + Navigator.of(context).pushNamed(Routes.exchangeConfirm);
542 + }
543 + });
544 +
545 + reaction((_) => exchangeViewModel.limitsState, (LimitsState state) {
546 + String min;
547 + String max;
548 +
549 + if (state is LimitsLoadedSuccessfully) {
550 + min = state.limits.min != null ? state.limits.min.toString() : null;
551 + max = state.limits.max != null ? state.limits.max.toString() : null;
552 + }
553 +
554 + if (state is LimitsLoadedFailure) {
555 + min = '0';
556 + max = '0';
557 + }
558 +
559 + if (state is LimitsIsLoading) {
560 + min = '...';
561 + max = '...';
562 + }
563 +
564 + depositKey.currentState.changeLimits(min: min, max: max);
565 + receiveKey.currentState.changeLimits(min: null, max: null);
566 + });
567
568 depositAddressController.addListener(
569 () => exchangeViewModel.depositAddress = depositAddressController.text);
lib/view_model/dashboard/dashboard_view_model.dart
+6 -1
@@ -138,7 +138,9 @@ abstract class DashboardViewModelBase with Store {
138 appStore.settingsStore.balanceDisplayMode;
139
140 @computed
141 - List<TradeListItem> get trades => tradesStore.trades;
141 + List<TradeListItem> get trades => tradesStore.trades
142 + .where((trade) => trade.trade.walletId == wallet.id)
143 + .toList();
144
145 @computed
146 double get price => balanceViewModel.price;
@@ -153,6 +155,7 @@ abstract class DashboardViewModelBase with Store {
155 return formattedItemsList(_items);
156 }
157
158 + @observable
159 WalletBase wallet;
160
161 BalanceViewModel balanceViewModel;
@@ -174,7 +177,9 @@ abstract class DashboardViewModelBase with Store {
177 await wallet.connectToNode(node: node);
178 }
179
180 + @action
181 void _onWalletChange(WalletBase wallet) {
182 + this.wallet = wallet;
183 name = wallet.name;
184 transactions.clear();
185 transactions.addAll(wallet.transactionHistory.transactions.values.map(
lib/view_model/exchange/exchange_view_model.dart
+2 -2
@@ -137,7 +137,7 @@ abstract class ExchangeViewModelBase with Store {
137 return;
138 }
139
140 - final _amount = double.parse(amount) ?? 0;
140 + final _amount = double.parse(amount.replaceAll(',', '.')) ?? 0;
141
142 provider
143 .calculateAmount(
@@ -160,7 +160,7 @@ abstract class ExchangeViewModelBase with Store {
160 return;
161 }
162
163 - final _amount = double.parse(amount);
163 + final _amount = double.parse(amount.replaceAll(',', '.'));
164 provider
165 .calculateAmount(
166 from: depositCurrency, to: receiveCurrency, amount: _amount,
pubspec.lock
+1 -1
@@ -930,7 +930,7 @@ packages:
930 name: url_launcher
931 url: "https://pub.dartlang.org"
932 source: hosted
933 - version: "5.7.6"
933 + version: "5.7.7"
934 url_launcher_linux:
935 dependency: transitive
936 description: