import 'package:flutter/material.dart'; import '../theme/design_tokens.dart'; class AppModalDialogAction { const AppModalDialogAction({ required this.label, required this.onPressed, this.primary = false, this.destructive = false, }); final String label; final VoidCallback onPressed; final bool primary; final bool destructive; } class AppModalDialog extends StatelessWidget { const AppModalDialog({ super.key, required this.title, required this.message, required this.actions, this.icon, }); final String title; final String message; final IconData? icon; final List actions; @override Widget build(BuildContext context) { final colors = Theme.of(context).colorScheme; return Dialog( insetPadding: const EdgeInsets.symmetric( horizontal: AppSpacing.lg, vertical: AppSpacing.xl, ), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(AppRadius.xl), ), child: Container( padding: const EdgeInsets.fromLTRB( AppSpacing.lg, AppSpacing.lg, AppSpacing.lg, AppSpacing.md, ), decoration: BoxDecoration( color: colors.surface, borderRadius: BorderRadius.circular(AppRadius.xl), border: Border.all(color: colors.outlineVariant), ), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ if (icon != null) Container( width: 36, height: 36, decoration: BoxDecoration( color: colors.primaryContainer, borderRadius: BorderRadius.circular(AppRadius.md), ), alignment: Alignment.center, child: Icon(icon, color: colors.primary, size: 20), ), if (icon != null) const SizedBox(width: AppSpacing.sm), Expanded( child: Text( title, style: Theme.of(context).textTheme.titleLarge?.copyWith( fontWeight: FontWeight.w700, ), ), ), ], ), const SizedBox(height: AppSpacing.md), Text( message, style: Theme.of(context).textTheme.bodyMedium?.copyWith( color: colors.onSurfaceVariant, height: 1.45, ), ), const SizedBox(height: AppSpacing.lg), Row( children: actions .map((action) { final child = action.primary ? FilledButton( onPressed: action.onPressed, style: FilledButton.styleFrom( backgroundColor: action.destructive ? colors.error : colors.primary, foregroundColor: action.destructive ? colors.onError : colors.onPrimary, minimumSize: const Size.fromHeight(44), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( AppRadius.full, ), ), ), child: Text(action.label), ) : OutlinedButton( onPressed: action.onPressed, style: OutlinedButton.styleFrom( foregroundColor: colors.onSurface, side: BorderSide(color: colors.outline), minimumSize: const Size.fromHeight(44), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular( AppRadius.full, ), ), ), child: Text(action.label), ); return Expanded( child: Padding( padding: const EdgeInsets.symmetric( horizontal: AppSpacing.xs, ), child: child, ), ); }) .toList(growable: false), ), ], ), ), ); } }