refactor: perform some clean up
This commit is contained in:
parent
ef130fa83c
commit
2df0390ae2
1 changed files with 8 additions and 45 deletions
|
|
@ -1,6 +1,5 @@
|
|||
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:flutter/material.dart';
|
||||
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||||
import 'package:timetracker/screens/home_screen.dart';
|
||||
import 'package:timetracker/screens/tags_screen.dart';
|
||||
import 'package:timetracker/screens/report_screen.dart';
|
||||
|
|
@ -15,14 +14,12 @@ class MainScreen extends StatefulWidget {
|
|||
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;
|
||||
|
|
@ -31,64 +28,30 @@ class _MainScreenState extends State<MainScreen> {
|
|||
|
||||
@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
|
||||
icon: Icon(context.platformIcons.clockSolid),
|
||||
activeIcon: Icon(context.platformIcons.clockSolid),
|
||||
label: 'Tracking',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(
|
||||
context.platformIcons.tagOutline,
|
||||
), // Passendes Icon finden
|
||||
activeIcon: Icon(
|
||||
context.platformIcons.tagSolid,
|
||||
), // Passendes Icon finden
|
||||
icon: Icon(context.platformIcons.tagOutline),
|
||||
activeIcon: Icon(context.platformIcons.tagSolid),
|
||||
label: 'Tags',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(
|
||||
context.platformIcons.bookmarkOutline,
|
||||
), // Passendes Icon finden (z.B. 'chart')
|
||||
activeIcon: Icon(
|
||||
context.platformIcons.bookmarkSolid,
|
||||
), // Passendes Icon finden
|
||||
icon: Icon(context.platformIcons.bookmarkOutline),
|
||||
activeIcon: Icon(context.platformIcons.bookmarkSolid),
|
||||
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,
|
||||
// // ...
|
||||
// ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue