MVP #141
@@ -5,6 +5,7 @@ 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/home_view.dart';
|
||||||
import 'package:game_tracker/presentation/views/main_menu/settings_view.dart';
|
import 'package:game_tracker/presentation/views/main_menu/settings_view.dart';
|
||||||
import 'package:game_tracker/presentation/views/main_menu/statistics_view.dart';
|
import 'package:game_tracker/presentation/views/main_menu/statistics_view.dart';
|
||||||
|
import 'package:game_tracker/presentation/widgets/navbar_item.dart';
|
||||||
|
|
||||||
class CustomNavigationBar extends StatefulWidget {
|
class CustomNavigationBar extends StatefulWidget {
|
||||||
const CustomNavigationBar({super.key});
|
const CustomNavigationBar({super.key});
|
||||||
@@ -53,54 +54,51 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
|
|||||||
backgroundColor: CustomTheme.backgroundColor,
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
body: tabs[currentIndex],
|
body: tabs[currentIndex],
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
floatingActionButton: FloatingActionButton(
|
bottomNavigationBar: Padding(
|
||||||
shape: const CircleBorder(),
|
padding: const EdgeInsets.only(left: 12.0, right: 12.0, bottom: 8.0),
|
||||||
backgroundColor: CustomTheme.primaryColor,
|
child: Material(
|
||||||
onPressed: () {},
|
elevation: 10,
|
||||||
child: const Icon(Icons.add),
|
borderRadius: BorderRadius.circular(24),
|
||||||
),
|
color: CustomTheme.primaryColor,
|
||||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
child: ClipRRect(
|
||||||
bottomNavigationBar: BottomAppBar(
|
borderRadius: BorderRadius.circular(24),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
child: SizedBox(
|
||||||
elevation: 10,
|
height: 60,
|
||||||
height: 60,
|
child: Row(
|
||||||
color: CustomTheme.primaryColor,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
shape: const CircularNotchedRectangle(),
|
children: <Widget>[
|
||||||
notchMargin: 5,
|
NavbarItem(
|
||||||
child: Row(
|
index: 0,
|
||||||
mainAxisSize: MainAxisSize.max,
|
isSelected: currentIndex == 0,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
icon: Icons.home_rounded,
|
||||||
children: <Widget>[
|
label: 'Home',
|
||||||
IconButton(
|
onTabTapped: onTabTapped,
|
||||||
icon: Icon(
|
),
|
||||||
Icons.home,
|
NavbarItem(
|
||||||
color: currentIndex == 0 ? Colors.white : Colors.black,
|
index: 1,
|
||||||
|
isSelected: currentIndex == 1,
|
||||||
|
icon: Icons.gamepad_rounded,
|
||||||
|
label: 'Games',
|
||||||
|
onTabTapped: onTabTapped,
|
||||||
|
),
|
||||||
|
NavbarItem(
|
||||||
|
index: 2,
|
||||||
|
isSelected: currentIndex == 2,
|
||||||
|
icon: Icons.group_rounded,
|
||||||
|
label: 'Groups',
|
||||||
|
onTabTapped: onTabTapped,
|
||||||
|
),
|
||||||
|
NavbarItem(
|
||||||
|
index: 3,
|
||||||
|
isSelected: currentIndex == 3,
|
||||||
|
icon: Icons.bar_chart_rounded,
|
||||||
|
label: 'Stats',
|
||||||
|
onTabTapped: onTabTapped,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
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.groups,
|
|
||||||
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),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
57
lib/presentation/widgets/navbar_item.dart
Normal file
57
lib/presentation/widgets/navbar_item.dart
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class NavbarItem extends StatefulWidget {
|
||||||
|
final int index;
|
||||||
|
final bool isSelected;
|
||||||
|
final IconData icon;
|
||||||
|
final String label;
|
||||||
|
final Function(int) onTabTapped;
|
||||||
|
|
||||||
|
const NavbarItem({
|
||||||
|
super.key,
|
||||||
|
required this.index,
|
||||||
|
required this.isSelected,
|
||||||
|
required this.icon,
|
||||||
|
required this.label,
|
||||||
|
required this.onTabTapped,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<NavbarItem> createState() => _NavbarItemState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _NavbarItemState extends State<NavbarItem> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Expanded(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () => widget.onTabTapped(widget.index),
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 5.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
widget.icon,
|
||||||
|
color: widget.isSelected ? Colors.white : Colors.black,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
widget.label,
|
||||||
|
style: TextStyle(
|
||||||
|
color: widget.isSelected ? Colors.white : Colors.black,
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: widget.isSelected
|
||||||
|
? FontWeight.bold
|
||||||
|
: FontWeight.normal,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user