Skip to content

Commit 66dad4d

Browse files
committed
fix repos detail ui
1 parent 631e400 commit 66dad4d

File tree

3 files changed

+74
-104
lines changed

3 files changed

+74
-104
lines changed

lib/page/RepositoryDetailPage.dart

Lines changed: 65 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -136,61 +136,45 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
136136
return list;
137137
}
138138

139+
_renderBottomItem(var text, var icon, var onPressed) {
140+
return new FlatButton(
141+
onPressed: onPressed,
142+
child: new GSYIConText(
143+
icon,
144+
text,
145+
GSYConstant.smallText,
146+
Color(GSYColors.primaryValue),
147+
15.0,
148+
padding: 5.0,
149+
mainAxisAlignment: MainAxisAlignment.center,
150+
));
151+
}
152+
139153
_getBottomWidget() {
140154
List<Widget> bottomWidget = (bottomStatusModel == null)
141155
? []
142156
: <Widget>[
143-
new FlatButton(
144-
onPressed: () {
145-
CommonUtils.showLoadingDialog(context);
146-
return ReposDao.doRepositoryStarDao(userName, reposName, bottomStatusModel.star).then((result) {
147-
_refresh();
148-
Navigator.pop(context);
149-
});
150-
},
151-
child: new GSYIConText(
152-
bottomStatusModel.starIcon,
153-
bottomStatusModel.starText,
154-
GSYConstant.smallText,
155-
Color(GSYColors.primaryValue),
156-
15.0,
157-
padding: 5.0,
158-
mainAxisAlignment: MainAxisAlignment.center,
159-
)),
160-
new FlatButton(
161-
onPressed: () {
162-
CommonUtils.showLoadingDialog(context);
163-
return ReposDao.doRepositoryWatchDao(userName, reposName, bottomStatusModel.watch).then((result) {
164-
_refresh();
165-
Navigator.pop(context);
166-
});
167-
},
168-
child: new GSYIConText(
169-
bottomStatusModel.watchIcon,
170-
bottomStatusModel.watchText,
171-
GSYConstant.smallText,
172-
Color(GSYColors.primaryValue),
173-
15.0,
174-
padding: 5.0,
175-
mainAxisAlignment: MainAxisAlignment.center,
176-
)),
177-
new FlatButton(
178-
onPressed: () {
179-
CommonUtils.showLoadingDialog(context);
180-
return ReposDao.createForkDao(userName, reposName).then((result) {
181-
_refresh();
182-
Navigator.pop(context);
183-
});
184-
},
185-
child: new GSYIConText(
186-
GSYICons.REPOS_ITEM_FORK,
187-
"fork",
188-
GSYConstant.smallText,
189-
Color(GSYColors.primaryValue),
190-
15.0,
191-
padding: 5.0,
192-
mainAxisAlignment: MainAxisAlignment.center,
193-
)),
157+
_renderBottomItem(bottomStatusModel.starText, bottomStatusModel.starIcon, () {
158+
CommonUtils.showLoadingDialog(context);
159+
return ReposDao.doRepositoryStarDao(userName, reposName, bottomStatusModel.star).then((result) {
160+
_refresh();
161+
Navigator.pop(context);
162+
});
163+
}),
164+
_renderBottomItem(bottomStatusModel.watchText, bottomStatusModel.watchIcon, () {
165+
CommonUtils.showLoadingDialog(context);
166+
return ReposDao.doRepositoryWatchDao(userName, reposName, bottomStatusModel.watch).then((result) {
167+
_refresh();
168+
Navigator.pop(context);
169+
});
170+
}),
171+
_renderBottomItem("fork", GSYICons.REPOS_ITEM_FORK, () {
172+
CommonUtils.showLoadingDialog(context);
173+
return ReposDao.createForkDao(userName, reposName).then((result) {
174+
_refresh();
175+
Navigator.pop(context);
176+
});
177+
}),
194178
_renderBranchPopItem(branchControl.currentBranch, branchList, (value) {
195179
setState(() {
196180
branchControl.currentBranch = value;
@@ -210,6 +194,35 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
210194
return bottomWidget;
211195
}
212196

197+
///无奈之举,只能pageView配合tabbar,通过control同步
198+
///TabView 配合tabbar 在四个页面上问题太多
199+
_renderTabItem() {
200+
var itemList = [
201+
GSYStrings.repos_tab_info,
202+
GSYStrings.repos_tab_readme,
203+
GSYStrings.repos_tab_issue,
204+
GSYStrings.repos_tab_file,
205+
];
206+
renderItem(String item, int i) {
207+
return new FlatButton(
208+
padding: EdgeInsets.all(0.0),
209+
onPressed: () {
210+
topPageControl.jumpTo(MediaQuery.of(context).size.width * i);
211+
},
212+
child: new Text(
213+
item,
214+
style: GSYConstant.smallTextWhite,
215+
maxLines: 1,
216+
));
217+
}
218+
219+
List<Widget> list = new List();
220+
for (int i = 0; i < itemList.length; i++) {
221+
list.add(renderItem(itemList[i], i));
222+
}
223+
return list;
224+
}
225+
213226
@override
214227
void initState() {
215228
super.initState();
@@ -224,50 +237,7 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
224237
return new GSYTabBarWidget(
225238
type: GSYTabBarWidget.TOP_TAB,
226239
tarWidgetControl: tarBarControl,
227-
tabItems: [
228-
///无奈之举,只能pageView配合tabbar,通过control同步
229-
///TabView 配合tabbar 在四个页面上问题太多
230-
new FlatButton(
231-
padding: EdgeInsets.all(0.0),
232-
onPressed: () {
233-
topPageControl.jumpTo(0.0);
234-
},
235-
child: new Text(
236-
GSYStrings.repos_tab_info,
237-
style: GSYConstant.smallTextWhite,
238-
maxLines: 1,
239-
)),
240-
new FlatButton(
241-
padding: EdgeInsets.all(0.0),
242-
onPressed: () {
243-
topPageControl.jumpTo(MediaQuery.of(context).size.width);
244-
},
245-
child: new Text(
246-
GSYStrings.repos_tab_readme,
247-
style: GSYConstant.smallTextWhite,
248-
maxLines: 1,
249-
)),
250-
new FlatButton(
251-
padding: EdgeInsets.all(0.0),
252-
onPressed: () {
253-
topPageControl.jumpTo(MediaQuery.of(context).size.width * 2);
254-
},
255-
child: new Text(
256-
GSYStrings.repos_tab_issue,
257-
style: GSYConstant.smallTextWhite,
258-
maxLines: 1,
259-
)),
260-
new FlatButton(
261-
padding: EdgeInsets.all(0.0),
262-
onPressed: () {
263-
topPageControl.jumpTo(MediaQuery.of(context).size.width * 3);
264-
},
265-
child: new Text(
266-
GSYStrings.repos_tab_file,
267-
style: GSYConstant.smallTextWhite,
268-
maxLines: 1,
269-
)),
270-
],
240+
tabItems: _renderTabItem(),
271241
tabViews: [
272242
new ReposDetailInfoPage(reposDetailInfoPageControl, userName, reposName, branchControl, key: infoListKey),
273243
new RepositoryDetailReadmePage(userName, reposName, branchControl, key: readmeKey),

lib/widget/GSYSelectItemWidget.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ class _GSYSelectItemWidgetState extends State<GSYSelectItemWidget> {
5454
_renderItem(String name, int index) {
5555
var style = index == selectIndex ? GSYConstant.middleTextWhite : GSYConstant.middleSubText;
5656
return new Expanded(
57-
child: FlatButton(
58-
padding: EdgeInsets.all(0.0),
57+
child: RawMaterialButton(
58+
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
59+
constraints: const BoxConstraints(minWidth: 0.0, minHeight: 0.0),
60+
padding: EdgeInsets.all(10.0),
5961
child: new Text(
6062
name,
6163
style: style,

lib/widget/ReposHeaderItem.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ReposHeaderItem extends StatelessWidget {
5555
child: new Container(
5656
decoration: new BoxDecoration(
5757
image: new DecorationImage(
58-
fit: BoxFit.fill,
58+
fit: BoxFit.fitWidth,
5959
image: new NetworkImage(reposHeaderViewModel.ownerPic),
6060
),
6161
),
@@ -64,7 +64,7 @@ class ReposHeaderItem extends StatelessWidget {
6464
color: Color(GSYColors.primaryDarkValue & 0xA0FFFFFF),
6565
),
6666
child: new Padding(
67-
padding: new EdgeInsets.only(left: 10.0, top: 10.0, right: 10.0, bottom: 10.0),
67+
padding: new EdgeInsets.only(left: 10.0, top: 0.0, right: 10.0, bottom: 10.0),
6868
child: new Column(
6969
mainAxisSize: MainAxisSize.min,
7070
children: <Widget>[
@@ -82,7 +82,6 @@ class ReposHeaderItem extends StatelessWidget {
8282
new Text(" " + reposHeaderViewModel.repositoryName, style: GSYConstant.normalTextMitWhiteBold),
8383
],
8484
),
85-
new Padding(padding: new EdgeInsets.all(5.0)),
8685
new Row(
8786
children: <Widget>[
8887
new Text(reposHeaderViewModel.repositoryType ?? "--",
@@ -94,7 +93,6 @@ class ReposHeaderItem extends StatelessWidget {
9493
new Text(reposHeaderViewModel.license ?? "--", style: GSYConstant.subLightSmallText),
9594
],
9695
),
97-
new Padding(padding: new EdgeInsets.all(5.0)),
9896
new Container(
9997
child:
10098
new Text(reposHeaderViewModel.repositoryDes ?? "---", style: GSYConstant.subLightSmallText),
@@ -121,7 +119,7 @@ class ReposHeaderItem extends StatelessWidget {
121119
userName: reposHeaderViewModel.ownerName, reposName: reposHeaderViewModel.repositoryName);
122120
},
123121
),
124-
new Container(width: 0.3, height: 30.0, color: Color(GSYColors.subLightTextColor)),
122+
new Container(width: 0.3, height: 25.0, color: Color(GSYColors.subLightTextColor)),
125123
_getBottomItem(
126124
GSYICons.REPOS_ITEM_FORK,
127125
reposHeaderViewModel.repositoryFork,
@@ -130,7 +128,7 @@ class ReposHeaderItem extends StatelessWidget {
130128
userName: reposHeaderViewModel.ownerName, reposName: reposHeaderViewModel.repositoryName);
131129
},
132130
),
133-
new Container(width: 0.3, height: 30.0, color: Color(GSYColors.subLightTextColor)),
131+
new Container(width: 0.3, height: 25.0, color: Color(GSYColors.subLightTextColor)),
134132
_getBottomItem(
135133
GSYICons.REPOS_ITEM_WATCH,
136134
reposHeaderViewModel.repositoryWatch,
@@ -139,7 +137,7 @@ class ReposHeaderItem extends StatelessWidget {
139137
userName: reposHeaderViewModel.ownerName, reposName: reposHeaderViewModel.repositoryName);
140138
},
141139
),
142-
new Container(width: 0.3, height: 30.0, color: Color(GSYColors.subLightTextColor)),
140+
new Container(width: 0.3, height: 25.0, color: Color(GSYColors.subLightTextColor)),
143141
_getBottomItem(
144142
GSYICons.REPOS_ITEM_ISSUE,
145143
reposHeaderViewModel.repositoryIssue,

0 commit comments

Comments
 (0)