2024-09-12 10:27:18 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2024-08-08 08:51:47 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import '../../configs/configs.dart';
|
|
|
|
|
import '../../core/core.dart';
|
|
|
|
|
|
|
|
|
|
Future<void> showErrorDialog({
|
|
|
|
|
required BuildContext context,
|
|
|
|
|
required String header,
|
|
|
|
|
required String body,
|
2024-09-12 10:27:18 +00:00
|
|
|
String dismissButtonText = 'dismiss',
|
2024-08-08 08:51:47 +00:00
|
|
|
VoidCallback? onDismiss,
|
|
|
|
|
}) async {
|
|
|
|
|
return showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
barrierDismissible: false,
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return Dialog(
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: Space.all(1, .5),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
color: AppColors.primary,
|
|
|
|
|
borderRadius: BorderRadius.all(
|
|
|
|
|
Radius.circular(12),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Text(
|
|
|
|
|
header,
|
|
|
|
|
style: AppText.h3b?.copyWith(color: Colors.white),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
|
child: Text(
|
|
|
|
|
body,
|
|
|
|
|
style: AppText.b1,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
TextButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
if (onDismiss != null) {
|
|
|
|
|
onDismiss();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
child: Text(
|
2024-09-12 10:27:18 +00:00
|
|
|
dismissButtonText.tr(),
|
2024-08-08 08:51:47 +00:00
|
|
|
style: AppText.h3b?.copyWith(
|
|
|
|
|
color: AppColors.primary,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|