mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-21 06:18:42 +02:00
Flutter upgrade
This commit is contained in:
@@ -14,15 +14,15 @@ class AppStore = AppStoreBase with _$AppStore;
|
||||
|
||||
abstract class AppStoreBase with Store {
|
||||
AppStoreBase(
|
||||
{this.authenticationStore,
|
||||
this.walletList,
|
||||
this.settingsStore,
|
||||
this.nodeListStore});
|
||||
{required this.authenticationStore,
|
||||
required this.walletList,
|
||||
required this.settingsStore,
|
||||
required this.nodeListStore});
|
||||
|
||||
AuthenticationStore authenticationStore;
|
||||
|
||||
@observable
|
||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>
|
||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>?
|
||||
wallet;
|
||||
|
||||
WalletListStore walletList;
|
||||
|
||||
@@ -10,26 +10,26 @@ part 'orders_store.g.dart';
|
||||
class OrdersStore = OrdersStoreBase with _$OrdersStore;
|
||||
|
||||
abstract class OrdersStoreBase with Store {
|
||||
OrdersStoreBase({this.ordersSource, this.settingsStore}) {
|
||||
orders = <OrderListItem>[];
|
||||
|
||||
orderId = '';
|
||||
|
||||
OrdersStoreBase({required this.ordersSource,
|
||||
required this.settingsStore})
|
||||
: orders = <OrderListItem>[],
|
||||
orderId = '' {
|
||||
_onOrdersChanged =
|
||||
ordersSource.watch().listen((_) async => await updateOrderList());
|
||||
|
||||
updateOrderList();
|
||||
}
|
||||
|
||||
Box<Order> ordersSource;
|
||||
StreamSubscription<BoxEvent> _onOrdersChanged;
|
||||
|
||||
SettingsStore settingsStore;
|
||||
|
||||
StreamSubscription<BoxEvent>? _onOrdersChanged;
|
||||
|
||||
@observable
|
||||
List<OrderListItem> orders;
|
||||
|
||||
@observable
|
||||
Order order;
|
||||
Order? order;
|
||||
|
||||
@observable
|
||||
String orderId;
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract class TradeFilterStoreBase with Store {
|
||||
}
|
||||
}
|
||||
|
||||
List<TradeListItem> filtered({List<TradeListItem> trades, WalletBase wallet}) {
|
||||
List<TradeListItem> filtered({required List<TradeListItem> trades, required WalletBase wallet}) {
|
||||
final _trades =
|
||||
trades.where((item) => item.trade.walletId == wallet.id).toList();
|
||||
final needToFilter = !displayChangeNow || !displayXMRTO || !displayMorphToken || !displaySimpleSwap;
|
||||
|
||||
@@ -10,31 +10,34 @@ part 'trades_store.g.dart';
|
||||
class TradesStore = TradesStoreBase with _$TradesStore;
|
||||
|
||||
abstract class TradesStoreBase with Store {
|
||||
TradesStoreBase({this.tradesSource, this.settingsStore}) {
|
||||
trades = <TradeListItem>[];
|
||||
|
||||
TradesStoreBase({required this.tradesSource, required this.settingsStore})
|
||||
: trades = <TradeListItem>[] {
|
||||
_onTradesChanged =
|
||||
tradesSource.watch().listen((_) async => await updateTradeList());
|
||||
|
||||
updateTradeList();
|
||||
}
|
||||
|
||||
Box<Trade> tradesSource;
|
||||
StreamSubscription<BoxEvent> _onTradesChanged;
|
||||
StreamSubscription<BoxEvent>? _onTradesChanged;
|
||||
SettingsStore settingsStore;
|
||||
|
||||
@observable
|
||||
List<TradeListItem> trades;
|
||||
|
||||
@observable
|
||||
Trade trade;
|
||||
Trade? trade;
|
||||
|
||||
@action
|
||||
void setTrade(Trade trade) => this.trade = trade;
|
||||
|
||||
@action
|
||||
Future updateTradeList() async => trades =
|
||||
tradesSource.values.map((trade) => TradeListItem(
|
||||
trade: trade,
|
||||
settingsStore: settingsStore)).toList();
|
||||
Future<void> updateTradeList() async {
|
||||
if (trade == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
trades = tradesSource.values.map((trade) => TradeListItem(
|
||||
trade: trade!,
|
||||
settingsStore: settingsStore)).toList();
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,10 @@ abstract class TransactionFilterStoreBase with Store {
|
||||
bool displayOutgoing;
|
||||
|
||||
@observable
|
||||
DateTime startDate;
|
||||
DateTime? startDate;
|
||||
|
||||
@observable
|
||||
DateTime endDate;
|
||||
DateTime? endDate;
|
||||
|
||||
@action
|
||||
void toggleIncoming() => displayIncoming = !displayIncoming;
|
||||
@@ -35,7 +35,7 @@ abstract class TransactionFilterStoreBase with Store {
|
||||
@action
|
||||
void changeEndDate(DateTime date) => endDate = date;
|
||||
|
||||
List<TransactionListItem> filtered({List<TransactionListItem> transactions}) {
|
||||
List<TransactionListItem> filtered({required List<TransactionListItem> transactions}) {
|
||||
var _transactions = <TransactionListItem>[];
|
||||
final needToFilter = !displayOutgoing ||
|
||||
!displayIncoming ||
|
||||
@@ -46,8 +46,8 @@ abstract class TransactionFilterStoreBase with Store {
|
||||
var allowed = true;
|
||||
|
||||
if (allowed && startDate != null && endDate != null) {
|
||||
allowed = startDate.isBefore(item.transaction.date) &&
|
||||
endDate.isAfter(item.transaction.date);
|
||||
allowed = (startDate?.isBefore(item.transaction.date) ?? false)
|
||||
&& (endDate?.isAfter(item.transaction.date) ?? false);
|
||||
}
|
||||
|
||||
if (allowed && (!displayOutgoing || !displayIncoming)) {
|
||||
|
||||
@@ -12,22 +12,22 @@ class NodeListStore = NodeListStoreBase with _$NodeListStore;
|
||||
abstract class NodeListStoreBase with Store {
|
||||
NodeListStoreBase() : nodes = ObservableList<Node>();
|
||||
|
||||
static StreamSubscription<BoxEvent> _onNodesSourceChange;
|
||||
static NodeListStore _instance;
|
||||
static StreamSubscription<BoxEvent>? _onNodesSourceChange;
|
||||
static NodeListStore? _instance;
|
||||
|
||||
static NodeListStore get instance {
|
||||
if (_instance != null) {
|
||||
return _instance;
|
||||
return _instance!;
|
||||
}
|
||||
|
||||
final nodeSource = getIt.get<Box<Node>>();
|
||||
_instance = NodeListStore();
|
||||
_instance.nodes.clear();
|
||||
_instance.nodes.addAll(nodeSource.values);
|
||||
_instance!.nodes.clear();
|
||||
_instance!.nodes.addAll(nodeSource.values);
|
||||
_onNodesSourceChange?.cancel();
|
||||
_onNodesSourceChange = nodeSource.bindToList(_instance.nodes);
|
||||
_onNodesSourceChange = nodeSource.bindToList(_instance!.nodes);
|
||||
|
||||
return _instance;
|
||||
return _instance!;
|
||||
}
|
||||
|
||||
final ObservableList<Node> nodes;
|
||||
|
||||
@@ -12,7 +12,8 @@ abstract class SecretStoreBase with Store {
|
||||
final secretStore = SecretStore();
|
||||
final backupPasswordKey = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
||||
final backupPassword = await storage.read(key: backupPasswordKey);
|
||||
secretStore.write(key: backupPasswordKey, value: backupPassword);
|
||||
// FIX-ME: backupPassword ?? '' ???
|
||||
secretStore.write(key: backupPasswordKey, value: backupPassword ?? '');
|
||||
|
||||
return secretStore;
|
||||
}
|
||||
@@ -23,6 +24,6 @@ abstract class SecretStoreBase with Store {
|
||||
|
||||
String read(String key) => values[key] as String;
|
||||
|
||||
String write({@required String key, @required String value}) =>
|
||||
String write({required String key, required String value}) =>
|
||||
values[key] = value;
|
||||
}
|
||||
|
||||
+121
-85
@@ -25,35 +25,41 @@ class SettingsStore = SettingsStoreBase with _$SettingsStore;
|
||||
|
||||
abstract class SettingsStoreBase with Store {
|
||||
SettingsStoreBase(
|
||||
{@required SharedPreferences sharedPreferences,
|
||||
@required FiatCurrency initialFiatCurrency,
|
||||
@required BalanceDisplayMode initialBalanceDisplayMode,
|
||||
@required bool initialSaveRecipientAddress,
|
||||
@required bool initialAllowBiometricalAuthentication,
|
||||
@required ThemeBase initialTheme,
|
||||
@required int initialPinLength,
|
||||
@required String initialLanguageCode,
|
||||
// @required String initialCurrentLocale,
|
||||
@required this.appVersion,
|
||||
@required Map<WalletType, Node> nodes,
|
||||
@required TransactionPriority initialBitcoinTransactionPriority,
|
||||
@required TransactionPriority initialMoneroTransactionPriority,
|
||||
@required this.shouldShowYatPopup,
|
||||
@required this.isBitcoinBuyEnabled,
|
||||
this.actionlistDisplayMode}) {
|
||||
fiatCurrency = initialFiatCurrency;
|
||||
balanceDisplayMode = initialBalanceDisplayMode;
|
||||
shouldSaveRecipientAddress = initialSaveRecipientAddress;
|
||||
allowBiometricalAuthentication = initialAllowBiometricalAuthentication;
|
||||
currentTheme = initialTheme;
|
||||
pinCodeLength = initialPinLength;
|
||||
languageCode = initialLanguageCode;
|
||||
priority = ObservableMap<WalletType, TransactionPriority>.of({
|
||||
WalletType.monero: initialMoneroTransactionPriority,
|
||||
WalletType.bitcoin: initialBitcoinTransactionPriority
|
||||
});
|
||||
this.nodes = ObservableMap<WalletType, Node>.of(nodes);
|
||||
_sharedPreferences = sharedPreferences;
|
||||
{required SharedPreferences sharedPreferences,
|
||||
required FiatCurrency initialFiatCurrency,
|
||||
required BalanceDisplayMode initialBalanceDisplayMode,
|
||||
required bool initialSaveRecipientAddress,
|
||||
required bool initialAllowBiometricalAuthentication,
|
||||
required ThemeBase initialTheme,
|
||||
required int initialPinLength,
|
||||
required String initialLanguageCode,
|
||||
// required String initialCurrentLocale,
|
||||
required this.appVersion,
|
||||
required Map<WalletType, Node> nodes,
|
||||
required this.shouldShowYatPopup,
|
||||
required this.isBitcoinBuyEnabled,
|
||||
required this.actionlistDisplayMode,
|
||||
TransactionPriority? initialBitcoinTransactionPriority,
|
||||
TransactionPriority? initialMoneroTransactionPriority})
|
||||
: nodes = ObservableMap<WalletType, Node>.of(nodes),
|
||||
_sharedPreferences = sharedPreferences,
|
||||
fiatCurrency = initialFiatCurrency,
|
||||
balanceDisplayMode = initialBalanceDisplayMode,
|
||||
shouldSaveRecipientAddress = initialSaveRecipientAddress,
|
||||
allowBiometricalAuthentication = initialAllowBiometricalAuthentication,
|
||||
currentTheme = initialTheme,
|
||||
pinCodeLength = initialPinLength,
|
||||
languageCode = initialLanguageCode,
|
||||
priority = ObservableMap<WalletType, TransactionPriority>() {
|
||||
//this.nodes = ObservableMap<WalletType, Node>.of(nodes);
|
||||
|
||||
if (initialMoneroTransactionPriority != null) {
|
||||
priority[WalletType.monero] = initialMoneroTransactionPriority;
|
||||
}
|
||||
|
||||
if (initialBitcoinTransactionPriority != null) {
|
||||
priority[WalletType.bitcoin] = initialBitcoinTransactionPriority;
|
||||
}
|
||||
|
||||
reaction(
|
||||
(_) => fiatCurrency,
|
||||
@@ -70,7 +76,9 @@ abstract class SettingsStoreBase with Store {
|
||||
? PreferencesKey.moneroTransactionPriority
|
||||
: PreferencesKey.bitcoinTransactionPriority;
|
||||
|
||||
sharedPreferences.setInt(key, change.newValue.serialize());
|
||||
if (change.newValue != null) {
|
||||
sharedPreferences.setInt(key, change.newValue!.serialize());
|
||||
}
|
||||
});
|
||||
|
||||
reaction(
|
||||
@@ -107,7 +115,11 @@ abstract class SettingsStoreBase with Store {
|
||||
|
||||
this
|
||||
.nodes
|
||||
.observe((change) => _saveCurrentNode(change.newValue, change.key));
|
||||
.observe((change) {
|
||||
if (change.newValue != null && change.key != null) {
|
||||
_saveCurrentNode(change.newValue!, change.key!);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static const defaultPinLength = 4;
|
||||
@@ -152,7 +164,15 @@ abstract class SettingsStoreBase with Store {
|
||||
|
||||
ObservableMap<WalletType, Node> nodes;
|
||||
|
||||
Node getCurrentNode(WalletType walletType) => nodes[walletType];
|
||||
Node getCurrentNode(WalletType walletType) {
|
||||
final node = nodes[walletType];
|
||||
|
||||
if (node == null) {
|
||||
throw Exception('No node found for wallet type: ${walletType.toString()}');
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
bool isBitcoinBuyEnabled;
|
||||
|
||||
@@ -163,11 +183,11 @@ abstract class SettingsStoreBase with Store {
|
||||
_sharedPreferences.setBool(PreferencesKey.shouldShowReceiveWarning, value);
|
||||
|
||||
static Future<SettingsStore> load(
|
||||
{@required Box<Node> nodeSource,
|
||||
@required bool isBitcoinBuyEnabled,
|
||||
{required Box<Node> nodeSource,
|
||||
required bool isBitcoinBuyEnabled,
|
||||
TransactionPriority? initialMoneroTransactionPriority,
|
||||
TransactionPriority? initialBitcoinTransactionPriority,
|
||||
FiatCurrency initialFiatCurrency = FiatCurrency.usd,
|
||||
TransactionPriority initialMoneroTransactionPriority,
|
||||
TransactionPriority initialBitcoinTransactionPriority,
|
||||
BalanceDisplayMode initialBalanceDisplayMode =
|
||||
BalanceDisplayMode.availableBalance}) async {
|
||||
if (initialBitcoinTransactionPriority == null) {
|
||||
@@ -179,25 +199,25 @@ abstract class SettingsStoreBase with Store {
|
||||
}
|
||||
|
||||
final sharedPreferences = await getIt.getAsync<SharedPreferences>();
|
||||
final currentFiatCurrency = FiatCurrency(
|
||||
symbol:
|
||||
sharedPreferences.getString(PreferencesKey.currentFiatCurrencyKey));
|
||||
final currentFiatCurrency = FiatCurrency.deserialize(raw:
|
||||
sharedPreferences.getString(PreferencesKey.currentFiatCurrencyKey)!);
|
||||
final savedMoneroTransactionPriority =
|
||||
monero?.deserializeMoneroTransactionPriority(
|
||||
raw: sharedPreferences
|
||||
.getInt(PreferencesKey.moneroTransactionPriority));
|
||||
.getInt(PreferencesKey.moneroTransactionPriority)!);
|
||||
final savedBitcoinTransactionPriority =
|
||||
bitcoin?.deserializeBitcoinTransactionPriority(sharedPreferences
|
||||
.getInt(PreferencesKey.bitcoinTransactionPriority));
|
||||
.getInt(PreferencesKey.bitcoinTransactionPriority)!);
|
||||
final moneroTransactionPriority =
|
||||
savedMoneroTransactionPriority ?? initialMoneroTransactionPriority;
|
||||
final bitcoinTransactionPriority =
|
||||
savedBitcoinTransactionPriority ?? initialBitcoinTransactionPriority;
|
||||
final currentBalanceDisplayMode = BalanceDisplayMode.deserialize(
|
||||
raw: sharedPreferences
|
||||
.getInt(PreferencesKey.currentBalanceDisplayModeKey));
|
||||
.getInt(PreferencesKey.currentBalanceDisplayModeKey)!);
|
||||
// FIX-ME: Check for which default value we should have here
|
||||
final shouldSaveRecipientAddress =
|
||||
sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey);
|
||||
sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey) ?? false;
|
||||
final allowBiometricalAuthentication = sharedPreferences
|
||||
.getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
|
||||
false;
|
||||
@@ -237,14 +257,27 @@ abstract class SettingsStoreBase with Store {
|
||||
final shouldShowYatPopup =
|
||||
sharedPreferences.getBool(PreferencesKey.shouldShowYatPopup) ?? true;
|
||||
|
||||
final nodes = <WalletType, Node>{};
|
||||
|
||||
if (moneroNode != null) {
|
||||
nodes[WalletType.monero] = moneroNode;
|
||||
}
|
||||
|
||||
if (bitcoinElectrumServer != null) {
|
||||
nodes[WalletType.bitcoin] = bitcoinElectrumServer;
|
||||
}
|
||||
|
||||
if (litecoinElectrumServer != null) {
|
||||
nodes[WalletType.litecoin] = litecoinElectrumServer;
|
||||
}
|
||||
|
||||
if (havenNode != null) {
|
||||
nodes[WalletType.haven] = havenNode;
|
||||
}
|
||||
|
||||
return SettingsStore(
|
||||
sharedPreferences: sharedPreferences,
|
||||
nodes: {
|
||||
WalletType.monero: moneroNode,
|
||||
WalletType.bitcoin: bitcoinElectrumServer,
|
||||
WalletType.litecoin: litecoinElectrumServer,
|
||||
WalletType.haven: havenNode
|
||||
},
|
||||
nodes: nodes,
|
||||
appVersion: packageInfo.version,
|
||||
isBitcoinBuyEnabled: isBitcoinBuyEnabled,
|
||||
initialFiatCurrency: currentFiatCurrency,
|
||||
@@ -260,45 +293,48 @@ abstract class SettingsStoreBase with Store {
|
||||
shouldShowYatPopup: shouldShowYatPopup);
|
||||
}
|
||||
|
||||
Future<void> reload(
|
||||
{@required Box<Node> nodeSource,
|
||||
FiatCurrency initialFiatCurrency = FiatCurrency.usd,
|
||||
TransactionPriority initialMoneroTransactionPriority,
|
||||
TransactionPriority initialBitcoinTransactionPriority,
|
||||
BalanceDisplayMode initialBalanceDisplayMode =
|
||||
BalanceDisplayMode.availableBalance}) async {
|
||||
if (initialBitcoinTransactionPriority == null) {
|
||||
initialBitcoinTransactionPriority = bitcoin?.getMediumTransactionPriority();
|
||||
}
|
||||
// FIX-ME: Dead code
|
||||
|
||||
if (initialMoneroTransactionPriority == null) {
|
||||
initialMoneroTransactionPriority = monero?.getDefaultTransactionPriority();
|
||||
}
|
||||
//Future<void> reload(
|
||||
// {required Box<Node> nodeSource,
|
||||
// FiatCurrency initialFiatCurrency = FiatCurrency.usd,
|
||||
// TransactionPriority? initialMoneroTransactionPriority,
|
||||
// TransactionPriority? initialBitcoinTransactionPriority,
|
||||
// BalanceDisplayMode initialBalanceDisplayMode =
|
||||
// BalanceDisplayMode.availableBalance}) async {
|
||||
|
||||
// if (initialBitcoinTransactionPriority == null) {
|
||||
// initialBitcoinTransactionPriority = bitcoin?.getMediumTransactionPriority();
|
||||
// }
|
||||
|
||||
final isBitcoinBuyEnabled = (secrets.wyreSecretKey?.isNotEmpty ?? false) &&
|
||||
(secrets.wyreApiKey?.isNotEmpty ?? false) &&
|
||||
(secrets.wyreAccountId?.isNotEmpty ?? false);
|
||||
// if (initialMoneroTransactionPriority == null) {
|
||||
// initialMoneroTransactionPriority = monero?.getDefaultTransactionPriority();
|
||||
// }
|
||||
|
||||
final settings = await SettingsStoreBase.load(
|
||||
nodeSource: nodeSource,
|
||||
isBitcoinBuyEnabled: isBitcoinBuyEnabled,
|
||||
initialBalanceDisplayMode: initialBalanceDisplayMode,
|
||||
initialFiatCurrency: initialFiatCurrency,
|
||||
initialMoneroTransactionPriority: initialMoneroTransactionPriority,
|
||||
initialBitcoinTransactionPriority: initialBitcoinTransactionPriority);
|
||||
fiatCurrency = settings.fiatCurrency;
|
||||
actionlistDisplayMode = settings.actionlistDisplayMode;
|
||||
priority[WalletType.monero] = initialMoneroTransactionPriority;
|
||||
priority[WalletType.bitcoin] = initialBitcoinTransactionPriority;
|
||||
balanceDisplayMode = settings.balanceDisplayMode;
|
||||
shouldSaveRecipientAddress = settings.shouldSaveRecipientAddress;
|
||||
allowBiometricalAuthentication = settings.allowBiometricalAuthentication;
|
||||
currentTheme = settings.currentTheme;
|
||||
pinCodeLength = settings.pinCodeLength;
|
||||
languageCode = settings.languageCode;
|
||||
appVersion = settings.appVersion;
|
||||
shouldShowYatPopup = settings.shouldShowYatPopup;
|
||||
}
|
||||
// final isBitcoinBuyEnabled = (secrets.wyreSecretKey?.isNotEmpty ?? false) &&
|
||||
// (secrets.wyreApiKey?.isNotEmpty ?? false) &&
|
||||
// (secrets.wyreAccountId?.isNotEmpty ?? false);
|
||||
|
||||
// final settings = await SettingsStoreBase.load(
|
||||
// nodeSource: nodeSource,
|
||||
// isBitcoinBuyEnabled: isBitcoinBuyEnabled,
|
||||
// initialBalanceDisplayMode: initialBalanceDisplayMode,
|
||||
// initialFiatCurrency: initialFiatCurrency,
|
||||
// initialMoneroTransactionPriority: initialMoneroTransactionPriority,
|
||||
// initialBitcoinTransactionPriority: initialBitcoinTransactionPriority);
|
||||
// fiatCurrency = settings.fiatCurrency;
|
||||
// actionlistDisplayMode = settings.actionlistDisplayMode;
|
||||
// priority[WalletType.monero] = initialMoneroTransactionPriority;
|
||||
// priority[WalletType.bitcoin] = initialBitcoinTransactionPriority;
|
||||
// balanceDisplayMode = settings.balanceDisplayMode;
|
||||
// shouldSaveRecipientAddress = settings.shouldSaveRecipientAddress;
|
||||
// allowBiometricalAuthentication = settings.allowBiometricalAuthentication;
|
||||
// currentTheme = settings.currentTheme;
|
||||
// pinCodeLength = settings.pinCodeLength;
|
||||
// languageCode = settings.languageCode;
|
||||
// appVersion = settings.appVersion;
|
||||
// shouldShowYatPopup = settings.shouldShowYatPopup;
|
||||
//}
|
||||
|
||||
Future<void> _saveCurrentNode(Node node, WalletType walletType) async {
|
||||
switch (walletType) {
|
||||
|
||||
@@ -8,7 +8,8 @@ part 'exchange_template_store.g.dart';
|
||||
class ExchangeTemplateStore = ExchangeTemplateBase with _$ExchangeTemplateStore;
|
||||
|
||||
abstract class ExchangeTemplateBase with Store {
|
||||
ExchangeTemplateBase({this.templateSource}) {
|
||||
ExchangeTemplateBase({required this.templateSource})
|
||||
: templates = ObservableList<ExchangeTemplate>() {
|
||||
templates = ObservableList<ExchangeTemplate>();
|
||||
update();
|
||||
}
|
||||
@@ -23,8 +24,13 @@ abstract class ExchangeTemplateBase with Store {
|
||||
templates.replaceRange(0, templates.length, templateSource.values.toList());
|
||||
|
||||
@action
|
||||
Future addTemplate({String amount, String depositCurrency, String receiveCurrency,
|
||||
String provider, String depositAddress, String receiveAddress}) async {
|
||||
Future addTemplate({
|
||||
required String amount,
|
||||
required String depositCurrency,
|
||||
required String receiveCurrency,
|
||||
required String provider,
|
||||
required String depositAddress,
|
||||
required String receiveAddress}) async {
|
||||
final template = ExchangeTemplate(
|
||||
amount: amount,
|
||||
depositCurrency: depositCurrency,
|
||||
@@ -36,5 +42,5 @@ abstract class ExchangeTemplateBase with Store {
|
||||
}
|
||||
|
||||
@action
|
||||
Future remove({ExchangeTemplate template}) async => await template.delete();
|
||||
Future remove({required ExchangeTemplate template}) async => await template.delete();
|
||||
}
|
||||
@@ -8,8 +8,8 @@ part 'send_template_store.g.dart';
|
||||
class SendTemplateStore = SendTemplateBase with _$SendTemplateStore;
|
||||
|
||||
abstract class SendTemplateBase with Store {
|
||||
SendTemplateBase({this.templateSource}) {
|
||||
templates = ObservableList<Template>();
|
||||
SendTemplateBase({required this.templateSource})
|
||||
: templates = ObservableList<Template>() {
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -23,12 +23,25 @@ abstract class SendTemplateBase with Store {
|
||||
templates.replaceRange(0, templates.length, templateSource.values.toList());
|
||||
|
||||
@action
|
||||
Future addTemplate({String name,bool isCurrencySelected, String address, String cryptoCurrency, String fiatCurrency, String amount,String amountFiat}) async {
|
||||
final template = Template(name: name,isCurrencySelected: isCurrencySelected, address: address,
|
||||
cryptoCurrency: cryptoCurrency, fiatCurrency: fiatCurrency, amount: amount, amountFiat: amountFiat);
|
||||
Future addTemplate({
|
||||
required String name,
|
||||
required bool isCurrencySelected,
|
||||
required String address,
|
||||
required String cryptoCurrency,
|
||||
required String fiatCurrency,
|
||||
required String amount,
|
||||
required String amountFiat}) async {
|
||||
final template = Template(
|
||||
name: name,
|
||||
isCurrencySelected: isCurrencySelected,
|
||||
address: address,
|
||||
cryptoCurrency: cryptoCurrency,
|
||||
fiatCurrency: fiatCurrency,
|
||||
amount: amount,
|
||||
amountFiat: amountFiat);
|
||||
await templateSource.add(template);
|
||||
}
|
||||
|
||||
@action
|
||||
Future remove({Template template}) async => await template.delete();
|
||||
Future remove({required Template template}) async => await template.delete();
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class YatException implements Exception {
|
||||
YatException({@required this.text});
|
||||
YatException({required this.text});
|
||||
|
||||
final String text;
|
||||
|
||||
|
||||
@@ -169,13 +169,18 @@ Future<String> visualisationForEmojiId(String emojiId) async {
|
||||
class YatStore = YatStoreBase with _$YatStore;
|
||||
|
||||
abstract class YatStoreBase with Store {
|
||||
YatStoreBase({@required this.appStore, @required this.secureStorage}) {
|
||||
_wallet ??= appStore.wallet;
|
||||
emoji = _wallet?.walletInfo?.yatEmojiId ?? '';
|
||||
YatStoreBase({
|
||||
required this.appStore,
|
||||
required this.secureStorage})
|
||||
: _wallet = appStore.wallet,
|
||||
emoji = appStore.wallet?.walletInfo?.yatEmojiId ?? '',
|
||||
refreshToken = '',
|
||||
accessToken = '',
|
||||
apiKey = '',
|
||||
emojiIncommingSC = StreamController<String>.broadcast() {
|
||||
//reaction((_) => appStore.wallet, _onWalletChange);
|
||||
//reaction((_) => emoji, (String _) => _onEmojiChange());
|
||||
//reaction((_) => refreshToken, (String _) => _onRefreshTokenChange());
|
||||
emojiIncommingSC = StreamController<String>.broadcast();
|
||||
}
|
||||
|
||||
static const yatRefreshTokenKeyBase = 'yat_refresh_token';
|
||||
@@ -207,17 +212,17 @@ abstract class YatStoreBase with Store {
|
||||
Stream<String> get emojiIncommingStream => emojiIncommingSC.stream;
|
||||
|
||||
@observable
|
||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>
|
||||
_wallet;
|
||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>?
|
||||
_wallet;
|
||||
|
||||
Future<void> init() async {
|
||||
if (_wallet == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
refreshToken = await secureStorage.read(key: yatRefreshTokenKey(_wallet.walletInfo.name));
|
||||
accessToken = await secureStorage.read(key: yatAccessTokenKey(_wallet.walletInfo.name));
|
||||
apiKey = await secureStorage.read(key: yatApiKey(_wallet.walletInfo.name));
|
||||
refreshToken = await secureStorage.read(key: yatRefreshTokenKey(_wallet!.walletInfo.name)) ?? '';
|
||||
accessToken = await secureStorage.read(key: yatAccessTokenKey(_wallet!.walletInfo.name)) ?? '';
|
||||
apiKey = await secureStorage.read(key: yatApiKey(_wallet!.walletInfo.name)) ?? '';
|
||||
}
|
||||
|
||||
@action
|
||||
@@ -233,16 +238,16 @@ abstract class YatStoreBase with Store {
|
||||
@action
|
||||
void _onEmojiChange() {
|
||||
try {
|
||||
final walletInfo = _wallet.walletInfo;
|
||||
final walletInfo = _wallet?.walletInfo;
|
||||
|
||||
if (walletInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
walletInfo.yatEid = emoji;
|
||||
walletInfo!.yatEid = emoji;
|
||||
|
||||
if (walletInfo.isInBox) {
|
||||
walletInfo.save();
|
||||
if (walletInfo!.isInBox) {
|
||||
walletInfo!.save();
|
||||
}
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
|
||||
Reference in New Issue
Block a user