Ref: Extrahiert den accountSelect in eine eigene Funktion

This commit is contained in:
2025-12-20 16:15:19 +01:00
parent 0b33b83a9c
commit 7eae712808

View File

@@ -28,7 +28,43 @@ class _HomePageState extends State<HomePage> {
titleSpacing: 0, titleSpacing: 0,
title: Padding( title: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12), padding: const EdgeInsets.symmetric(horizontal: 12),
child: DropdownSearch<String>( child: _accountSelect(),
),
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: TabBarView(
controller: tabPage.controller,
children: <Widget>[
for (final PageStack stack in tabPage.stacks)
PageStackNavigator(stack: stack),
],
),
),
),
bottomNavigationBar: _bottomNav(tabPage),
);
}
Widget _bottomNav(final TabPageState tabPage) =>
BottomNavigationBar(
currentIndex: tabPage.index,
onTap: tabPage.controller.animateTo,
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(icon: Icon(Icons.dashboard), label: 'Dashboard'),
BottomNavigationBarItem(icon: Icon(Icons.history), label: 'Verlauf'),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
label: 'Einstellungen',
),
],
);
Widget _accountSelect() =>
DropdownSearch<String>(
items: items:
(final String filter, final LoadProps? infiniteScrollProps) => (final String filter, final LoadProps? infiniteScrollProps) =>
<String>['Konto 1', 'Konto 2', 'Konto 3', 'Konto 4'], <String>['Konto 1', 'Konto 2', 'Konto 3', 'Konto 4'],
@@ -47,37 +83,5 @@ class _HomePageState extends State<HomePage> {
), ),
), ),
), ),
),
),
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: TabBarView(
controller: tabPage.controller,
children: <Widget>[
for (final PageStack stack in tabPage.stacks)
PageStackNavigator(stack: stack),
],
),
),
),
bottomNavigationBar: _buildBottomNav(tabPage),
);
}
Widget _buildBottomNav(final TabPageState tabPage) => BottomNavigationBar(
currentIndex: tabPage.index,
onTap: tabPage.controller.animateTo,
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(icon: Icon(Icons.dashboard), label: 'Dashboard'),
BottomNavigationBarItem(icon: Icon(Icons.history), label: 'Verlauf'),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
label: 'Einstellungen',
),
],
); );
} }