64 lines
1.9 KiB
Dart
64 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_expandable_fab/flutter_expandable_fab.dart';
|
|
import 'package:routemaster/routemaster.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 StatelessWidget {
|
|
/// Erstellt eine neue Instanz dieser Klasse
|
|
const HomePage({super.key});
|
|
|
|
@override
|
|
Widget build(final BuildContext context) {
|
|
final TabPageState tabPage = TabPage.of(context);
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
centerTitle: true,
|
|
titleSpacing: 0,
|
|
title: const Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 12),
|
|
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),
|
|
|
|
floatingActionButtonLocation: ExpandableFab.location,
|
|
floatingActionButton: const FloatingCreationButton(),
|
|
);
|
|
}
|
|
|
|
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',
|
|
),
|
|
],
|
|
);
|
|
}
|