mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-07-03 23:00:26 +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.MODE_WORLD_READABLE"/>
|
||||
<uses-permission android:name="android.permission.MODE_WORLD_WRITEABLE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
|
||||
<application
|
||||
android:name="io.flutter.app.FlutterApplication"
|
||||
|
@ -17,11 +17,11 @@ class FirstPage extends StatefulWidget {
|
||||
FirstPageState createState() => new FirstPageState();
|
||||
}
|
||||
|
||||
|
||||
class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin{
|
||||
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
|
||||
Future<bool> _unKnow;
|
||||
GlobalKey<DisclaimerMsgState> key;
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@ -50,8 +50,7 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
||||
|
||||
|
||||
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';
|
||||
var pageIndex = (params is Map) ? params['pageIndex'] : 0;
|
||||
final _param = {'page':pageIndex,'pageSize':20,'sort':'rankIndex'};
|
||||
var responseList = [];
|
||||
@ -77,15 +76,10 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
||||
// No specified type, handles all
|
||||
}
|
||||
}
|
||||
Map<String, dynamic> result = {
|
||||
"list": resultList,
|
||||
'total': pageTotal,
|
||||
'pageIndex': pageIndex
|
||||
};
|
||||
Map<String, dynamic> result = {"list":resultList, 'total':pageTotal, 'pageIndex':pageIndex};
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// 每个item的样式
|
||||
Widget makeCard(index,item){
|
||||
var myTitle = '${item.title}';
|
||||
@ -118,22 +112,27 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return new Column(children: <Widget>[
|
||||
new Stack(
|
||||
//alignment: const FractionalOffset(0.9, 0.1),//方法一
|
||||
return new Column(
|
||||
children: <Widget>[
|
||||
Pagination(),
|
||||
Positioned(
|
||||
//方法二
|
||||
top: 10.0,
|
||||
left: 0.0,
|
||||
child: new DisclaimerMsg(key: key, pWidget: this)),
|
||||
]),
|
||||
SizedBox(
|
||||
height: 2, child: Container(color: Theme.of(context).primaryColor)),
|
||||
// new Stack(
|
||||
// //alignment: const FractionalOffset(0.9, 0.1),//方法一
|
||||
// children: <Widget>[
|
||||
// Pagination(),
|
||||
// Positioned(//方法二
|
||||
// top: 10.0,
|
||||
// left: 0.0,
|
||||
// child: DisclaimerMsg(key:key,pWidget:this)
|
||||
// ),
|
||||
// ]),
|
||||
// SizedBox(height: 2, child:Container(color: Theme.of(context).primaryColor)),
|
||||
new Expanded(
|
||||
//child: new List(),
|
||||
child: listComp.ListRefresh(getIndexListData, makeCard))
|
||||
]);
|
||||
child: listComp.ListRefresh(getIndexListData,makeCard,headerView)
|
||||
)
|
||||
]
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.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/main_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/collection_page/collection_page.dart';
|
||||
@ -42,7 +43,8 @@ class _MyHomePageState extends State<AppPage>
|
||||
{'text': '业界动态', 'icon': Icon(Icons.language)},
|
||||
{'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.update)}
|
||||
];
|
||||
|
||||
List<BottomNavigationBarItem> myTabs = [];
|
||||
@ -60,10 +62,11 @@ class _MyHomePageState extends State<AppPage>
|
||||
));
|
||||
}
|
||||
list
|
||||
..add(FirstPage())
|
||||
..add(MainPage())
|
||||
..add(WidgetPage(Provider.db))
|
||||
..add(CollectionPage())
|
||||
..add(FourthPage());
|
||||
// ..add(FourthPage());
|
||||
}
|
||||
|
||||
@override
|
||||
@ -115,11 +118,18 @@ class _MyHomePageState extends State<AppPage>
|
||||
}, (value) {}, () {});
|
||||
}
|
||||
|
||||
renderAppBar(BuildContext context,Widget widget,int index) {
|
||||
print('renderAppBar=====>>>>>>${index}');
|
||||
if(index == 0) {
|
||||
return null;
|
||||
}
|
||||
return AppBar(title: buildSearchInput(context));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(title: buildSearchInput(context)),
|
||||
appBar: renderAppBar(context,widget,_currentIndex),
|
||||
body: list[_currentIndex],
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
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