Skip to content

Commit 318cd3a

Browse files
committed
add repos info select button
1 parent a87de60 commit 318cd3a

4 files changed

Lines changed: 77 additions & 66 deletions

File tree

‎lib/common/style/GSYStyle.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ class GSYStrings {
221221
static const String repos_tab_info = "动态";
222222
static const String repos_tab_file = "文件";
223223
static const String repos_tab_issue = "ISSUE";
224+
static const String repos_tab_activity = "动态";
225+
static const String repos_tab_commits = "提交";
224226
static const String repos_tab_issue_all = "所有";
225227
static const String repos_tab_issue_open = "打开";
226228
static const String repos_tab_issue_closed = "关闭";

‎lib/page/RepostoryDetailInfoPage.dart‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import 'package:flutter/material.dart';
32
import 'package:gsy_github_app_flutter/common/dao/ReposDao.dart';
43
import 'package:gsy_github_app_flutter/common/utils/EventUtils.dart';
@@ -26,7 +25,6 @@ class ReposDetailInfoPage extends StatefulWidget {
2625

2726
// ignore: mixin_inherits_from_not_object
2827
class _ReposDetailInfoPageState extends GSYListState<ReposDetailInfoPage> {
29-
3028
final String userName;
3129

3230
final String reposName;
@@ -37,7 +35,7 @@ class _ReposDetailInfoPageState extends GSYListState<ReposDetailInfoPage> {
3735

3836
_renderEventItem(index) {
3937
if (index == 0) {
40-
return new ReposHeaderItem(reposDetailInfoPageControl.reposHeaderViewModel);
38+
return new ReposHeaderItem(reposDetailInfoPageControl.reposHeaderViewModel, (index) {});
4139
}
4240

4341
EventViewModel eventViewModel = pullLoadWidgetControl.dataList[index - 1];

‎lib/widget/GSYSelectItemWidget.dart‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ class _GSYSelectItemWidgetState extends State<GSYSelectItemWidget> {
4545
textAlign: TextAlign.center,
4646
),
4747
onPressed: () {
48+
if (selectItemChanged != null) {
49+
if (selectIndex != index) {
50+
selectItemChanged(index);
51+
}
52+
}
4853
setState(() {
4954
selectIndex = index;
5055
});
51-
if (selectItemChanged != null) {
52-
selectItemChanged(index);
53-
}
5456
}),
5557
);
5658
}

‎lib/widget/ReposHeaderItem.dart‎

Lines changed: 69 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@ import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
33
import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart';
44
import 'package:gsy_github_app_flutter/widget/GSYCardItem.dart';
55
import 'package:gsy_github_app_flutter/widget/GSYIConText.dart';
6+
import 'package:gsy_github_app_flutter/widget/GSYSelectItemWidget.dart';
67

78
/**
89
* 仓库详情信息头控件
910
* Created by guoshuyu
1011
* Date: 2018-07-18
1112
*/
1213
class ReposHeaderItem extends StatelessWidget {
14+
final SelectItemChanged selectItemChanged;
15+
1316
final ReposHeaderViewModel reposHeaderViewModel;
1417

15-
ReposHeaderItem(this.reposHeaderViewModel) : super();
18+
ReposHeaderItem(this.reposHeaderViewModel, this.selectItemChanged) : super();
1619

1720
_getBottomItem(IconData icon, String text) {
1821
return new Expanded(
@@ -40,65 +43,71 @@ class ReposHeaderItem extends StatelessWidget {
4043

4144
String infoText = createStr + ((reposHeaderViewModel.push_at != null) ? updateStr : '');
4245

43-
return new Container(
44-
child: new GSYCardItem(
45-
color: new Color(GSYColors.primaryValue),
46-
child: new Padding(
47-
padding: new EdgeInsets.only(left: 10.0, top: 10.0, right: 10.0, bottom: 10.0),
48-
child: new Column(
49-
mainAxisSize: MainAxisSize.min,
50-
children: <Widget>[
51-
new Row(
52-
children: <Widget>[
53-
new RawMaterialButton(
54-
constraints: new BoxConstraints(minWidth: 0.0, minHeight: 0.0),
55-
padding: new EdgeInsets.all(0.0),
56-
onPressed: () {},
57-
child: new Text(reposHeaderViewModel.ownerName, style: GSYConstant.normalTextMitWhiteBold),
58-
),
59-
new Text(" /", style: GSYConstant.normalTextMitWhiteBold),
60-
new Text(" " + reposHeaderViewModel.repositoryName, style: GSYConstant.normalTextMitWhiteBold),
61-
],
62-
),
63-
new Padding(padding: new EdgeInsets.all(5.0)),
64-
new Row(
65-
children: <Widget>[
66-
new Text(reposHeaderViewModel.repositoryType != null ? reposHeaderViewModel.repositoryType : "--",
67-
style: GSYConstant.subLightSmallText),
68-
new Container(width: 5.3, height: 1.0),
69-
new Text(reposHeaderViewModel.repositorySize != null ? reposHeaderViewModel.repositorySize : "--",
70-
style: GSYConstant.subLightSmallText),
71-
new Container(width: 5.3, height: 1.0),
72-
new Text(reposHeaderViewModel.license != null ? reposHeaderViewModel.license : "--", style: GSYConstant.subLightSmallText),
73-
],
74-
),
75-
new Padding(padding: new EdgeInsets.all(5.0)),
76-
new Container(
77-
child: new Text(reposHeaderViewModel.repositoryDes, style: GSYConstant.subSmallText),
78-
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0),
79-
alignment: Alignment.topLeft),
80-
new Container(
81-
child: new Text(infoText, style: GSYConstant.subSmallText),
82-
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0, right: 5.0),
83-
alignment: Alignment.topRight),
84-
new Divider(
85-
color: Color(GSYColors.subTextColor),
86-
),
87-
new Padding(
88-
padding: new EdgeInsets.all(5.0),
89-
child: new Row(
90-
crossAxisAlignment: CrossAxisAlignment.center,
91-
mainAxisAlignment: MainAxisAlignment.center,
92-
children: <Widget>[
93-
_getBottomItem(GSYICons.REPOS_ITEM_STAR, reposHeaderViewModel.repositoryStar),
94-
_getBottomItem(GSYICons.REPOS_ITEM_FORK, reposHeaderViewModel.repositoryFork),
95-
_getBottomItem(GSYICons.REPOS_ITEM_WATCH, reposHeaderViewModel.repositoryWatch),
96-
_getBottomItem(GSYICons.REPOS_ITEM_ISSUE, reposHeaderViewModel.repositoryIssue),
97-
],
98-
)),
99-
],
100-
),
101-
)),
46+
return new Column(
47+
children: <Widget>[
48+
new GSYCardItem(
49+
color: new Color(GSYColors.primaryValue),
50+
child: new Padding(
51+
padding: new EdgeInsets.only(left: 10.0, top: 10.0, right: 10.0, bottom: 10.0),
52+
child: new Column(
53+
mainAxisSize: MainAxisSize.min,
54+
children: <Widget>[
55+
new Row(
56+
children: <Widget>[
57+
new RawMaterialButton(
58+
constraints: new BoxConstraints(minWidth: 0.0, minHeight: 0.0),
59+
padding: new EdgeInsets.all(0.0),
60+
onPressed: () {},
61+
child: new Text(reposHeaderViewModel.ownerName, style: GSYConstant.normalTextMitWhiteBold),
62+
),
63+
new Text(" /", style: GSYConstant.normalTextMitWhiteBold),
64+
new Text(" " + reposHeaderViewModel.repositoryName, style: GSYConstant.normalTextMitWhiteBold),
65+
],
66+
),
67+
new Padding(padding: new EdgeInsets.all(5.0)),
68+
new Row(
69+
children: <Widget>[
70+
new Text(reposHeaderViewModel.repositoryType != null ? reposHeaderViewModel.repositoryType : "--",
71+
style: GSYConstant.subLightSmallText),
72+
new Container(width: 5.3, height: 1.0),
73+
new Text(reposHeaderViewModel.repositorySize != null ? reposHeaderViewModel.repositorySize : "--",
74+
style: GSYConstant.subLightSmallText),
75+
new Container(width: 5.3, height: 1.0),
76+
new Text(reposHeaderViewModel.license != null ? reposHeaderViewModel.license : "--", style: GSYConstant.subLightSmallText),
77+
],
78+
),
79+
new Padding(padding: new EdgeInsets.all(5.0)),
80+
new Container(
81+
child: new Text(reposHeaderViewModel.repositoryDes, style: GSYConstant.subSmallText),
82+
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0),
83+
alignment: Alignment.topLeft),
84+
new Container(
85+
child: new Text(infoText, style: GSYConstant.subSmallText),
86+
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0, right: 5.0),
87+
alignment: Alignment.topRight),
88+
new Divider(
89+
color: Color(GSYColors.subTextColor),
90+
),
91+
new Padding(
92+
padding: new EdgeInsets.all(5.0),
93+
child: new Row(
94+
crossAxisAlignment: CrossAxisAlignment.center,
95+
mainAxisAlignment: MainAxisAlignment.center,
96+
children: <Widget>[
97+
_getBottomItem(GSYICons.REPOS_ITEM_STAR, reposHeaderViewModel.repositoryStar),
98+
_getBottomItem(GSYICons.REPOS_ITEM_FORK, reposHeaderViewModel.repositoryFork),
99+
_getBottomItem(GSYICons.REPOS_ITEM_WATCH, reposHeaderViewModel.repositoryWatch),
100+
_getBottomItem(GSYICons.REPOS_ITEM_ISSUE, reposHeaderViewModel.repositoryIssue),
101+
],
102+
)),
103+
],
104+
),
105+
)),
106+
new GSYSelectItemWidget([
107+
GSYStrings.repos_tab_activity,
108+
GSYStrings.repos_tab_commits,
109+
], selectItemChanged)
110+
],
102111
);
103112
}
104113
}

0 commit comments

Comments
 (0)