mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
optimized
This commit is contained in:
@ -3,75 +3,31 @@ import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
void showDeleteConfirmationDialog(BuildContext context, VoidCallback onConfirm, bool isSpace) {
|
||||
final String title = isSpace ? 'Delete Space' : 'Delete Community';
|
||||
final String subtitle = isSpace
|
||||
? 'All the data in the space will be lost'
|
||||
: 'All the data in the community will be lost';
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false, // Prevent dismissing by tapping outside
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
|
||||
child: SizedBox(
|
||||
width: 500, // Set the desired width
|
||||
width: 500,
|
||||
child: Container(
|
||||
color: ColorsManager.whiteColors,
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Icon
|
||||
Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.warningRed,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.close,
|
||||
color: Colors.white,
|
||||
size: 40,
|
||||
),
|
||||
),
|
||||
_buildWarningIcon(),
|
||||
const SizedBox(height: 20),
|
||||
// Title
|
||||
isSpace
|
||||
? const Text(
|
||||
'Delete Space',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
)
|
||||
: const Text(
|
||||
'Delete Community',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
_buildDialogTitle(context,title),
|
||||
const SizedBox(height: 10),
|
||||
// Subtitle
|
||||
isSpace
|
||||
? const Text(
|
||||
'All the data in the space will be lost',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey,
|
||||
),
|
||||
)
|
||||
: const Text(
|
||||
'All the data in the community will be lost',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
|
||||
_buildDialogSubtitle(context, subtitle),
|
||||
const SizedBox(height: 20),
|
||||
// Buttons
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
@ -84,16 +40,8 @@ void showDeleteConfirmationDialog(BuildContext context, VoidCallback onConfirm,
|
||||
Navigator.of(context).pop(); // Close the first dialog
|
||||
showProcessingPopup(context, isSpace, onConfirm);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.blue,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
fixedSize: Size(140, 40)),
|
||||
child: const Text(
|
||||
'Continue',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
style: _dialogButtonStyle(Colors.blue),
|
||||
child: const Text('Continue', style: TextStyle(color: Colors.white)),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -107,14 +55,14 @@ void showDeleteConfirmationDialog(BuildContext context, VoidCallback onConfirm,
|
||||
}
|
||||
|
||||
void showProcessingPopup(BuildContext context, bool isSpace, VoidCallback onDelete) {
|
||||
final String title = isSpace ? 'Delete Space' : 'Delete Community';
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
|
||||
child: SizedBox(
|
||||
width: 500,
|
||||
child: Container(
|
||||
@ -123,68 +71,19 @@ void showProcessingPopup(BuildContext context, bool isSpace, VoidCallback onDele
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Icon
|
||||
Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.warningRed,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.close,
|
||||
color: Colors.white,
|
||||
size: 40,
|
||||
),
|
||||
),
|
||||
_buildWarningIcon(),
|
||||
const SizedBox(height: 20),
|
||||
// Title
|
||||
isSpace
|
||||
? const Text(
|
||||
'Delete Space',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
)
|
||||
: const Text(
|
||||
'Delete Community',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
_buildDialogTitle(context,title),
|
||||
const SizedBox(height: 10),
|
||||
// Subtitle
|
||||
const Text(
|
||||
'Are you sure you want to Delete?',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
_buildDialogSubtitle(context, 'Are you sure you want to delete?'),
|
||||
const SizedBox(height: 20),
|
||||
// Buttons (Optional)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
// Trigger the second popup
|
||||
onDelete();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: ColorsManager.warningRed,
|
||||
fixedSize: Size(140, 40),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'Delete',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
onPressed: onDelete,
|
||||
style: _dialogButtonStyle(ColorsManager.warningRed),
|
||||
child: const Text('Delete', style: TextStyle(color: Colors.white)),
|
||||
),
|
||||
CancelButton(
|
||||
label: 'Cancel',
|
||||
@ -200,3 +99,40 @@ void showProcessingPopup(BuildContext context, bool isSpace, VoidCallback onDele
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildWarningIcon() {
|
||||
return Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.warningRed,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(Icons.close, color: Colors.white, size: 40),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDialogTitle(BuildContext context, String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDialogSubtitle(BuildContext context, String subtitle) {
|
||||
return Text(
|
||||
subtitle,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: ColorsManager.grayColor
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
ButtonStyle _dialogButtonStyle(Color color) {
|
||||
return ElevatedButton.styleFrom(
|
||||
backgroundColor: color,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
|
||||
fixedSize: const Size(140, 40),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user