mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-24 06:48:38 +02:00
Merge redesign part 1.
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'page_view_store.g.dart';
|
||||
|
||||
class PageViewStore = PageViewStoreBase with _$PageViewStore;
|
||||
|
||||
abstract class PageViewStoreBase with Store {
|
||||
PageViewStoreBase() {
|
||||
setCurrentPage(1);
|
||||
}
|
||||
|
||||
@observable
|
||||
double currentPage;
|
||||
|
||||
@action
|
||||
void setCurrentPage(double currentPage) {
|
||||
this.currentPage = currentPage;
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,7 @@ abstract class TradeFilterStoreBase with Store {
|
||||
TradeFilterStoreBase(
|
||||
{this.displayXMRTO = true,
|
||||
this.displayChangeNow = true,
|
||||
this.displayMorphToken = true,
|
||||
this.wallet});
|
||||
this.displayMorphToken = true});
|
||||
|
||||
@observable
|
||||
bool displayXMRTO;
|
||||
@@ -23,8 +22,6 @@ abstract class TradeFilterStoreBase with Store {
|
||||
@observable
|
||||
bool displayMorphToken;
|
||||
|
||||
WalletBase wallet;
|
||||
|
||||
@action
|
||||
void toggleDisplayExchange(ExchangeProviderDescription provider) {
|
||||
switch (provider) {
|
||||
@@ -40,13 +37,13 @@ abstract class TradeFilterStoreBase with Store {
|
||||
}
|
||||
}
|
||||
|
||||
List<TradeListItem> filtered({List<TradeListItem> trades}) {
|
||||
List<TradeListItem> filtered({List<TradeListItem> trades, WalletBase wallet}) {
|
||||
final _trades =
|
||||
trades.where((item) => item.trade.walletId == wallet.id).toList();
|
||||
final needToFilter = !displayChangeNow || !displayXMRTO || !displayMorphToken;
|
||||
|
||||
return needToFilter
|
||||
? trades
|
||||
? _trades
|
||||
.where((item) =>
|
||||
(displayXMRTO &&
|
||||
item.trade.provider == ExchangeProviderDescription.xmrto) ||
|
||||
|
||||
@@ -27,6 +27,12 @@ abstract class TradesStoreBase with Store {
|
||||
@observable
|
||||
List<TradeListItem> trades;
|
||||
|
||||
@observable
|
||||
Trade trade;
|
||||
|
||||
@action
|
||||
void setTrade(Trade trade) => this.trade = trade;
|
||||
|
||||
@action
|
||||
Future updateTradeList() async => trades =
|
||||
tradesSource.values.map((trade) => TradeListItem(
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import 'dart:async';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/exchange_template.dart';
|
||||
|
||||
part 'exchange_template_store.g.dart';
|
||||
|
||||
class ExchangeTemplateStore = ExchangeTemplateBase with _$ExchangeTemplateStore;
|
||||
|
||||
abstract class ExchangeTemplateBase with Store {
|
||||
ExchangeTemplateBase({this.templateSource}) {
|
||||
templates = ObservableList<ExchangeTemplate>();
|
||||
update();
|
||||
}
|
||||
|
||||
@observable
|
||||
ObservableList<ExchangeTemplate> templates;
|
||||
|
||||
Box<ExchangeTemplate> templateSource;
|
||||
|
||||
@action
|
||||
void update() =>
|
||||
templates.replaceRange(0, templates.length, templateSource.values.toList());
|
||||
|
||||
@action
|
||||
Future addTemplate({String amount, String depositCurrency, String receiveCurrency,
|
||||
String provider, String depositAddress, String receiveAddress}) async {
|
||||
final template = ExchangeTemplate(
|
||||
amount: amount,
|
||||
depositCurrency: depositCurrency,
|
||||
receiveCurrency: receiveCurrency,
|
||||
provider: provider,
|
||||
depositAddress: depositAddress,
|
||||
receiveAddress: receiveAddress);
|
||||
await templateSource.add(template);
|
||||
}
|
||||
|
||||
@action
|
||||
Future remove({ExchangeTemplate template}) async => await template.delete();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import 'dart:async';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:cake_wallet/src/domain/common/template.dart';
|
||||
|
||||
part 'send_template_store.g.dart';
|
||||
|
||||
class SendTemplateStore = SendTemplateBase with _$SendTemplateStore;
|
||||
|
||||
abstract class SendTemplateBase with Store {
|
||||
SendTemplateBase({this.templateSource}) {
|
||||
templates = ObservableList<Template>();
|
||||
update();
|
||||
}
|
||||
|
||||
@observable
|
||||
ObservableList<Template> templates;
|
||||
|
||||
Box<Template> templateSource;
|
||||
|
||||
@action
|
||||
void update() =>
|
||||
templates.replaceRange(0, templates.length, templateSource.values.toList());
|
||||
|
||||
@action
|
||||
Future addTemplate({String name, String address, String cryptoCurrency, String amount}) async {
|
||||
final template = Template(name: name, address: address,
|
||||
cryptoCurrency: cryptoCurrency, amount: amount);
|
||||
await templateSource.add(template);
|
||||
}
|
||||
|
||||
@action
|
||||
Future remove({Template template}) async => await template.delete();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:cake_wallet/theme_changer.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'theme_changer_store.g.dart';
|
||||
|
||||
class ThemeChangerStore = ThemeChangerStoreBase with _$ThemeChangerStore;
|
||||
|
||||
abstract class ThemeChangerStoreBase with Store {
|
||||
ThemeChangerStoreBase({this.themeChanger});
|
||||
|
||||
@observable
|
||||
ThemeChanger themeChanger;
|
||||
}
|
||||
Reference in New Issue
Block a user