Feat: Macht die Kontoliste und Versionsanzeige funktional
This commit is contained in:
56
lib/Pages/Settings/account_list.dart
Normal file
56
lib/Pages/Settings/account_list.dart
Normal file
@@ -0,0 +1,56 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../Controller/account_controller.dart';
|
||||
import '../../Entities/drift_database.dart';
|
||||
import '../../Entities/list_item.dart';
|
||||
import '../Misc/editable_list.dart';
|
||||
|
||||
class AccountList extends StatefulWidget {
|
||||
const AccountList({super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _AccountListState();
|
||||
}
|
||||
|
||||
class _AccountListState extends State<AccountList> {
|
||||
final AccountController _accountController = AccountController();
|
||||
List<Account> _accounts = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_accounts = _accountController.accounts.value;
|
||||
|
||||
_accountController.accounts.addListener(() {
|
||||
setState(() {
|
||||
if (context.mounted) {
|
||||
_accounts = _accountController.accounts.value;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(final BuildContext context) {
|
||||
if (_accounts != []) {
|
||||
final List<ListItem> formatedAccounts = [];
|
||||
for (final Account data in _accounts) {
|
||||
formatedAccounts.add(ListItem(id: data.id, name: data.name));
|
||||
}
|
||||
|
||||
return EditableList(
|
||||
name: 'Konten',
|
||||
items: formatedAccounts,
|
||||
onAdd: _accountController.newAccountHandler,
|
||||
onRename: _accountController.renameAccountHandler,
|
||||
onDelete: _accountController.deleteAccountHandler,
|
||||
icon: const Icon(Icons.account_balance_wallet),
|
||||
addTooltip: 'Konto hinzufügen',
|
||||
menuTooltip: 'Menü anzeigen',
|
||||
);
|
||||
} else {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user