Skip to content

Commit cf4c215

Browse files
authored
Merge pull request alibaba#322 from alibaba/beta
Modify: web view 方法回退
2 parents 0696c5a + 799ae20 commit cf4c215

File tree

1 file changed

+14
-74
lines changed

1 file changed

+14
-74
lines changed

lib/views/web_page/web_view_page.dart

Lines changed: 14 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
/// @Last Modified time: 2019-01-14 19:47:14
55
66
import 'dart:core';
7-
import 'dart:math';
7+
88
import 'package:flutter/material.dart';
99
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
1010

11-
import 'package:flutter_go/model/collection.dart';
11+
/// import 'package:flutter_go/model/collection.dart';
1212
import 'package:flutter_go/event/event_bus.dart';
1313
import 'package:flutter_go/event/event_model.dart';
1414
import 'package:flutter_go/api/api.dart';
15-
import 'package:flutter_go/routers/application.dart' show Application;
1615

1716
class WebViewPage extends StatefulWidget {
1817
final String url;
@@ -22,21 +21,16 @@ class WebViewPage extends StatefulWidget {
2221
_WebViewPageState createState() => _WebViewPageState();
2322
}
2423

25-
class _WebViewPageState extends State<WebViewPage> with AutomaticKeepAliveClientMixin{
26-
@override
27-
bool get wantKeepAlive => true;
28-
24+
class _WebViewPageState extends State<WebViewPage> {
2925
final flutterWebviewPlugin = new FlutterWebviewPlugin();
3026

3127
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
3228

3329
@override
3430
void initState() {
3531
super.initState();
36-
dialog = dialogContext(false);
3732

3833
flutterWebviewPlugin.onUrlChanged.listen((String url) {
39-
4034
print('url change:$url');
4135
if (url.indexOf('loginSuccess') > -1) {
4236
String urlQuery = url.substring(url.indexOf('?') + 1);
@@ -68,75 +62,21 @@ class _WebViewPageState extends State<WebViewPage> with AutomaticKeepAliveClient
6862
flutterWebviewPlugin.close();
6963
}
7064
});
71-
flutterWebviewPlugin.onStateChanged.listen((state) async {
72-
print('url state:$state');
73-
if(state.type == WebViewState.finishLoad) {
74-
}
75-
});
7665
}
7766

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;
10867
@override
10968
Widget build(BuildContext context) {
11069
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+
);
14181
}
14282
}

0 commit comments

Comments
 (0)