Implement a nicer account switcher

This commit is contained in:
2025-05-12 22:16:14 +02:00
parent 88c9991e0d
commit e0c16031ef
3 changed files with 85 additions and 109 deletions

View File

@@ -32,90 +32,6 @@ class AccountListPageState extends State<AccountListPage> {
children: [
ListView(
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Text(
t.pages.accounts.title,
style: Theme.of(context).textTheme.titleLarge,
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: BlocBuilder<CoreCubit, CoreState>(
builder:
(context, state) => Row(
children: [
OutlinedButton(
onPressed:
state.accounts.isEmpty
? null
: () {
showDialogOrModal(
context: context,
builder:
(context) => ListView.builder(
shrinkWrap: true,
itemCount: state.accounts.length,
itemBuilder: (context, index) {
final item =
state.accounts[index];
return ListTile(
title: Text(item.name!),
trailing: IconButton(
icon: Icon(Icons.delete),
color: Colors.red,
onPressed: () async {
await showDialog(
context: context,
barrierDismissible: false,
builder:
(context) =>
DeleteAccountPopup(
account: item,
onCancel: () {
Navigator.of(
context,
).pop();
Navigator.of(
context,
).pop();
},
afterDelete: () {
Navigator.of(
context,
).pop();
Navigator.of(
context,
).pop();
},
),
);
},
),
onTap: () {
GetIt.I
.get<CoreCubit>()
.setActiveAccountIndex(
index,
);
Navigator.of(context).pop();
},
);
},
),
);
},
child: Text(
bloc.activeAccount?.name ??
t.pages.accounts.accountSelector.none,
),
),
],
),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: BlocBuilder<CoreCubit, CoreState>(