refactor dyn page

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-06-24 10:47:27 +08:00
parent 63fa031137
commit ebcbe8143b
10 changed files with 385 additions and 492 deletions

View File

@@ -134,7 +134,7 @@ class Word {
style = json['style'] == null ? null : Style.fromJson(json['style']);
if (json['color'] case final String rawColor
when rawColor.startsWith('#')) {
color = ColourUtils.parse2Int(json['color']);
color = ColourUtils.parse2Int(rawColor);
}
fontLevel = json['font_level'];
}

View File

@@ -1,41 +1,28 @@
import 'package:PiliPlus/utils/parse_int.dart';
class FollowUpModel {
FollowUpModel({
this.liveUsers,
required this.upList,
});
LiveUsers? liveUsers;
late List<UpItem> upList;
bool? hasMore;
String? offset;
FollowUpModel.fromJson(Map<String, dynamic> json) {
liveUsers = json['live_users'] != null
? LiveUsers.fromJson(json['live_users'])
: null;
upList =
(json['up_list']?['items'] as List?)
?.map<UpItem>((e) => UpItem.fromJson(e))
.toList() ??
<UpItem>[];
hasMore = json['up_list']?['has_more'];
offset = json['up_list']?['offset'];
}
}
class DynUpList {
List<UpItem>? upList;
bool? hasMore;
String? offset;
DynUpList.fromJson(Map<String, dynamic> json) {
upList = (json['items'] as List?)
?.map<UpItem>((e) => UpItem.fromJson(e))
.toList();
hasMore = json['has_more'];
offset = json['offset'];
factory FollowUpModel.fromJson(Map<String, dynamic> json) {
final model = FollowUpModel.fromUpList(json['up_list']);
final liveUsers = json['live_users'];
if (liveUsers != null) {
model.liveUsers = LiveUsers.fromJson(liveUsers);
}
return model;
}
FollowUpModel.fromUpList(Map<String, dynamic>? json) {
if (json != null) {
upList = (json['items'] as List?)
?.map((e) => UpItem.fromJson(e))
.toList();
hasMore = json['has_more'];
offset = json['offset'];
}
}
}