Files
SDKmuta/lib/widgets/bottom_nav.dart
T
2026-11-27 14:37:44 +01:00

83 lines
2.3 KiB
Dart

import 'package:flutter/material.dart';
import '../theme/app_theme.dart';
class NavItem {
final IconData icon;
final IconData selectedIcon;
final String label;
const NavItem(this.icon, this.selectedIcon, this.label);
}
/// Bottom navigation of the design: icon + label, the selected one on a soft
/// accent pill. Paints the gesture-bar strip below it too (edge-to-edge).
class BottomNavBar extends StatelessWidget {
final int selectedIndex;
final ValueChanged<int> onItemTapped;
final List<NavItem> items;
const BottomNavBar({
super.key,
required this.selectedIndex,
required this.onItemTapped,
required this.items,
});
@override
Widget build(BuildContext context) {
final c = Palette.current;
return DecoratedBox(
decoration: BoxDecoration(
color: c.nav,
border: Border(top: BorderSide(color: c.line2)),
),
child: SafeArea(
top: false,
child: SizedBox(
height: 66,
child: Row(
children: [
for (int i = 0; i < items.length; i++)
Expanded(child: _item(c, items[i], i == selectedIndex, () => onItemTapped(i))),
],
),
),
),
);
}
Widget _item(Palette c, NavItem item, bool selected, VoidCallback onTap) {
return InkWell(
onTap: onTap,
splashFactory: NoSplash.splashFactory,
highlightColor: Colors.transparent,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AnimatedContainer(
duration: const Duration(milliseconds: 200),
curve: Curves.easeOut,
width: 52,
height: 30,
decoration: BoxDecoration(
color: selected ? c.accentSoft : Colors.transparent,
borderRadius: BorderRadius.circular(15),
),
child: Icon(selected ? item.selectedIcon : item.icon, size: 22, color: selected ? c.accent : c.muted),
),
const SizedBox(height: 4),
Text(
item.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 11,
fontWeight: selected ? FontWeight.w700 : FontWeight.w500,
color: selected ? c.ink : c.muted,
),
),
],
),
);
}
}