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.
		
		
		
		
		
			
		
			
	
	
		
			72 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Dart
		
	
		
		
			
		
	
	
			72 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Dart
		
	
| 
											2 months ago
										 | import 'package:flutter/material.dart'; | ||
|  | import 'package:hmg_patient_app_new/services/navigation_service.dart'; | ||
|  | 
 | ||
|  | abstract class DialogService { | ||
|  |   Future<void> showErrorDialog(String message); | ||
|  | } | ||
|  | 
 | ||
|  | class DialogServiceImp implements DialogService { | ||
|  |   final NavigationService navigationService; | ||
|  | 
 | ||
|  |   DialogServiceImp({required this.navigationService}); | ||
|  | 
 | ||
|  |   @override | ||
|  |   Future<void> showErrorDialog(String message) async { | ||
|  |     final context = navigationService.navigatorKey.currentContext; | ||
|  |     if (context == null) return; | ||
|  | 
 | ||
|  |     await showModalBottomSheet( | ||
|  |       context: context, | ||
|  |       isScrollControlled: false, | ||
|  |       shape: const RoundedRectangleBorder( | ||
|  |         borderRadius: BorderRadius.vertical(top: Radius.circular(16)), | ||
|  |       ), | ||
|  |       builder: (_) => _ErrorBottomSheet(message: message), | ||
|  |     ); | ||
|  |   } | ||
|  | } | ||
|  | 
 | ||
|  | class _ErrorBottomSheet extends StatelessWidget { | ||
|  |   final String message; | ||
|  | 
 | ||
|  |   const _ErrorBottomSheet({required this.message}); | ||
|  | 
 | ||
|  |   @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: () => Navigator.of(context).pop(), | ||
|  |             style: ElevatedButton.styleFrom( | ||
|  |               backgroundColor: Colors.red, | ||
|  |               shape: RoundedRectangleBorder( | ||
|  |                 borderRadius: BorderRadius.circular(8), | ||
|  |               ), | ||
|  |             ), | ||
|  |             child: const Text("OK"), | ||
|  |           ), | ||
|  |         ], | ||
|  |       ), | ||
|  |     ); | ||
|  |   } | ||
|  | } |