Improved layout, fixed transaction popup
This commit is contained in:
@@ -16,6 +16,7 @@ class AccountRepository {
|
||||
final _transactionsController = BehaviorSubject<List<Transaction>>.seeded(const []);
|
||||
final _categoriesController = BehaviorSubject<List<Category>>.seeded(const []);
|
||||
final _budgetController = BehaviorSubject<List<Budget>>.seeded(const []);
|
||||
final _subAccountController = BehaviorSubject<Set<String>>.seeded(const {});
|
||||
|
||||
AccountRepository({
|
||||
required storageClient,
|
||||
@@ -25,9 +26,7 @@ class AccountRepository {
|
||||
|
||||
init() async {
|
||||
final account = await getAccount();
|
||||
_transactionsController.add(account.transactions);
|
||||
_categoriesController.add(account.categories);
|
||||
_budgetController.add(account.budgets);
|
||||
_broadcastAccountData(account);
|
||||
}
|
||||
|
||||
Stream<List<Transaction>> getTransactionsStream() {
|
||||
@@ -42,6 +41,10 @@ class AccountRepository {
|
||||
return _budgetController.asBroadcastStream();
|
||||
}
|
||||
|
||||
Stream<Set<String>> getSubAccountsStream() {
|
||||
return _subAccountController.asBroadcastStream();
|
||||
}
|
||||
|
||||
Future<Account> getAccount() async {
|
||||
String json = await _storageClient.load(accountFile);
|
||||
Map<String, dynamic> accountJson = jsonDecode(json);
|
||||
@@ -72,5 +75,6 @@ class AccountRepository {
|
||||
_transactionsController.add(account.transactions);
|
||||
_categoriesController.add(account.categories);
|
||||
_budgetController.add(account.budgets);
|
||||
_subAccountController.add(account.subAccounts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,13 @@ class Account {
|
||||
List<Transaction> transactions;
|
||||
List<Budget> budgets;
|
||||
List<Category> categories;
|
||||
Set<String> subAccounts;
|
||||
|
||||
Account({
|
||||
this.transactions = const [],
|
||||
this.budgets = const [],
|
||||
this.categories = const [],
|
||||
this.subAccounts = const {},
|
||||
});
|
||||
|
||||
factory Account.fromJson(Map<String, dynamic> json) {
|
||||
@@ -21,6 +23,7 @@ class Account {
|
||||
transactions: (jsonDecode(json['transactions']) as List<dynamic>).map((transaction) => Transaction.fromJson(transaction)).toList(),
|
||||
budgets: (jsonDecode(json['budgets']) as List<dynamic>).map((budget) => Budget.fromJson(budget)).toList(),
|
||||
categories: (jsonDecode(json['categories']) as List<dynamic>).map((category) => Category.fromJson(category)).toList(),
|
||||
subAccounts: Set.from(jsonDecode(json['subAccounts'])),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,5 +31,6 @@ class Account {
|
||||
'transactions': jsonEncode(transactions.map((transaction) => transaction.toJson()).toList()),
|
||||
'budgets': jsonEncode(budgets.map((budget) => budget.toJson()).toList()),
|
||||
'categories': jsonEncode(categories.map((category) => category.toJson()).toList()),
|
||||
'subAccounts': jsonEncode(subAccounts.toList()),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user