show static method

Future<void> show(
  1. BuildContext context, {
  2. required String title,
  3. required String description,
  4. String? confirmText,
  5. String? cancelText,
  6. VoidCallback? onConfirm,
  7. VoidCallback? onCancel,
  8. Widget? icon,
  9. ModulaDialogType type = ModulaDialogType.info,
  10. bool barrierDismissible = true,
  11. TextStyle? titleStyle,
  12. TextStyle? descriptionStyle,
  13. ShapeBorder? shape,
  14. Color? backgroundColor,
  15. double elevation = 24.0,
  16. EdgeInsetsGeometry? contentPadding,
  17. Widget? customContent,
})

Implementation

static Future<void> show(
  BuildContext context, {
  required String title,
  required String description,
  String? confirmText,
  String? cancelText,
  VoidCallback? onConfirm,
  VoidCallback? onCancel,
  Widget? icon,
  ModulaDialogType type = ModulaDialogType.info,
  bool barrierDismissible = true,
  TextStyle? titleStyle,
  TextStyle? descriptionStyle,
  ShapeBorder? shape,
  Color? backgroundColor,
  double elevation = 24.0,
  EdgeInsetsGeometry? contentPadding,
  Widget? customContent,
}) async {
  final resolvedIcon = icon ?? _getDefaultIcon(type);
  await showDialog<void>(
    context: context,
    barrierDismissible: barrierDismissible,
    builder:
        (context) => AlertDialog(
          backgroundColor: backgroundColor,
          elevation: elevation,
          shape:
              shape ??
              RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
          contentPadding: contentPadding ?? const EdgeInsets.all(20),
          title: Row(
            children: [
              if (resolvedIcon != null) ...[
                resolvedIcon,
                const SizedBox(width: 12),
              ],
              Expanded(
                child: Text(
                  title,
                  style: titleStyle ?? Theme.of(context).textTheme.titleLarge,
                ),
              ),
            ],
          ),
          content:
              customContent ??
              Text(
                description,
                style:
                    descriptionStyle ??
                    Theme.of(context).textTheme.bodyMedium,
              ),
          actions: [
            if (cancelText != null)
              TextButton(
                onPressed: () {
                  Navigator.of(context).pop();
                  onCancel?.call();
                },
                child: Text(cancelText),
              ),
            if (confirmText != null)
              ElevatedButton(
                onPressed: () {
                  Navigator.of(context).pop();
                  onConfirm?.call();
                },
                child: Text(confirmText),
              ),
          ],
        ),
  );
}