mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
Merge pull request #91 from cake-tech/CAKE-284-add-support-to-the-main-menu
Cake 284 add support to the main menu
This commit is contained in:
commit
fd2cf98e51
3 changed files with 42 additions and 54 deletions
|
@ -158,30 +158,17 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
|
||||||
? DateTime.parse(expiredAtRaw).toLocal()
|
? DateTime.parse(expiredAtRaw).toLocal()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (expiredAt != null) {
|
return Trade(
|
||||||
return Trade(
|
id: id,
|
||||||
id: id,
|
from: from,
|
||||||
from: from,
|
to: to,
|
||||||
to: to,
|
provider: description,
|
||||||
provider: description,
|
inputAddress: inputAddress,
|
||||||
inputAddress: inputAddress,
|
amount: expectedSendAmount,
|
||||||
amount: expectedSendAmount,
|
state: state,
|
||||||
state: state,
|
extraId: extraId,
|
||||||
extraId: extraId,
|
expiredAt: expiredAt,
|
||||||
expiredAt: expiredAt,
|
outputTransaction: outputTransaction);
|
||||||
outputTransaction: outputTransaction);
|
|
||||||
} else {
|
|
||||||
return Trade(
|
|
||||||
id: id,
|
|
||||||
from: from,
|
|
||||||
to: to,
|
|
||||||
provider: description,
|
|
||||||
inputAddress: inputAddress,
|
|
||||||
amount: expectedSendAmount,
|
|
||||||
state: state,
|
|
||||||
extraId: extraId,
|
|
||||||
outputTransaction: outputTransaction);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -215,23 +202,7 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
|
||||||
|
|
||||||
return estimatedAmount;
|
return estimatedAmount;
|
||||||
} else {
|
} else {
|
||||||
final url = isFixedRateMode
|
final url = defineUrlForCalculatingAmount(from, to, amount, isFixedRateMode);
|
||||||
? apiUri +
|
|
||||||
_exchangeAmountUriSufix +
|
|
||||||
_fixedRateUriSufix +
|
|
||||||
amount.toString() +
|
|
||||||
'/' +
|
|
||||||
from.toString() +
|
|
||||||
'_' +
|
|
||||||
to.toString() +
|
|
||||||
'?api_key=' + apiKey
|
|
||||||
: apiUri +
|
|
||||||
_exchangeAmountUriSufix +
|
|
||||||
amount.toString() +
|
|
||||||
'/' +
|
|
||||||
from.toString() +
|
|
||||||
'_' +
|
|
||||||
to.toString();
|
|
||||||
final response = await get(url);
|
final response = await get(url);
|
||||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||||
final estimatedAmount = responseJSON['estimatedAmount'] as double;
|
final estimatedAmount = responseJSON['estimatedAmount'] as double;
|
||||||
|
@ -239,4 +210,28 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
|
||||||
return estimatedAmount;
|
return estimatedAmount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String defineUrlForCalculatingAmount(
|
||||||
|
CryptoCurrency from,
|
||||||
|
CryptoCurrency to,
|
||||||
|
double amount,
|
||||||
|
bool isFixedRateMode) {
|
||||||
|
return isFixedRateMode
|
||||||
|
? apiUri +
|
||||||
|
_exchangeAmountUriSufix +
|
||||||
|
_fixedRateUriSufix +
|
||||||
|
amount.toString() +
|
||||||
|
'/' +
|
||||||
|
from.toString() +
|
||||||
|
'_' +
|
||||||
|
to.toString() +
|
||||||
|
'?api_key=' + apiKey
|
||||||
|
: apiUri +
|
||||||
|
_exchangeAmountUriSufix +
|
||||||
|
amount.toString() +
|
||||||
|
'/' +
|
||||||
|
from.toString() +
|
||||||
|
'_' +
|
||||||
|
to.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,11 @@ import 'package:cake_wallet/entities/node.dart';
|
||||||
import 'package:cake_wallet/entities/monero_transaction_priority.dart';
|
import 'package:cake_wallet/entities/monero_transaction_priority.dart';
|
||||||
import 'package:cake_wallet/entities/action_list_display_mode.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/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/picker_list_item.dart';
|
||||||
import 'package:cake_wallet/view_model/settings/regular_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';
|
import 'package:cake_wallet/view_model/settings/settings_list_item.dart';
|
||||||
import 'package:cake_wallet/view_model/settings/switcher_list_item.dart';
|
import 'package:cake_wallet/view_model/settings/switcher_list_item.dart';
|
||||||
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
part 'settings_view_model.g.dart';
|
part 'settings_view_model.g.dart';
|
||||||
|
|
||||||
|
@ -152,20 +150,12 @@ abstract class SettingsViewModelBase with Store {
|
||||||
title: S.current.settings_terms_and_conditions,
|
title: S.current.settings_terms_and_conditions,
|
||||||
handler: (BuildContext context) =>
|
handler: (BuildContext context) =>
|
||||||
Navigator.of(context).pushNamed(Routes.readDisclaimer),
|
Navigator.of(context).pushNamed(Routes.readDisclaimer),
|
||||||
),
|
|
||||||
RegularListItem(
|
|
||||||
title: S.current.faq,
|
|
||||||
handler: (BuildContext context) async {
|
|
||||||
if (await canLaunch(url)) await launch(url);
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
[VersionListItem(title: currentVersion)]
|
[VersionListItem(title: currentVersion)]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
static const url = 'https://cakewallet.com/guide/';
|
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
String currentVersion;
|
String currentVersion;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import 'package:cake_wallet/generated/i18n.dart';
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
import 'package:cake_wallet/routes.dart';
|
|
||||||
import 'package:cake_wallet/view_model/settings/link_list_item.dart';
|
import 'package:cake_wallet/view_model/settings/link_list_item.dart';
|
||||||
import 'package:cake_wallet/view_model/settings/regular_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';
|
import 'package:cake_wallet/view_model/settings/settings_list_item.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
part 'support_view_model.g.dart';
|
part 'support_view_model.g.dart';
|
||||||
|
|
||||||
|
@ -16,8 +16,9 @@ abstract class SupportViewModelBase with Store {
|
||||||
items = [
|
items = [
|
||||||
RegularListItem(
|
RegularListItem(
|
||||||
title: S.current.faq,
|
title: S.current.faq,
|
||||||
handler: (BuildContext context) =>
|
handler: (BuildContext context) async {
|
||||||
Navigator.pushNamed(context, Routes.faq),
|
if (await canLaunch(url)) await launch(url);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
LinkListItem(
|
LinkListItem(
|
||||||
title: 'Email',
|
title: 'Email',
|
||||||
|
@ -40,5 +41,7 @@ abstract class SupportViewModelBase with Store {
|
||||||
link: 'mailto:support@changenow.io')
|
link: 'mailto:support@changenow.io')
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
static const url = 'https://cakewallet.com/guide/';
|
||||||
|
|
||||||
List<SettingsListItem> items;
|
List<SettingsListItem> items;
|
||||||
}
|
}
|
Loading…
Reference in a new issue