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 = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@ -493,7 +493,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@ -526,7 +526,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 8;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = 32J6BB6VUS;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (

View file

@ -89,8 +89,8 @@ class XMRTOExchangeProvider extends ExchangeProvider {
final url = await getApiUri() + _orderCreateUriSufix;
final body = {
'amount': _request.isBTCRequest
? _request.receiveAmount
: _request.amount,
? _request.receiveAmount.replaceAll(',', '.')
: _request.amount.replaceAll(',', '.'),
'amount_currency': _request.isBTCRequest
? _request.to.toString()
: _request.from.toString(),
@ -146,9 +146,9 @@ class XMRTOExchangeProvider extends ExchangeProvider {
}
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 amount = responseJSON['xmr_amount_total'].toString();
final amount = responseJSON['incoming_amount_total'].toString();
final stateRaw = responseJSON['state'] as String;
final expiredAtRaw = responseJSON['expires_at'] as String;
final expiredAt = DateTime.parse(expiredAtRaw).toLocal();

View file

@ -1,26 +1,25 @@
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:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:keyboard_actions/keyboard_actions.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/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';
@ -209,9 +208,10 @@ class ExchangePage extends BasePage {
exchangeViewModel.wallet.currency
? exchangeViewModel.wallet.address
: exchangeViewModel.receiveAddress,
initialIsAmountEditable:
exchangeViewModel.provider is
XMRTOExchangeProvider ? true : false,
initialIsAmountEditable: exchangeViewModel
.provider is XMRTOExchangeProvider
? true
: false,
initialIsAddressEditable:
exchangeViewModel
.isReceiveAddressEnabled,
@ -401,7 +401,7 @@ class ExchangePage extends BasePage {
Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white,
isLoading: exchangeViewModel.tradeState
is IsExecutingState,
is TradeIsCreating,
)),
]),
)),
@ -447,20 +447,16 @@ class ExchangePage extends BasePage {
final receiveAmountController = receiveKey.currentState.amountController;
final limitsState = exchangeViewModel.limitsState;
// 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);
// }
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);
@ -527,51 +523,47 @@ class ExchangePage extends BasePage {
: 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) {
// 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.limitsState, (LimitsState state) {
String min;
String max;
// 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) {
// 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);
// });
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

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

View file

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

View file

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