|
|
@ -6,13 +6,16 @@ class NewsArticlePage extends StatefulWidget { |
|
|
|
required this.articlesBloc, |
|
|
|
required this.articlesBloc, |
|
|
|
required this.useWebView, |
|
|
|
required this.useWebView, |
|
|
|
this.bodyData, |
|
|
|
this.bodyData, |
|
|
|
|
|
|
|
this.url, |
|
|
|
super.key, |
|
|
|
super.key, |
|
|
|
}) : assert(useWebView || bodyData != null, 'bodyData has to be set when not using a WebView'); |
|
|
|
}) : assert(useWebView || bodyData != null, 'bodyData has to be set when not using a WebView'), |
|
|
|
|
|
|
|
assert(!useWebView || url != null, 'url has to be set when using a WebView'); |
|
|
|
|
|
|
|
|
|
|
|
final NewsArticleBloc bloc; |
|
|
|
final NewsArticleBloc bloc; |
|
|
|
final NewsArticlesBloc articlesBloc; |
|
|
|
final NewsArticlesBloc articlesBloc; |
|
|
|
final bool useWebView; |
|
|
|
final bool useWebView; |
|
|
|
final String? bodyData; |
|
|
|
final String? bodyData; |
|
|
|
|
|
|
|
final String? url; |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
State<NewsArticlePage> createState() => _NewsArticlePageState(); |
|
|
|
State<NewsArticlePage> createState() => _NewsArticlePageState(); |
|
|
@ -75,7 +78,7 @@ class _NewsArticlePageState extends State<NewsArticlePage> { |
|
|
|
return (await _webviewController!.currentUrl())!; |
|
|
|
return (await _webviewController!.currentUrl())!; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return widget.bloc.url; |
|
|
|
return widget.url!; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
@ -129,6 +132,7 @@ class _NewsArticlePageState extends State<NewsArticlePage> { |
|
|
|
); |
|
|
|
); |
|
|
|
}, |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
if (widget.url != null) ...[ |
|
|
|
IconButton( |
|
|
|
IconButton( |
|
|
|
onPressed: () async { |
|
|
|
onPressed: () async { |
|
|
|
await launchUrlString( |
|
|
|
await launchUrlString( |
|
|
@ -145,6 +149,7 @@ class _NewsArticlePageState extends State<NewsArticlePage> { |
|
|
|
icon: const Icon(Icons.share), |
|
|
|
icon: const Icon(Icons.share), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
body: widget.useWebView |
|
|
|
body: widget.useWebView |
|
|
|
? Stack( |
|
|
|
? Stack( |
|
|
@ -155,7 +160,7 @@ class _NewsArticlePageState extends State<NewsArticlePage> { |
|
|
|
javascriptMode: JavascriptMode.unrestricted, |
|
|
|
javascriptMode: JavascriptMode.unrestricted, |
|
|
|
onWebViewCreated: (final controller) async { |
|
|
|
onWebViewCreated: (final controller) async { |
|
|
|
_webviewController = controller; |
|
|
|
_webviewController = controller; |
|
|
|
await controller.loadUrl(widget.bloc.url); |
|
|
|
await controller.loadUrl(widget.url!); |
|
|
|
}, |
|
|
|
}, |
|
|
|
onPageStarted: (final _) { |
|
|
|
onPageStarted: (final _) { |
|
|
|
setState(() { |
|
|
|
setState(() { |
|
|
|