mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-05-20 06:16:20 +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"
|
||||
|
@ -178,7 +178,7 @@ class DisclaimerMsgState extends State<DisclaimerMsg> {
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.horizontal(right: Radius.circular(10)),
|
||||
BorderRadius.horizontal(right: Radius.circular(10)),
|
||||
color: Colors.black45,
|
||||
),
|
||||
child: Text(
|
||||
|
@ -17,41 +17,40 @@ 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;
|
||||
|
||||
|
||||
@override
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (key == null) {
|
||||
key = GlobalKey<DisclaimerMsgState>();
|
||||
// key = const Key('__RIKEY1__');
|
||||
key = GlobalKey<DisclaimerMsgState>();
|
||||
// key = const Key('__RIKEY1__');
|
||||
//获取sharePre
|
||||
_unKnow = _prefs.then((SharedPreferences prefs) {
|
||||
return (prefs.getBool('disclaimer::Boolean') ?? false);
|
||||
});
|
||||
_unKnow = _prefs.then((SharedPreferences prefs) {
|
||||
return (prefs.getBool('disclaimer::Boolean') ?? false);
|
||||
});
|
||||
|
||||
/// 判断是否需要弹出免责声明,已经勾选过不在显示,就不会主动弹
|
||||
_unKnow.then((bool value) {
|
||||
new Future.delayed(const Duration(seconds: 1),(){
|
||||
if (!value && key.currentState is DisclaimerMsgState && key.currentState.showAlertDialog is Function) {
|
||||
key.currentState.showAlertDialog(context);
|
||||
}
|
||||
});
|
||||
new Future.delayed(const Duration(seconds: 1),(){
|
||||
if (!value && key.currentState is DisclaimerMsgState && key.currentState.showAlertDialog is Function) {
|
||||
key.currentState.showAlertDialog(context);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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}';
|
||||
@ -99,15 +93,15 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
||||
Column(
|
||||
children: <Widget>[
|
||||
Stack(
|
||||
//alignment: const FractionalOffset(0.9, 0.1),//方法一
|
||||
children: <Widget>[
|
||||
Pagination(),
|
||||
Positioned(//方法二
|
||||
top: 10.0,
|
||||
left: 0.0,
|
||||
child: DisclaimerMsg(key:key,pWidget:this)
|
||||
),
|
||||
]),
|
||||
//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: 1, child:Container(color: Theme.of(context).primaryColor)),
|
||||
SizedBox(height: 10),
|
||||
],
|
||||
@ -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),//方法一
|
||||
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 Expanded(
|
||||
//child: new List(),
|
||||
child: listComp.ListRefresh(getIndexListData, makeCard))
|
||||
]);
|
||||
return new Column(
|
||||
children: <Widget>[
|
||||
// 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,headerView)
|
||||
)
|
||||
]
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,10 +12,10 @@ class _Page {
|
||||
}
|
||||
|
||||
final List<_Page> _allPages = <_Page>[
|
||||
_Page('项目1'),
|
||||
_Page('项目2'),
|
||||
_Page('项目3'),
|
||||
_Page('项目4'),
|
||||
_Page('项目1'),
|
||||
_Page('项目2'),
|
||||
_Page('项目3'),
|
||||
_Page('项目4'),
|
||||
];
|
||||
|
||||
class MainPage extends StatelessWidget {
|
||||
@ -37,7 +37,7 @@ class MainPage extends StatelessWidget {
|
||||
centerTitle: true,
|
||||
title: TabLayout(),
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
IconButton(
|
||||
icon: Icon(Icons.search),
|
||||
onPressed: () {
|
||||
pushPage(context, SearchPage(), pageName: "SearchPage");
|
||||
@ -67,7 +67,7 @@ class TabLayout extends StatelessWidget {
|
||||
indicatorSize: TabBarIndicatorSize.label,
|
||||
tabs: _allPages
|
||||
.map((_Page page) =>
|
||||
Tab(text: page.labelId))
|
||||
Tab(text: page.labelId))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
@ -100,7 +100,7 @@ class TabBarViewLayout extends StatelessWidget {
|
||||
print("TabBarViewLayout build.......");
|
||||
return TabBarView(
|
||||
children: _allPages.map((_Page page) {
|
||||
return buildTabView(context, page);
|
||||
}).toList());
|
||||
return buildTabView(context, page);
|
||||
}).toList());
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
@ -96,7 +99,7 @@ class _MyHomePageState extends State<AppPage>
|
||||
}
|
||||
|
||||
Widget buildSearchInput(BuildContext context) {
|
||||
return new SearchInput((value) async {
|
||||
return new SearchInput((value) async {
|
||||
if (value != '') {
|
||||
List<WidgetPoint> list = await widgetControl.search(value);
|
||||
return list
|
||||
@ -105,7 +108,7 @@ class _MyHomePageState extends State<AppPage>
|
||||
icon: WidgetName2Icon.icons[item.name] ?? null,
|
||||
text: 'widget',
|
||||
onTap: () {
|
||||
onWidgetTap(item, context);
|
||||
onWidgetTap(item, context);
|
||||
},
|
||||
))
|
||||
.toList();
|
||||
@ -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