forked from CarGuo/gsy_github_app_flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserItem.dart
More file actions
67 lines (59 loc) · 1.82 KB
/
UserItem.dart
File metadata and controls
67 lines (59 loc) · 1.82 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
import 'package:flutter/material.dart';
import 'package:gsy_github_app_flutter/common/model/User.dart';
import 'package:gsy_github_app_flutter/common/model/UserOrg.dart';
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
import 'package:gsy_github_app_flutter/widget/GSYCardItem.dart';
/**
* 用户item
* Created by guoshuyu
* Date: 2018-07-23
*/
class UserItem extends StatelessWidget {
final UserItemViewModel userItemViewModel;
final VoidCallback onPressed;
final bool needImage;
UserItem(this.userItemViewModel, {this.onPressed, this.needImage = true}) : super();
@override
Widget build(BuildContext context) {
Widget userImage = new IconButton(
padding: EdgeInsets.only(top: 0.0, left: 0.0, bottom: 0.0, right: 10.0),
icon: new ClipOval(
child: new FadeInImage.assetNetwork(
placeholder: GSYICons.DEFAULT_USER_ICON,
//预览图
fit: BoxFit.fitWidth,
image: userItemViewModel.userPic,
width: 30.0,
height: 30.0,
),
),
onPressed: null);
return new Container(
child: new GSYCardItem(
child: new FlatButton(
onPressed: onPressed,
child: new Padding(
padding: new EdgeInsets.only(left: 0.0, top: 5.0, right: 0.0, bottom: 10.0),
child: new Row(
children: <Widget>[
userImage,
new Expanded(child: new Text(userItemViewModel.userName, style: GSYConstant.smallTextBold)),
],
),
),
),
));
}
}
class UserItemViewModel {
String userPic;
String userName;
UserItemViewModel.fromMap(User user) {
userName = user.login;
userPic = user.avatar_url;
}
UserItemViewModel.fromOrgMap(UserOrg org) {
userName = org.login;
userPic = org.avatarUrl;
}
}