This commit is contained in:
M 2020-10-24 15:55:24 +03:00
parent 0c197660a8
commit 588d93c1a4
6 changed files with 82 additions and 85 deletions

View file

@ -354,7 +354,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 8; CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = 32J6BB6VUS; DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
@ -493,7 +493,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 8; CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = 32J6BB6VUS; DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
@ -526,7 +526,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 8; CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = 32J6BB6VUS; DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (

View file

@ -89,8 +89,8 @@ class XMRTOExchangeProvider extends ExchangeProvider {
final url = await getApiUri() + _orderCreateUriSufix; final url = await getApiUri() + _orderCreateUriSufix;
final body = { final body = {
'amount': _request.isBTCRequest 'amount': _request.isBTCRequest
? _request.receiveAmount ? _request.receiveAmount.replaceAll(',', '.')
: _request.amount, : _request.amount.replaceAll(',', '.'),
'amount_currency': _request.isBTCRequest 'amount_currency': _request.isBTCRequest
? _request.to.toString() ? _request.to.toString()
: _request.from.toString(), : _request.from.toString(),
@ -146,9 +146,9 @@ class XMRTOExchangeProvider extends ExchangeProvider {
} }
final responseJSON = json.decode(response.body) as Map<String, dynamic>; final responseJSON = json.decode(response.body) as Map<String, dynamic>;
final address = responseJSON['xmr_receiving_integrated_address'] as String; final address = responseJSON['receiving_subaddress'] as String;
final paymentId = responseJSON['xmr_required_payment_id_short'] as String; final paymentId = responseJSON['xmr_required_payment_id_short'] as String;
final amount = responseJSON['xmr_amount_total'].toString(); final amount = responseJSON['incoming_amount_total'].toString();
final stateRaw = responseJSON['state'] as String; final stateRaw = responseJSON['state'] as String;
final expiredAtRaw = responseJSON['expires_at'] as String; final expiredAtRaw = responseJSON['expires_at'] as String;
final expiredAt = DateTime.parse(expiredAtRaw).toLocal(); final expiredAt = DateTime.parse(expiredAtRaw).toLocal();

View file

@ -1,26 +1,25 @@
import 'dart:ui'; import 'dart:ui';
import 'package:cake_wallet/exchange/exchange_provider.dart';
import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/exchange/exchange_template.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
import 'package:cake_wallet/src/widgets/template_tile.dart';
import 'package:cake_wallet/src/widgets/trail_button.dart';
import 'package:cake_wallet/utils/show_pop_up.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:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:keyboard_actions/keyboard_actions.dart'; import 'package:keyboard_actions/keyboard_actions.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:cake_wallet/exchange/exchange_provider.dart';
import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/exchange/exchange_template.dart';
import 'package:cake_wallet/exchange/exchange_trade_state.dart';
import 'package:cake_wallet/exchange/limits_state.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/keyboard_done_button.dart';
import 'package:cake_wallet/src/widgets/template_tile.dart';
import 'package:cake_wallet/src/widgets/trail_button.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/entities/crypto_currency.dart'; import 'package:cake_wallet/entities/crypto_currency.dart';
import 'package:cake_wallet/exchange/xmrto/xmrto_exchange_provider.dart'; import 'package:cake_wallet/exchange/xmrto/xmrto_exchange_provider.dart';
// import 'package:cake_wallet/exchange/exchange_trade_state.dart';
// import 'package:cake_wallet/exchange/limits_state.dart';
import 'package:cake_wallet/src/screens/exchange/widgets/exchange_card.dart'; import 'package:cake_wallet/src/screens/exchange/widgets/exchange_card.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart'; import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart'; import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
@ -209,9 +208,10 @@ class ExchangePage extends BasePage {
exchangeViewModel.wallet.currency exchangeViewModel.wallet.currency
? exchangeViewModel.wallet.address ? exchangeViewModel.wallet.address
: exchangeViewModel.receiveAddress, : exchangeViewModel.receiveAddress,
initialIsAmountEditable: initialIsAmountEditable: exchangeViewModel
exchangeViewModel.provider is .provider is XMRTOExchangeProvider
XMRTOExchangeProvider ? true : false, ? true
: false,
initialIsAddressEditable: initialIsAddressEditable:
exchangeViewModel exchangeViewModel
.isReceiveAddressEnabled, .isReceiveAddressEnabled,
@ -401,7 +401,7 @@ class ExchangePage extends BasePage {
Theme.of(context).accentTextTheme.body2.color, Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white, textColor: Colors.white,
isLoading: exchangeViewModel.tradeState isLoading: exchangeViewModel.tradeState
is IsExecutingState, is TradeIsCreating,
)), )),
]), ]),
)), )),
@ -447,20 +447,16 @@ class ExchangePage extends BasePage {
final receiveAmountController = receiveKey.currentState.amountController; final receiveAmountController = receiveKey.currentState.amountController;
final limitsState = exchangeViewModel.limitsState; final limitsState = exchangeViewModel.limitsState;
// FIXME: FIXME if (limitsState is LimitsLoadedSuccessfully) {
final min = limitsState.limits.min != null
// final limitsState = exchangeViewModel.limitsState; ? limitsState.limits.min.toString()
// : null;
// if (limitsState is LimitsLoadedSuccessfully) { final max = limitsState.limits.max != null
// final min = limitsState.limits.min != null ? limitsState.limits.max.toString()
// ? limitsState.limits.min.toString() : null;
// : null; final key = depositKey;
// final max = limitsState.limits.max != null key.currentState.changeLimits(min: min, max: max);
// ? 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);
@ -523,55 +519,51 @@ class ExchangePage extends BasePage {
reaction((_) => exchangeViewModel.provider, (ExchangeProvider provider) { reaction((_) => exchangeViewModel.provider, (ExchangeProvider provider) {
provider is XMRTOExchangeProvider provider is XMRTOExchangeProvider
? receiveKey.currentState.isAmountEditable(isEditable: true) ? receiveKey.currentState.isAmountEditable(isEditable: true)
: receiveKey.currentState.isAmountEditable(isEditable: false); : receiveKey.currentState.isAmountEditable(isEditable: false);
}); });
// FIXME: FIXME reaction((_) => exchangeViewModel.tradeState, (ExchangeTradeState state) {
if (state is TradeIsCreatedFailure) {
WidgetsBinding.instance.addPostFrameCallback((_) {
showPopUp<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.tradeState, (ExchangeTradeState state) { reaction((_) => exchangeViewModel.limitsState, (LimitsState state) {
// if (state is TradeIsCreatedFailure) { String min;
// WidgetsBinding.instance.addPostFrameCallback((_) { String max;
// showPopUp<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 if (state is LimitsLoadedSuccessfully) {
min = state.limits.min != null ? state.limits.min.toString() : null;
max = state.limits.max != null ? state.limits.max.toString() : null;
}
// reaction((_) => exchangeViewModel.limitsState, (LimitsState state) { if (state is LimitsLoadedFailure) {
// String min; min = '0';
// String max; max = '0';
// }
// if (state is LimitsLoadedSuccessfully) {
// min = state.limits.min != null ? state.limits.min.toString() : null; if (state is LimitsIsLoading) {
// max = state.limits.max != null ? state.limits.max.toString() : null; min = '...';
// } max = '...';
// }
// if (state is LimitsLoadedFailure) {
// min = '0'; depositKey.currentState.changeLimits(min: min, max: max);
// max = '0'; receiveKey.currentState.changeLimits(min: null, max: null);
// } });
//
// 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

@ -138,7 +138,9 @@ abstract class DashboardViewModelBase with Store {
appStore.settingsStore.balanceDisplayMode; appStore.settingsStore.balanceDisplayMode;
@computed @computed
List<TradeListItem> get trades => tradesStore.trades; List<TradeListItem> get trades => tradesStore.trades
.where((trade) => trade.trade.walletId == wallet.id)
.toList();
@computed @computed
double get price => balanceViewModel.price; double get price => balanceViewModel.price;
@ -153,6 +155,7 @@ abstract class DashboardViewModelBase with Store {
return formattedItemsList(_items); return formattedItemsList(_items);
} }
@observable
WalletBase wallet; WalletBase wallet;
BalanceViewModel balanceViewModel; BalanceViewModel balanceViewModel;
@ -174,7 +177,9 @@ abstract class DashboardViewModelBase with Store {
await wallet.connectToNode(node: node); await wallet.connectToNode(node: node);
} }
@action
void _onWalletChange(WalletBase wallet) { void _onWalletChange(WalletBase wallet) {
this.wallet = wallet;
name = wallet.name; name = wallet.name;
transactions.clear(); transactions.clear();
transactions.addAll(wallet.transactionHistory.transactions.values.map( transactions.addAll(wallet.transactionHistory.transactions.values.map(

View file

@ -137,7 +137,7 @@ abstract class ExchangeViewModelBase with Store {
return; return;
} }
final _amount = double.parse(amount) ?? 0; final _amount = double.parse(amount.replaceAll(',', '.')) ?? 0;
provider provider
.calculateAmount( .calculateAmount(
@ -160,7 +160,7 @@ abstract class ExchangeViewModelBase with Store {
return; return;
} }
final _amount = double.parse(amount); final _amount = double.parse(amount.replaceAll(',', '.'));
provider provider
.calculateAmount( .calculateAmount(
from: depositCurrency, to: receiveCurrency, amount: _amount, from: depositCurrency, to: receiveCurrency, amount: _amount,

View file

@ -930,7 +930,7 @@ packages:
name: url_launcher name: url_launcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.7.6" version: "5.7.7"
url_launcher_linux: url_launcher_linux:
dependency: transitive dependency: transitive
description: description: