mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-08-06 17:48:43 +08:00
add update test
This commit is contained in:
@ -10,6 +10,7 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.MODE_WORLD_READABLE"/>
|
<uses-permission android:name="android.permission.MODE_WORLD_READABLE"/>
|
||||||
<uses-permission android:name="android.permission.MODE_WORLD_WRITEABLE"/>
|
<uses-permission android:name="android.permission.MODE_WORLD_WRITEABLE"/>
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="io.flutter.app.FlutterApplication"
|
android:name="io.flutter.app.FlutterApplication"
|
||||||
|
@ -178,7 +178,7 @@ class DisclaimerMsgState extends State<DisclaimerMsg> {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius:
|
borderRadius:
|
||||||
BorderRadius.horizontal(right: Radius.circular(10)),
|
BorderRadius.horizontal(right: Radius.circular(10)),
|
||||||
color: Colors.black45,
|
color: Colors.black45,
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
@ -17,41 +17,40 @@ class FirstPage extends StatefulWidget {
|
|||||||
FirstPageState createState() => new FirstPageState();
|
FirstPageState createState() => new FirstPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin{
|
class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin{
|
||||||
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
|
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
|
||||||
Future<bool> _unKnow;
|
Future<bool> _unKnow;
|
||||||
GlobalKey<DisclaimerMsgState> key;
|
GlobalKey<DisclaimerMsgState> key;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => true;
|
bool get wantKeepAlive => true;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
key = GlobalKey<DisclaimerMsgState>();
|
key = GlobalKey<DisclaimerMsgState>();
|
||||||
// key = const Key('__RIKEY1__');
|
// key = const Key('__RIKEY1__');
|
||||||
//获取sharePre
|
//获取sharePre
|
||||||
_unKnow = _prefs.then((SharedPreferences prefs) {
|
_unKnow = _prefs.then((SharedPreferences prefs) {
|
||||||
return (prefs.getBool('disclaimer::Boolean') ?? false);
|
return (prefs.getBool('disclaimer::Boolean') ?? false);
|
||||||
});
|
});
|
||||||
|
|
||||||
/// 判断是否需要弹出免责声明,已经勾选过不在显示,就不会主动弹
|
/// 判断是否需要弹出免责声明,已经勾选过不在显示,就不会主动弹
|
||||||
_unKnow.then((bool value) {
|
_unKnow.then((bool value) {
|
||||||
new Future.delayed(const Duration(seconds: 1),(){
|
new Future.delayed(const Duration(seconds: 1),(){
|
||||||
if (!value && key.currentState is DisclaimerMsgState && key.currentState.showAlertDialog is Function) {
|
if (!value && key.currentState is DisclaimerMsgState && key.currentState.showAlertDialog is Function) {
|
||||||
key.currentState.showAlertDialog(context);
|
key.currentState.showAlertDialog(context);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<Map> getIndexListData([Map<String, dynamic> params]) async {
|
Future<Map> getIndexListData([Map<String, dynamic> params]) async {
|
||||||
const juejin_flutter =
|
const juejin_flutter = 'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438';
|
||||||
'https://timeline-merger-ms.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 = [];
|
||||||
@ -77,15 +76,10 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
|||||||
// No specified type, handles all
|
// No specified type, handles all
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map<String, dynamic> result = {
|
Map<String, dynamic> result = {"list":resultList, 'total':pageTotal, 'pageIndex':pageIndex};
|
||||||
"list": resultList,
|
|
||||||
'total': pageTotal,
|
|
||||||
'pageIndex': pageIndex
|
|
||||||
};
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// 每个item的样式
|
/// 每个item的样式
|
||||||
Widget makeCard(index,item){
|
Widget makeCard(index,item){
|
||||||
var myTitle = '${item.title}';
|
var myTitle = '${item.title}';
|
||||||
@ -99,15 +93,15 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
|||||||
Column(
|
Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Stack(
|
Stack(
|
||||||
//alignment: const FractionalOffset(0.9, 0.1),//方法一
|
//alignment: const FractionalOffset(0.9, 0.1),//方法一
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Pagination(),
|
Pagination(),
|
||||||
Positioned(//方法二
|
Positioned(//方法二
|
||||||
top: 10.0,
|
top: 10.0,
|
||||||
left: 0.0,
|
left: 0.0,
|
||||||
child: DisclaimerMsg(key:key,pWidget:this)
|
child: DisclaimerMsg(key:key,pWidget:this)
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
SizedBox(height: 1, child:Container(color: Theme.of(context).primaryColor)),
|
SizedBox(height: 1, child:Container(color: Theme.of(context).primaryColor)),
|
||||||
SizedBox(height: 10),
|
SizedBox(height: 10),
|
||||||
],
|
],
|
||||||
@ -118,22 +112,27 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
return new Column(children: <Widget>[
|
return new Column(
|
||||||
new Stack(
|
children: <Widget>[
|
||||||
//alignment: const FractionalOffset(0.9, 0.1),//方法一
|
// new Stack(
|
||||||
children: <Widget>[
|
// //alignment: const FractionalOffset(0.9, 0.1),//方法一
|
||||||
Pagination(),
|
// children: <Widget>[
|
||||||
Positioned(
|
// Pagination(),
|
||||||
//方法二
|
// Positioned(//方法二
|
||||||
top: 10.0,
|
// top: 10.0,
|
||||||
left: 0.0,
|
// left: 0.0,
|
||||||
child: new DisclaimerMsg(key: key, pWidget: this)),
|
// child: DisclaimerMsg(key:key,pWidget:this)
|
||||||
]),
|
// ),
|
||||||
SizedBox(
|
// ]),
|
||||||
height: 2, child: Container(color: Theme.of(context).primaryColor)),
|
// SizedBox(height: 2, child:Container(color: Theme.of(context).primaryColor)),
|
||||||
new Expanded(
|
new Expanded(
|
||||||
//child: new List(),
|
//child: new List(),
|
||||||
child: listComp.ListRefresh(getIndexListData, makeCard))
|
child: listComp.ListRefresh(getIndexListData,makeCard,headerView)
|
||||||
]);
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,10 +12,10 @@ class _Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final List<_Page> _allPages = <_Page>[
|
final List<_Page> _allPages = <_Page>[
|
||||||
_Page('项目1'),
|
_Page('项目1'),
|
||||||
_Page('项目2'),
|
_Page('项目2'),
|
||||||
_Page('项目3'),
|
_Page('项目3'),
|
||||||
_Page('项目4'),
|
_Page('项目4'),
|
||||||
];
|
];
|
||||||
|
|
||||||
class MainPage extends StatelessWidget {
|
class MainPage extends StatelessWidget {
|
||||||
@ -37,7 +37,7 @@ class MainPage extends StatelessWidget {
|
|||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
title: TabLayout(),
|
title: TabLayout(),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.search),
|
icon: Icon(Icons.search),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
pushPage(context, SearchPage(), pageName: "SearchPage");
|
pushPage(context, SearchPage(), pageName: "SearchPage");
|
||||||
@ -67,7 +67,7 @@ class TabLayout extends StatelessWidget {
|
|||||||
indicatorSize: TabBarIndicatorSize.label,
|
indicatorSize: TabBarIndicatorSize.label,
|
||||||
tabs: _allPages
|
tabs: _allPages
|
||||||
.map((_Page page) =>
|
.map((_Page page) =>
|
||||||
Tab(text: page.labelId))
|
Tab(text: page.labelId))
|
||||||
.toList(),
|
.toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ class TabBarViewLayout extends StatelessWidget {
|
|||||||
print("TabBarViewLayout build.......");
|
print("TabBarViewLayout build.......");
|
||||||
return TabBarView(
|
return TabBarView(
|
||||||
children: _allPages.map((_Page page) {
|
children: _allPages.map((_Page page) {
|
||||||
return buildTabView(context, page);
|
return buildTabView(context, page);
|
||||||
}).toList());
|
}).toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_go/utils/shared_preferences.dart';
|
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/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';
|
||||||
@ -42,7 +43,8 @@ class _MyHomePageState extends State<AppPage>
|
|||||||
{'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.favorite)},
|
||||||
{'text': '关于手册', 'icon': Icon(Icons.import_contacts)}
|
{'text': '关于手册', 'icon': Icon(Icons.import_contacts)},
|
||||||
|
// {'text': '点击更新', 'icon': Icon(Icons.update)}
|
||||||
];
|
];
|
||||||
|
|
||||||
List<BottomNavigationBarItem> myTabs = [];
|
List<BottomNavigationBarItem> myTabs = [];
|
||||||
@ -60,10 +62,11 @@ class _MyHomePageState extends State<AppPage>
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
list
|
list
|
||||||
..add(FirstPage())
|
..add(MainPage())
|
||||||
..add(WidgetPage(Provider.db))
|
..add(WidgetPage(Provider.db))
|
||||||
..add(CollectionPage())
|
..add(CollectionPage())
|
||||||
..add(FourthPage());
|
..add(FourthPage());
|
||||||
|
// ..add(FourthPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -96,7 +99,7 @@ class _MyHomePageState extends State<AppPage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget buildSearchInput(BuildContext context) {
|
Widget buildSearchInput(BuildContext context) {
|
||||||
return new SearchInput((value) async {
|
return new SearchInput((value) async {
|
||||||
if (value != '') {
|
if (value != '') {
|
||||||
List<WidgetPoint> list = await widgetControl.search(value);
|
List<WidgetPoint> list = await widgetControl.search(value);
|
||||||
return list
|
return list
|
||||||
@ -105,7 +108,7 @@ class _MyHomePageState extends State<AppPage>
|
|||||||
icon: WidgetName2Icon.icons[item.name] ?? null,
|
icon: WidgetName2Icon.icons[item.name] ?? null,
|
||||||
text: 'widget',
|
text: 'widget',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
onWidgetTap(item, context);
|
onWidgetTap(item, context);
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
.toList();
|
.toList();
|
||||||
@ -115,11 +118,18 @@ class _MyHomePageState extends State<AppPage>
|
|||||||
}, (value) {}, () {});
|
}, (value) {}, () {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderAppBar(BuildContext context,Widget widget,int index) {
|
||||||
|
print('renderAppBar=====>>>>>>${index}');
|
||||||
|
if(index == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return AppBar(title: buildSearchInput(context));
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return new Scaffold(
|
return new Scaffold(
|
||||||
appBar: new AppBar(title: buildSearchInput(context)),
|
appBar: renderAppBar(context,widget,_currentIndex),
|
||||||
body: list[_currentIndex],
|
body: list[_currentIndex],
|
||||||
bottomNavigationBar: BottomNavigationBar(
|
bottomNavigationBar: BottomNavigationBar(
|
||||||
items: myTabs,
|
items: myTabs,
|
||||||
|
40
lib/views/update_test.dart
Normal file
40
lib/views/update_test.dart
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_go/blocs/bak/search_api.dart';
|
||||||
|
|
||||||
|
class UpdatePage extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_UpdatePageState createState() => _UpdatePageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UpdatePageState extends State<UpdatePage> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Center(
|
||||||
|
child: Text("现在是1.0.0",
|
||||||
|
textAlign: TextAlign.center, style: TextStyle(fontSize: 20)),
|
||||||
|
),
|
||||||
|
Center(
|
||||||
|
child: FlatButton(
|
||||||
|
onPressed: () {
|
||||||
|
print("点击");
|
||||||
|
_UpdatePageNet();
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
"点击获取新版本",
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
color: Colors.red[800],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _UpdatePageNet() async {
|
||||||
|
Response response = await dio.get("https://github.com/alibaba/flutter-go/raw/master/FlutterGo.apk");
|
||||||
|
print("=====response============="+response.data);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user