Skip to content

Commit b04ce90

Browse files
committed
trend header
1 parent 57a1ba3 commit b04ce90

1 file changed

Lines changed: 71 additions & 7 deletions

File tree

‎lib/page/TrendPage.dart‎

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import 'package:flutter/material.dart';
22
import 'package:gsy_github_app_flutter/common/dao/ReposDao.dart';
3+
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
34
import 'package:gsy_github_app_flutter/common/utils/NavigatorUtils.dart';
5+
import 'package:gsy_github_app_flutter/widget/GSYCardItem.dart';
46
import 'package:gsy_github_app_flutter/widget/GSYListState.dart';
57
import 'package:gsy_github_app_flutter/widget/GSYPullLoadWidget.dart';
68
import 'package:gsy_github_app_flutter/widget/ReposItem.dart';
@@ -16,13 +18,59 @@ class TrendPage extends StatefulWidget {
1618
}
1719

1820
class _TrendPageState extends GSYListState<TrendPage> {
19-
2021
_renderItem(ReposViewModel e) {
2122
return new ReposItem(e, onPressed: () {
2223
NavigatorUtils.goReposDetail(context, e.ownerName, e.repositoryName);
2324
});
2425
}
2526

27+
_renderHeader() {
28+
return new GSYCardItem(
29+
color: Color(GSYColors.primaryValue),
30+
margin: EdgeInsets.all(10.0),
31+
shape: new RoundedRectangleBorder(
32+
borderRadius: BorderRadius.all(Radius.circular(4.0)),
33+
),
34+
child: new Padding(
35+
padding: new EdgeInsets.only(left: 0.0, top: 5.0, right: 0.0, bottom: 5.0),
36+
child: new Row(
37+
children: <Widget>[
38+
_renderHeaderPopItem("aaa", [new TrendTypeModel("fff", "fff"), new TrendTypeModel("fff", "fff")], (TrendTypeModel result) {
39+
setState(() {});
40+
}),
41+
new Container(height: 10.0, width: 0.5, color: Colors.white),
42+
_renderHeaderPopItem("bbb", [new TrendTypeModel("fff", "fff"), new TrendTypeModel("fff", "fff")], (TrendTypeModel result) {
43+
setState(() {});
44+
}),
45+
],
46+
),
47+
),
48+
);
49+
}
50+
51+
_renderHeaderPopItem(String data, List<TrendTypeModel> list, PopupMenuItemSelected<TrendTypeModel> onSelected) {
52+
return new Expanded(
53+
child: new PopupMenuButton<TrendTypeModel>(
54+
child: new Center(child: new Text(data, style: GSYConstant.middleTextWhite)),
55+
onSelected: onSelected,
56+
itemBuilder: (BuildContext context) {
57+
return _renderHeaderPopItemChild(list);
58+
},
59+
),
60+
);
61+
}
62+
63+
_renderHeaderPopItemChild(List<TrendTypeModel> data) {
64+
List<PopupMenuEntry<TrendTypeModel>> list = new List();
65+
for (TrendTypeModel item in data) {
66+
list.add(PopupMenuItem<TrendTypeModel>(
67+
value: item,
68+
child: new Text(item.name),
69+
));
70+
}
71+
return list;
72+
}
73+
2674
@override
2775
requestRefresh() async {
2876
return await ReposDao.getTrendDao(since: 'daily');
@@ -44,12 +92,28 @@ class _TrendPageState extends GSYListState<TrendPage> {
4492
@override
4593
Widget build(BuildContext context) {
4694
super.build(context); // See AutomaticKeepAliveClientMixin.
47-
return GSYPullLoadWidget(
48-
pullLoadWidgetControl,
49-
(BuildContext context, int index) => _renderItem(pullLoadWidgetControl.dataList[index]),
50-
handleRefresh,
51-
onLoadMore,
52-
refreshKey: refreshIndicatorKey,
95+
return new Scaffold(
96+
backgroundColor: Color(GSYColors.mainBackgroundColor),
97+
appBar: new AppBar(
98+
flexibleSpace: _renderHeader(),
99+
backgroundColor: Color(GSYColors.mainBackgroundColor),
100+
leading: new Container(),
101+
elevation: 0.0,
102+
),
103+
body: GSYPullLoadWidget(
104+
pullLoadWidgetControl,
105+
(BuildContext context, int index) => _renderItem(pullLoadWidgetControl.dataList[index]),
106+
handleRefresh,
107+
onLoadMore,
108+
refreshKey: refreshIndicatorKey,
109+
),
53110
);
54111
}
55112
}
113+
114+
class TrendTypeModel {
115+
final String name;
116+
final String value;
117+
118+
TrendTypeModel(this.name, this.value);
119+
}

0 commit comments

Comments
 (0)