show static method

Future<void> show({
  1. BuildContext? context,
  2. required String url,
  3. Map<String, String>? headers,
  4. List<WebViewCookie>? cookies,
  5. String? title,
  6. double heightFactor = 0.92,
  7. Future<GpWebViewNavigationDecision> onNavigationRequest(
    1. String url
    )?,
  8. String errorTitle = 'No pudimos cargar la página',
  9. String errorRetryLabel = 'Reintentar',
  10. bool showLoadingOverlay = true,
  11. bool disableInputZoom = true,
  12. bool debugLogConsole = false,
  13. bool debugLogNetwork = false,
  14. bool debugLogStorage = false,
  15. void onControllerReady(
    1. WebViewController controller
    )?,
})

context es opcional — ver nota en GpModal.showCustomModal.

Implementation

static Future<void> show({
  BuildContext? context,
  required String url,
  Map<String, String>? headers,
  List<WebViewCookie>? cookies,
  String? title,
  double heightFactor = 0.92,
  Future<GpWebViewNavigationDecision> Function(String url)?
  onNavigationRequest,
  String errorTitle = 'No pudimos cargar la página',
  String errorRetryLabel = 'Reintentar',
  bool showLoadingOverlay = true,
  bool disableInputZoom = true,
  bool debugLogConsole = false,
  bool debugLogNetwork = false,
  bool debugLogStorage = false,
  void Function(WebViewController controller)? onControllerReady,
}) {
  final resolvedContext = GpNavigator.resolve(context);
  if (resolvedContext == null) return Future.value();

  return GpModal.showCustomModal<void>(
    context: resolvedContext,
    child: SizedBox(
      height: MediaQuery.of(resolvedContext).size.height * heightFactor,
      child: Column(
        children: [
          SizedBox(height: GpSpacing.sm()),
          Container(
            width: 36,
            height: 4,
            decoration: BoxDecoration(
              color: Theme.of(resolvedContext).colorScheme.outlineVariant,
              borderRadius: BorderRadius.circular(2),
            ),
          ),
          Padding(
            padding: EdgeInsets.fromLTRB(
              GpSpacing.md(),
              GpSpacing.sm(),
              GpSpacing.xs(),
              GpSpacing.xs(),
            ),
            child: Row(
              children: [
                if (title != null && title.trim().isNotEmpty)
                  Expanded(
                    child: GpText(
                      text: title,
                      variant: GpTextVariant.titleMedium,
                      maxLines: 1,
                    ),
                  )
                else
                  const Spacer(),
                GpIconButton(
                  icon: Icons.close_rounded,
                  onPressed: () => Navigator.of(resolvedContext).pop(),
                  variant: GpSurfaceVariant.text,
                  tone: GpSemanticTone.neutral,
                  semanticLabel: 'Cerrar',
                ),
              ],
            ),
          ),
          Expanded(
            child: GpWebView(
              url: url,
              headers: headers,
              cookies: cookies,
              onNavigationRequest: onNavigationRequest,
              errorTitle: errorTitle,
              errorRetryLabel: errorRetryLabel,
              showLoadingOverlay: showLoadingOverlay,
              disableInputZoom: disableInputZoom,
              debugLogConsole: debugLogConsole,
              debugLogNetwork: debugLogNetwork,
              debugLogStorage: debugLogStorage,
              onControllerReady: onControllerReady,
            ),
          ),
        ],
      ),
    ),
  );
}