import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; class ConfirmDialog extends StatelessWidget { const ConfirmDialog({ required this.title, required this.message, this.confirmLabel = '확인', this.cancelLabel = '취소', this.isDestructive = false, super.key, }); final String title; final String message; final String confirmLabel; final String cancelLabel; final bool isDestructive; static Future show( BuildContext context, { required String title, required String message, String confirmLabel = '확인', String cancelLabel = '취소', bool isDestructive = false, }) { return showDialog( context: context, builder: (context) => ConfirmDialog( title: title, message: message, confirmLabel: confirmLabel, cancelLabel: cancelLabel, isDestructive: isDestructive, ), ); } @override Widget build(BuildContext context) { final theme = Theme.of(context); return AlertDialog( title: Text(title), content: Text(message), actions: [ TextButton( onPressed: () => Navigator.of(context).pop(false), child: Text(cancelLabel), ), const Gap(8), FilledButton( onPressed: () => Navigator.of(context).pop(true), style: isDestructive ? FilledButton.styleFrom( backgroundColor: theme.colorScheme.error, foregroundColor: theme.colorScheme.onError, ) : null, child: Text(confirmLabel), ), ], ); } }