4
4
/// @Last Modified time: 2019-01-14 19:47:14
5
5
6
6
import 'dart:core' ;
7
- import 'dart:math' ;
7
+
8
8
import 'package:flutter/material.dart' ;
9
9
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart' ;
10
10
11
- import 'package:flutter_go/model/collection.dart' ;
11
+ /// import 'package:flutter_go/model/collection.dart';
12
12
import 'package:flutter_go/event/event_bus.dart' ;
13
13
import 'package:flutter_go/event/event_model.dart' ;
14
14
import 'package:flutter_go/api/api.dart' ;
15
- import 'package:flutter_go/routers/application.dart' show Application;
16
15
17
16
class WebViewPage extends StatefulWidget {
18
17
final String url;
@@ -22,21 +21,16 @@ class WebViewPage extends StatefulWidget {
22
21
_WebViewPageState createState () => _WebViewPageState ();
23
22
}
24
23
25
- class _WebViewPageState extends State <WebViewPage > with AutomaticKeepAliveClientMixin {
26
- @override
27
- bool get wantKeepAlive => true ;
28
-
24
+ class _WebViewPageState extends State <WebViewPage > {
29
25
final flutterWebviewPlugin = new FlutterWebviewPlugin ();
30
26
31
27
final GlobalKey <ScaffoldState > _scaffoldKey = GlobalKey <ScaffoldState >();
32
28
33
29
@override
34
30
void initState () {
35
31
super .initState ();
36
- dialog = dialogContext (false );
37
32
38
33
flutterWebviewPlugin.onUrlChanged.listen ((String url) {
39
-
40
34
print ('url change:$url ' );
41
35
if (url.indexOf ('loginSuccess' ) > - 1 ) {
42
36
String urlQuery = url.substring (url.indexOf ('?' ) + 1 );
@@ -68,75 +62,21 @@ class _WebViewPageState extends State<WebViewPage> with AutomaticKeepAliveClient
68
62
flutterWebviewPlugin.close ();
69
63
}
70
64
});
71
- flutterWebviewPlugin.onStateChanged.listen ((state) async {
72
- print ('url state:$state ' );
73
- if (state.type == WebViewState .finishLoad) {
74
- }
75
- });
76
65
}
77
66
78
- Widget dialogContext (bool isShow){
79
- if (! isShow){
80
- return Container (child: Text ("" ));
81
- }
82
- return Container (
83
- height: 200 ,
84
- child: Column (
85
- mainAxisAlignment: MainAxisAlignment .start,
86
- children: < Widget > [
87
- SizedBox (height: 20 ),
88
- Row (
89
- mainAxisAlignment: MainAxisAlignment .spaceAround,
90
- children: < Widget > [
91
- Text ('分享到' ,style: TextStyle (fontSize: 16 ,color: Colors .deepOrange)),
92
- FlatButton (
93
- child: Text ('取消' ,style: TextStyle (fontSize: 16 ,color: Colors .black45),),
94
- onPressed: (){
95
- setState (() {
96
- dialog = dialogContext (false );
97
-
98
- });
99
- }
100
- )
101
- ]
102
- )
103
- ])
104
- );
105
- }
106
-
107
- Container dialog;
108
67
@override
109
68
Widget build (BuildContext context) {
110
69
return Scaffold (
111
- key: _scaffoldKey,
112
- appBar: AppBar (
113
- title: Text (widget.title),
114
- // actions: <Widget>[
115
- // IconButton(
116
- // icon: Icon(Icons.announcement),
117
- // onPressed: () {
118
- // /// flutterWebviewPlugin.evalJavascript("alert('Flutter Go H5 版本')");
119
- // setState(() {
120
- // dialog = dialogContext(true);
121
- // });
122
- // },
123
- // )
124
- // ],
125
- ),
126
- body: WebviewScaffold (
127
- url: widget.url,
128
- withZoom: true ,
129
- withLocalStorage: true ,
130
- withJavascript: true ,
131
- userAgent: "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Mobile Safari/537.36" ,
132
- bottomNavigationBar: dialog,
133
- initialChild: Container (
134
- color: Colors .white,
135
- child: const Center (
136
- child: Text ("Loading...." ),
137
- ),
138
- ),
139
- ));
140
-
70
+ key: _scaffoldKey,
71
+ appBar: AppBar (
72
+ title: Text (widget.title),
73
+ ),
74
+ body: WebviewScaffold (
75
+ url: widget.url,
76
+ withZoom: false ,
77
+ withLocalStorage: true ,
78
+ withJavascript: true ,
79
+ ),
80
+ );
141
81
}
142
82
}
0 commit comments