You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			105 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			105 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Dart
		
	
| 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/generated/locale_keys.g.dart';
 | |
| import 'package:hmg_patient_app_new/theme/colors.dart';
 | |
| 
 | |
| class BottomNavigation extends StatelessWidget {
 | |
|   final int currentIndex;
 | |
|   final ValueChanged<int> onTap;
 | |
|   BuildContext? context;
 | |
| 
 | |
|   BottomNavigation({super.key, required this.currentIndex, required this.onTap, this.context});
 | |
| 
 | |
|   @override
 | |
|   Widget build(BuildContext context) {
 | |
|     AppState appState = getIt.get<AppState>();
 | |
|     final items = [
 | |
|       BottomNavItem(icon: AppAssets.homeBottom, label: LocaleKeys.home.tr(context: context)),
 | |
|       appState.isAuthenticated
 | |
|           ? BottomNavItem(icon: AppAssets.myFilesBottom, label: LocaleKeys.myFiles.tr(context: context))
 | |
|           : BottomNavItem(icon: AppAssets.feedback, label: LocaleKeys.feedback.tr()),
 | |
|       BottomNavItem(
 | |
|         icon: AppAssets.bookAppoBottom,
 | |
|         label: LocaleKeys.appointment.tr(context: context),
 | |
|         iconSize: 27,
 | |
|         isSpecial: true,
 | |
|       ),
 | |
|       appState.isAuthenticated ? BottomNavItem(icon: AppAssets.toDoBottom, label: LocaleKeys.todoList.tr(context: context)) : BottomNavItem(icon: AppAssets.news, label: LocaleKeys.news.tr()),
 | |
|       BottomNavItem(icon: AppAssets.servicesBottom, label: LocaleKeys.services2.tr(context: context)),
 | |
|     ];
 | |
| 
 | |
|     return Container(
 | |
|       decoration: _containerDecoration,
 | |
|       padding: _containerPadding,
 | |
|       child: Row(
 | |
|         mainAxisAlignment: MainAxisAlignment.spaceAround,
 | |
|         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: Column(
 | |
|         mainAxisSize: MainAxisSize.min,
 | |
|         children: [
 | |
|           Center(
 | |
|             child: Utils.buildSvgWithAssets(
 | |
|               icon: item.icon,
 | |
|               height: item.iconSize.h,
 | |
|               width: item.iconSize.h,
 | |
|               // iconColor:  isSelected ? Colors.black87 : Colors.black87,
 | |
|             ),
 | |
|           ),
 | |
|           const SizedBox(height: 10),
 | |
|           item.label.toText12(
 | |
|             fontWeight: FontWeight.w500,
 | |
|             // color:  Colors.black87,
 | |
|             // textAlign: TextAlign.center,
 | |
|           ),
 | |
|           SizedBox(height: item.isSpecial ? 5 : 0)
 | |
|         ],
 | |
|       ),
 | |
|     );
 | |
|   }
 | |
| }
 | |
| 
 | |
| class BottomNavItem {
 | |
|   final String icon;
 | |
|   final String label;
 | |
|   final double iconSize;
 | |
|   final bool isSpecial;
 | |
| 
 | |
|   const BottomNavItem({
 | |
|     required this.icon,
 | |
|     required this.label,
 | |
|     this.iconSize = 21,
 | |
|     this.isSpecial = false,
 | |
|   });
 | |
| }
 | |
| 
 | |
| // Constants
 | |
| const EdgeInsets _containerPadding = EdgeInsets.all(15);
 | |
| const BoxDecoration _containerDecoration = BoxDecoration(
 | |
|   color: Colors.white,
 | |
|   border: Border(
 | |
|     top: BorderSide(
 | |
|       color: AppColors.bottomNAVBorder,
 | |
|       width: 0.5,
 | |
|     ),
 | |
|   ),
 | |
| );
 |