forked from CarGuo/gsy_github_app_flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathissue_header_item.dart
More file actions
179 lines (160 loc) · 6.16 KB
/
issue_header_item.dart
File metadata and controls
179 lines (160 loc) · 6.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import 'package:flutter/material.dart';
import 'package:gsy_github_app_flutter/common/model/Issue.dart';
import 'package:gsy_github_app_flutter/common/style/gsy_style.dart';
import 'package:gsy_github_app_flutter/common/utils/common_utils.dart';
import 'package:gsy_github_app_flutter/common/utils/navigator_utils.dart';
import 'package:gsy_github_app_flutter/widget/gsy_card_item.dart';
import 'package:gsy_github_app_flutter/widget/gsy_icon_text.dart';
import 'package:gsy_github_app_flutter/widget/gsy_markdown_widget.dart';
import 'package:gsy_github_app_flutter/widget/gsy_user_icon_widget.dart';
/**
* Issue 详情头
* Created by guoshuyu
* on 2018/7/21.
*/
class IssueHeaderItem extends StatelessWidget {
final IssueHeaderViewModel issueHeaderViewModel;
final VoidCallback onPressed;
IssueHeaderItem(this.issueHeaderViewModel, {this.onPressed});
_renderBottomContainer() {
Color issueStateColor = issueHeaderViewModel.state == "open" ? Colors.green : Colors.red;
///底部Issue状态
Widget bottomContainer = new Row(
children: <Widget>[
///issue 关闭打开状态
new GSYIConText(
GSYICons.ISSUE_ITEM_ISSUE,
issueHeaderViewModel.state,
TextStyle(
color: issueStateColor,
fontSize: GSYConstant.smallTextSize,
),
issueStateColor,
15.0,
padding: 2.0,
),
new Padding(padding: new EdgeInsets.all(2.0)),
///issue issue编码
new Text(issueHeaderViewModel.issueTag, style: GSYConstant.smallTextWhite),
new Padding(padding: new EdgeInsets.all(2.0)),
///issue 评论数
new GSYIConText(
GSYICons.ISSUE_ITEM_COMMENT,
issueHeaderViewModel.commentCount,
GSYConstant.smallTextWhite,
Color(GSYColors.white),
15.0,
padding: 2.0,
),
],
);
return bottomContainer;
}
///关闭操作人
_renderCloseByText() {
return (issueHeaderViewModel.closedBy == null || issueHeaderViewModel.closedBy.trim().length == 0)
? new Container()
: new Container(
child: new Text(
"Close By " + issueHeaderViewModel.closedBy,
style: GSYConstant.smallSubLightText,
),
margin: new EdgeInsets.only(right: 5.0, top: 10.0, bottom: 10.0),
alignment: Alignment.topRight);
}
@override
Widget build(BuildContext context) {
return new GSYCardItem(
color: Theme.of(context).primaryColor,
child: new FlatButton(
padding: new EdgeInsets.all(0.0),
onPressed: onPressed,
child: new Padding(
padding: new EdgeInsets.all(10.0),
child: new Column(
children: <Widget>[
new Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
///头像
new GSYUserIconWidget(
padding: const EdgeInsets.only(top: 0.0, right: 10.0, left: 0.0),
width: 50.0,
height: 50.0,
image: issueHeaderViewModel.actionUserPic ?? GSYICons.DEFAULT_REMOTE_PIC,
onPressed: () {
NavigatorUtils.goPerson(context, issueHeaderViewModel.actionUser);
}),
new Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new Row(
children: <Widget>[
///名称
new Expanded(child: new Text(issueHeaderViewModel.actionUser, style: GSYConstant.normalTextWhite)),
///时间
new Text(
issueHeaderViewModel.actionTime,
style: GSYConstant.smallSubLightText,
overflow: TextOverflow.ellipsis,
),
],
),
new Padding(padding: new EdgeInsets.all(2.0)),
///底部Item
_renderBottomContainer(),
new Container(
///评论标题
child: new Text(
issueHeaderViewModel.issueComment,
style: GSYConstant.smallTextWhite,
),
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0),
alignment: Alignment.topLeft),
new Padding(
padding: new EdgeInsets.only(left: 0.0, top: 2.0, right: 0.0, bottom: 0.0),
),
],
),
),
],
),
///评论内容
GSYMarkdownWidget(markdownData: issueHeaderViewModel.issueDesHtml, style: GSYMarkdownWidget.DARK_THEME),
///close 用户
_renderCloseByText()
],
),
),
),
);
}
}
class IssueHeaderViewModel {
String actionTime = "---";
String actionUser = "---";
String actionUserPic;
String closedBy = "";
bool locked = false;
String issueComment = "---";
String issueDesHtml = "---";
String commentCount = "---";
String state = "---";
String issueDes = "---";
String issueTag = "---";
IssueHeaderViewModel();
IssueHeaderViewModel.fromMap(Issue issueMap) {
actionTime = CommonUtils.getNewsTimeStr(issueMap.createdAt);
actionUser = issueMap.user.login;
actionUserPic = issueMap.user.avatar_url;
closedBy = issueMap.closeBy != null ? issueMap.closeBy.login : "";
locked = issueMap.locked;
issueComment = issueMap.title;
issueDesHtml = issueMap.bodyHtml != null ? issueMap.bodyHtml : (issueMap.body != null) ? issueMap.body : "";
commentCount = issueMap.commentNum.toString() + "";
state = issueMap.state;
issueDes = issueMap.body != null ? ": \n" + issueMap.body : '';
issueTag = "#" + issueMap.number.toString();
}
}