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.
		
		
		
		
		
			
		
			
				
	
	
		
			247 lines
		
	
	
		
			8.3 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			247 lines
		
	
	
		
			8.3 KiB
		
	
	
	
		
			Dart
		
	
| import 'package:flutter/material.dart';
 | |
| import 'package:hmg_patient_app_new/core/app_assets.dart';
 | |
| import 'package:hmg_patient_app_new/core/app_export.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/theme/colors.dart';
 | |
| 
 | |
| void showCommonBottomSheet(BuildContext context,
 | |
|     {required Widget child,
 | |
|     Function(String?)? callBackFunc,
 | |
|     String? title,
 | |
|     required double height,
 | |
|     bool isCloseButtonVisible = true,
 | |
|     bool isFullScreen = true,
 | |
|     bool isDismissible = true,
 | |
|     bool isSuccessDialog = false}) {
 | |
|   showModalBottomSheet<String>(
 | |
|       sheetAnimationStyle: AnimationStyle(
 | |
|         duration: Duration(milliseconds: 500), // Custom animation duration
 | |
|         reverseDuration: Duration(milliseconds: 300), // Custom reverse animation duration
 | |
|       ),
 | |
|       context: context,
 | |
|       isScrollControlled: true,
 | |
|       showDragHandle: false,
 | |
|       isDismissible: isDismissible,
 | |
|       backgroundColor: isSuccessDialog ? AppColors.whiteColor : AppColors.scaffoldBgColor,
 | |
|       builder: (BuildContext context) {
 | |
|         return Container(
 | |
|           height: height,
 | |
|           decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.scaffoldBgColor, borderRadius: 24.h),
 | |
|           child: ButtonSheetContent(
 | |
|             title: title!,
 | |
|             isCloseButtonVisible: isCloseButtonVisible,
 | |
|             isFullScreen: isFullScreen,
 | |
|             child: child,
 | |
|           ),
 | |
|         );
 | |
|       }).then((value) {
 | |
|     if (value != null) {
 | |
|       callBackFunc!(value);
 | |
|     }
 | |
|   });
 | |
| }
 | |
| 
 | |
| class ButtonSheetContent extends StatelessWidget {
 | |
|   final Widget child;
 | |
|   final String title;
 | |
|   final bool isCloseButtonVisible;
 | |
|   final bool isFullScreen;
 | |
| 
 | |
|   const ButtonSheetContent({super.key, required this.child, required this.isCloseButtonVisible, required this.title, required this.isFullScreen});
 | |
| 
 | |
|   @override
 | |
|   Widget build(BuildContext context) {
 | |
|     return Column(
 | |
|       crossAxisAlignment: CrossAxisAlignment.center,
 | |
|       children: [
 | |
|         // SizedBox(
 | |
|         //   height: 20.h,
 | |
|         // ),
 | |
|         // Center(
 | |
|         //   child: Container(
 | |
|         //     margin: const EdgeInsets.only(top: 18, bottom: 12),
 | |
|         //     height: 4,
 | |
|         //     width: 40.h,
 | |
|         //     decoration: BoxDecoration(
 | |
|         //       color: Colors.grey[400],
 | |
|         //       borderRadius: BorderRadius.circular(2),
 | |
|         //     ),
 | |
|         //   ),
 | |
|         // ),
 | |
| 
 | |
|         // Close button
 | |
|         isCloseButtonVisible && isFullScreen
 | |
|             ? Column(children: [
 | |
|                 SizedBox(
 | |
|                   height: 40.h,
 | |
|                 ),
 | |
|                 Padding(
 | |
|                   padding: EdgeInsets.symmetric(
 | |
|                     horizontal: 16,
 | |
|                   ),
 | |
|                   child: Utils.buildSvgWithAssets(icon: AppAssets.closeBottomNav, width: 32, height: 32).onPress(() {
 | |
|                     Navigator.of(context).pop();
 | |
|                   }),
 | |
|                 )
 | |
|               ])
 | |
|             : SizedBox(),
 | |
| 
 | |
|         isFullScreen
 | |
|             ? Column(
 | |
|                 children: [
 | |
|                   SizedBox(height: 20.h),
 | |
|                   Padding(padding: EdgeInsets.symmetric(horizontal: 16.h), child: title.toText24(isBold: true)),
 | |
|                   SizedBox(height: 16.h),
 | |
|                 ],
 | |
|               )
 | |
|             : SizedBox(),
 | |
| 
 | |
|         Expanded(child: child)
 | |
|       ],
 | |
|     );
 | |
|   }
 | |
| }
 | |
| 
 | |
| void showCommonBottomSheetWithoutHeight(
 | |
|     BuildContext context, {
 | |
|       required Widget child,
 | |
|       required VoidCallback callBackFunc,
 | |
|       String title = "",
 | |
|       bool isCloseButtonVisible = true,
 | |
|       bool isFullScreen = true,
 | |
|       bool isDismissible = true,
 | |
|       Widget? titleWidget,
 | |
|       bool useSafeArea = false,
 | |
|   bool hasBottomPadding = true,
 | |
|   Color backgroundColor = AppColors.bottomSheetBgColor,
 | |
| }) {
 | |
|   showModalBottomSheet<String>(
 | |
|     sheetAnimationStyle: AnimationStyle(
 | |
|       duration: Duration(milliseconds: 500),
 | |
|       reverseDuration: Duration(milliseconds: 300),
 | |
|     ),
 | |
|     constraints: BoxConstraints(
 | |
|       maxWidth: MediaQuery.of(context).size.width, // Full width
 | |
|     ),
 | |
|     context: context,
 | |
|     isScrollControlled: true,
 | |
|     showDragHandle: false,
 | |
|     isDismissible: isDismissible,
 | |
|     backgroundColor: backgroundColor,
 | |
|     useSafeArea: useSafeArea,
 | |
|     builder: (BuildContext context) {
 | |
|       return SafeArea(
 | |
|         top: false,
 | |
|         left: false,
 | |
|         right: false,
 | |
|         bottom: hasBottomPadding,
 | |
|         child: Padding(
 | |
|           padding: EdgeInsets.only(
 | |
|             bottom: MediaQuery.of(context).viewInsets.bottom,
 | |
|           ),
 | |
|           child: SingleChildScrollView(
 | |
|             physics: ClampingScrollPhysics(),
 | |
|             child: isCloseButtonVisible
 | |
|                 ? Container(
 | |
|               padding: EdgeInsets.only(
 | |
|                 left: 24,
 | |
|                 top: 24,
 | |
|                 right: 24,
 | |
|                 bottom: 12,
 | |
|               ),
 | |
|               decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
 | |
|                 color: AppColors.bottomSheetBgColor,
 | |
|                 borderRadius: 24.h,
 | |
|               ),
 | |
|               child: Column(
 | |
|                 mainAxisSize: MainAxisSize.min,
 | |
|                 children: [
 | |
|                   Row(
 | |
|                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
 | |
|                     crossAxisAlignment: CrossAxisAlignment.center,
 | |
|                     children: [
 | |
|                       titleWidget ??
 | |
|                           Expanded(
 | |
|                             child: title.toText20(weight: FontWeight.w600),
 | |
|                           ),
 | |
|                       Utils.buildSvgWithAssets(
 | |
|                         icon: AppAssets.close_bottom_sheet_icon,
 | |
|                         iconColor: Color(0xff2B353E),
 | |
|                       ).onPress(() {
 | |
|                         Navigator.of(context).pop();
 | |
|                       }),
 | |
|                     ],
 | |
|                   ),
 | |
|                   SizedBox(height: 16.h),
 | |
|                   child,
 | |
|                 ],
 | |
|               ),
 | |
|             )
 | |
|                 : child,
 | |
|           ),
 | |
|         ),
 | |
|       );
 | |
|     },
 | |
|   ).then((value) {
 | |
|     callBackFunc();
 | |
|   });
 | |
| }
 | |
| 
 | |
| // void showCommonBottomSheetWithoutHeight(
 | |
| //   BuildContext context, {
 | |
| //   required Widget child,
 | |
| //   required VoidCallback callBackFunc,
 | |
| //   String title = "",
 | |
| //   bool isCloseButtonVisible = true,
 | |
| //   bool isFullScreen = true,
 | |
| //   bool isDismissible = true,
 | |
| //   Widget? titleWidget,
 | |
| //   bool useSafeArea = false,
 | |
| //
 | |
| // }) {
 | |
| //   showModalBottomSheet<String>(
 | |
| //       sheetAnimationStyle: AnimationStyle(
 | |
| //         duration: Duration(milliseconds: 500), // Custom animation duration
 | |
| //         reverseDuration: Duration(milliseconds: 300), // Custom reverse animation duration
 | |
| //       ),
 | |
| //       context: context,
 | |
| //       isScrollControlled: true,
 | |
| //       showDragHandle: false,
 | |
| //       isDismissible: isDismissible,
 | |
| //       backgroundColor: AppColors.bottomSheetBgColor,
 | |
| //       useSafeArea: useSafeArea,
 | |
| //       builder: (BuildContext context) {
 | |
| //         return SafeArea(
 | |
| //           top: false,
 | |
| //           left: false,
 | |
| //           right: false,
 | |
| //           child: isCloseButtonVisible
 | |
| //               ? Container(
 | |
| //                   padding: EdgeInsets.only(left: 24, top: 24, right: 24, bottom: 12),
 | |
| //                   decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.bottomSheetBgColor, borderRadius: 24.h),
 | |
| //                   child: Column(
 | |
| //                     mainAxisSize: MainAxisSize.min,
 | |
| //                     spacing: 16.h,
 | |
| //                     children: [
 | |
| //                       Row(
 | |
| //                         mainAxisAlignment: MainAxisAlignment.spaceBetween,
 | |
| //                         crossAxisAlignment: CrossAxisAlignment.center,
 | |
| //                         children: [
 | |
| //                           titleWidget ?? Expanded(child: title.toText20(weight: FontWeight.w600)),
 | |
| //                           Utils.buildSvgWithAssets(icon: AppAssets.close_bottom_sheet_icon, iconColor: Color(0xff2B353E)).onPress(() {
 | |
| //                             Navigator.of(context).pop();
 | |
| //                           }),
 | |
| //                         ],
 | |
| //                       ),
 | |
| //                       child,
 | |
| //                     ],
 | |
| //                   ))
 | |
| //               : child,
 | |
| //         );
 | |
| //       }).then((value) {
 | |
| //     callBackFunc();
 | |
| //   });
 | |
| // }
 |