feat: 更新 H5ShellPage 以支持顶部安全区域并优化布局
This commit is contained in:
106
lib/main.dart
106
lib/main.dart
@@ -549,6 +549,7 @@ class _H5ShellPageState extends State<H5ShellPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final currentSlot = _currentSlot;
|
final currentSlot = _currentSlot;
|
||||||
|
final topInset = MediaQuery.paddingOf(context).top;
|
||||||
final bottomInset = MediaQuery.viewInsetsOf(context).bottom;
|
final bottomInset = MediaQuery.viewInsetsOf(context).bottom;
|
||||||
final showLineSwitch = !currentSlot.showShellCover &&
|
final showLineSwitch = !currentSlot.showShellCover &&
|
||||||
currentSlot.loadError == null &&
|
currentSlot.loadError == null &&
|
||||||
@@ -564,55 +565,68 @@ class _H5ShellPageState extends State<H5ShellPage> {
|
|||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
body: SafeArea(
|
body: Stack(
|
||||||
bottom: false,
|
children: [
|
||||||
child: Stack(
|
SafeArea(
|
||||||
children: [
|
bottom: false,
|
||||||
Positioned.fill(
|
child: Stack(
|
||||||
child: _ShellFallback(progress: currentSlot.progress),
|
children: [
|
||||||
),
|
Positioned.fill(
|
||||||
Positioned.fill(
|
|
||||||
child: IndexedStack(
|
|
||||||
index: _currentLineIndex,
|
|
||||||
children: [
|
|
||||||
for (var index = 0; index < _lineSlots.length; index += 1)
|
|
||||||
WebViewWidget(
|
|
||||||
key: ValueKey<int>(index),
|
|
||||||
controller: _lineSlots[index].controller,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (currentSlot.showShellCover)
|
|
||||||
Positioned.fill(
|
|
||||||
child: IgnorePointer(
|
|
||||||
child: _ShellFallback(progress: currentSlot.progress),
|
child: _ShellFallback(progress: currentSlot.progress),
|
||||||
),
|
),
|
||||||
),
|
Positioned.fill(
|
||||||
if (!currentSlot.showShellCover && currentSlot.progress < 100)
|
child: IndexedStack(
|
||||||
LinearProgressIndicator(
|
index: _currentLineIndex,
|
||||||
value: currentSlot.progress == 0
|
children: [
|
||||||
? null
|
for (var index = 0;
|
||||||
: currentSlot.progress / 100,
|
index < _lineSlots.length;
|
||||||
minHeight: 2,
|
index += 1)
|
||||||
),
|
WebViewWidget(
|
||||||
if (currentSlot.loadError != null)
|
key: ValueKey<int>(index),
|
||||||
_ErrorPanel(
|
controller: _lineSlots[index].controller,
|
||||||
message: currentSlot.loadError!,
|
),
|
||||||
onRetry: () => unawaited(_reloadCurrentLine()),
|
],
|
||||||
),
|
),
|
||||||
if (showLineSwitch)
|
|
||||||
Positioned(
|
|
||||||
left: 20,
|
|
||||||
right: 20,
|
|
||||||
bottom: MediaQuery.paddingOf(context).bottom + 14,
|
|
||||||
child: _LineSwitchBar(
|
|
||||||
currentLine: _currentLine,
|
|
||||||
onSwitch: _showLineSwitcher,
|
|
||||||
),
|
),
|
||||||
),
|
if (currentSlot.showShellCover)
|
||||||
],
|
Positioned.fill(
|
||||||
),
|
child: IgnorePointer(
|
||||||
|
child: _ShellFallback(progress: currentSlot.progress),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (!currentSlot.showShellCover && currentSlot.progress < 100)
|
||||||
|
LinearProgressIndicator(
|
||||||
|
value: currentSlot.progress == 0
|
||||||
|
? null
|
||||||
|
: currentSlot.progress / 100,
|
||||||
|
minHeight: 2,
|
||||||
|
),
|
||||||
|
if (currentSlot.loadError != null)
|
||||||
|
_ErrorPanel(
|
||||||
|
message: currentSlot.loadError!,
|
||||||
|
onRetry: () => unawaited(_reloadCurrentLine()),
|
||||||
|
),
|
||||||
|
if (showLineSwitch)
|
||||||
|
Positioned(
|
||||||
|
left: 20,
|
||||||
|
right: 20,
|
||||||
|
bottom: MediaQuery.paddingOf(context).bottom + 14,
|
||||||
|
child: _LineSwitchBar(
|
||||||
|
currentLine: _currentLine,
|
||||||
|
onSwitch: _showLineSwitcher,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
height: topInset,
|
||||||
|
child: const ColoredBox(color: Colors.white),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user