|
@@ -1,6 +1,7 @@
|
1
|
1
|
import 'package:auto_route/annotations.dart';
|
2
|
2
|
import 'package:eitc_erm_dental_flutter/exts.dart';
|
3
|
3
|
import 'package:eitc_erm_dental_flutter/funcs.dart';
|
|
4
|
+import 'package:eitc_erm_dental_flutter/widget/webview_progress_bar.dart';
|
4
|
5
|
import 'package:flutter/foundation.dart';
|
5
|
6
|
import 'package:flutter/material.dart';
|
6
|
7
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
|
@@ -34,6 +35,9 @@ class _WebviewPageState extends State<WebviewPage> {
|
34
|
35
|
iframeAllowFullscreen: true,
|
35
|
36
|
javaScriptEnabled: true);
|
36
|
37
|
|
|
38
|
+ final WebviewProgressBarController _progressBarController =
|
|
39
|
+ WebviewProgressBarController();
|
|
40
|
+
|
37
|
41
|
@override
|
38
|
42
|
void initState() {
|
39
|
43
|
super.initState();
|
|
@@ -42,6 +46,7 @@ class _WebviewPageState extends State<WebviewPage> {
|
42
|
46
|
@override
|
43
|
47
|
void dispose() {
|
44
|
48
|
super.dispose();
|
|
49
|
+ _progressBarController.dispose();
|
45
|
50
|
}
|
46
|
51
|
|
47
|
52
|
void _load() async {
|
|
@@ -67,35 +72,44 @@ class _WebviewPageState extends State<WebviewPage> {
|
67
|
72
|
),
|
68
|
73
|
//body: SafeArea(child: WebViewWidget(controller: _controller)),
|
69
|
74
|
body: SafeArea(
|
70
|
|
- child: InAppWebView(
|
71
|
|
- key: _webViewKey,
|
72
|
|
- initialSettings: _settings,
|
73
|
|
- onWebViewCreated: (controller) {
|
74
|
|
- _webViewController = controller;
|
75
|
|
- _load();
|
76
|
|
- },
|
77
|
|
- onLoadStart: (controller, url) {
|
78
|
|
- logd("onLoadStart,url=$url");
|
79
|
|
- },
|
80
|
|
- onPermissionRequest: (controller, request) async {
|
81
|
|
- return PermissionResponse(
|
82
|
|
- resources: request.resources,
|
83
|
|
- action: PermissionResponseAction.GRANT);
|
84
|
|
- },
|
85
|
|
- onLoadStop: (controller, url) async {
|
86
|
|
- logd("onLoadStop,url=$url");
|
87
|
|
- },
|
88
|
|
- onReceivedError: (controller, request, error) {
|
89
|
|
- loge("onReceivedError", error: error);
|
90
|
|
- },
|
91
|
|
- onProgressChanged: (controller, progress) {
|
92
|
|
- logd("onProgressChanged,progress=$progress");
|
93
|
|
- },
|
94
|
|
- onConsoleMessage: (controller, consoleMessage) {
|
95
|
|
- if (kDebugMode) {
|
96
|
|
- logd(consoleMessage);
|
97
|
|
- }
|
98
|
|
- },
|
|
75
|
+ child: Stack(
|
|
76
|
+ children: [
|
|
77
|
+ InAppWebView(
|
|
78
|
+ key: _webViewKey,
|
|
79
|
+ initialSettings: _settings,
|
|
80
|
+ onWebViewCreated: (controller) {
|
|
81
|
+ _webViewController = controller;
|
|
82
|
+ _load();
|
|
83
|
+ },
|
|
84
|
+ onLoadStart: (controller, url) {
|
|
85
|
+ logd("onLoadStart,url=$url");
|
|
86
|
+ },
|
|
87
|
+ onPermissionRequest: (controller, request) async {
|
|
88
|
+ return PermissionResponse(
|
|
89
|
+ resources: request.resources,
|
|
90
|
+ action: PermissionResponseAction.GRANT);
|
|
91
|
+ },
|
|
92
|
+ onLoadStop: (controller, url) async {
|
|
93
|
+ logd("onLoadStop,url=$url");
|
|
94
|
+ },
|
|
95
|
+ onReceivedError: (controller, request, error) {
|
|
96
|
+ loge("onReceivedError", error: error);
|
|
97
|
+ },
|
|
98
|
+ onProgressChanged: (controller, progress) {
|
|
99
|
+ logd("onProgressChanged,progress=$progress");
|
|
100
|
+ _progressBarController.setProgress(progress);
|
|
101
|
+ },
|
|
102
|
+ onConsoleMessage: (controller, consoleMessage) {
|
|
103
|
+ if (kDebugMode) {
|
|
104
|
+ logd(consoleMessage);
|
|
105
|
+ }
|
|
106
|
+ },
|
|
107
|
+ ),
|
|
108
|
+ Align(
|
|
109
|
+ alignment: Alignment.topLeft,
|
|
110
|
+ child: WebviewProgressBar(controller: _progressBarController),
|
|
111
|
+ )
|
|
112
|
+ ],
|
99
|
113
|
),
|
100
|
114
|
),
|
101
|
115
|
);
|