diff --git a/lib/main.dart b/lib/main.dart index d3632a5..2941477 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -164,7 +164,7 @@ class _H5ShellPageState extends State with WidgetsBindingObserver { onMessageReceived: (message) => _handleFlutterShellMessage(generation, message), ) - ..setBackgroundColor(Colors.white) + ..setBackgroundColor(Colors.transparent) ..setNavigationDelegate( NavigationDelegate( onProgress: (progress) { @@ -1009,6 +1009,12 @@ class _H5ShellPageState extends State with WidgetsBindingObserver { final shouldPaintShellFallback = (_isPreparingInitialLine || currentSlot.isAwaitingFirstScreen) && currentSlot.loadError == null; + final shouldPaintShellCover = + currentSlot.showShellCover && !currentSlot.hasPresentedFirstScreen; + final shouldPaintWebView = currentSlot.hasLoadedInitialRequest || + currentSlot.hasPresentedFirstScreen; + final shellBackgroundColor = + shouldPaintShellFallback ? _shellBackground : Colors.white; return PopScope( canPop: false, @@ -1018,20 +1024,20 @@ class _H5ShellPageState extends State with WidgetsBindingObserver { } }, child: Scaffold( - backgroundColor: Colors.white, + backgroundColor: shellBackgroundColor, body: Stack( children: [ SafeArea( bottom: false, child: Stack( children: [ - if (shouldPaintShellFallback) + if (shouldPaintShellFallback && !shouldPaintShellCover) Positioned.fill( child: _ShellFallback(progress: currentSlot.progress), ), - Positioned.fill(child: _buildWebViewWidget()), - if (currentSlot.showShellCover && - !currentSlot.hasPresentedFirstScreen) + if (shouldPaintWebView) + Positioned.fill(child: _buildWebViewWidget()), + if (shouldPaintShellCover) Positioned.fill( child: IgnorePointer( child: _ShellFallback(progress: currentSlot.progress), @@ -1060,8 +1066,7 @@ class _H5ShellPageState extends State with WidgetsBindingObserver { right: 0, height: topInset, child: ColoredBox( - color: - shouldPaintShellFallback ? _shellBackground : Colors.white, + color: shellBackgroundColor, ), ), ],