Feat: Zeigt Knöpfe zum Transaktion erstellen nur an, wenn ein Konto ausgewählt ist
This commit is contained in:
@@ -51,7 +51,7 @@ class _RecentTransactionsListState extends State<RecentTransactionsList> {
|
|||||||
final ThemeData theme = Theme.of(context);
|
final ThemeData theme = Theme.of(context);
|
||||||
|
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
final List<Padding>? recentTransactionsWidgetList = snapshot.data
|
final List<Widget>? recentTransactionsWidgetList = snapshot.data
|
||||||
?.map(
|
?.map(
|
||||||
(final Transaction transaction) => Padding(
|
(final Transaction transaction) => Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
@@ -74,7 +74,42 @@ class _RecentTransactionsListState extends State<RecentTransactionsList> {
|
|||||||
)
|
)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
return Column(children: [...?recentTransactionsWidgetList]);
|
if (recentTransactionsWidgetList != null &&
|
||||||
|
recentTransactionsWidgetList.isNotEmpty) {
|
||||||
|
recentTransactionsWidgetList.add(
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: _transactionController.newTransactionHandler,
|
||||||
|
child: const Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.swap_horiz),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Text('Transaktion hinzufügen'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return Column(children: [...recentTransactionsWidgetList]);
|
||||||
|
} else {
|
||||||
|
if (_accountController.selected.value != null) {
|
||||||
|
return TextButton(
|
||||||
|
onPressed: _transactionController.newTransactionHandler,
|
||||||
|
child: const Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.swap_horiz),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Text('Transaktion hinzufügen'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const Text('');
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (snapshot.hasError) {
|
} else if (snapshot.hasError) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|||||||
@@ -24,33 +24,57 @@ class _FloatingCreationButtonState extends State<FloatingCreationButton> {
|
|||||||
final _key = GlobalKey<ExpandableFabState>();
|
final _key = GlobalKey<ExpandableFabState>();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(final BuildContext context) => ExpandableFab(
|
void initState() {
|
||||||
key: _key,
|
super.initState();
|
||||||
openButtonBuilder: RotateFloatingActionButtonBuilder(
|
|
||||||
child: const Icon(Icons.add),
|
_accountController.selected.addListener(() {
|
||||||
),
|
if (mounted) {
|
||||||
type: ExpandableFabType.up,
|
setState(() {});
|
||||||
childrenAnimation: ExpandableFabAnimation.none,
|
}
|
||||||
distance: 70,
|
});
|
||||||
children: <Widget>[
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(final BuildContext context) {
|
||||||
|
final List<Widget> fabs = [];
|
||||||
|
if (_accountController.selected.value != null) {
|
||||||
|
fabs
|
||||||
|
..add(
|
||||||
|
_expandableButton(
|
||||||
|
label: 'Neue Transaktion',
|
||||||
|
icon: Icons.swap_horiz,
|
||||||
|
onPressed: _transactionController.newTransactionHandler,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
..add(
|
||||||
|
_expandableButton(
|
||||||
|
label: 'Neue wiederkehrende Transaktion',
|
||||||
|
icon: Icons.repeat,
|
||||||
|
onPressed:
|
||||||
|
_recurringTransactionController.newRecurringTransactionHandler,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fabs.add(
|
||||||
_expandableButton(
|
_expandableButton(
|
||||||
label: 'Neues Konto',
|
label: 'Neues Konto',
|
||||||
icon: Icons.account_balance_wallet,
|
icon: Icons.account_balance_wallet,
|
||||||
onPressed: _accountController.newAccountHandler,
|
onPressed: _accountController.newAccountHandler,
|
||||||
),
|
),
|
||||||
_expandableButton(
|
);
|
||||||
label: 'Neue Transaktion',
|
|
||||||
icon: Icons.swap_horiz,
|
return ExpandableFab(
|
||||||
onPressed: _transactionController.newTransactionHandler,
|
key: _key,
|
||||||
|
openButtonBuilder: RotateFloatingActionButtonBuilder(
|
||||||
|
child: const Icon(Icons.add),
|
||||||
),
|
),
|
||||||
_expandableButton(
|
type: ExpandableFabType.up,
|
||||||
label: 'Neue wiederkehrende Transaktion',
|
childrenAnimation: ExpandableFabAnimation.none,
|
||||||
icon: Icons.repeat,
|
distance: 70,
|
||||||
onPressed:
|
children: fabs,
|
||||||
_recurringTransactionController.newRecurringTransactionHandler,
|
);
|
||||||
),
|
}
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
Widget _expandableButton({
|
Widget _expandableButton({
|
||||||
required final String label,
|
required final String label,
|
||||||
|
|||||||
Reference in New Issue
Block a user