From 6fee468f49a32f0ba39fa2ee04f188524999ea1a Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Tue, 26 Nov 2024 13:08:40 +0800 Subject: [PATCH] opt: member video item Signed-off-by: bggRGjQaUbCoE --- .../widgets/video_card_h_member_video.dart | 23 ++- lib/models/space_archive/item.dart | 180 +++++++++--------- lib/models/space_archive/item.g.dart | 2 + 3 files changed, 110 insertions(+), 95 deletions(-) diff --git a/lib/common/widgets/video_card_h_member_video.dart b/lib/common/widgets/video_card_h_member_video.dart index 7b042048..525fe5e1 100644 --- a/lib/common/widgets/video_card_h_member_video.dart +++ b/lib/common/widgets/video_card_h_member_video.dart @@ -61,12 +61,20 @@ class VideoCardHMemberVideo extends StatelessWidget { Hero( tag: heroTag, child: NetworkImgLayer( - src: videoItem.cover, + src: + videoItem.season?['cover'] ?? videoItem.cover, width: maxWidth, height: maxHeight, ), ), - if (videoItem.duration != null) + if (videoItem.season != null) + PBadge( + text: '合集: ${videoItem.season?['count']}', + right: 6.0, + bottom: 6.0, + type: 'gray', + ) + else if (videoItem.duration != null) PBadge( text: Utils.timeFormat(videoItem.duration), right: 6.0, @@ -118,7 +126,7 @@ class VideoContent extends StatelessWidget { ...[ Expanded( child: Text( - videoItem.title ?? '', + videoItem.season?['title'] ?? videoItem.title ?? '', textAlign: TextAlign.start, style: TextStyle( fontWeight: FontWeight.w400, @@ -132,7 +140,9 @@ class VideoContent extends StatelessWidget { ), ], Text( - videoItem.publishTimeText ?? '', + videoItem.season != null + ? Utils.dateFormat(videoItem.season?['mtime']) + : videoItem.publishTimeText ?? '', maxLines: 1, style: TextStyle( fontWeight: FontWeight.w400, @@ -147,12 +157,13 @@ class VideoContent extends StatelessWidget { children: [ StatView( theme: 'gray', - view: videoItem.viewContent, + view: videoItem.season?['view_content'] ?? + videoItem.viewContent, ), const SizedBox(width: 8), StatDanMu( theme: 'gray', - danmu: videoItem.danmaku, + danmu: videoItem.season?['danmaku'] ?? videoItem.danmaku, ), ], ), diff --git a/lib/models/space_archive/item.dart b/lib/models/space_archive/item.dart index d9ae962c..303bc94d 100644 --- a/lib/models/space_archive/item.dart +++ b/lib/models/space_archive/item.dart @@ -8,96 +8,98 @@ part 'item.g.dart'; @JsonSerializable() class Item { - String? title; - String? subtitle; - String? tname; - String? cover; - @JsonKey(name: 'cover_icon') - String? coverIcon; - String? uri; - String? param; - String? goto; - String? length; - int? duration; - @JsonKey(name: 'is_popular') - bool? isPopular; - @JsonKey(name: 'is_steins') - bool? isSteins; - @JsonKey(name: 'is_ugcpay') - bool? isUgcpay; - @JsonKey(name: 'is_cooperation') - bool? isCooperation; - @JsonKey(name: 'is_pgc') - bool? isPgc; - @JsonKey(name: 'is_live_playback') - bool? isLivePlayback; - @JsonKey(name: 'is_pugv') - bool? isPugv; - @JsonKey(name: 'is_fold') - bool? isFold; - @JsonKey(name: 'is_oneself') - bool? isOneself; - int? play; - int? danmaku; - int? ctime; - @JsonKey(name: 'ugc_pay') - int? ugcPay; - String? author; - bool? state; - String? bvid; - int? videos; - @JsonKey(name: 'three_point') - List? threePoint; - @JsonKey(name: 'first_cid') - int? firstCid; - @JsonKey(name: 'cursor_attr') - CursorAttr? cursorAttr; - @JsonKey(name: 'view_content') - String? viewContent; - @JsonKey(name: 'icon_type') - int? iconType; - @JsonKey(name: 'publish_time_text') - String? publishTimeText; - List? badges; + String? title; + String? subtitle; + String? tname; + String? cover; + @JsonKey(name: 'cover_icon') + String? coverIcon; + String? uri; + String? param; + String? goto; + String? length; + int? duration; + @JsonKey(name: 'is_popular') + bool? isPopular; + @JsonKey(name: 'is_steins') + bool? isSteins; + @JsonKey(name: 'is_ugcpay') + bool? isUgcpay; + @JsonKey(name: 'is_cooperation') + bool? isCooperation; + @JsonKey(name: 'is_pgc') + bool? isPgc; + @JsonKey(name: 'is_live_playback') + bool? isLivePlayback; + @JsonKey(name: 'is_pugv') + bool? isPugv; + @JsonKey(name: 'is_fold') + bool? isFold; + @JsonKey(name: 'is_oneself') + bool? isOneself; + int? play; + int? danmaku; + int? ctime; + @JsonKey(name: 'ugc_pay') + int? ugcPay; + String? author; + bool? state; + String? bvid; + int? videos; + @JsonKey(name: 'three_point') + List? threePoint; + @JsonKey(name: 'first_cid') + int? firstCid; + @JsonKey(name: 'cursor_attr') + CursorAttr? cursorAttr; + @JsonKey(name: 'view_content') + String? viewContent; + @JsonKey(name: 'icon_type') + int? iconType; + @JsonKey(name: 'publish_time_text') + String? publishTimeText; + List? badges; + Map? season; - Item({ - this.title, - this.subtitle, - this.tname, - this.cover, - this.coverIcon, - this.uri, - this.param, - this.goto, - this.length, - this.duration, - this.isPopular, - this.isSteins, - this.isUgcpay, - this.isCooperation, - this.isPgc, - this.isLivePlayback, - this.isPugv, - this.isFold, - this.isOneself, - this.play, - this.danmaku, - this.ctime, - this.ugcPay, - this.author, - this.state, - this.bvid, - this.videos, - this.threePoint, - this.firstCid, - this.cursorAttr, - this.viewContent, - this.iconType, - this.publishTimeText, - this.badges, - }); + Item({ + this.title, + this.subtitle, + this.tname, + this.cover, + this.coverIcon, + this.uri, + this.param, + this.goto, + this.length, + this.duration, + this.isPopular, + this.isSteins, + this.isUgcpay, + this.isCooperation, + this.isPgc, + this.isLivePlayback, + this.isPugv, + this.isFold, + this.isOneself, + this.play, + this.danmaku, + this.ctime, + this.ugcPay, + this.author, + this.state, + this.bvid, + this.videos, + this.threePoint, + this.firstCid, + this.cursorAttr, + this.viewContent, + this.iconType, + this.publishTimeText, + this.badges, + this.season, + }); - factory Item.fromJson(Map json) => _$ItemFromJson(json); + factory Item.fromJson(Map json) => _$ItemFromJson(json); - Map toJson() => _$ItemToJson(this); + Map toJson() => _$ItemToJson(this); } diff --git a/lib/models/space_archive/item.g.dart b/lib/models/space_archive/item.g.dart index 001fa263..44eaeef0 100644 --- a/lib/models/space_archive/item.g.dart +++ b/lib/models/space_archive/item.g.dart @@ -47,6 +47,7 @@ Item _$ItemFromJson(Map json) => Item( badges: (json['badges'] as List?) ?.map((e) => Badge.fromJson(e as Map)) .toList(), + season: json['season'], ); Map _$ItemToJson(Item instance) => { @@ -84,4 +85,5 @@ Map _$ItemToJson(Item instance) => { 'icon_type': instance.iconType, 'publish_time_text': instance.publishTimeText, 'badges': instance.badges, + 'season': instance.season, };