add bigger hitboxes
This commit is contained in:
@@ -80,31 +80,37 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildNavItem(IconData icon, String label, int index) {
|
Widget _buildNavItem(IconData icon, String label, int index) {
|
||||||
final isSelected = currentIndex == index;
|
final isSelected = currentIndex == index;
|
||||||
|
|
||||||
return GestureDetector(
|
return Expanded( // makes each nav item occupy equal width = large horizontal hitbox
|
||||||
|
child: GestureDetector(
|
||||||
onTap: () => onTabTapped(index),
|
onTap: () => onTabTapped(index),
|
||||||
child: Column(
|
behavior: HitTestBehavior.opaque, // ensures the entire area is tappable
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Padding(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
padding: const EdgeInsets.symmetric(vertical: 5.0), // adds comfortable tap height
|
||||||
children: [
|
child: Column(
|
||||||
Icon(
|
mainAxisSize: MainAxisSize.min,
|
||||||
icon,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
color: isSelected ? Colors.white : Colors.black,
|
children: [
|
||||||
),
|
Icon(
|
||||||
const SizedBox(height: 4),
|
icon,
|
||||||
Text(
|
|
||||||
label,
|
|
||||||
style: TextStyle(
|
|
||||||
color: isSelected ? Colors.white : Colors.black,
|
color: isSelected ? Colors.white : Colors.black,
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
|
||||||
),
|
),
|
||||||
),
|
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) {
|
void onTabTapped(int index) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
Reference in New Issue
Block a user