forked from CarGuo/gsy_github_app_flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush_header.dart
More file actions
139 lines (130 loc) · 5.04 KB
/
push_header.dart
File metadata and controls
139 lines (130 loc) · 5.04 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
import 'package:flutter/material.dart';
import 'package:gsy_github_app_flutter/common/model/PushCommit.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_user_icon_widget.dart';
/**
* 提交详情的头
* Created by guoshuyu
* Date: 2018-07-27
*/
class PushHeader extends StatelessWidget {
final PushHeaderViewModel pushHeaderViewModel;
PushHeader(this.pushHeaderViewModel);
/// 头部变化数量图标
_getIconItem(IconData icon, String text) {
return new GSYIConText(
icon,
text,
GSYConstant.smallSubLightText,
Color(GSYColors.subLightTextColor),
15.0,
padding: 0.0,
);
}
@override
Widget build(BuildContext context) {
return new GSYCardItem(
color: Theme.of(context).primaryColor,
child: new FlatButton(
padding: new EdgeInsets.all(0.0),
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: 5.0, left: 0.0),
width: 40.0,
height: 40.0,
image: pushHeaderViewModel.actionUserPic,
onPressed: () {
NavigatorUtils.goPerson(context, pushHeaderViewModel.actionUser);
}),
new Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
///变化状态
new Row(
children: <Widget>[
_getIconItem(GSYICons.PUSH_ITEM_EDIT, pushHeaderViewModel.editCount),
new Container(width: 8.0),
_getIconItem(GSYICons.PUSH_ITEM_ADD, pushHeaderViewModel.addCount),
new Container(width: 8.0),
_getIconItem(GSYICons.PUSH_ITEM_MIN, pushHeaderViewModel.deleteCount),
new Container(width: 8.0),
],
),
new Padding(padding: new EdgeInsets.all(2.0)),
///修改时间
new Container(
child: new Text(
pushHeaderViewModel.pushTime,
style: GSYConstant.smallTextWhite,
maxLines: 2,
),
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0),
alignment: Alignment.topLeft),
///修改的commit内容
new Container(
child: new Text(
pushHeaderViewModel.pushDes,
style: GSYConstant.smallTextWhite,
maxLines: 2,
),
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),
),
],
),
),
],
),
],
),
),
),
);
}
}
class PushHeaderViewModel {
String actionUser = "---";
String actionUserPic = "---";
String pushDes = "---";
String pushTime = "---";
String editCount = "---";
String addCount = "---";
String deleteCount = "---";
String htmlUrl = GSYConstant.app_default_share_url;
PushHeaderViewModel();
PushHeaderViewModel.forMap(PushCommit pushMap) {
String name = "---";
String pic = "---";
if (pushMap.committer != null) {
name = pushMap.committer.login;
} else if (pushMap.commit != null && pushMap.commit.author != null) {
name = pushMap.commit.author.name;
}
if (pushMap.committer != null && pushMap.committer.avatar_url != null) {
pic = pushMap.committer.avatar_url;
}
actionUser = name;
actionUserPic = pic;
pushDes = "Push at " + pushMap.commit.message;
pushTime = CommonUtils.getNewsTimeStr(pushMap.commit.committer.date);
editCount = pushMap.files.length.toString() + "";
addCount = pushMap.stats.additions.toString() + "";
deleteCount = pushMap.stats.deletions.toString() + "";
htmlUrl = pushMap.htmlUrl;
}
}