mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
working on preferences
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
extension BuildContextExt on BuildContext {
|
||||
ThemeData get theme => Theme.of(this);
|
||||
@ -14,4 +15,115 @@ extension BuildContextExt on BuildContext {
|
||||
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,
|
||||
}) {
|
||||
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: 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(
|
||||
'Cancel',
|
||||
style: context.textTheme.bodyMedium!
|
||||
.copyWith(color: ColorsManager.greyColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 50,
|
||||
width: 1,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: onConfirm,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Confirm',
|
||||
style: context.textTheme.bodyMedium!.copyWith(
|
||||
color:
|
||||
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),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user