opt: stat组件传参
This commit is contained in:
@ -6,7 +6,7 @@ class StatDanMu extends StatelessWidget {
|
||||
final dynamic danmu;
|
||||
final String? size;
|
||||
|
||||
const StatDanMu({Key? key, this.theme, this.danmu, this.size})
|
||||
const StatDanMu({Key? key, this.theme = 'gray', this.danmu, this.size})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@ -17,21 +17,46 @@ class StatDanMu extends StatelessWidget {
|
||||
'black': Theme.of(context).colorScheme.onSurface.withOpacity(0.8),
|
||||
};
|
||||
Color color = colorObject[theme]!;
|
||||
return StatIconText(
|
||||
icon: Icons.subtitles_outlined,
|
||||
text: Utils.numFormat(danmu!),
|
||||
color: color,
|
||||
size: size,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StatIconText extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String text;
|
||||
final Color color;
|
||||
final String? size;
|
||||
|
||||
const StatIconText({
|
||||
Key? key,
|
||||
required this.icon,
|
||||
required this.text,
|
||||
required this.color,
|
||||
this.size,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.subtitles_outlined,
|
||||
icon,
|
||||
size: 14,
|
||||
color: color,
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
Text(
|
||||
Utils.numFormat(danmu!),
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: size == 'medium' ? 12 : 11,
|
||||
color: color,
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -6,8 +6,12 @@ class StatView extends StatelessWidget {
|
||||
final dynamic view;
|
||||
final String? size;
|
||||
|
||||
const StatView({Key? key, this.theme, this.view, this.size})
|
||||
: super(key: key);
|
||||
const StatView({
|
||||
Key? key,
|
||||
this.theme = 'gray',
|
||||
this.view,
|
||||
this.size,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -17,16 +21,41 @@ class StatView extends StatelessWidget {
|
||||
'black': Theme.of(context).colorScheme.onSurface.withOpacity(0.8),
|
||||
};
|
||||
Color color = colorObject[theme]!;
|
||||
return StatIconText(
|
||||
icon: Icons.play_circle_outlined,
|
||||
text: Utils.numFormat(view!),
|
||||
color: color,
|
||||
size: size,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StatIconText extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String text;
|
||||
final Color color;
|
||||
final String? size;
|
||||
|
||||
const StatIconText({
|
||||
Key? key,
|
||||
required this.icon,
|
||||
required this.text,
|
||||
required this.color,
|
||||
this.size,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.play_circle_outlined,
|
||||
icon,
|
||||
size: 13,
|
||||
color: color,
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
Text(
|
||||
Utils.numFormat(view!),
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: size == 'medium' ? 12 : 11,
|
||||
color: color,
|
||||
|
@ -266,17 +266,11 @@ class VideoContent extends StatelessWidget {
|
||||
Row(
|
||||
children: [
|
||||
if (showView) ...[
|
||||
StatView(
|
||||
theme: 'gray',
|
||||
view: videoItem.stat.view as int,
|
||||
),
|
||||
StatView(view: videoItem.stat.view as int),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
if (showDanmaku)
|
||||
StatDanMu(
|
||||
theme: 'gray',
|
||||
danmu: videoItem.stat.danmaku as int,
|
||||
),
|
||||
StatDanMu(danmu: videoItem.stat.danmaku as int),
|
||||
const Spacer(),
|
||||
if (source == 'normal')
|
||||
SizedBox(
|
||||
|
@ -287,9 +287,9 @@ class VideoStat extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
StatView(theme: 'gray', view: videoItem.stat.view),
|
||||
StatView(view: videoItem.stat.view),
|
||||
const SizedBox(width: 8),
|
||||
StatDanMu(theme: 'gray', danmu: videoItem.stat.danmu),
|
||||
StatDanMu(danmu: videoItem.stat.danmu),
|
||||
if (videoItem is RecVideoItemModel) ...<Widget>[
|
||||
crossAxisCount > 1 ? const Spacer() : const SizedBox(width: 8),
|
||||
RichText(
|
||||
|
@ -255,13 +255,11 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
||||
Row(
|
||||
children: [
|
||||
StatView(
|
||||
theme: 'gray',
|
||||
view: widget.bangumiDetail!.stat!['views'],
|
||||
size: 'medium',
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
StatDanMu(
|
||||
theme: 'gray',
|
||||
danmu: widget.bangumiDetail!.stat!['danmakus'],
|
||||
size: 'medium',
|
||||
),
|
||||
|
@ -60,13 +60,11 @@ class IntroDetail extends StatelessWidget {
|
||||
Row(
|
||||
children: [
|
||||
StatView(
|
||||
theme: 'gray',
|
||||
view: bangumiDetail!.stat!['views'],
|
||||
size: 'medium',
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
StatDanMu(
|
||||
theme: 'gray',
|
||||
danmu: bangumiDetail!.stat!['danmakus'],
|
||||
size: 'medium',
|
||||
),
|
||||
|
@ -203,13 +203,9 @@ class VideoContent extends StatelessWidget {
|
||||
padding: const EdgeInsets.only(top: 2),
|
||||
child: Row(
|
||||
children: [
|
||||
StatView(
|
||||
theme: 'gray',
|
||||
view: videoItem.cntInfo['play'],
|
||||
),
|
||||
StatView(view: videoItem.cntInfo['play']),
|
||||
const SizedBox(width: 8),
|
||||
StatDanMu(
|
||||
theme: 'gray', danmu: videoItem.cntInfo['danmaku']),
|
||||
StatDanMu(danmu: videoItem.cntInfo['danmaku']),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
|
@ -69,10 +69,7 @@ class MemberCoinsItem extends StatelessWidget {
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
StatView(
|
||||
view: coinItem.view,
|
||||
theme: 'gray',
|
||||
),
|
||||
StatView(view: coinItem.view),
|
||||
const Spacer(),
|
||||
Text(
|
||||
Utils.CustomStamp_str(
|
||||
|
@ -69,10 +69,7 @@ class MemberLikeItem extends StatelessWidget {
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
StatView(
|
||||
view: likeItem.stat!.view,
|
||||
theme: 'gray',
|
||||
),
|
||||
StatView(view: likeItem.stat!.view),
|
||||
const Spacer(),
|
||||
Text(
|
||||
Utils.CustomStamp_str(
|
||||
|
@ -78,10 +78,7 @@ class MemberSeasonsItem extends StatelessWidget {
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
StatView(
|
||||
view: seasonItem.view,
|
||||
theme: 'gray',
|
||||
),
|
||||
StatView(view: seasonItem.view),
|
||||
const Spacer(),
|
||||
Text(
|
||||
Utils.CustomStamp_str(
|
||||
|
@ -154,13 +154,9 @@ class VideoContent extends StatelessWidget {
|
||||
padding: const EdgeInsets.only(top: 2),
|
||||
child: Row(
|
||||
children: [
|
||||
StatView(
|
||||
theme: 'gray',
|
||||
view: videoItem.cntInfo['play'],
|
||||
),
|
||||
StatView(view: videoItem.cntInfo['play']),
|
||||
const SizedBox(width: 8),
|
||||
StatDanMu(
|
||||
theme: 'gray', danmu: videoItem.cntInfo['danmaku']),
|
||||
StatDanMu(danmu: videoItem.cntInfo['danmaku']),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
|
@ -346,13 +346,11 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
child: Row(
|
||||
children: [
|
||||
StatView(
|
||||
theme: 'gray',
|
||||
view: widget.videoDetail!.stat!.view,
|
||||
size: 'medium',
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
StatDanMu(
|
||||
theme: 'gray',
|
||||
danmu: widget.videoDetail!.stat!.danmaku,
|
||||
size: 'medium',
|
||||
),
|
||||
|
Reference in New Issue
Block a user