CAKE-356 | added "Manage Yats" item to the settings page; reworked primary icon button; added yat address to qr widget; created yat_alert.dart, yat_webview_page.dart, yat_store.dart, yat_view_model.dart, yat_exception.dart, yat_record.dart

This commit is contained in:
OleksandrSobol
2021-08-20 16:26:00 +03:00
parent a2206f6fbd
commit 92aece5e31
18 changed files with 400 additions and 14 deletions
@@ -1,3 +1,5 @@
import 'package:cake_wallet/src/screens/yat/yat_alert.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:flutter/cupertino.dart';
import 'package:mobx/mobx.dart';
import 'package:package_info/package_info.dart';
@@ -154,6 +156,16 @@ abstract class SettingsViewModelBase with Store {
_settingsStore.currentTheme = theme)
],
[
RegularListItem(
title: 'Manage Yats',
handler: (BuildContext context) async {
await showPopUp<void>(
context: context,
builder: (BuildContext context) {
return YatAlert();
});
},
),
RegularListItem(
title: S.current.settings_terms_and_conditions,
handler: (BuildContext context) =>
@@ -1,3 +1,4 @@
import 'package:cake_wallet/store/yat_store.dart';
import 'package:flutter/foundation.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
@@ -59,7 +60,10 @@ class BitcoinURI extends PaymentURI {
}
abstract class WalletAddressListViewModelBase with Store {
WalletAddressListViewModelBase({@required AppStore appStore}) {
WalletAddressListViewModelBase({
@required AppStore appStore,
@required this.yatStore
}) {
_appStore = appStore;
_wallet = _appStore.wallet;
hasAccounts = _wallet?.type == WalletType.monero;
@@ -150,6 +154,9 @@ abstract class WalletAddressListViewModelBase with Store {
@computed
bool get hasAddressList => _wallet.type == WalletType.monero;
@computed
String get yatAddress => yatStore.yatAddress;
@observable
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>
_wallet;
@@ -158,6 +165,8 @@ abstract class WalletAddressListViewModelBase with Store {
AppStore _appStore;
final YatStore yatStore;
ReactionDisposer _onWalletChangeReaction;
@action
+37
View File
@@ -0,0 +1,37 @@
import 'package:cake_wallet/store/yat_store.dart';
import 'package:flutter/foundation.dart';
import 'package:mobx/mobx.dart';
import 'dart:convert';
import 'package:cake_wallet/yat/yat_exception.dart';
import 'package:http/http.dart';
part 'yat_view_model.g.dart';
class YatViewModel = YatViewModelBase with _$YatViewModel;
abstract class YatViewModelBase with Store {
YatViewModelBase({@required this.yatStore});
final YatStore yatStore;
Future<void> fetchCartInfo() async {
const _apiKey = ''; // FIXME
final url = 'https://api.y.at/cart';
final response = await get(
url,
headers: {
'Accept': '*/*',
'Authorization,X-Api-Key': _apiKey
}
);
if (response.statusCode != 200) {
throw YatException(text: response.body.toString());
}
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
yatStore.yatAddress = responseJSON[''] as String; // FIXME
}
}