Improved layout, fixed transaction popup
This commit is contained in:
@@ -41,8 +41,13 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
super(const AccountState()) {
|
||||
on<AccountImportJSON>(_onAccountImportJSON);
|
||||
on<AccountImportCSV>(_onAccountImportCSV);
|
||||
on<SubAccountLoad>(_onSubAccountLoad);
|
||||
// on<AccountExportJSON>(_onAccountImportJSON);
|
||||
// on<AccountExportCSV>(_onAccountImportJSON);
|
||||
|
||||
_accountRepository
|
||||
.getSubAccountsStream()
|
||||
.listen((subAccounts) => add(SubAccountLoad(subAccounts)));
|
||||
}
|
||||
|
||||
double _universalConvertToDouble(dynamic value) {
|
||||
@@ -69,6 +74,7 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
final List<List<dynamic>> csvList = const CsvToListConverter(fieldDelimiter: '|', eol: '\n').convert(csvFileContent);
|
||||
|
||||
final Map<String, Category> categoriesMap = {};
|
||||
final Set<String> subAccounts = {};
|
||||
|
||||
final transactions = csvList
|
||||
.map((line) {
|
||||
@@ -88,6 +94,8 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
}
|
||||
}
|
||||
|
||||
subAccounts.add(line[3]);
|
||||
|
||||
return Transaction(
|
||||
uuid: const Uuid().v8(),
|
||||
date: DateTime.parse(line[0]),
|
||||
@@ -99,7 +107,7 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
.toList();
|
||||
|
||||
await _accountRepository.deleteAccount();
|
||||
final account = Account(transactions: transactions, categories: categoriesMap.values.toList());
|
||||
final account = Account(transactions: transactions, categories: categoriesMap.values.toList(), subAccounts: subAccounts);
|
||||
await _accountRepository.saveAccount(account);
|
||||
}
|
||||
}
|
||||
@@ -119,4 +127,12 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
await _accountRepository.saveTransactions(transactions);
|
||||
}
|
||||
}
|
||||
|
||||
_onSubAccountLoad(
|
||||
SubAccountLoad event, Emitter<AccountState> emit
|
||||
) {
|
||||
emit(
|
||||
state.copyWith(event.subAccounts)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user