Always show the add button for budgets

This commit is contained in:
PapaTutuWawa 2025-05-04 23:36:17 +02:00
parent 2cc9a2bef5
commit 6e3329b9f4

View File

@ -12,73 +12,83 @@ class BudgetListPage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocBuilder<CoreCubit, CoreState>( return Stack(
builder: (context, state) { children: [
if (state.budgets.isEmpty) { BlocBuilder<CoreCubit, CoreState>(
return Column( builder: (context, state) {
crossAxisAlignment: CrossAxisAlignment.center, if (state.budgets.isEmpty) {
children: [ return Column(
Text("No budgets"), crossAxisAlignment: CrossAxisAlignment.center,
OutlinedButton( children: [
onPressed: () { Text("No budgets"),
showDialogOrModal( ],
context: context, );
builder: }
(_) => AddBudgetPopup(
onDone: () { return ListView.builder(
Navigator.of(context).pop(); itemCount: state.budgets.length,
itemBuilder:
(context, index) => ListTile(
title: Text(state.budgets[index].name),
selected: state.budgets[index] == state.activeBudget,
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: Icon(Icons.edit),
onPressed: () {
showDialogOrModal(
context: context,
builder:
(_) => EditBudgetPopup(
budget: state.activeBudget!,
onDone: () {
Navigator.of(context).pop();
},
),
);
}, },
), ),
); IconButton(
}, icon: Icon(Icons.delete, color: Colors.redAccent),
child: Text("Add"), onPressed: () {
), // TODO
], },
); ),
} ],
),
onTap: () {
GetIt.I.get<CoreCubit>().setActiveBudget(
state.budgets[index],
);
if (getScreenSize(context) == ScreenSize.small) {
Navigator.of(context).pushNamed("/budgets/details");
}
},
),
);
},
),
return ListView.builder( Positioned(
itemCount: state.budgets.length, right: 16,
itemBuilder: bottom: 16,
(context, index) => ListTile( child: FloatingActionButton(
title: Text(state.budgets[index].name), child: Icon(Icons.add),
selected: state.budgets[index] == state.activeBudget, onPressed: () {
trailing: Row( showDialogOrModal(
mainAxisSize: MainAxisSize.min, context: context,
children: [ builder:
IconButton( (_) => AddBudgetPopup(
icon: Icon(Icons.edit), onDone: () {
onPressed: () { Navigator.of(context).pop();
showDialogOrModal( },
context: context, ),
builder: (_) => EditBudgetPopup( );
budget: state.activeBudget!, },
onDone: () { ),
Navigator.of(context).pop(); ),
}, ],
),
);
},
),
IconButton(
icon: Icon(Icons.delete, color: Colors.redAccent),
onPressed: () {
// TODO
},
),
],
),
onTap: () {
GetIt.I.get<CoreCubit>().setActiveBudget(
state.budgets[index],
);
if (getScreenSize(context) == ScreenSize.small) {
Navigator.of(context).pushNamed("/budgets/details");
}
},
),
);
},
); );
} }
} }