feat:调整了启动/首屏阶段的 WebView 和壳层 fallback 展示:
WebView 背景从白色改成透明。 WebView 不再无条件渲染,只有已发起初始加载或首屏已展示后才渲染。 首屏未 ready 时,用 shell cover/fallback 盖住 WebView,避免白屏或 WebView 空白层提前露出。 顶部安全区背景色跟随 shell 背景,减少状态栏区域闪白
This commit is contained in:
@@ -164,7 +164,7 @@ class _H5ShellPageState extends State<H5ShellPage> 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<H5ShellPage> 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<H5ShellPage> 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),
|
||||
),
|
||||
if (shouldPaintWebView)
|
||||
Positioned.fill(child: _buildWebViewWidget()),
|
||||
if (currentSlot.showShellCover &&
|
||||
!currentSlot.hasPresentedFirstScreen)
|
||||
if (shouldPaintShellCover)
|
||||
Positioned.fill(
|
||||
child: IgnorePointer(
|
||||
child: _ShellFallback(progress: currentSlot.progress),
|
||||
@@ -1060,8 +1066,7 @@ class _H5ShellPageState extends State<H5ShellPage> with WidgetsBindingObserver {
|
||||
right: 0,
|
||||
height: topInset,
|
||||
child: ColoredBox(
|
||||
color:
|
||||
shouldPaintShellFallback ? _shellBackground : Colors.white,
|
||||
color: shellBackgroundColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user