feat(flutter): 播放页互动数量与评论面板收紧
This commit is contained in:
1 parent
e39aa766ac
commit
bed6bbb75b
13 files changed
+265
-59
No files matched your search
@@ -65,6 +65,9 @@ class Drama {
|
||||
this.freeEpisodes = 0,
|
||||
this.isHot = false,
|
||||
this.viewCount = 0,
|
||||
this.likeCount,
|
||||
this.favoriteCount,
|
||||
this.commentCount,
|
||||
this.language = '',
|
||||
this.detailLoaded = false,
|
||||
});
|
||||
@@ -81,6 +84,11 @@ class Drama {
|
||||
final bool isHot;
|
||||
final int viewCount;
|
||||
|
||||
/// 详情下发的互动数量;卡片或旧接口没有这些字段时为 null(客户端不显示数字)。
|
||||
final int? likeCount;
|
||||
final int? favoriteCount;
|
||||
final int? commentCount;
|
||||
|
||||
/// 卡片语种(如 zh-CN / id),用于剧场语言筛选。
|
||||
final String language;
|
||||
|
||||
@@ -108,6 +116,9 @@ class Drama {
|
||||
isHot: json['isHot'] == true,
|
||||
// viewCount 后端是 Long,按字符串下发(见 json_numbers.dart)
|
||||
viewCount: jsonToInt(json['viewCount']),
|
||||
likeCount: _optionalInt(json['likeCount']),
|
||||
favoriteCount: _optionalInt(json['favoriteCount']),
|
||||
commentCount: _optionalInt(json['commentCount']),
|
||||
language: json['language'] as String? ?? '',
|
||||
);
|
||||
}
|
||||
@@ -125,6 +136,9 @@ class Drama {
|
||||
freeEpisodes: (json['freeEpisodes'] as num?)?.toInt() ?? 0,
|
||||
isHot: json['isHot'] == true,
|
||||
viewCount: jsonToInt(json['viewCount']),
|
||||
likeCount: _optionalInt(json['likeCount']),
|
||||
favoriteCount: _optionalInt(json['favoriteCount']),
|
||||
commentCount: _optionalInt(json['commentCount']),
|
||||
language: json['language'] as String? ?? '',
|
||||
detailLoaded: true,
|
||||
episodes: (json['episodes'] as List? ?? const [])
|
||||
@@ -134,3 +148,5 @@ class Drama {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
int? _optionalInt(dynamic value) => value == null ? null : jsonToInt(value);
|
||||
@@ -0,0 +1,9 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
/// 互动数量展示:不足一万显示原数,一万及以上显示一位小数的「万」。
|
||||
///
|
||||
/// 例:`3200` → `3200`,`12400` → `1.2万`。
|
||||
String formatInteractionCount(int count) {
|
||||
if (count < 10000) return '$count';
|
||||
return '${(count / 10000).toStringAsFixed(1)}万';
|
||||
}
|
||||
Reference in new issue
Block a user