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.
car_common_app/lib/widgets/bottom_sheet.dart

89 lines
2.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
void showMyBottomSheet(BuildContext context, {bool isDismissible = true, required Widget child, VoidCallback? callBackFunc}) {
showModalBottomSheet<String>(
context: context,
isScrollControlled: true,
isDismissible: isDismissible,
backgroundColor: Colors.transparent,
builder: (BuildContext context) {
return Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topRight: Radius.circular(0),
topLeft: Radius.circular(0),
),
),
clipBehavior: Clip.antiAlias,
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") {
// if (callBackFunc != null) callBackFunc();
// }
if (callBackFunc != null) callBackFunc();
});
}
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),
),
],
),
),
);
}
}