forked from aniketambore/savior-bitcoin-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Blockstream Block Explorer Webview
- Loading branch information
1 parent
661e023
commit ceb45a3
Showing
10 changed files
with
514 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include: package:flutter_lints/flutter.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:webview_flutter/webview_flutter.dart'; | ||
import 'package:component_library/component_library.dart'; | ||
|
||
class WebViewScreen extends StatefulWidget { | ||
const WebViewScreen({ | ||
super.key, | ||
required this.label, | ||
required this.url, | ||
}); | ||
|
||
final String label; | ||
final String url; | ||
|
||
@override | ||
State<WebViewScreen> createState() => _WebViewScreenState(); | ||
} | ||
|
||
class _WebViewScreenState extends State<WebViewScreen> { | ||
late final WebViewController _controller; | ||
bool _isLoading = true; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
_controller = WebViewController() | ||
..setJavaScriptMode(JavaScriptMode.unrestricted) | ||
..setNavigationDelegate( | ||
NavigationDelegate( | ||
onProgress: (int progress) { | ||
if (progress == 100) setState(() => _isLoading = false); | ||
}, | ||
onNavigationRequest: (NavigationRequest request) { | ||
if (request.url.startsWith(widget.url)) { | ||
return NavigationDecision.navigate; | ||
} | ||
return NavigationDecision.prevent; | ||
}, | ||
), | ||
) | ||
..loadRequest( | ||
Uri.parse(widget.url), | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text(widget.label), | ||
), | ||
body: _isLoading | ||
? const CenteredCircularProgressIndicator() | ||
: WebViewWidget( | ||
controller: _controller, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'src/webview_screen.dart'; |
Oops, something went wrong.