mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
137 lines
4.8 KiB
Dart
137 lines
4.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:syncrow_web/utils/color_manager.dart';
|
|
|
|
extension BuildContextExt on BuildContext {
|
|
ThemeData get theme => Theme.of(this);
|
|
|
|
TextTheme get textTheme => Theme.of(this).textTheme;
|
|
|
|
AppBarTheme get appBarTheme => Theme.of(this).appBarTheme;
|
|
|
|
Size get screenSize => MediaQuery.of(this).size;
|
|
|
|
double get screenWidth => MediaQuery.of(this).size.width;
|
|
|
|
double get screenHeight => MediaQuery.of(this).size.height;
|
|
|
|
double get textScale => MediaQuery.textScalerOf(this).scale(1);
|
|
|
|
void customAlertDialog({
|
|
required Widget alertBody,
|
|
required String title,
|
|
required VoidCallback onConfirm,
|
|
VoidCallback? onDismiss,
|
|
bool? hideConfirmButton,
|
|
final double? dialogWidth,
|
|
TextStyle? titleStyle,
|
|
String? onDismissText,
|
|
String? onConfirmText,
|
|
Color? onDismissColor,
|
|
Color? onConfirmColor,
|
|
}) {
|
|
showDialog(
|
|
context: this,
|
|
builder: (BuildContext context) {
|
|
return AlertDialog(
|
|
contentPadding: EdgeInsets.zero,
|
|
content: Container(
|
|
width: dialogWidth ?? 360,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(20),
|
|
),
|
|
padding: const EdgeInsets.only(top: 20),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
/// header widget
|
|
Text(
|
|
title,
|
|
style: titleStyle ??
|
|
context.textTheme.bodyMedium!.copyWith(
|
|
color: ColorsManager.primaryColorWithOpacity,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
vertical: 15,
|
|
horizontal: 50,
|
|
),
|
|
child: Container(
|
|
height: 1,
|
|
width: double.infinity,
|
|
color: ColorsManager.greyColor,
|
|
),
|
|
),
|
|
|
|
/// custom body content
|
|
Flexible(child: SingleChildScrollView(child: alertBody)),
|
|
|
|
/// Footer buttons
|
|
Container(
|
|
height: 1,
|
|
width: double.infinity,
|
|
color: ColorsManager.greyColor,
|
|
),
|
|
hideConfirmButton != true
|
|
? Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
GestureDetector(
|
|
onTap: onDismiss ??
|
|
() {
|
|
Navigator.pop(context);
|
|
},
|
|
child: Center(
|
|
child: Text(
|
|
onDismissText ?? 'Cancel',
|
|
style: context.textTheme.bodyMedium!.copyWith(
|
|
color: onDismissColor ??
|
|
ColorsManager.greyColor),
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
height: 50,
|
|
width: 1,
|
|
color: ColorsManager.greyColor,
|
|
),
|
|
GestureDetector(
|
|
onTap: onConfirm,
|
|
child: Center(
|
|
child: Text(
|
|
onConfirmText ?? 'Confirm',
|
|
style: context.textTheme.bodyMedium!.copyWith(
|
|
color: onConfirmColor ??
|
|
ColorsManager.primaryColorWithOpacity),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
: Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
|
child: GestureDetector(
|
|
onTap: onDismiss ??
|
|
() {
|
|
Navigator.pop(context);
|
|
},
|
|
child: Center(
|
|
child: Text(
|
|
'Cancel',
|
|
style: context.textTheme.bodyMedium!
|
|
.copyWith(color: ColorsManager.greyColor),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|