mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-07-03 23:00:26 +08:00
+
This commit is contained in:
@ -70,53 +70,6 @@ void pushPage(BuildContext context, Widget page, {String pageName}) {
|
||||
Navigator.push(context, CupertinoPageRoute<void>(builder: (ctx) => page));
|
||||
}
|
||||
|
||||
void showAlertDialog(BuildContext context) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false, // user must tap button!
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
//title: Text('免责声明'),
|
||||
content: SingleChildScrollView(
|
||||
child: ListBody(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.fromLTRB(5.0, 5.0, 10.0, 10.0),
|
||||
//width: 100,
|
||||
height: 35,
|
||||
child: Text('免责声明',
|
||||
style: TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.w700)),
|
||||
decoration: BoxDecoration(
|
||||
//color: Colors.blue,
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.fitWidth,
|
||||
image: AssetImage('assets/images/paimaiLogo.png')),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10.0),
|
||||
),
|
||||
//alignment: Alignment.bottomRight,
|
||||
)),
|
||||
SizedBox(height: 20),
|
||||
Text('111111111'),
|
||||
Text('222222222'),
|
||||
],
|
||||
),
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: new BorderRadius.circular(20.0)), // 圆角
|
||||
|
||||
actions: <Widget>[
|
||||
new Container(
|
||||
width: 250,
|
||||
/// child: _create(),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class TabLayout extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -152,12 +105,6 @@ class TabBarViewLayout extends StatelessWidget {
|
||||
case 1:
|
||||
return FirstPage();
|
||||
break;
|
||||
case 2:
|
||||
return Container(child:Text('1'));
|
||||
break;
|
||||
case 3:
|
||||
return Container(child:Text('2'));
|
||||
break;
|
||||
default:
|
||||
return Container();
|
||||
break;
|
||||
|
@ -4,7 +4,7 @@
|
||||
/// @Last Modified time: 2019-01-14 19:47:14
|
||||
|
||||
import 'dart:core';
|
||||
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
|
||||
|
||||
@ -12,6 +12,7 @@ import 'package:flutter_go/model/collection.dart';
|
||||
import 'package:flutter_go/event/event_bus.dart';
|
||||
import 'package:flutter_go/event/event_model.dart';
|
||||
import 'package:flutter_go/api/api.dart';
|
||||
import 'package:flutter_go/routers/application.dart' show Application;
|
||||
|
||||
class WebViewPage extends StatefulWidget {
|
||||
final String url;
|
||||
@ -21,15 +22,21 @@ class WebViewPage extends StatefulWidget {
|
||||
_WebViewPageState createState() => _WebViewPageState();
|
||||
}
|
||||
|
||||
class _WebViewPageState extends State<WebViewPage> {
|
||||
class _WebViewPageState extends State<WebViewPage> with AutomaticKeepAliveClientMixin{
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
final flutterWebviewPlugin = new FlutterWebviewPlugin();
|
||||
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
dialog = dialogContext(false);
|
||||
|
||||
flutterWebviewPlugin.onUrlChanged.listen((String url) {
|
||||
|
||||
print('url change:$url');
|
||||
if (url.indexOf('loginSuccess') > -1) {
|
||||
String urlQuery = url.substring(url.indexOf('?') + 1);
|
||||
@ -50,7 +57,7 @@ class _WebViewPageState extends State<WebViewPage> {
|
||||
.fire(UserGithubOAuthEvent(loginName, token, true));
|
||||
}
|
||||
print('ready close');
|
||||
|
||||
|
||||
flutterWebviewPlugin.close();
|
||||
// 验证成功
|
||||
} else if (url.indexOf('${Api.BASE_URL}loginFail') == 0) {
|
||||
@ -61,21 +68,75 @@ class _WebViewPageState extends State<WebViewPage> {
|
||||
flutterWebviewPlugin.close();
|
||||
}
|
||||
});
|
||||
flutterWebviewPlugin.onStateChanged.listen((state) async {
|
||||
print('url state:$state');
|
||||
if(state.type == WebViewState.finishLoad) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget dialogContext(bool isShow){
|
||||
if(!isShow){
|
||||
return Container(child:Text(""));
|
||||
}
|
||||
return Container(
|
||||
height: 200,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
Text('分享到',style: TextStyle(fontSize:16,color: Colors.deepOrange)),
|
||||
FlatButton(
|
||||
child: Text('取消',style: TextStyle(fontSize:16,color: Colors.black45),),
|
||||
onPressed: (){
|
||||
setState(() {
|
||||
dialog = dialogContext(false);
|
||||
|
||||
});
|
||||
}
|
||||
)
|
||||
]
|
||||
)
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
Container dialog;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: AppBar(
|
||||
title: Text(widget.title),
|
||||
),
|
||||
body: WebviewScaffold(
|
||||
url: widget.url,
|
||||
withZoom: false,
|
||||
withLocalStorage: true,
|
||||
withJavascript: true,
|
||||
),
|
||||
);
|
||||
key: _scaffoldKey,
|
||||
appBar: AppBar(
|
||||
title: Text(widget.title),
|
||||
// actions: <Widget>[
|
||||
// IconButton(
|
||||
// icon: Icon(Icons.announcement),
|
||||
// onPressed: () {
|
||||
// /// flutterWebviewPlugin.evalJavascript("alert('Flutter Go H5 版本')");
|
||||
// setState(() {
|
||||
// dialog = dialogContext(true);
|
||||
// });
|
||||
// },
|
||||
// )
|
||||
// ],
|
||||
),
|
||||
body: WebviewScaffold(
|
||||
url: widget.url,
|
||||
withZoom: true,
|
||||
withLocalStorage: true,
|
||||
withJavascript: true,
|
||||
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",
|
||||
bottomNavigationBar:dialog,
|
||||
initialChild: Container(
|
||||
color: Colors.white,
|
||||
child: const Center(
|
||||
child: Text("Loading...."),
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user