TKK_E32221292/Aplikasi Android/lib/shared/dialogs/warning_dialog.dart

101 lines
2.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_application_1/core/theme/app_colors.dart';
class WarningDialog extends StatelessWidget {
final String title;
final String message;
final String buttonText;
const WarningDialog({
super.key,
required this.title,
required this.message,
this.buttonText = 'OK',
});
static Future<void> show(
BuildContext context, {
required String title,
required String message,
String buttonText = 'OK',
}) {
return showDialog<void>(
context: context,
barrierDismissible: true,
builder: (_) => WarningDialog(
title: title,
message: message,
buttonText: buttonText,
),
);
}
@override
Widget build(BuildContext context) {
return Dialog(
insetPadding: const EdgeInsets.symmetric(horizontal: 24),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(28)),
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 52,
width: 52,
decoration: BoxDecoration(
color: const Color(0xFFFEECEC),
borderRadius: BorderRadius.circular(16),
),
child: const Icon(
Icons.warning_amber_rounded,
color: AppColors.red,
size: 28,
),
),
const SizedBox(height: 18),
Text(
title,
style: const TextStyle(
fontSize: 22,
fontWeight: FontWeight.w800,
color: AppColors.textDark,
),
),
const SizedBox(height: 10),
Text(
message,
style: const TextStyle(
fontSize: 14,
height: 1.5,
color: AppColors.textMuted,
),
),
const SizedBox(height: 24),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () => Navigator.of(context).pop(),
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(54),
backgroundColor: AppColors.primaryBlue,
foregroundColor: AppColors.white,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18),
),
),
child: Text(
buttonText,
style: const TextStyle(fontWeight: FontWeight.w800),
),
),
),
],
),
),
);
}
}