move navbar widget to its own file

This commit is contained in:
Yannick
2025-11-08 18:05:19 +01:00
parent 34df9f007b
commit 92817bc4db
2 changed files with 49 additions and 40 deletions

View File

@@ -1,7 +1,18 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class NavbarItem extends StatefulWidget {
const NavbarItem({super.key});
final int currentIndex;
final int index;
final IconData icon;
final String label;
final Function(int) onTabTapped;
const NavbarItem(
{super.key, required this.currentIndex, required this.index,
required this.icon, required this.label, required this.onTabTapped
}
);
@override
State<NavbarItem> createState() => _NavbarItemState();
@@ -10,6 +21,36 @@ class NavbarItem extends StatefulWidget {
class _NavbarItemState extends State<NavbarItem> {
@override
Widget build(BuildContext context) {
return const Placeholder();
bool isSelected = widget.currentIndex == widget.index;
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: isSelected ? Colors.white : Colors.black,
),
const SizedBox(height: 4),
Text(
widget.label,
style: TextStyle(
color: isSelected ? Colors.white : Colors.black,
fontSize: 12,
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
),
),
],
),
),
),
);
}
}