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.
mohemm-flutter-app/lib/widgets/bottom_sheet.dart

169 lines
5.0 KiB
Dart

import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
void showMyBottomSheet(BuildContext context, {required Widget child, required VoidCallback callBackFunc, String? type}) {
showModalBottomSheet<String>(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (BuildContext context) {
return Container(
constraints: BoxConstraints(
maxHeight: type =='CONTINUE_ACTION' ? MediaQuery.of(context).size.height *.75 : double.infinity,),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topRight: Radius.circular(25),
topLeft: Radius.circular(25),
),
),
padding: MediaQuery.of(context).viewInsets,
clipBehavior: Clip.antiAlias,
child:SingleChildScrollView(child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
13.height,
Container(
height: 6,
width: 60,
decoration: const BoxDecoration(
color: Color(0xff9A9A9A),
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
),
8.height,
child,
],
)),
);
},
).then((value) {
// print("BACK FROM DELEGATE!!!!");
// print("value: $value");
if (value == "delegate_reload") {
callBackFunc();
}
});
}
Widget openWorkListBottomSheet(BuildContext context, String? val, String? title){
return SafeArea(
child: Container(
padding: const EdgeInsets.all(16),
height: MediaQuery.of(context).size.height * 0.3 , // half-screen height
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// ---- Top Row with Title & Close Button ----
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title ?? "Details",
style: const TextStyle(
color: Color(0xff2BB8A6),
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
IconButton(
icon: const Icon(Icons.close, color: Colors.black54, size: 20),
onPressed: () {
Navigator.pop(context);
},
),
],
),
const Divider(height: 1, color: Colors.grey),
const SizedBox(height: 12),
// ---- Scrollable Content ----
Expanded(
child: SingleChildScrollView(
child: Text(
(val?.isEmpty ?? true)
? "--"
: val.toString(),
style: TextStyle(
color: MyColors.normalTextColor,
fontSize: 14,
height: 1.4,
),
),
),
),
SizedBox(
width: double.infinity,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff2BB8A6),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
padding: const EdgeInsets.symmetric(vertical: 12),
),
onPressed: () {
Navigator.pop(context);
},
child: Text(
LocaleKeys.close.tr(),
style: const TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
),
),
],
),
),
);
}
class BottomSheetItem extends StatelessWidget {
final Function onTap;
final IconData icon;
final String title;
final Color color;
const BottomSheetItem({Key? key, required this.onTap, required this.title, required this.icon, this.color = Colors.black}) : super(key: key);
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
if (onTap != null) {
Navigator.pop(context);
onTap();
}
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 18.0, vertical: 18.0),
child: Row(
children: <Widget>[
if (icon != null)
Icon(
icon,
color: color,
size: 18.0,
),
if (icon != null) SizedBox(width: 24.0),
Text(
title ?? "",
style: TextStyle(color: color),
),
],
),
),
);
}
}