From c78a3ed171b959e79a82e6619ca65d14279e5ee0 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Mon, 23 Jun 2025 23:47:59 +0200 Subject: [PATCH] Implemented custom navigation bar --- lib/core/custom_theme.dart | 19 ++++ lib/main.dart | 12 ++- lib/presentation/views/home_view.dart | 10 -- .../main_menu/custom_navigation_bar.dart | 101 ++++++++++++++++++ pubspec.yaml | 3 +- 5 files changed, 129 insertions(+), 16 deletions(-) create mode 100644 lib/core/custom_theme.dart delete mode 100644 lib/presentation/views/home_view.dart create mode 100644 lib/presentation/views/main_menu/custom_navigation_bar.dart diff --git a/lib/core/custom_theme.dart b/lib/core/custom_theme.dart new file mode 100644 index 0000000..afc8dee --- /dev/null +++ b/lib/core/custom_theme.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +class CustomTheme { + static Color primaryColor = const Color(0xFF71C0BB); + static Color secondaryColor = const Color(0xFF2A4759); + static Color backgroundColor = const Color(0xFF1A1A1A); + + static AppBarTheme appBarTheme = const AppBarTheme( + backgroundColor: Color(0xFF1A1A1A), + foregroundColor: Colors.white, + elevation: 0, + titleTextStyle: TextStyle( + color: Colors.white, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + iconTheme: IconThemeData(color: Colors.white), + ); +} diff --git a/lib/main.dart b/lib/main.dart index 1188332..656788b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:game_tracker/presentation/views/home_view.dart'; +import 'package:game_tracker/core/custom_theme.dart'; +import 'package:game_tracker/presentation/views/main_menu/custom_navigation_bar.dart'; void main() { runApp(const MyApp()); @@ -11,11 +12,12 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( + debugShowCheckedModeBanner: false, title: 'Game Tracker', - theme: ThemeData( - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), - ), - home: const HomeView(), + themeMode: ThemeMode.dark, + darkTheme: ThemeData.dark(), + theme: ThemeData(appBarTheme: CustomTheme.appBarTheme), + home: const CustomNavigationBar(), ); } } diff --git a/lib/presentation/views/home_view.dart b/lib/presentation/views/home_view.dart deleted file mode 100644 index 234dc1a..0000000 --- a/lib/presentation/views/home_view.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter/material.dart'; - -class HomeView extends StatelessWidget { - const HomeView({super.key}); - - @override - Widget build(BuildContext context) { - return const Placeholder(); - } -} diff --git a/lib/presentation/views/main_menu/custom_navigation_bar.dart b/lib/presentation/views/main_menu/custom_navigation_bar.dart new file mode 100644 index 0000000..0be94fe --- /dev/null +++ b/lib/presentation/views/main_menu/custom_navigation_bar.dart @@ -0,0 +1,101 @@ +import 'package:flutter/material.dart'; +import 'package:game_tracker/core/custom_theme.dart'; +import 'package:game_tracker/presentation/views/main_menu/game_history_view.dart'; +import 'package:game_tracker/presentation/views/main_menu/groups_view.dart'; +import 'package:game_tracker/presentation/views/main_menu/home_view.dart'; +import 'package:game_tracker/presentation/views/main_menu/statistics_view.dart'; + +class CustomNavigationBar extends StatefulWidget { + const CustomNavigationBar({super.key}); + + @override + State createState() => _CustomNavigationBarState(); +} + +class _CustomNavigationBarState extends State + with SingleTickerProviderStateMixin { + int currentIndex = 0; + final List tabs = [ + const HomeView(), + const GameHistoryView(), + const GroupsView(), + const StatisticsView(), + ]; + + void onTabTapped(int index) { + setState(() { + currentIndex = index; + }); + } + + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: CustomTheme.backgroundColor, + actions: [ + IconButton(onPressed: () {}, icon: const Icon(Icons.settings)), + ], + elevation: 0, + ), + backgroundColor: CustomTheme.backgroundColor, + body: tabs[currentIndex], + extendBody: true, + floatingActionButton: FloatingActionButton( + shape: const CircleBorder(), + backgroundColor: CustomTheme.primaryColor, + onPressed: () {}, + child: const Icon(Icons.add), + ), + floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, + bottomNavigationBar: BottomAppBar( + padding: const EdgeInsets.symmetric(horizontal: 10), + elevation: 10, + height: 60, + color: CustomTheme.primaryColor, + shape: const CircularNotchedRectangle(), + notchMargin: 5, + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + icon: Icon( + Icons.home, + color: currentIndex == 0 ? Colors.white : Colors.black, + ), + onPressed: () => onTabTapped(0), + ), + IconButton( + icon: Icon( + Icons.history, + color: currentIndex == 1 ? Colors.white : Colors.black, + ), + onPressed: () => onTabTapped(1), + ), + const SizedBox(width: 40), + IconButton( + icon: Icon( + Icons.group, + color: currentIndex == 2 ? Colors.white : Colors.black, + ), + onPressed: () => onTabTapped(2), + ), + IconButton( + icon: Icon( + Icons.bar_chart, + color: currentIndex == 3 ? Colors.white : Colors.black, + ), + onPressed: () => onTabTapped(3), + ), + ], + ), + ), + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 7f2a6a8..992bd8f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: game_tracker description: "Game Tracking App for Card Games" publish_to: 'none' -version: 0.0.1+1 +version: 0.0.1+18 environment: sdk: ^3.8.1 @@ -9,6 +9,7 @@ environment: dependencies: flutter: sdk: flutter + material_symbols_icons: ^4.2815.1 dev_dependencies: