complete budget page
This commit is contained in:
@@ -123,13 +123,13 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
})
|
||||
.toList();
|
||||
|
||||
await _metadataRepository.deleteMetadata();
|
||||
await _transactionsRepository.deleteTransactions();
|
||||
_metadataRepository.deleteMetadata();
|
||||
_transactionsRepository.deleteTransactions();
|
||||
|
||||
await _metadataRepository.saveAccounts(accounts.values.toList());
|
||||
await _metadataRepository.saveBudgets([]);
|
||||
await _metadataRepository.saveCategories(categoriesMap.values.toList());
|
||||
await _transactionsRepository.saveTransactions(transactions);
|
||||
_metadataRepository.saveAccounts(accounts.values.toList());
|
||||
_metadataRepository.saveBudgets([]);
|
||||
_metadataRepository.saveCategories(categoriesMap.values.toList());
|
||||
_transactionsRepository.saveTransactions(transactions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
);
|
||||
}
|
||||
|
||||
_onAccountAdd(AccountAdd event, Emitter<AccountState> emit) async {
|
||||
_onAccountAdd(AccountAdd event, Emitter<AccountState> emit) {
|
||||
String uuid = const Uuid().v8();
|
||||
Account account = Account(
|
||||
label: 'Account $uuid',
|
||||
@@ -149,11 +149,11 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
saving: false
|
||||
);
|
||||
emit(
|
||||
state.copyWith(await _saveAccount(account))
|
||||
state.copyWith(_saveAccount(account))
|
||||
);
|
||||
}
|
||||
|
||||
_onAcountRemove(AccountRemove event, Emitter<AccountState> emit) async {
|
||||
_onAcountRemove(AccountRemove event, Emitter<AccountState> emit) {
|
||||
Account accountToRemove = event.account;
|
||||
List<Account> accounts = state.accounts;
|
||||
List<Transaction> transactions = _transactionsRepository.getTransactions();
|
||||
@@ -165,33 +165,33 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
accounts.removeWhere((account) => account.label == accountToRemove.label);
|
||||
emit(AccountRemoveSucess());
|
||||
emit(
|
||||
state.copyWith(await _metadataRepository.saveAccounts(accounts))
|
||||
state.copyWith(_metadataRepository.saveAccounts(accounts))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_onAccountEditLabel(AccountEditLabel event, Emitter<AccountState> emit) async {
|
||||
_onAccountEditLabel(AccountEditLabel event, Emitter<AccountState> emit) {
|
||||
Account account = event.account;
|
||||
// TODO check for existance, rename every transaction
|
||||
}
|
||||
|
||||
_onAccountEditSaving(AccountEditSaving event, Emitter<AccountState> emit) async {
|
||||
_onAccountEditSaving(AccountEditSaving event, Emitter<AccountState> emit) {
|
||||
Account account = event.account;
|
||||
account.saving = event.saving;
|
||||
emit(
|
||||
state.copyWith(await _saveAccount(account))
|
||||
state.copyWith(_saveAccount(account))
|
||||
);
|
||||
}
|
||||
|
||||
_onAccountEditColor(AccountEditColor event, Emitter<AccountState> emit) async {
|
||||
_onAccountEditColor(AccountEditColor event, Emitter<AccountState> emit) {
|
||||
Account account = event.account;
|
||||
account.color = event.color;
|
||||
emit(
|
||||
state.copyWith(await _saveAccount(account))
|
||||
state.copyWith(_saveAccount(account))
|
||||
);
|
||||
}
|
||||
|
||||
Future<List<Account>> _saveAccount(Account accountToSave) async {
|
||||
List<Account> _saveAccount(Account accountToSave) {
|
||||
List<Account> accounts = _metadataRepository.getAccounts();
|
||||
|
||||
try {
|
||||
@@ -206,7 +206,7 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
}
|
||||
}
|
||||
|
||||
await _metadataRepository.saveAccounts(accounts);
|
||||
_metadataRepository.saveAccounts(accounts);
|
||||
return accounts;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user