clean up models

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-04-05 12:10:18 +08:00
parent b897103af0
commit 279f21857d
308 changed files with 156 additions and 6243 deletions

View File

@@ -1,19 +1,17 @@
import 'package:flutter/foundation.dart';
class Cover {
int? height;
String? url;
int? width;
late double ratio;
Cover({this.height, this.url, this.width, required this.ratio});
Cover({required this.ratio});
Cover.fromJson(Map<String, dynamic> json) {
height = json['height'] as int?;
url = json['url'] as String?;
width = json['width'] as int?;
final height = json['height'] as int?;
final width = json['width'] as int?;
if (height != null && width != null) {
ratio = clampDouble(height! / width!, 0.68, 2.7);
ratio = clampDouble(height / width, 0.68, 2.7);
} else {
ratio = 1;
}

View File

@@ -4,9 +4,8 @@ class SpaceOpusData {
bool? hasMore;
List<SpaceOpusItemModel>? items;
String? offset;
int? updateNum;
SpaceOpusData({this.hasMore, this.items, this.offset, this.updateNum});
SpaceOpusData({this.hasMore, this.items, this.offset});
factory SpaceOpusData.fromJson(Map<String, dynamic> json) => SpaceOpusData(
hasMore: json['has_more'] as bool?,
@@ -14,6 +13,5 @@ class SpaceOpusData {
?.map((e) => SpaceOpusItemModel.fromJson(e as Map<String, dynamic>))
.toList(),
offset: json['offset'] as String?,
updateNum: json['update_num'] as int?,
);
}

View File

@@ -3,14 +3,12 @@ import 'package:PiliPlus/models_new/space/space_opus/stat.dart';
class SpaceOpusItemModel {
String? content;
String? jumpUrl;
String? opusId;
Stat? stat;
Cover? cover;
SpaceOpusItemModel({
this.content,
this.jumpUrl,
this.opusId,
this.stat,
this.cover,
@@ -19,7 +17,6 @@ class SpaceOpusItemModel {
factory SpaceOpusItemModel.fromJson(Map<String, dynamic> json) =>
SpaceOpusItemModel(
content: json['content'] as String?,
jumpUrl: json['jump_url'] as String?,
opusId: json['opus_id'] as String?,
stat: json['stat'] == null
? null