Navbar Anpassen #9
@@ -63,40 +63,45 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
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),
|
||||
),
|
||||
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),
|
||||
),
|
||||
const SizedBox(width: 0),
|
||||
_buildNavItem(Icons.home, 'Home', 0),
|
||||
_buildNavItem(Icons.history, 'History', 1),
|
||||
_buildNavItem(Icons.groups, 'Groups', 2),
|
||||
_buildNavItem(Icons.bar_chart, 'Stats', 3),
|
||||
const SizedBox(width: 0),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNavItem(IconData icon, String label, int index) {
|
||||
final isSelected = currentIndex == index;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => onTabTapped(index),
|
||||
|
flixcoo marked this conversation as resolved
Outdated
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
gelbeinhalb marked this conversation as resolved
Outdated
flixcoo
commented
Chat GPT kommentare? Chat GPT kommentare?
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
color: isSelected ? Colors.white : Colors.black,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: isSelected ? Colors.white : Colors.black,
|
||||
fontSize: 12,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void onTabTapped(int index) {
|
||||
setState(() {
|
||||
currentIndex = index;
|
||||
|
||||
Reference in New Issue
Block a user
Ich würde das Widget entweder Auslagern (als
nav_item.dartimwidgetsOrdner) oder dasExpandedWidget direkt in die Row setzen (nicht so geil). Wenn du das Auslagerst sparst du dir ganz viel Code hier und übergibst die Parameter einfach direkt in das Widget.Ja stimmt.
Ich lager das dann aus.