-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathfriend_circle.dart
173 lines (157 loc) · 4.32 KB
/
friend_circle.dart
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
import 'package:flutter/material.dart';
class FriendCircle extends StatelessWidget {
final FriendCircleViewModel data;
const FriendCircle({
Key key,
this.data,
}) : super(key: key);
Widget renderComments() {
return Container(
margin: EdgeInsets.only(top: 10),
padding: EdgeInsets.all(10),
color: Color(0xFFF3F3F5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: this.data.comments.map((comment) {
return Text.rich(
TextSpan(
style: TextStyle(
fontSize: 15,
color: Color(0xFF333333),
),
children: [
TextSpan(
text: comment.fromUser,
style: TextStyle(
fontWeight: FontWeight.w500,
color: Color(0xFF636F80),
),
),
TextSpan(text: ':${comment.content}'),
]..insertAll(1, comment.source ? [TextSpan()] : [
TextSpan(text: ' 回复 '),
TextSpan(
text: comment.toUser,
style: TextStyle(
fontWeight: FontWeight.w500,
color: Color(0xFF636F80),
),
),
],
),
),
);
}).toList(),
),
);
}
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(top: 16),
padding: EdgeInsets.symmetric(horizontal: 16),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ClipRRect(
borderRadius: BorderRadius.circular(6),
child: Image.network(
this.data.userImgUrl,
width: 50,
height: 50,
),
),
Padding(padding: EdgeInsets.only(left: 12)),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
this.data.userName,
style: TextStyle(
fontSize: 19,
fontWeight: FontWeight.bold,
color: Color(0xFF636F80),
),
),
Padding(padding: EdgeInsets.only(top: 6)),
Text(
this.data.saying,
style: TextStyle(
fontSize: 15,
height: 0.8,
color: Color(0xFF333333),
),
),
Padding(
padding: EdgeInsets.symmetric(vertical: 10),
child: Image.network(
this.data.pic,
fit: BoxFit.fitWidth,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
this.data.publishTime,
style: TextStyle(
fontSize: 13,
color: Color(0xFF999999),
),
),
Icon(
Icons.comment,
size: 16,
color: Color(0xFF999999),
),
],
),
this.renderComments(),
],
),
),
],
),
);
}
}
class FriendCircleViewModel {
/// 用户名
final String userName;
/// 用户头像地址
final String userImgUrl;
/// 说说
final String saying;
/// 图片
final String pic;
///发布时间
final String publishTime;
/// 评论内容
final List<Comment> comments;
const FriendCircleViewModel({
this.userName,
this.userImgUrl,
this.saying,
this.pic,
this.publishTime,
this.comments,
});
}
class Comment {
/// 是否发起人
final bool source;
/// 评论者
final String fromUser;
/// 被评论者
final String toUser;
// 评论内容
final String content;
const Comment({
this.source,
this.fromUser,
this.toUser,
this.content,
});
}