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