Feat: Macht die Kontoauswahl funktional

This commit is contained in:
2025-12-25 16:23:01 +01:00
parent c11515d447
commit 05a5bddf09
4 changed files with 162 additions and 81 deletions

View File

@@ -1,28 +1,19 @@
import 'package:dropdown_search/dropdown_search.dart';
import 'package:flutter/material.dart';
import 'package:flutter_expandable_fab/flutter_expandable_fab.dart';
import 'package:routemaster/routemaster.dart';
import '../Controller/account_controller.dart';
import 'Misc/account_select.dart';
import 'Misc/floating_creation_button.dart';
/// Eine Seite, die als Container für die verschiedenen Tabs der App dient.
///
/// Diese Seite enthält eine App-Bar mit einer Kontoauswahl sowie ein
/// Bottom-Navigation-Bar für die Navigation zwischen
/// Dashboard, Verlauf und Einstellungen.
class HomePage extends StatefulWidget {
/// Erstellt eine neue Instanz der HomePage.
class HomePage extends StatelessWidget {
/// Erstellt eine neue Instanz dieser Klasse
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final AccountController _accountController = AccountController();
String selected = 'Konto 1';
@override
Widget build(final BuildContext context) {
final TabPageState tabPage = TabPage.of(context);
@@ -31,9 +22,9 @@ class _HomePageState extends State<HomePage> {
appBar: AppBar(
centerTitle: true,
titleSpacing: 0,
title: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: _accountSelect(),
title: const Padding(
padding: EdgeInsets.symmetric(horizontal: 12),
child: AccountSelect(),
),
),
@@ -53,7 +44,7 @@ class _HomePageState extends State<HomePage> {
bottomNavigationBar: _bottomNav(tabPage),
floatingActionButtonLocation: ExpandableFab.location,
floatingActionButton: _floatingActionButton(),
floatingActionButton: const FloatingCreationButton(),
);
}
@@ -69,66 +60,4 @@ class _HomePageState extends State<HomePage> {
),
],
);
Widget _accountSelect() => DropdownSearch<String>(
items: (final String filter, final LoadProps? infiniteScrollProps) =>
<String>['Konto 1', 'Konto 2', 'Konto 3', 'Konto 4'],
selectedItem: selected,
onChanged: (final String? value) => setState(() => selected = value!),
popupProps: const PopupProps<String>.menu(
showSearchBox: true,
searchFieldProps: TextFieldProps(
decoration: InputDecoration(
hintText: 'Suchen...',
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
),
),
),
);
Widget _floatingActionButton() => ExpandableFab(
openButtonBuilder: RotateFloatingActionButtonBuilder(
child: const Icon(Icons.add),
),
type: ExpandableFabType.up,
childrenAnimation: ExpandableFabAnimation.none,
distance: 70,
children: <Widget>[
_expandableButton(
label: 'Neue Transaktion',
icon: Icons.add,
onPressed: () {},
),
_expandableButton(
label: 'Neues Konto',
icon: Icons.account_balance_wallet,
onPressed: () {
_accountController.newAccountHandler(context);
},
),
],
);
Widget _expandableButton({
required final String label,
required final IconData icon,
required final VoidCallback onPressed,
}) => GestureDetector(
onTap: onPressed,
child: Row(
children: <Widget>[
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8)),
child: Text(label),
),
const SizedBox(width: 12),
FloatingActionButton.small(
heroTag: null,
onPressed: onPressed,
child: Icon(icon),
),
],
),
);
}