From 2df0390ae26795d84348af97867d8251319677ec Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Wed, 9 Apr 2025 22:29:03 +0200 Subject: [PATCH] refactor: perform some clean up --- lib/screens/main_screen.dart | 53 ++++++------------------------------ 1 file changed, 8 insertions(+), 45 deletions(-) diff --git a/lib/screens/main_screen.dart b/lib/screens/main_screen.dart index e5387b6..652b864 100644 --- a/lib/screens/main_screen.dart +++ b/lib/screens/main_screen.dart @@ -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 { int _selectedIndex = 0; - // Die Liste der Screens bleibt gleich static const List _widgetOptions = [ 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 { @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, - // // ... - // ), ), ); }