CAKE-284 | added static function defineUrlForCalculatingAmount() to changenow_exchange_provider.dart; fixed FAQ in the support_view_model.dart

This commit is contained in:
OleksandrSobol 2021-03-01 20:16:28 +02:00
parent 5b242002d1
commit 6245dfe885
3 changed files with 42 additions and 44 deletions

View file

@ -158,7 +158,6 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
? DateTime.parse(expiredAtRaw).toLocal()
: null;
if (expiredAt != null) {
return Trade(
id: id,
from: from,
@ -170,18 +169,6 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
extraId: extraId,
expiredAt: expiredAt,
outputTransaction: outputTransaction);
} else {
return Trade(
id: id,
from: from,
to: to,
provider: description,
inputAddress: inputAddress,
amount: expectedSendAmount,
state: state,
extraId: extraId,
outputTransaction: outputTransaction);
}
}
@override
@ -215,7 +202,21 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
return estimatedAmount;
} else {
final url = isFixedRateMode
final url = defineUrlForCalculatingAmount(from, to, amount, isFixedRateMode);
final response = await get(url);
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
final estimatedAmount = responseJSON['estimatedAmount'] as double;
return estimatedAmount;
}
}
static String defineUrlForCalculatingAmount(
CryptoCurrency from,
CryptoCurrency to,
double amount,
bool isFixedRateMode) {
return isFixedRateMode
? apiUri +
_exchangeAmountUriSufix +
_fixedRateUriSufix +
@ -232,11 +233,5 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
from.toString() +
'_' +
to.toString();
final response = await get(url);
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
final estimatedAmount = responseJSON['estimatedAmount'] as double;
return estimatedAmount;
}
}
}

View file

@ -20,7 +20,6 @@ import 'package:cake_wallet/entities/node.dart';
import 'package:cake_wallet/entities/monero_transaction_priority.dart';
import 'package:cake_wallet/entities/action_list_display_mode.dart';
import 'package:cake_wallet/view_model/settings/version_list_item.dart';
import 'package:cake_wallet/view_model/settings/link_list_item.dart';
import 'package:cake_wallet/view_model/settings/picker_list_item.dart';
import 'package:cake_wallet/view_model/settings/regular_list_item.dart';
import 'package:cake_wallet/view_model/settings/settings_list_item.dart';

View file

@ -6,6 +6,7 @@ import 'package:cake_wallet/view_model/settings/settings_list_item.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:mobx/mobx.dart';
import 'package:url_launcher/url_launcher.dart';
part 'support_view_model.g.dart';
@ -16,8 +17,9 @@ abstract class SupportViewModelBase with Store {
items = [
RegularListItem(
title: S.current.faq,
handler: (BuildContext context) =>
Navigator.pushNamed(context, Routes.faq),
handler: (BuildContext context) async {
if (await canLaunch(url)) await launch(url);
},
),
LinkListItem(
title: 'Email',
@ -40,5 +42,7 @@ abstract class SupportViewModelBase with Store {
link: 'mailto:support@changenow.io')
];
}
static const url = 'https://cakewallet.com/guide/';
List<SettingsListItem> items;
}