|  |  |  | @ -4,18 +4,15 @@ import 'package:hmg_patient_app_new/core/app_assets.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/extensions/route_extensions.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/features/authentication/authentication_view_model.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/services/navigation_service.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/theme/colors.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/widgets/bottomsheet/exception_bottom_sheet.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:provider/provider.dart'; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | abstract class DialogService { | 
		
	
		
			
				|  |  |  |  |   Future<void> showErrorBottomSheet({required String message, Function()? onOkPressed}); | 
		
	
		
			
				|  |  |  |  |   Future<void> showErrorBottomSheet({String title = "", required String message, Function()? onOkPressed, Function()? onCancelPressed}); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<void> showExceptionBottomSheet({required String message, required Function() onOkPressed, Function()? onCancelPressed}); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
	
		
			
				
					|  |  |  | @ -28,21 +25,40 @@ abstract class DialogService { | 
		
	
		
			
				|  |  |  |  | class DialogServiceImp implements DialogService { | 
		
	
		
			
				|  |  |  |  |   final NavigationService navigationService; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   bool _isErrorSheetShowing = false; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   DialogServiceImp({required this.navigationService}); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   @override | 
		
	
		
			
				|  |  |  |  |   Future<void> showErrorBottomSheet({required String message, Function()? onOkPressed}) async { | 
		
	
		
			
				|  |  |  |  |   Future<void> showErrorBottomSheet({String title = "", required String message, Function()? onOkPressed, Function()? onCancelPressed}) async { | 
		
	
		
			
				|  |  |  |  |     if (_isErrorSheetShowing) return; | 
		
	
		
			
				|  |  |  |  |     final context = navigationService.navigatorKey.currentContext; | 
		
	
		
			
				|  |  |  |  |     if (context == null) return; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     _isErrorSheetShowing = true; | 
		
	
		
			
				|  |  |  |  |     await showModalBottomSheet( | 
		
	
		
			
				|  |  |  |  |       context: context, | 
		
	
		
			
				|  |  |  |  |       isScrollControlled: false, | 
		
	
		
			
				|  |  |  |  |       shape: const RoundedRectangleBorder( | 
		
	
		
			
				|  |  |  |  |         borderRadius: BorderRadius.vertical(top: Radius.circular(16)), | 
		
	
		
			
				|  |  |  |  |       ), | 
		
	
		
			
				|  |  |  |  |       builder: (_) => _ErrorBottomSheet(message: message, onOkPressed: onOkPressed ?? () {}), | 
		
	
		
			
				|  |  |  |  |       builder: (_) => ExceptionBottomSheet( | 
		
	
		
			
				|  |  |  |  |         // title: title, | 
		
	
		
			
				|  |  |  |  |         message: message, | 
		
	
		
			
				|  |  |  |  |         showCancel: onCancelPressed != null ? true : false, | 
		
	
		
			
				|  |  |  |  |         onOkPressed: () { | 
		
	
		
			
				|  |  |  |  |           if (onOkPressed != null) { | 
		
	
		
			
				|  |  |  |  |             onOkPressed(); | 
		
	
		
			
				|  |  |  |  |           } | 
		
	
		
			
				|  |  |  |  |         }, | 
		
	
		
			
				|  |  |  |  |         onCancelPressed: () { | 
		
	
		
			
				|  |  |  |  |           if (onCancelPressed != null) { | 
		
	
		
			
				|  |  |  |  |             context.pop(); | 
		
	
		
			
				|  |  |  |  |           } | 
		
	
		
			
				|  |  |  |  |         }, | 
		
	
		
			
				|  |  |  |  |       ), | 
		
	
		
			
				|  |  |  |  |     ); | 
		
	
		
			
				|  |  |  |  |     _isErrorSheetShowing = false; | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   @override | 
		
	
	
		
			
				
					|  |  |  | @ -73,9 +89,8 @@ class DialogServiceImp implements DialogService { | 
		
	
		
			
				|  |  |  |  |   Future<void> showCommonBottomSheetWithoutH({String? label, required String message, required Function() onOkPressed, Function()? onCancelPressed}) async { | 
		
	
		
			
				|  |  |  |  |     final context = navigationService.navigatorKey.currentContext; | 
		
	
		
			
				|  |  |  |  |     if (context == null) return; | 
		
	
		
			
				|  |  |  |  |     showCommonBottomSheetWithoutHeight(context, title: label ?? "", child: exceptionBottomSheetWidget(context: context, message: message, onOkPressed: onOkPressed, onCancelPressed: onCancelPressed), | 
		
	
		
			
				|  |  |  |  |         callBackFunc: () { | 
		
	
		
			
				|  |  |  |  |     }); | 
		
	
		
			
				|  |  |  |  |     showCommonBottomSheetWithoutHeight(context, | 
		
	
		
			
				|  |  |  |  |         title: label ?? "", child: exceptionBottomSheetWidget(context: context, message: message, onOkPressed: onOkPressed, onCancelPressed: onCancelPressed), callBackFunc: () {}); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   @override | 
		
	
	
		
			
				
					|  |  |  | @ -90,10 +105,10 @@ class DialogServiceImp implements DialogService { | 
		
	
		
			
				|  |  |  |  | Widget exceptionBottomSheetWidget({required BuildContext context, required String message, required Function() onOkPressed, Function()? onCancelPressed}) { | 
		
	
		
			
				|  |  |  |  |   return Column( | 
		
	
		
			
				|  |  |  |  |     children: [ | 
		
	
		
			
				|  |  |  |  |       (message ?? "").toText16(isBold: false, color: AppColors.textColor), | 
		
	
		
			
				|  |  |  |  |       (message).toText16(isBold: false, color: AppColors.textColor), | 
		
	
		
			
				|  |  |  |  |       SizedBox(height: 10.h), | 
		
	
		
			
				|  |  |  |  |       SizedBox(height: 24.h), | 
		
	
		
			
				|  |  |  |  |       if (onOkPressed != null && onCancelPressed != null) | 
		
	
		
			
				|  |  |  |  |       if (onCancelPressed != null) | 
		
	
		
			
				|  |  |  |  |         Row( | 
		
	
		
			
				|  |  |  |  |           children: [ | 
		
	
		
			
				|  |  |  |  |             Expanded( | 
		
	
	
		
			
				
					|  |  |  | @ -112,7 +127,7 @@ Widget exceptionBottomSheetWidget({required BuildContext context, required Strin | 
		
	
		
			
				|  |  |  |  |             SizedBox(width: 5.h), | 
		
	
		
			
				|  |  |  |  |             Expanded( | 
		
	
		
			
				|  |  |  |  |               child: CustomButton( | 
		
	
		
			
				|  |  |  |  |                 text: onCancelPressed != null ? LocaleKeys.confirm.tr() : LocaleKeys.ok.tr(), | 
		
	
		
			
				|  |  |  |  |                 text: LocaleKeys.confirm.tr(), | 
		
	
		
			
				|  |  |  |  |                 onPressed: onOkPressed, | 
		
	
		
			
				|  |  |  |  |                 backgroundColor: AppColors.bgGreenColor, | 
		
	
		
			
				|  |  |  |  |                 borderColor: AppColors.bgGreenColor, | 
		
	
	
		
			
				
					|  |  |  | @ -122,14 +137,14 @@ Widget exceptionBottomSheetWidget({required BuildContext context, required Strin | 
		
	
		
			
				|  |  |  |  |             ), | 
		
	
		
			
				|  |  |  |  |           ], | 
		
	
		
			
				|  |  |  |  |         ), | 
		
	
		
			
				|  |  |  |  |       if (onOkPressed != null && onCancelPressed == null) | 
		
	
		
			
				|  |  |  |  |       if (onCancelPressed == null) | 
		
	
		
			
				|  |  |  |  |         Padding( | 
		
	
		
			
				|  |  |  |  |           padding: EdgeInsets.only(bottom: 10.h), | 
		
	
		
			
				|  |  |  |  |           child: CustomButton( | 
		
	
		
			
				|  |  |  |  |             text: LocaleKeys.ok.tr(), | 
		
	
		
			
				|  |  |  |  |             onPressed: (onOkPressed != null && onCancelPressed == null) | 
		
	
		
			
				|  |  |  |  |             onPressed: (onCancelPressed == null) | 
		
	
		
			
				|  |  |  |  |                 ? () { | 
		
	
		
			
				|  |  |  |  |                     Navigator.of(context).pop(); | 
		
	
		
			
				|  |  |  |  |                     context.pop(); | 
		
	
		
			
				|  |  |  |  |                   } | 
		
	
		
			
				|  |  |  |  |                 : onOkPressed, | 
		
	
		
			
				|  |  |  |  |             backgroundColor: AppColors.primaryRedColor, | 
		
	
	
		
			
				
					|  |  |  | @ -144,7 +159,6 @@ Widget exceptionBottomSheetWidget({required BuildContext context, required Strin | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | Widget showPhoneNumberPickerWidget({required BuildContext context, String? message, required Function() onSMSPress, required Function() onWhatsappPress}) { | 
		
	
		
			
				|  |  |  |  |   return StatefulBuilder(builder: (BuildContext context, StateSetter setModalState) { | 
		
	
		
			
				|  |  |  |  |     AuthenticationViewModel authViewModel = context.read<AuthenticationViewModel>(); | 
		
	
		
			
				|  |  |  |  |     return Column( | 
		
	
		
			
				|  |  |  |  |       children: [ | 
		
	
		
			
				|  |  |  |  |         (message ?? "").toText16(isBold: false, color: AppColors.textColor), | 
		
	
	
		
			
				
					|  |  |  | @ -202,56 +216,3 @@ Widget showPhoneNumberPickerWidget({required BuildContext context, String? messa | 
		
	
		
			
				|  |  |  |  |     //     ); | 
		
	
		
			
				|  |  |  |  |   }); | 
		
	
		
			
				|  |  |  |  | } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | class _ErrorBottomSheet extends StatelessWidget { | 
		
	
		
			
				|  |  |  |  |   final String message; | 
		
	
		
			
				|  |  |  |  |   final Function()? onOkPressed; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   const _ErrorBottomSheet({required this.message, this.onOkPressed}); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   @override | 
		
	
		
			
				|  |  |  |  |   Widget build(BuildContext context) { | 
		
	
		
			
				|  |  |  |  |     return Padding( | 
		
	
		
			
				|  |  |  |  |       padding: const EdgeInsets.all(16), | 
		
	
		
			
				|  |  |  |  |       child: Column( | 
		
	
		
			
				|  |  |  |  |         mainAxisSize: MainAxisSize.min, | 
		
	
		
			
				|  |  |  |  |         children: [ | 
		
	
		
			
				|  |  |  |  |           const Icon(Icons.error_outline, color: Colors.red, size: 40), | 
		
	
		
			
				|  |  |  |  |           const SizedBox(height: 12), | 
		
	
		
			
				|  |  |  |  |           Text( | 
		
	
		
			
				|  |  |  |  |             "Error", | 
		
	
		
			
				|  |  |  |  |             style: Theme.of(context).textTheme.titleLarge?.copyWith( | 
		
	
		
			
				|  |  |  |  |                   color: Colors.red, | 
		
	
		
			
				|  |  |  |  |                   fontWeight: FontWeight.bold, | 
		
	
		
			
				|  |  |  |  |                 ), | 
		
	
		
			
				|  |  |  |  |           ), | 
		
	
		
			
				|  |  |  |  |           const SizedBox(height: 8), | 
		
	
		
			
				|  |  |  |  |           Text( | 
		
	
		
			
				|  |  |  |  |             message, | 
		
	
		
			
				|  |  |  |  |             textAlign: TextAlign.center, | 
		
	
		
			
				|  |  |  |  |             style: Theme.of(context).textTheme.bodyMedium, | 
		
	
		
			
				|  |  |  |  |           ), | 
		
	
		
			
				|  |  |  |  |           const SizedBox(height: 16), | 
		
	
		
			
				|  |  |  |  |           ElevatedButton( | 
		
	
		
			
				|  |  |  |  |             onPressed: () { | 
		
	
		
			
				|  |  |  |  |               if (onOkPressed != null) { | 
		
	
		
			
				|  |  |  |  |                 onOkPressed!(); | 
		
	
		
			
				|  |  |  |  |               } else { | 
		
	
		
			
				|  |  |  |  |                 context.pop(); | 
		
	
		
			
				|  |  |  |  |               } | 
		
	
		
			
				|  |  |  |  |             }, | 
		
	
		
			
				|  |  |  |  |             style: ElevatedButton.styleFrom( | 
		
	
		
			
				|  |  |  |  |               backgroundColor: Colors.red, | 
		
	
		
			
				|  |  |  |  |               shape: RoundedRectangleBorder( | 
		
	
		
			
				|  |  |  |  |                 borderRadius: BorderRadius.circular(8), | 
		
	
		
			
				|  |  |  |  |               ), | 
		
	
		
			
				|  |  |  |  |             ), | 
		
	
		
			
				|  |  |  |  |             child: const Text("OK", style: TextStyle(color: Colors.white)).onPress(() { | 
		
	
		
			
				|  |  |  |  |               Navigator.of(context).pop(); | 
		
	
		
			
				|  |  |  |  |             }), | 
		
	
		
			
				|  |  |  |  |           ), | 
		
	
		
			
				|  |  |  |  |         ], | 
		
	
		
			
				|  |  |  |  |       ), | 
		
	
		
			
				|  |  |  |  |     ); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | } | 
		
	
	
		
			
				
					|  |  |  | 
 |