From f39324e814c76e1d2b738e4ec45e45990fd9a9c8 Mon Sep 17 00:00:00 2001 From: Filip Rojek Date: Sat, 3 May 2025 17:08:46 +0200 Subject: [PATCH] Added: user settings screen, Several changes in main.lib --- lib/main.dart | 31 +++++++++++++++++++++++++++---- lib/screens/add_screen.dart | 1 - lib/screens/history_screen.dart | 5 +---- lib/screens/home_screen.dart | 1 - lib/screens/user_settings.dart | 32 ++++++++++++++++++++++++++++++++ lib/screens/vehicles_screen.dart | 1 - 6 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 lib/screens/user_settings.dart diff --git a/lib/main.dart b/lib/main.dart index f5737ab..f67f64a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -3,6 +3,7 @@ import 'screens/home_screen.dart'; import 'screens/add_screen.dart'; import 'screens/vehicles_screen.dart'; import 'screens/history_screen.dart'; +import 'screens/user_settings.dart'; void main() { runApp(FuelStatsApp()); @@ -12,9 +13,9 @@ class FuelStatsApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( - title: 'Fuel Stats', theme: ThemeData.dark(), themeMode: ThemeMode.dark, + debugShowCheckedModeBanner: false, home: MainNavigation(), ); } @@ -35,20 +36,42 @@ class _MainNavigationState extends State { AddScreen(), VehiclesScreen(), HistoryScreen(), + UserSettingsScreen(), + ]; + + final List titles = [ + Text("Fuel Stats"), + Text("Add record"), + Text("Vehicles"), + Text("History"), ]; @override Widget build(BuildContext context) { return Scaffold( + appBar: AppBar( + title: _currentIndex <= 3 ? titles[_currentIndex] : Text("Fuel Stats"), + actions: [ + IconButton( + icon: const Icon(Icons.person), + tooltip: "User settings", + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => UserSettingsScreen()), + ); + }, + ), + ], + ), body: _screens[_currentIndex], bottomNavigationBar: BottomNavigationBar( - currentIndex: _currentIndex, + currentIndex: _currentIndex <= 3 ? _currentIndex : 0, onTap: (index) => setState(() => _currentIndex = index), backgroundColor: Colors.grey[900], selectedItemColor: Colors.white, unselectedItemColor: Colors.grey, - - items: [ + items: const [ BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'), BottomNavigationBarItem(icon: Icon(Icons.add), label: 'Add'), BottomNavigationBarItem( diff --git a/lib/screens/add_screen.dart b/lib/screens/add_screen.dart index a583371..ee7da42 100644 --- a/lib/screens/add_screen.dart +++ b/lib/screens/add_screen.dart @@ -23,7 +23,6 @@ class _AddScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Add Entry')), body: Padding( padding: const EdgeInsets.all(16.0), child: Form( diff --git a/lib/screens/history_screen.dart b/lib/screens/history_screen.dart index 52849e2..8de19d3 100644 --- a/lib/screens/history_screen.dart +++ b/lib/screens/history_screen.dart @@ -3,9 +3,6 @@ import 'package:flutter/material.dart'; class HistoryScreen extends StatelessWidget { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: Text('History')), - body: Center(child: Text('History Screen Content')), - ); + return Scaffold(body: Center(child: Text('History Screen Content'))); } } diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index f6cb0b4..35a7f29 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -5,7 +5,6 @@ class HomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Fuel Stats')), body: SingleChildScrollView( child: Column( children: [ diff --git a/lib/screens/user_settings.dart b/lib/screens/user_settings.dart new file mode 100644 index 0000000..9c57498 --- /dev/null +++ b/lib/screens/user_settings.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; + +class UserSettingsScreen extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text('User settings')), + body: Center( + child: Column( + spacing: 20.0, + children: [ + const Text( + "Test User", + style: TextStyle(fontSize: 32, fontWeight: FontWeight.bold), + ), + ElevatedButton.icon( + onPressed: () { + // TODO: Add sign-out logic here + }, + icon: Icon(Icons.logout), + label: Text("Sign Out"), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.redAccent, + foregroundColor: Colors.white, + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/screens/vehicles_screen.dart b/lib/screens/vehicles_screen.dart index e45e2dc..ecd1f83 100644 --- a/lib/screens/vehicles_screen.dart +++ b/lib/screens/vehicles_screen.dart @@ -79,7 +79,6 @@ class _VehiclesScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Vehicles')), body: _vehicles.isEmpty ? Center(child: Text('No vehicles added yet.'))