Skip to content

Commit 20b78a4

Browse files
committed
feat: 完善关注
1 parent c9e13b8 commit 20b78a4

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

lib/helpers/constants.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class AppColors {
1111
static const int colorRed = 0xffDD4E43;
1212
static const int colorYellow = 0xffFDAF01;
1313
static const int colorBlue = 0xff00A2FF;
14+
static const int boderGrayColor = 0xff525467;
15+
static const int colorBlue2 = 0xff478CE0;
1416
}
1517

1618
// 数值常量

lib/widgets/Leaderboard/CrownAvatar.dart

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
);

lib/widgets/Leaderboard/LeaderboardContent.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class LeaderboardContent extends StatelessWidget {
4444
(_) => CrownAvatar(
4545
crownAvatarType: AvatarType.normal,
4646
color: AppColors.colorYellow,
47+
follow: true,
4748
avatarUrl:
4849
"http://admin.soscoon.com/uploadImages/0136afa3b04e2d754feaed525fa02f474dd08aa0.jpg",
4950
))),
@@ -59,6 +60,7 @@ class LeaderboardContent extends StatelessWidget {
5960
(_) => CrownAvatar(
6061
crownAvatarType: AvatarType.normal,
6162
color: AppColors.colorYellow,
63+
follow: true,
6264
avatarUrl:
6365
"http://admin.soscoon.com/uploadImages/0136afa3b04e2d754feaed525fa02f474dd08aa0.jpg",
6466
))),

0 commit comments

Comments
 (0)