@@ -10,10 +10,12 @@ class CrownAvatar extends StatefulWidget {
1010 final AvatarType crownAvatarType;
1111 final int color;
1212 final String avatarUrl;
13+ final bool follow;
1314
1415 CrownAvatar (
1516 {@required this .crownAvatarType,
1617 @required this .avatarUrl,
18+ this .follow = false ,
1719 this .color = AppColors .colorRed});
1820
1921 @override
@@ -33,6 +35,39 @@ class _CrownAvatarState extends State<CrownAvatar> {
3335 double circleFontSize = 14.0 ;
3436 double crownTextSize = 16.0 ;
3537
38+ Widget get _followButton {
39+ if (widget.follow) {
40+ return Container (
41+ margin: EdgeInsets .only (top: 4.0 ),
42+ width: 60.0 ,
43+ height: 26.0 ,
44+ decoration: BoxDecoration (
45+ color: Color (AppColors .colorBlue2),
46+ borderRadius: BorderRadius .circular (4.0 )),
47+ child: Align (
48+ child: Text (
49+ "已关注" ,
50+ style: TextStyle (color: Color (AppColors .fontColor), fontSize: 14.0 ),
51+ ),
52+ ),
53+ );
54+ }
55+ return Container (
56+ margin: EdgeInsets .only (top: 4.0 ),
57+ width: 60.0 ,
58+ height: 26.0 ,
59+ decoration: BoxDecoration (
60+ border: Border .all (color: Color (AppColors .boderGrayColor)),
61+ borderRadius: BorderRadius .circular (4.0 )),
62+ child: Align (
63+ child: Text (
64+ "关注" ,
65+ style: TextStyle (color: Color (AppColors .fontColor), fontSize: 14.0 ),
66+ ),
67+ ),
68+ );
69+ }
70+
3671 @override
3772 Widget build (BuildContext context) {
3873 // 判断头像的类型给出对应的尺寸
@@ -60,16 +95,16 @@ class _CrownAvatarState extends State<CrownAvatar> {
6095 fit: BoxFit .cover,
6196 ),
6297 ),
98+ SizedBox (
99+ height: 10.0 ,
100+ width: 60.0 ,
101+ ),
63102 Text (
64103 "阿明" ,
65104 style:
66105 TextStyle (color: Color (AppColors .fontColor), fontSize: 16.0 ),
67106 ),
68- MaterialButton (
69- onPressed: () {},
70- child: Text ("关注" ),
71- color: Color (AppColors .lightGray),
72- )
107+ _followButton,
73108 ],
74109 ),
75110 );
0 commit comments