tiktok_video_button_column.dart
4.11 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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
import 'package:flutter/material.dart';
import 'package:Parlando/tiktok/style/style.dart';
import 'package:getwidget/getwidget.dart';
import 'package:tapped/tapped.dart';
import 'package:Parlando/extension/int_extension.dart';
class TikTokButtonColumn extends StatelessWidget {
final double? bottomPadding;
final bool isPraise;
final bool isCollect;
final bool isSharing;
final Function? onPraise;
final Function? onCollect;
final Function? onShare;
final Function? onAvatar;
const TikTokButtonColumn({
Key? key,
this.bottomPadding,
this.onPraise,
this.onCollect,
this.onShare,
this.isPraise = false,
this.isCollect = false,
this.onAvatar,
this.isSharing = false,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
width: SysSize.avatar,
margin: EdgeInsets.only(
bottom: bottomPadding ?? 50.px,
right: 5.px,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
FavoriteIcon(
onFavorite: onPraise,
isFavorite: isPraise,
),
CollectIcon(
onCollect: onCollect,
isCollect: isCollect,
),
isSharing
? const GFLoader()
: _IconButton(
icon: IconToText(Icons.share, size: 20.px),
text: '分享',
onTap: onShare,
),
],
),
);
}
}
class FavoriteIcon extends StatelessWidget {
const FavoriteIcon({
Key? key,
required this.onFavorite,
this.isFavorite,
}) : super(key: key);
final bool? isFavorite;
final Function? onFavorite;
@override
Widget build(BuildContext context) {
return _IconButton(
icon: IconToText(
Icons.favorite_border_outlined,
size: 20,
color: isFavorite! ? ColorPlate.red : null,
),
text: '点赞',
onTap: onFavorite,
);
}
}
class CollectIcon extends StatelessWidget {
const CollectIcon({
Key? key,
required this.onCollect,
this.isCollect,
}) : super(key: key);
final bool? isCollect;
final Function? onCollect;
@override
Widget build(BuildContext context) {
return _IconButton(
icon: IconToText(
Icons.star_border_outlined,
size: 20,
color: isCollect! ? ColorPlate.red : null,
),
text: '收藏',
onTap: onCollect,
);
}
}
/// 把IconData转换为文字,使其可以使用文字样式
class IconToText extends StatelessWidget {
final IconData? icon;
final TextStyle? style;
final double? size;
final Color? color;
const IconToText(
this.icon, {
Key? key,
this.style,
this.size,
this.color,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Text(
String.fromCharCode(icon!.codePoint),
style: style ??
TextStyle(
fontFamily: 'MaterialIcons',
fontSize: size ?? 15.px,
inherit: true,
color: color ?? ColorPlate.white,
),
);
}
}
class _IconButton extends StatelessWidget {
final Widget? icon;
final String? text;
final Function? onTap;
const _IconButton({
Key? key,
this.icon,
this.text,
this.onTap,
}) : super(key: key);
@override
Widget build(BuildContext context) {
var shadowStyle = TextStyle(
shadows: [
Shadow(
color: Colors.black.withOpacity(0.15),
offset: const Offset(0, 1),
blurRadius: 1,
),
],
);
Widget body = Column(
children: <Widget>[
Tapped(
onTap: onTap,
child: icon ?? Container(),
),
Container(height: 2.px),
Text(
text ?? '??',
style: const TextStyle(
fontSize: 12,
color: ColorPlate.white,
),
),
],
);
return Container(
padding: EdgeInsets.symmetric(vertical: 10.px),
child: DefaultTextStyle(
style: shadowStyle,
child: body,
),
);
}
}