showNiceDialog function
Show a NiceToDev-styled confirmation dialog.
Returns true if confirmed, false if cancelled.
Implementation
Future<bool> showNiceDialog(
BuildContext context, {
required String title,
required String message,
String confirmLabel = 'OK',
String cancelLabel = 'Cancel',
bool destructive = false,
}) async {
final theme = NiceTheme.of(context);
final result = await showDialog<bool>(
context: context,
builder: (ctx) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(theme.borderRadius * 1.5),
),
title: Text(title, style: theme.typography.heading3),
content: Text(message, style: theme.typography.body),
actions: [
TextButton(
onPressed: () => Navigator.of(ctx).pop(false),
child: Text(cancelLabel),
),
FilledButton(
onPressed: () => Navigator.of(ctx).pop(true),
style: destructive
? FilledButton.styleFrom(backgroundColor: theme.colors.error)
: null,
child: Text(confirmLabel),
),
],
),
);
return result ?? false;
}