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.
94 lines
3.2 KiB
Dart
94 lines
3.2 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}) {
|
|
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.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.start,
|
|
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)
|
|
],
|
|
);
|
|
}
|
|
}
|