mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-05-20 14:26:23 +08:00
Merge branch 'beta' of github.com:alibaba/flutter-go into beta
This commit is contained in:
18
README.md
18
README.md
@ -22,7 +22,25 @@ Language: [English](https://github.com/alibaba/flutter-go/blob/master/README-en.
|
|||||||
|
|
||||||
<img src="https://img.alicdn.com/tfs/TB19UahQQzoK1RjSZFlXXai4VXa-1500-1106.png" width="600px">
|
<img src="https://img.alicdn.com/tfs/TB19UahQQzoK1RjSZFlXXai4VXa-1500-1106.png" width="600px">
|
||||||
|
|
||||||
|
## 运行方式
|
||||||
|
|
||||||
|
- 查看一下版本号是否正确
|
||||||
|
```dart
|
||||||
|
flutter --version
|
||||||
|
```
|
||||||
|
- 运行以下命令查看是否需要安装其它依赖项来完成安装
|
||||||
|
```dart
|
||||||
|
flutter doctor
|
||||||
|
```
|
||||||
|
- 运行启动您的应用
|
||||||
|
```dart
|
||||||
|
flutter packages get
|
||||||
|
flutter run
|
||||||
|
```
|
||||||
|
|
||||||
|
- 如果有其他问题,请参考
|
||||||
|
- https://flutterchina.club/setup-macos/
|
||||||
|
- https://flutter.dev/docs/get-started/install/macos
|
||||||
|
|
||||||
## Release安装包下载地址
|
## Release安装包下载地址
|
||||||
|
|
||||||
|
@ -174,6 +174,7 @@ class _ListRefreshState extends State<ListRefresh> {
|
|||||||
return widget.renderItem(index, items[index]);
|
return widget.renderItem(index, items[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
),
|
),
|
||||||
|
@ -155,7 +155,7 @@ class _DrawerPageState extends State<DrawerPage> {
|
|||||||
size: 27.0,
|
size: 27.0,
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
'搜索',
|
'全网搜',
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@ -223,7 +223,7 @@ class _DrawerPageState extends State<DrawerPage> {
|
|||||||
style: textStyle,
|
style: textStyle,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Share.share('https://github.com/alibaba/flutter-go');
|
Share.share('https://flutter-go.pub/website/');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
new Divider(),
|
new Divider(),
|
||||||
|
@ -50,7 +50,9 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
|||||||
|
|
||||||
|
|
||||||
Future<Map> getIndexListData([Map<String, dynamic> params]) async {
|
Future<Map> getIndexListData([Map<String, dynamic> params]) async {
|
||||||
const juejin_flutter = 'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438';
|
/// const juejin_flutter = 'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438';
|
||||||
|
const juejin_flutter = 'https://fluttergo.pub:9527/juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438';
|
||||||
|
|
||||||
var pageIndex = (params is Map) ? params['pageIndex'] : 0;
|
var pageIndex = (params is Map) ? params['pageIndex'] : 0;
|
||||||
final _param = {'page':pageIndex,'pageSize':20,'sort':'rankIndex'};
|
final _param = {'page':pageIndex,'pageSize':20,'sort':'rankIndex'};
|
||||||
var responseList = [];
|
var responseList = [];
|
||||||
|
@ -6,18 +6,24 @@ import './sub_page.dart';
|
|||||||
import './main_app_bar.dart';
|
import './main_app_bar.dart';
|
||||||
import './search_page.dart';
|
import './search_page.dart';
|
||||||
import 'package:flutter_go/model/user_info.dart';
|
import 'package:flutter_go/model/user_info.dart';
|
||||||
|
import 'package:flutter_go/routers/application.dart' show Application;
|
||||||
|
import 'package:flutter_go/routers/routers.dart' show Routes;
|
||||||
|
|
||||||
|
DefaultTabController _tabController;
|
||||||
|
TabBar _tabBar;
|
||||||
|
|
||||||
class _Page {
|
class _Page {
|
||||||
final String labelId;
|
final String labelId;
|
||||||
|
final int labelIndex;
|
||||||
|
|
||||||
_Page(this.labelId);
|
_Page(this.labelId,this.labelIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<_Page> _allPages = <_Page>[
|
final List<_Page> _allPages = <_Page>[
|
||||||
_Page('项目1'),
|
_Page('热门资讯', 1),
|
||||||
_Page('项目2'),
|
_Page('FG-官网', 2),
|
||||||
_Page('项目3'),
|
_Page('FG-web版', 3),
|
||||||
_Page('项目4'),
|
///_Page('项目4'),
|
||||||
];
|
];
|
||||||
|
|
||||||
class MainPage extends StatelessWidget {
|
class MainPage extends StatelessWidget {
|
||||||
@ -27,12 +33,12 @@ class MainPage extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
print("MainPagess build......");
|
print("MainPagess build......");
|
||||||
return DefaultTabController(
|
_tabController = DefaultTabController(
|
||||||
length: _allPages.length,
|
length: _allPages.length,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: new MyAppBar(
|
appBar: MyAppBar(
|
||||||
leading: Container(
|
leading: Container(
|
||||||
child: new ClipOval(
|
child: ClipOval(
|
||||||
child: Image.network(
|
child: Image.network(
|
||||||
userInfo.id == 0?'https://hbimg.huabanimg.com/9bfa0fad3b1284d652d370fa0a8155e1222c62c0bf9d-YjG0Vt_fw658':userInfo.avatarPic,
|
userInfo.id == 0?'https://hbimg.huabanimg.com/9bfa0fad3b1284d652d370fa0a8155e1222c62c0bf9d-YjG0Vt_fw658':userInfo.avatarPic,
|
||||||
scale: 15.0,
|
scale: 15.0,
|
||||||
@ -54,10 +60,8 @@ class MainPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: TabBarViewLayout(),
|
body: TabBarViewLayout(),
|
||||||
// drawer: Drawer(
|
|
||||||
// child: MainLeftPage(),
|
|
||||||
// ),
|
|
||||||
));
|
));
|
||||||
|
return _tabController;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,35 +73,38 @@ void pushPage(BuildContext context, Widget page, {String pageName}) {
|
|||||||
class TabLayout extends StatelessWidget {
|
class TabLayout extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return TabBar(
|
_tabBar = TabBar(
|
||||||
isScrollable: true,
|
isScrollable: true,
|
||||||
//labelPadding: EdgeInsets.all(12.0),
|
//labelPadding: EdgeInsets.all(12.0),
|
||||||
labelPadding: EdgeInsets.only(top: 12.0, left: 12.0, right: 12.0),
|
labelPadding: EdgeInsets.only(top: 12.0, left: 12.0, right: 12.0),
|
||||||
indicatorSize: TabBarIndicatorSize.label,
|
indicatorSize: TabBarIndicatorSize.label,
|
||||||
tabs: _allPages
|
tabs: _allPages.map((_Page page) => Tab(text: page.labelId)).toList(),
|
||||||
.map((_Page page) =>
|
onTap: (index) {
|
||||||
Tab(text: page.labelId))
|
if (index == 1) {
|
||||||
.toList(),
|
DefaultTabController.of(context).animateTo(0);
|
||||||
|
Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go 官方网站')}&url=${Uri.encodeComponent('https://flutter-go.pub')}');
|
||||||
|
} else if (index == 2) {
|
||||||
|
|
||||||
|
// new Future.delayed(const Duration(seconds: 1),(){
|
||||||
|
// showAlertDialog(Application.globalContext);
|
||||||
|
// });
|
||||||
|
|
||||||
|
DefaultTabController.of(context).animateTo(0);
|
||||||
|
Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go web版(H5)')}&url=${Uri.encodeComponent('https://flutter-go.pub/flutter_go_web')}');
|
||||||
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
return _tabBar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TabBarViewLayout extends StatelessWidget {
|
class TabBarViewLayout extends StatelessWidget {
|
||||||
Widget buildTabView(BuildContext context, _Page page) {
|
Widget buildTabView(BuildContext context, _Page page) {
|
||||||
String labelId = page.labelId;
|
int labelIndex = page.labelIndex;
|
||||||
switch (labelId) {
|
switch (labelIndex) {
|
||||||
case '项目1':
|
case 1:
|
||||||
return FirstPage();
|
return FirstPage();
|
||||||
break;
|
break;
|
||||||
case '项目2':
|
|
||||||
return SubPage();
|
|
||||||
break;
|
|
||||||
case '项目3':
|
|
||||||
return SubPage();
|
|
||||||
break;
|
|
||||||
case '项目4':
|
|
||||||
return SubPage();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return Container();
|
return Container();
|
||||||
break;
|
break;
|
||||||
|
@ -23,7 +23,7 @@ final _industryPage = Industry.IndustryPage(itemTitle: (state){
|
|||||||
),
|
),
|
||||||
subtitle: Text(state.res[index].source),
|
subtitle: Text(state.res[index].source),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// 在这里对选中的结果进行解析,因为我目前是用golang实现的,所以就没贴代码了。
|
// 在这里对选中的结果进行解析
|
||||||
print(state.res[index].source);
|
print(state.res[index].source);
|
||||||
final itemTitle = state.res[index].title;
|
final itemTitle = state.res[index].title;
|
||||||
final itemUrl = state.res[index].source;
|
final itemUrl = state.res[index].source;
|
||||||
@ -44,7 +44,7 @@ class SearchPage extends StatelessWidget {
|
|||||||
/// print('suggestion::${Industry.suggestion}');
|
/// print('suggestion::${Industry.suggestion}');
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: PreferredSize(
|
appBar: PreferredSize(
|
||||||
preferredSize: Size(double.infinity, 52), // 44 is the height
|
preferredSize: Size(double.infinity, 52), // is the height
|
||||||
child: AppBar(title: searchBarPage)
|
child: AppBar(title: searchBarPage)
|
||||||
),
|
),
|
||||||
//body: ProgressView(),
|
//body: ProgressView(),
|
||||||
@ -160,7 +160,7 @@ class _SearchBarPageState extends State<SearchBarPage> {
|
|||||||
controller: controller,
|
controller: controller,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
contentPadding: EdgeInsets.only(top: 0.0),
|
contentPadding: EdgeInsets.only(top: 0.0),
|
||||||
hintText: '搜索全局flutter知识库',
|
hintText: '全网搜索 Flutter 相关知识库',
|
||||||
hintStyle:TextStyle(fontSize: 12.0),
|
hintStyle:TextStyle(fontSize: 12.0),
|
||||||
border: InputBorder.none
|
border: InputBorder.none
|
||||||
),
|
),
|
||||||
|
@ -12,6 +12,7 @@ import 'package:flutter_go/utils/shared_preferences.dart';
|
|||||||
import 'package:flutter_go/views/first_page/first_page.dart';
|
import 'package:flutter_go/views/first_page/first_page.dart';
|
||||||
import 'package:flutter_go/views/first_page/main_page.dart';
|
import 'package:flutter_go/views/first_page/main_page.dart';
|
||||||
import 'package:fluro/fluro.dart';
|
import 'package:fluro/fluro.dart';
|
||||||
|
import 'package:flutter_go/views/user_page/user_page.dart';
|
||||||
import 'package:flutter_go/views/widget_page/widget_page.dart';
|
import 'package:flutter_go/views/widget_page/widget_page.dart';
|
||||||
import 'package:flutter_go/views/welcome_page/fourth_page.dart';
|
import 'package:flutter_go/views/welcome_page/fourth_page.dart';
|
||||||
import 'package:flutter_go/views/collection_page/collection_page.dart';
|
import 'package:flutter_go/views/collection_page/collection_page.dart';
|
||||||
@ -24,9 +25,7 @@ import 'package:flutter_go/model/search_history.dart';
|
|||||||
import 'package:flutter_go/resources/widget_name_to_icon.dart';
|
import 'package:flutter_go/resources/widget_name_to_icon.dart';
|
||||||
import 'package:flutter_go/model/user_info.dart';
|
import 'package:flutter_go/model/user_info.dart';
|
||||||
|
|
||||||
|
|
||||||
class AppPage extends StatefulWidget {
|
class AppPage extends StatefulWidget {
|
||||||
|
|
||||||
final UserInformation userInfo;
|
final UserInformation userInfo;
|
||||||
|
|
||||||
AppPage(this.userInfo);
|
AppPage(this.userInfo);
|
||||||
@ -49,8 +48,9 @@ class _MyHomePageState extends State<AppPage>
|
|||||||
static List tabData = [
|
static List tabData = [
|
||||||
{'text': '业界动态', 'icon': Icon(Icons.language)},
|
{'text': '业界动态', 'icon': Icon(Icons.language)},
|
||||||
{'text': 'WIDGET', 'icon': Icon(Icons.extension)},
|
{'text': 'WIDGET', 'icon': Icon(Icons.extension)},
|
||||||
{'text': '组件收藏', 'icon': Icon(Icons.favorite)},
|
|
||||||
{'text': '关于手册', 'icon': Icon(Icons.import_contacts)},
|
{'text': '关于手册', 'icon': Icon(Icons.import_contacts)},
|
||||||
|
{'text': '个人中心', 'icon': Icon(Icons.account_circle)},
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
List<BottomNavigationBarItem> _myTabs = [];
|
List<BottomNavigationBarItem> _myTabs = [];
|
||||||
@ -72,8 +72,8 @@ class _MyHomePageState extends State<AppPage>
|
|||||||
// ..add(FirstPage())
|
// ..add(FirstPage())
|
||||||
..add(MainPage(userInfo: widget.userInfo))
|
..add(MainPage(userInfo: widget.userInfo))
|
||||||
..add(WidgetPage())
|
..add(WidgetPage())
|
||||||
..add(CollectionPage())
|
..add(FourthPage())
|
||||||
..add(FourthPage());
|
..add(UserPage(userInfo: widget.userInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -90,12 +90,11 @@ class _MyHomePageState extends State<AppPage>
|
|||||||
|
|
||||||
void onWidgetTap(WidgetPoint widgetPoint, BuildContext context) {
|
void onWidgetTap(WidgetPoint widgetPoint, BuildContext context) {
|
||||||
String targetName = widgetPoint.name;
|
String targetName = widgetPoint.name;
|
||||||
searchHistoryList
|
searchHistoryList.add(
|
||||||
.add(SearchHistory(name: targetName, targetRouter: widgetPoint.routerName));
|
SearchHistory(name: targetName, targetRouter: widgetPoint.routerName));
|
||||||
print("searchHistoryList1 ${searchHistoryList.toString()}");
|
print("searchHistoryList1 ${searchHistoryList.toString()}");
|
||||||
Application.router.navigateTo(
|
Application.router.navigateTo(context, widgetPoint.routerName,
|
||||||
context, widgetPoint.routerName,
|
transition: TransitionType.inFromRight);
|
||||||
transition: TransitionType.inFromRight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildSearchInput(BuildContext context) {
|
Widget buildSearchInput(BuildContext context) {
|
||||||
@ -121,10 +120,9 @@ class _MyHomePageState extends State<AppPage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderAppBar(BuildContext context, Widget widget, int index) {
|
renderAppBar(BuildContext context, Widget widget, int index) {
|
||||||
if (index == 0) {
|
if (index == 1) {
|
||||||
return null;
|
return AppBar(title: buildSearchInput(context));
|
||||||
}
|
}
|
||||||
return AppBar(title: buildSearchInput(context));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -46,10 +46,10 @@ class _IssuesMessagePageState extends State<IssuesMessagePage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_submit() {
|
_submit() {
|
||||||
String mk = notusMarkdown.encode(_delta);
|
|
||||||
if (_title.trim().isEmpty) {
|
if (_title.trim().isEmpty) {
|
||||||
_show('标题不能为空');
|
_show('标题不能为空');
|
||||||
} else {
|
} else {
|
||||||
|
String mk = (_delta==null)?'No description provided.':notusMarkdown.encode(_delta);
|
||||||
DataUtils.feedback({'title': _title, "body": mk},context).then((result) {
|
DataUtils.feedback({'title': _title, "body": mk},context).then((result) {
|
||||||
_show('提交成功');
|
_show('提交成功');
|
||||||
Navigator.maybePop(context);
|
Navigator.maybePop(context);
|
||||||
|
@ -67,7 +67,9 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
DataUtils.getUserInfo({'loginName': event.loginName,'token':event.token}).then((result) {
|
DataUtils.getUserInfo(
|
||||||
|
{'loginName': event.loginName, 'token': event.token})
|
||||||
|
.then((result) {
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
@ -215,7 +217,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
// 如果输入都检验通过,则进行登录操作
|
// 如果输入都检验通过,则进行登录操作
|
||||||
// Scaffold.of(context)
|
// Scaffold.of(context)
|
||||||
// .showSnackBar(new SnackBar(content: new Text("执行登录操作")));
|
// .showSnackBar(new SnackBar(content: new Text("执行登录操作")));
|
||||||
//调用所有自孩子的save回调,保存表单内容
|
//调用所有自孩子<EFBFBD><EFBFBD>save回调,保存表单内容
|
||||||
doLogin();
|
doLogin();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -234,22 +236,33 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
try {
|
if (userResult.runtimeType == UserInformation) {
|
||||||
_userInfoControlModel.deleteAll().then((result) {
|
try {
|
||||||
// print('删除结果:$result');
|
_userInfoControlModel.deleteAll().then((result) {
|
||||||
_userInfoControlModel
|
// print('删除结果:$result');
|
||||||
.insert(UserInfo(password: password, username: username))
|
_userInfoControlModel
|
||||||
.then((value) {
|
.insert(UserInfo(password: password, username: username))
|
||||||
print('存储成功:$value');
|
.then((value) {
|
||||||
Navigator.of(context).pushAndRemoveUntil(
|
print('存储成功:$value');
|
||||||
MaterialPageRoute(builder: (context) => AppPage(userResult)),
|
Navigator.of(context).pushAndRemoveUntil(
|
||||||
(route) => route == null);
|
MaterialPageRoute(builder: (context) => AppPage(userResult)),
|
||||||
|
(route) => route == null);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
} catch (err) {
|
||||||
} catch (err) {
|
Navigator.of(context).pushAndRemoveUntil(
|
||||||
Navigator.of(context).pushAndRemoveUntil(
|
MaterialPageRoute(builder: (context) => AppPage(userResult)),
|
||||||
MaterialPageRoute(builder: (context) => AppPage(userResult)),
|
(route) => route == null);
|
||||||
(route) => route == null);
|
}
|
||||||
|
}else if(userResult.runtimeType == String){
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: userResult,
|
||||||
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
|
gravity: ToastGravity.CENTER,
|
||||||
|
timeInSecForIos: 1,
|
||||||
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
|
textColor: Colors.white,
|
||||||
|
fontSize: 16.0);
|
||||||
}
|
}
|
||||||
}).catchError((errorMsg) {
|
}).catchError((errorMsg) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -375,7 +388,8 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pushAndRemoveUntil(
|
Navigator.of(context).pushAndRemoveUntil(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => AppPage(UserInformation(id: 0))),
|
builder: (context) =>
|
||||||
|
AppPage(UserInformation(id: 0))),
|
||||||
(route) => route == null);
|
(route) => route == null);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
26
lib/views/user_page/user_page.dart
Normal file
26
lib/views/user_page/user_page.dart
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_go/model/user_info.dart';
|
||||||
|
import 'package:flutter_go/views/first_page/drawer_page.dart';
|
||||||
|
|
||||||
|
class UserPage extends StatefulWidget {
|
||||||
|
final UserInformation userInfo;
|
||||||
|
|
||||||
|
UserPage({Key key, this.userInfo}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_UserPageState createState() => _UserPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UserPageState extends State<UserPage> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
print(widget.userInfo);
|
||||||
|
return Scaffold(
|
||||||
|
body: Container(
|
||||||
|
child: DrawerPage(
|
||||||
|
userInfo: widget.userInfo,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
/// @Last Modified time: 2019-01-14 19:47:14
|
/// @Last Modified time: 2019-01-14 19:47:14
|
||||||
|
|
||||||
import 'dart:core';
|
import 'dart:core';
|
||||||
|
import 'dart:math';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_webview_plugin/flutter_webview_plugin.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_bus.dart';
|
||||||
import 'package:flutter_go/event/event_model.dart';
|
import 'package:flutter_go/event/event_model.dart';
|
||||||
import 'package:flutter_go/api/api.dart';
|
import 'package:flutter_go/api/api.dart';
|
||||||
|
import 'package:flutter_go/routers/application.dart' show Application;
|
||||||
|
|
||||||
class WebViewPage extends StatefulWidget {
|
class WebViewPage extends StatefulWidget {
|
||||||
final String url;
|
final String url;
|
||||||
@ -21,15 +22,21 @@ class WebViewPage extends StatefulWidget {
|
|||||||
_WebViewPageState createState() => _WebViewPageState();
|
_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 flutterWebviewPlugin = new FlutterWebviewPlugin();
|
||||||
|
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
dialog = dialogContext(false);
|
||||||
|
|
||||||
flutterWebviewPlugin.onUrlChanged.listen((String url) {
|
flutterWebviewPlugin.onUrlChanged.listen((String url) {
|
||||||
|
|
||||||
print('url change:$url');
|
print('url change:$url');
|
||||||
if (url.indexOf('loginSuccess') > -1) {
|
if (url.indexOf('loginSuccess') > -1) {
|
||||||
String urlQuery = url.substring(url.indexOf('?') + 1);
|
String urlQuery = url.substring(url.indexOf('?') + 1);
|
||||||
@ -61,21 +68,75 @@ class _WebViewPageState extends State<WebViewPage> {
|
|||||||
flutterWebviewPlugin.close();
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
key: _scaffoldKey,
|
key: _scaffoldKey,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(widget.title),
|
title: Text(widget.title),
|
||||||
),
|
// actions: <Widget>[
|
||||||
body: WebviewScaffold(
|
// IconButton(
|
||||||
url: widget.url,
|
// icon: Icon(Icons.announcement),
|
||||||
withZoom: false,
|
// onPressed: () {
|
||||||
withLocalStorage: true,
|
// /// flutterWebviewPlugin.evalJavascript("alert('Flutter Go H5 版本')");
|
||||||
withJavascript: true,
|
// 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...."),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ dependencies:
|
|||||||
flutter_spinkit: "^3.1.0"
|
flutter_spinkit: "^3.1.0"
|
||||||
fluttertoast: ^3.1.0
|
fluttertoast: ^3.1.0
|
||||||
dio: ^2.0.15
|
dio: ^2.0.15
|
||||||
flutter_webview_plugin: ^0.3.4
|
flutter_webview_plugin: ^0.3.5
|
||||||
cookie_jar: ^1.0.0
|
cookie_jar: ^1.0.0
|
||||||
# 日期格式化
|
# 日期格式化
|
||||||
intl: 0.15.7
|
intl: 0.15.7
|
||||||
|
Reference in New Issue
Block a user