showCustomModal<T> static method

Future<T?> showCustomModal<T>({
  1. BuildContext? context,
  2. required Widget child,
  3. double? borderRadius,
  4. Color? backgroundColor,
  5. Duration animationDuration = GpMotion.medium,
  6. Curve animationCurve = GpMotion.emphasized,
  7. bool isScrollControlled = true,
  8. bool dismissible = true,
})

Muestra un modal personalizado desde abajo (Bottom Sheet)

context es opcional: si no lo pasás, usa GpNavigator.navigatorKey (requiere tenerlo conectado en tu MaterialApp/Router — ver GpNavigator). Pasarlo explícito sigue siendo lo recomendado cuando lo llamás desde dentro de un widget.

Implementation

static Future<T?> showCustomModal<T>({
  BuildContext? context,
  required Widget child,
  double? borderRadius,
  Color? backgroundColor,
  Duration animationDuration = GpMotion.medium,
  Curve animationCurve = GpMotion.emphasized,
  bool isScrollControlled = true,
  bool dismissible = true,
}) {
  final resolvedContext = GpNavigator.resolve(context);
  if (resolvedContext == null) return Future.value(null);

  final theme = Theme.of(resolvedContext);
  final surfaceTheme = theme.gpSurfaceTheme;
  return showModalBottomSheet<T>(
    context: resolvedContext,
    isScrollControlled: isScrollControlled,
    backgroundColor: Colors.transparent,
    isDismissible: dismissible,
    builder: (context) {
      return TweenAnimationBuilder<double>(
        tween: Tween(begin: 0.0, end: 1.0),
        duration: animationDuration,
        curve: animationCurve,
        builder: (context, value, child) {
          return Transform.translate(
            offset: Offset(0, 50 * (1 - value)),
            child: Opacity(opacity: value, child: child),
          );
        },
        child: Container(
          decoration: BoxDecoration(
            color: backgroundColor ?? theme.colorScheme.surface,
            borderRadius: BorderRadius.vertical(
              top: Radius.circular(
                borderRadius ?? surfaceTheme.panelBorderRadius,
              ),
            ),
            boxShadow: [
              BoxShadow(
                color: (surfaceTheme.shadowColor ?? theme.colorScheme.shadow)
                    .withValues(alpha: surfaceTheme.subtleBorderAlpha),
                blurRadius: surfaceTheme.shadowBlurRadius + 12,
                offset: const Offset(0, -5),
              ),
            ],
          ),
          child: child,
        ),
      );
    },
  );
}