Skip to content

Commit b59505f

Browse files
committed
add repos item
1 parent 50d838b commit b59505f

7 files changed

Lines changed: 139 additions & 118 deletions

File tree

‎lib/common/net/trending/GithubTrending.dart‎

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
12
import 'dart:io';
23

34
import 'package:dio/dio.dart';
4-
import 'package:gsy_github_app_flutter/common/config/Config.dart';
5+
import 'package:gsy_github_app_flutter/common/net/Api.dart';
56
import 'package:gsy_github_app_flutter/common/net/Code.dart';
67
import 'package:gsy_github_app_flutter/common/net/ResultData.dart';
78

@@ -12,27 +13,8 @@ import 'package:gsy_github_app_flutter/common/net/ResultData.dart';
1213

1314
class GitHubTrending {
1415
fetchTrending(url) async {
15-
Dio dio = new Dio();
16-
Response res;
17-
try {
18-
res = await dio.request(url, data: null, options: new Options(contentType: ContentType.parse("application/x-www-form-urlencoded")));
19-
} on DioError catch (e) {
20-
Response errorResponse;
21-
if (e.response != null) {
22-
errorResponse = e.response;
23-
} else {
24-
errorResponse = new Response(statusCode: 666);
25-
}
26-
if (e.type == DioErrorType.CONNECT_TIMEOUT) {
27-
errorResponse.statusCode = Code.NETWORK_TIMEOUT;
28-
}
29-
if (Config.DEBUG) {
30-
print('请求异常: ' + e.toString());
31-
print('请求异常url: ' + url);
32-
}
33-
return new ResultData(Code.errorHandleFunction(errorResponse.statusCode, e.message), false, errorResponse.statusCode);
34-
}
35-
if (res != null && res.statusCode == 200) {
16+
var res = await HttpManager.netFetch(url, null, null, new Options(contentType: ContentType.TEXT));
17+
if (res != null && res.result && res.data != null) {
3618
return new ResultData(TrendingUtil.htmlToRepo(res.data), true, Code.SUCCESS);
3719
} else {
3820
return res;

‎lib/common/style/GSYStyle.dart‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ class GSYConstant {
127127
fontSize: normalTextSize,
128128
);
129129

130+
static const normalTextBold = TextStyle(
131+
color: Color(GSYColors.mainTextColor),
132+
fontSize: normalTextSize,
133+
fontWeight: FontWeight.bold,
134+
);
135+
130136
static const subNormalText = TextStyle(
131137
color: Color(GSYColors.subTextColor),
132138
fontSize: normalTextSize,
@@ -185,8 +191,8 @@ class GSYICons {
185191
static String FONT_FAMILY = 'wxcIconFont';
186192

187193
static IconData MAIN_DT = new IconData(0xe684, fontFamily: GSYICons.FONT_FAMILY);
188-
189194
static IconData MAIN_QS = new IconData(0xe818, fontFamily: GSYICons.FONT_FAMILY);
190-
191195
static IconData MAIN_MY = new IconData(0xe6d0, fontFamily: GSYICons.FONT_FAMILY);
196+
197+
static IconData REPOS_ITEM_USER = new IconData(0xe63e, fontFamily: GSYICons.FONT_FAMILY);
192198
}

‎lib/page/DynamicPage.dart‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class DynamicPage extends StatefulWidget {
1818
}
1919

2020
class _DynamicPageState extends State<DynamicPage> {
21+
2122
bool isLoading = false;
2223

2324
int page = 1;
@@ -70,7 +71,9 @@ class _DynamicPageState extends State<DynamicPage> {
7071
@override
7172
void didChangeDependencies() {
7273
pullLoadWidgetControl.dataList = _getStore().state.eventList;
73-
_handleRefresh();
74+
if (pullLoadWidgetControl.dataList.length == 0) {
75+
_handleRefresh();
76+
}
7477
super.didChangeDependencies();
7578
}
7679

‎lib/page/TrendPage.dart‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
33
import 'package:flutter_redux/flutter_redux.dart';
44
import 'package:gsy_github_app_flutter/common/dao/ReposDao.dart';
55
import 'package:gsy_github_app_flutter/common/redux/GSYState.dart';
6+
import 'package:gsy_github_app_flutter/widget/ReposItem.dart';
67

78

89
class TrendPage extends StatefulWidget {
@@ -22,10 +23,7 @@ class _TrendPageState extends State<TrendPage> {
2223

2324
@override
2425
Widget build(BuildContext context) {
25-
return new Text(
26-
"555555555",
27-
style: Theme.of(context).textTheme.display1,
28-
);
26+
return new ReposItem(new ReposViewModel());
2927
}
3028

3129
}

‎lib/page/TrendingPage.dart‎

Lines changed: 0 additions & 89 deletions
This file was deleted.

‎lib/widget/GSYIConText.dart‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import 'package:flutter/material.dart';
2+
3+
/**
4+
* Created by guoshuyu
5+
* Date: 2018-07-16
6+
*/
7+
8+
class GSYIConText extends StatelessWidget {
9+
final String iconText;
10+
11+
final IconData iconData;
12+
13+
final TextStyle textStyle;
14+
15+
final Color iconColor;
16+
17+
final double padding;
18+
19+
final double iconSize;
20+
21+
GSYIConText(this.iconData, this.iconText, this.textStyle, this.iconColor, this.iconSize, {this.padding = 0.0});
22+
23+
@override
24+
Widget build(BuildContext context) {
25+
return new Row(
26+
children: <Widget>[
27+
new Icon(
28+
iconData,
29+
size: iconSize,
30+
color: iconColor,
31+
),
32+
new Padding(padding: new EdgeInsets.all(padding)),
33+
new Text(
34+
iconText,
35+
style: textStyle,
36+
),
37+
],
38+
);
39+
}
40+
}

‎lib/widget/ReposItem.dart‎

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
3+
import 'package:gsy_github_app_flutter/widget/GSYCardItem.dart';
4+
import 'package:gsy_github_app_flutter/widget/GSYIConText.dart';
5+
6+
/**
7+
* Created by guoshuyu
8+
* Date: 2018-07-16
9+
*/
10+
11+
class ReposItem extends StatelessWidget {
12+
final ReposViewModel reposViewModel;
13+
14+
ReposItem(this.reposViewModel) : super();
15+
16+
@override
17+
Widget build(BuildContext context) {
18+
return new Container(
19+
child: new GSYCardItem(
20+
child: new FlatButton(
21+
onPressed: () => {},
22+
child: new Padding(
23+
padding: new EdgeInsets.only(left: 10.0, top: 10.0, right: 10.0, bottom: 10.0),
24+
child: new Column(
25+
mainAxisSize: MainAxisSize.min,
26+
children: <Widget>[
27+
new Row(
28+
crossAxisAlignment: CrossAxisAlignment.start,
29+
children: <Widget>[
30+
new ClipOval(
31+
child: new FadeInImage.assetNetwork(
32+
placeholder: "static/images/logo.png",
33+
//预览图
34+
fit: BoxFit.fitWidth,
35+
image: "FFFF",
36+
width: 40.0,
37+
height: 40.0,
38+
),
39+
),
40+
new Padding(padding: EdgeInsets.all(10.0)),
41+
new Expanded(
42+
child: new Column(
43+
crossAxisAlignment: CrossAxisAlignment.start,
44+
children: <Widget>[
45+
new Text("FFFF", style: GSYConstant.normalTextBold),
46+
new GSYIConText(
47+
GSYICons.REPOS_ITEM_USER,
48+
"FFF",
49+
GSYConstant.subLightSmallText,
50+
Color(GSYColors.subLightTextColor),
51+
10.0,
52+
padding: 3.0,
53+
),
54+
],
55+
),
56+
),
57+
new Text("FFFF", style: GSYConstant.subSmallText),
58+
],
59+
),
60+
new Container(
61+
child: new Text("ggggggggggggggggggggggggggggggg", style: GSYConstant.subSmallText),
62+
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0),
63+
alignment: Alignment.topLeft),
64+
],
65+
),
66+
))),
67+
);
68+
}
69+
}
70+
71+
class ReposViewModel {
72+
String ownerName;
73+
String ownerPic;
74+
String repositoryName;
75+
String repositoryStar;
76+
String repositoryFork;
77+
String repositoryWatch;
78+
String hideWatchIcon;
79+
String repositoryTyp;
80+
String repositoryDes;
81+
}

0 commit comments

Comments
 (0)