106 lines
3.8 KiB
Dart
106 lines
3.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:trainhub_flutter/core/constants/ui_constants.dart';
|
|
import 'package:trainhub_flutter/core/theme/app_colors.dart';
|
|
|
|
class ConfirmDialog {
|
|
ConfirmDialog._();
|
|
|
|
static Future<bool?> show(
|
|
BuildContext context, {
|
|
required String title,
|
|
required String message,
|
|
String confirmLabel = 'Delete',
|
|
Color? confirmColor,
|
|
}) {
|
|
final color = confirmColor ?? AppColors.destructive;
|
|
|
|
return showDialog<bool>(
|
|
context: context,
|
|
builder: (context) => Dialog(
|
|
backgroundColor: AppColors.surfaceContainer,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: UIConstants.cardBorderRadius,
|
|
side: const BorderSide(color: AppColors.border),
|
|
),
|
|
child: ConstrainedBox(
|
|
constraints: const BoxConstraints(maxWidth: UIConstants.dialogWidth),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(UIConstants.pagePadding),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: GoogleFonts.inter(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.textPrimary,
|
|
),
|
|
),
|
|
const SizedBox(height: UIConstants.spacing8),
|
|
Text(
|
|
message,
|
|
style: GoogleFonts.inter(
|
|
fontSize: 14,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
),
|
|
const SizedBox(height: UIConstants.spacing24),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(false),
|
|
style: TextButton.styleFrom(
|
|
foregroundColor: AppColors.textSecondary,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: UIConstants.smallCardBorderRadius,
|
|
),
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: UIConstants.spacing16,
|
|
vertical: UIConstants.spacing12,
|
|
),
|
|
),
|
|
child: Text(
|
|
'Cancel',
|
|
style: GoogleFonts.inter(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: UIConstants.spacing8),
|
|
FilledButton(
|
|
onPressed: () => Navigator.of(context).pop(true),
|
|
style: FilledButton.styleFrom(
|
|
backgroundColor: color,
|
|
foregroundColor: AppColors.zinc50,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: UIConstants.smallCardBorderRadius,
|
|
),
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: UIConstants.spacing16,
|
|
vertical: UIConstants.spacing12,
|
|
),
|
|
),
|
|
child: Text(
|
|
confirmLabel,
|
|
style: GoogleFonts.inter(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|