import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:hmg_patient_app_new/core/app_assets.dart'; import 'package:hmg_patient_app_new/core/app_state.dart'; import 'package:hmg_patient_app_new/core/dependencies.dart'; import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; class BottomNavigation extends StatelessWidget { final int currentIndex; final ValueChanged onTap; const BottomNavigation({super.key, required this.currentIndex, required this.onTap}); @override Widget build(BuildContext context) { AppState appState = getIt.get(); final items = [ BottomNavItem(icon: AppAssets.homeBottom, fillIcon: AppAssets.homeBottomFill, label: LocaleKeys.home.tr(context: context)), appState.isAuthenticated ? BottomNavItem(icon: AppAssets.myFilesBottom, fillIcon: AppAssets.myFilesBottomFill, label: LocaleKeys.medicalFile.tr(context: context)) : BottomNavItem(icon: AppAssets.feedback, fillIcon: AppAssets.feedbackFill, label: LocaleKeys.feedback.tr()), BottomNavItem( icon: AppAssets.bookAppoBottom, fillIcon: AppAssets.bookAppoBottom, label: LocaleKeys.appointment.tr(context: context), iconSize: 32, isSpecial: true, ), appState.isAuthenticated // ? BottomNavItem(icon: AppAssets.toDoBottom, label: LocaleKeys.todoList.tr(context: context)) ? BottomNavItem(icon: AppAssets.symptomCheckerBottomIcon, fillIcon: AppAssets.symptomCheckerBottomFillIcon, label: "Symptoms") : BottomNavItem(icon: AppAssets.news, fillIcon: AppAssets.newsFill, label: LocaleKeys.news.tr()), BottomNavItem(icon: AppAssets.servicesBottom, fillIcon: AppAssets.servicesBottomFill, label: LocaleKeys.services2.tr(context: context)), ]; return Container( decoration: _containerDecoration, padding: _containerPadding, // height: 84.h, child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: List.generate( items.length, (index) => _buildNavItem(items[index], index), ), ), ); } Widget _buildNavItem(BottomNavItem item, int index) { final bool isSelected = currentIndex == index; return GestureDetector( onTap: () => onTap(index), behavior: HitTestBehavior.opaque, child: SizedBox( height: 50.h, child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Utils.buildSvgWithAssets( icon: isSelected ? item.fillIcon : item.icon, height: item.iconSize.h, width: item.iconSize.w, // iconColor: isSelected ? Colors.black87 : Colors.black87, ), // const SizedBox(height: 10), SizedBox(height: item.isSpecial ? 0 : 8.h), item.label.toText11(weight: FontWeight.w500), // SizedBox(height: item.isSpecial ? 5 : 0) ], ), ), ).expanded; } } class BottomNavItem { final String icon; final String fillIcon; final String label; final double iconSize; final bool isSpecial; final Color? color; const BottomNavItem({ required this.icon, required this.fillIcon, required this.label, this.iconSize = 24, this.isSpecial = false, this.color, }); } // Constants const EdgeInsets _containerPadding = EdgeInsets.all(15); const BoxDecoration _containerDecoration = BoxDecoration( color: Colors.white, border: Border( top: BorderSide( color: AppColors.bottomNAVBorder, width: 0.5, ), ), );