import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:flutter/material.dart';
class GenericDialog extends StatelessWidget {
final String title;
final String content;
final String confirmButtonText;
final Color confirmButtonTextColor;
final String cancelButtonText;
final VoidCallback onConfirm;
final VoidCallback onCancel;
const GenericDialog({
super.key,
required this.title,
required this.content,
required this.confirmButtonText,
required this.confirmButtonTextColor,
required this.cancelButtonText,
required this.onConfirm,
required this.onCancel,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final showCancel = cancelButtonText.isNotEmpty;
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
child: SizedBox(
height: 202 + (showCancel ? 80 : 0),
child: Padding(
padding: const EdgeInsets.only(left: 20, right: 20, top: 20),
child: Column(
children: [
const SizedBox(height: 10),
Text(
title,
textAlign: TextAlign.center,
style: theme.textTheme.headlineMedium
),
const SizedBox(height: 20),
Text(
content,
textAlign: TextAlign.center,
style: theme.textTheme.bodySmall?.copyWith(color: colorHeadlineText)
),
const SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: showCancel
? OutlinedButton(
style: OutlinedButton.styleFrom(
side: const BorderSide(color: colorDivider),
minimumSize: const Size(280, 52),
maximumSize: const Size(280, 52),
),
onPressed: onConfirm,
child: Text(
confirmButtonText,
style: theme.textTheme.headlineSmall?.copyWith(color: confirmButtonTextColor),
),
)
: ElevatedButton(
style: theme.elevatedButtonTheme.style?.copyWith(
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25))),
),
onPressed: onConfirm,
child: Text(
confirmButtonText,
style: theme.textTheme.headlineSmall?.copyWith(color: Colors.white),
),
),
),
if (showCancel) ...[
const SizedBox(height: 5),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: ElevatedButton(
style: theme.elevatedButtonTheme.style?.copyWith(
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25))),
),
onPressed: onCancel,
child: Text(
cancelButtonText,
style: theme.textTheme.headlineSmall?.copyWith(color: Colors.white)
),
),
),
],
const SizedBox(height: 10),
],
),
),
),
);
}
}