import 'package:didvan/config/design_config.dart'; import 'package:didvan/config/theme_data.dart'; import 'package:didvan/constants/app_icons.dart'; import 'package:didvan/routes/routes.dart'; import 'package:didvan/views/widgets/didvan/text.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import '../audio/player_navbar.dart'; class DidvanBNB extends StatelessWidget { final int currentTabIndex; final void Function(int index) onTabChanged; const DidvanBNB( {Key? key, required this.currentTabIndex, required this.onTabChanged}) : super(key: key); @override Widget build(BuildContext context) { return Stack( children: [ const PlayerNavBar( inHome: true, ), Positioned( bottom: 0, left: 0, right: 0, child: Container( height: 72, decoration: BoxDecoration( color: Theme.of(context).colorScheme.surface, borderRadius: const BorderRadius.vertical(top: Radius.circular(0)), border: const Border( top: BorderSide( color: const Color.fromARGB(255, 224, 224, 224), width: 1.5, ), ), ), padding: const EdgeInsets.symmetric(horizontal: 12), child: Row( children: [ _NavBarItem( isSelected: currentTabIndex == 1, title: 'دسته‌بندی', selectedIcon: DidvanIcons.category_solid, unselectedIcon: DidvanIcons.category_light, onTap: () => onTabChanged(1), ), _NavBarItem( isSelected: false, title: 'هوشان', selectedIcon: DidvanIcons.ai_solid, unselectedIcon: DidvanIcons.ai_regular, onTap: () => Navigator.of(context).pushNamed(Routes.aiSection), isHomeButton: false, customLogo: SvgPicture.asset( 'lib/assets/icons/bot.svg', width: 32, height: 32, ), ), _NavBarItem( isSelected: currentTabIndex == 0, title: 'خانه', selectedIcon: DidvanIcons.house_solid, unselectedIcon: DidvanIcons.house_light, onTap: () => onTabChanged(0), isHomeButton: false, customLogo: SvgPicture.asset( DesignConfig.isDark ? 'assets/images/logos/logo-vertical-dark.svg' : 'lib/assets/icons/home2.svg', width: 32, height: 32, ), ), _NavBarItem( isSelected: currentTabIndex == 2, title: 'آمار و داده', selectedIcon: DidvanIcons.stats__solid, unselectedIcon: DidvanIcons.stats__light, onTap: () => onTabChanged(2), isHomeButton: false, customLogo: SvgPicture.asset( DesignConfig.isDark ? 'lib/assets/icons/stats_nav_icon_dark.svg' : 'lib/assets/icons/chart 2.svg', width: 32, height: 32, ), ), _NavBarItem( isSelected: currentTabIndex == 3, title: 'کاوش', selectedIcon: DidvanIcons.profile_solid, // Placeholder unselectedIcon: DidvanIcons.profile_light, // Placeholder onTap: () => onTabChanged(3), customLogo: SvgPicture.asset( 'lib/assets/icons/discover.svg', width: 25, height: 25, ), ), ], ), ), ), ], ); } } class _NavBarItem extends StatelessWidget { final VoidCallback onTap; final bool isSelected; final String title; final IconData selectedIcon; final IconData unselectedIcon; final bool isHomeButton; final Widget? customLogo; const _NavBarItem({ Key? key, required this.isSelected, required this.title, required this.selectedIcon, required this.unselectedIcon, required this.onTap, this.isHomeButton = false, this.customLogo, }) : super(key: key); @override Widget build(BuildContext context) { return Expanded( child: Tooltip( message: title, decoration: BoxDecoration( color: Theme.of(context).colorScheme.title, borderRadius: DesignConfig.highBorderRadius, boxShadow: DesignConfig.defaultShadow, ), child: GestureDetector( onTap: onTap, child: Container( color: Colors.transparent, child: Column( children: [ const SizedBox( height: 4, ), if (customLogo != null) ...[ AnimatedContainer( padding: EdgeInsets.all(isHomeButton ? 8 : 4), duration: DesignConfig.lowAnimationDuration, child: SizedBox( width: isHomeButton ? 50 : (isSelected ? 50 : 32), height: isHomeButton ? 50 : (isSelected ? 50 : 32), child: customLogo, ), ), if (!isHomeButton && !isSelected) DidvanText( title, style: Theme.of(context).textTheme.bodySmall, color: Theme.of(context).colorScheme.title, ), ] else ...[ AnimatedContainer( padding: const EdgeInsets.all(4), duration: DesignConfig.lowAnimationDuration, child: Icon( isSelected ? selectedIcon : unselectedIcon, size: isSelected ? 40 : 32, color: DesignConfig.isDark ? Theme.of(context).colorScheme.text : Theme.of(context).colorScheme.title, ), ), if (!isHomeButton && !isSelected) DidvanText( title, style: Theme.of(context).textTheme.bodySmall, color: Theme.of(context).colorScheme.title, ), ], const Spacer(), ], ), ), ), ), ); } }