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.
		
		
		
		
		
			
		
			
				
	
	
		
			49 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Dart
		
	
| import 'package:flutter/foundation.dart';
 | |
| import 'package:flutter/material.dart';
 | |
| import 'package:get_it/get_it.dart';
 | |
| import 'package:hmg_patient_app_new/core/api_consts.dart';
 | |
| import 'package:hmg_patient_app_new/core/dependencies.dart';
 | |
| import 'package:hmg_patient_app_new/core/enums.dart';
 | |
| import 'package:hmg_patient_app_new/core/utils/utils.dart';
 | |
| import 'package:hmg_patient_app_new/services/navigation_service.dart';
 | |
| 
 | |
| class LoaderBottomSheet {
 | |
|   static final NavigationService _navService = GetIt.I<NavigationService>();
 | |
|   static bool _isVisible = false;
 | |
| 
 | |
|   static void showLoader() {
 | |
|     if (_isVisible) return;
 | |
| 
 | |
|     _isVisible = true;
 | |
| 
 | |
|     showModalBottomSheet(
 | |
|       context: _navService.navigatorKey.currentContext!,
 | |
|       isDismissible: (ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat || kDebugMode) ? true : false,
 | |
|       enableDrag: false,
 | |
|       backgroundColor: Colors.transparent,
 | |
|       builder: (_) {
 | |
|         return Container(
 | |
|           height: MediaQuery.of(_navService.navigatorKey.currentContext!).size.height * 0.3,
 | |
|           decoration: const BoxDecoration(
 | |
|             color: Colors.white,
 | |
|             borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
 | |
|           ),
 | |
|           child: Center(
 | |
|             child: Utils.getLoadingWidget(),
 | |
|           ),
 | |
|         );
 | |
|       },
 | |
|     ).whenComplete(() {
 | |
|       // reset state if dismissed by system
 | |
|       _isVisible = false;
 | |
|     });
 | |
|   }
 | |
| 
 | |
|   static void hideLoader() {
 | |
|     if (_isVisible) {
 | |
|       Navigator.of(_navService.navigatorKey.currentContext!).pop();
 | |
|       _isVisible = false;
 | |
|     }
 | |
|   }
 | |
| }
 |