onufitness_mobile/lib/widgets/others/button_action_bottom_sheet.dart
2026-06-29 13:43:40 +05:30

110 lines
3.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:onufitness/utils/helper_function.dart';
import 'package:onufitness/widgets/Buttons/custom_social_login_button.dart';
import 'package:onufitness/widgets/Buttons/custom_submit_button.dart';
Future<bool> actionButtonBottomSheet({
required BuildContext context,
required String title,
required String subtitle,
required String submitButtonText,
required Future<bool> Function() onPressed,
required String cancelButtonText,
required VoidCallback onCancelPressed,
required String assetPath,
required Color primaryColor,
required Color cancelBorderColor,
required RxBool isLoading,
}) async {
bool result = false;
await showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
isScrollControlled: true,
builder: (context) {
return Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(20.r)),
),
padding: EdgeInsets.all(20.w),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: EdgeInsets.all(20.w),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.pink.shade50,
),
child: SizedBox(
height: 30.h,
width: 30.w,
child: Image.asset(assetPath),
),
),
SizedBox(height: 16.h),
Text(
title,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: isTablet ? 24.sp : 18.sp,
fontWeight: FontWeight.w600,
),
),
SizedBox(height: 10.h),
Text(
subtitle,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14.sp, color: Colors.black87),
),
SizedBox(height: 20.h),
Obx(
() => CustomSubmitButton(
backgroundColor: primaryColor,
textColor: Colors.black,
fontWeight: FontWeight.w600,
fontSize: isTablet ? 20.sp : 18.sp,
text: submitButtonText,
isLoading: isLoading.value,
onPressed: () async {
final navigator = Navigator.of(context);
final shouldPop = await onPressed();
result = shouldPop;
if (shouldPop) {
navigator.pop();
}
},
),
),
SizedBox(height: 10.h),
CustomSocialLoginButton(
textColor: Colors.black,
text: cancelButtonText,
borderSide: BorderSide(color: cancelBorderColor),
onPressed: onCancelPressed,
),
SizedBox(height: 10.h),
Container(
color: Colors.white,
padding: EdgeInsetsDirectional.only(
bottom: MediaQuery.of(context).viewPadding.bottom,
),
),
],
),
),
);
},
);
return result;
}