95 lines
3.3 KiB
Dart
95 lines
3.3 KiB
Dart
import 'package:flutter/material.dart'; // Kann oft drin bleiben für ThemeData etc.
|
|
// import 'package:flutter/cupertino.dart'; // Wird evtl. weniger direkt gebraucht
|
|
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'; // Wichtigster Import
|
|
import 'package:timetracker/screens/home_screen.dart';
|
|
import 'package:timetracker/screens/tags_screen.dart';
|
|
import 'package:timetracker/screens/report_screen.dart';
|
|
|
|
class MainScreen extends StatefulWidget {
|
|
const MainScreen({super.key});
|
|
|
|
@override
|
|
State<MainScreen> createState() => _MainScreenState();
|
|
}
|
|
|
|
class _MainScreenState extends State<MainScreen> {
|
|
int _selectedIndex = 0;
|
|
|
|
// Die Liste der Screens bleibt gleich
|
|
static const List<Widget> _widgetOptions = <Widget>[
|
|
HomeScreen(),
|
|
TagsScreen(),
|
|
ReportScreen(),
|
|
];
|
|
|
|
// Callback für Tab-Wechsel, Logik bleibt gleich
|
|
void _onTabTapped(int index) {
|
|
setState(() {
|
|
_selectedIndex = index;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Ersetze Scaffold durch PlatformScaffold
|
|
return PlatformScaffold(
|
|
// Eine globale AppBar wird hier nicht gesetzt, da jeder Screen seine
|
|
// eigene plattformadaptive AppBar haben soll (innerhalb von HomeScreen etc.).
|
|
// appBar: PlatformAppBar(title: Text("App Titel")),
|
|
|
|
// Der Body bleibt der IndexedStack, um den State der Screens zu erhalten
|
|
body: IndexedStack(index: _selectedIndex, children: _widgetOptions),
|
|
|
|
// Ersetze BottomNavigationBar durch PlatformNavBar
|
|
bottomNavBar: PlatformNavBar(
|
|
currentIndex: _selectedIndex,
|
|
// Wichtig: Der Callback heißt hier oft 'itemChanged' statt 'onTap'
|
|
itemChanged: _onTabTapped,
|
|
|
|
// Die Items bleiben BottomNavigationBarItem, aber wir verwenden
|
|
// platformIcons(context) für die Icons, damit sie sich anpassen.
|
|
items: [
|
|
BottomNavigationBarItem(
|
|
icon: Icon(
|
|
context.platformIcons.clockSolid,
|
|
), // Passendes Icon finden
|
|
activeIcon: Icon(
|
|
context.platformIcons.clockSolid,
|
|
), // Passendes Icon finden
|
|
label: 'Tracking',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(
|
|
context.platformIcons.tagOutline,
|
|
), // Passendes Icon finden
|
|
activeIcon: Icon(
|
|
context.platformIcons.tagSolid,
|
|
), // Passendes Icon finden
|
|
label: 'Tags',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(
|
|
context.platformIcons.bookmarkOutline,
|
|
), // Passendes Icon finden (z.B. 'chart')
|
|
activeIcon: Icon(
|
|
context.platformIcons.bookmarkSolid,
|
|
), // Passendes Icon finden
|
|
label: 'Reports',
|
|
),
|
|
],
|
|
|
|
// Hier könntest du plattformspezifisches Styling hinzufügen, falls nötig:
|
|
// material: (_, __) => MaterialNavBarData(
|
|
// // backgroundColor: Colors.white,
|
|
// selectedItemColor: Theme.of(context).primaryColor,
|
|
// // ...
|
|
// ),
|
|
// cupertino: (_, __) => CupertinoTabBarData(
|
|
// // backgroundColor: CupertinoColors.systemBackground,
|
|
// activeColor: CupertinoColors.activeBlue,
|
|
// // ...
|
|
// ),
|
|
),
|
|
);
|
|
}
|
|
}
|