showActionSheet<T> static method

Future<T?> showActionSheet<T>({
  1. required BuildContext context,
  2. required List<AtomicSheetAction<T>> actions,
  3. String? title,
  4. String? message,
  5. bool showCancelButton = true,
  6. String cancelText = 'Cancel',
  7. Color? backgroundColor,
  8. Color? actionColor,
  9. Color? cancelColor,
  10. bool isDismissible = true,
  11. bool enableDrag = true,
})

Implementation

static Future<T?> showActionSheet<T>({
  required BuildContext context,
  required List<AtomicSheetAction<T>> actions,
  String? title,
  String? message,
  bool showCancelButton = true,
  String cancelText = 'Cancel',
  Color? backgroundColor,
  Color? actionColor,
  Color? cancelColor,
  bool isDismissible = true,
  bool enableDrag = true,
}) {
  final theme = AtomicTheme.of(context);

  return showCustomSheet<T>(
    context: context,
    isDismissible: isDismissible,
    enableDrag: enableDrag,
    scrollable: false,
    builder: (context) => Column(
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: [
        if (title != null || message != null)
          Padding(
            padding: EdgeInsets.only(
              bottom: theme.spacing.md,
            ),
            child: Column(
              children: [
                if (title != null)
                  Text(
                    title,
                    style: theme.typography.titleMedium.copyWith(
                      fontWeight: FontWeight.w600,
                    ),
                    textAlign: TextAlign.center,
                  ),
                if (title != null && message != null)
                  SizedBox(height: theme.spacing.xs),
                if (message != null)
                  Text(
                    message,
                    style: theme.typography.bodyMedium.copyWith(
                      color: theme.colors.textSecondary,
                    ),
                    textAlign: TextAlign.center,
                  ),
              ],
            ),
          ),
        ...actions.map((action) => _buildActionItem(
          context: context,
          action: action,
          theme: theme,
          actionColor: actionColor,
        )),
        if (showCancelButton) ...[
          SizedBox(height: theme.spacing.sm),
          _buildCancelButton(
            context: context,
            theme: theme,
            cancelText: cancelText,
            cancelColor: cancelColor,
          ),
        ],
      ],
    ),
  );
}