From a07d8dc921b1824a57e7ce1c0f7808b3ea376299 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sun, 2 Apr 2023 17:45:03 +0200 Subject: [PATCH] neon: Fix news article loading in webview --- .../neon/lib/src/apps/news/pages/article.dart | 46 ++++--------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/packages/neon/lib/src/apps/news/pages/article.dart b/packages/neon/lib/src/apps/news/pages/article.dart index 6cb7356f..1ffc8aed 100644 --- a/packages/neon/lib/src/apps/news/pages/article.dart +++ b/packages/neon/lib/src/apps/news/pages/article.dart @@ -22,7 +22,6 @@ class NewsArticlePage extends StatefulWidget { } class _NewsArticlePageState extends State { - bool _webviewLoading = true; WebViewController? _webviewController; Timer? _markAsReadTimer; @@ -150,42 +149,15 @@ class _NewsArticlePageState extends State { ], ), body: widget.useWebView - ? Stack( - alignment: Alignment.center, - fit: StackFit.expand, - children: [ - WebView( - javascriptMode: JavascriptMode.unrestricted, - onWebViewCreated: (final controller) async { - _webviewController = controller; - await controller.loadUrl(widget.url!); - }, - onPageStarted: (final _) { - setState(() { - _webviewLoading = true; - }); - }, - onPageFinished: (final _) async { - await _startMarkAsReadTimer(); - setState(() { - _webviewLoading = false; - }); - }, - ), - if (_webviewLoading) ...[ - ColoredBox( - color: Theme.of(context).colorScheme.background, - child: Center( - child: LayoutBuilder( - builder: (final context, final constraints) => SizedBox( - width: constraints.maxWidth / 2, - child: const CustomLinearProgressIndicator(), - ), - ), - ), - ), - ], - ], + ? WebView( + javascriptMode: JavascriptMode.unrestricted, + onWebViewCreated: (final controller) async { + _webviewController = controller; + await controller.loadUrl(widget.url!); + }, + onPageFinished: (final _) async { + await _startMarkAsReadTimer(); + }, ) : SingleChildScrollView( padding: const EdgeInsets.all(10),