mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-21 11:22:16 +08:00
21
lib/models_new/space/space_opus/cover.dart
Normal file
21
lib/models_new/space/space_opus/cover.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
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.fromJson(Map<String, dynamic> json) {
|
||||
height = json['height'] as int?;
|
||||
url = json['url'] as String?;
|
||||
width = json['width'] as int?;
|
||||
if (height != null && width != null) {
|
||||
ratio = clampDouble(height! / width!, 0.68, 2.7);
|
||||
} else {
|
||||
ratio = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
19
lib/models_new/space/space_opus/data.dart
Normal file
19
lib/models_new/space/space_opus/data.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:PiliPlus/models_new/space/space_opus/item.dart';
|
||||
|
||||
class SpaceOpusData {
|
||||
bool? hasMore;
|
||||
List<SpaceOpusItemModel>? items;
|
||||
String? offset;
|
||||
int? updateNum;
|
||||
|
||||
SpaceOpusData({this.hasMore, this.items, this.offset, this.updateNum});
|
||||
|
||||
factory SpaceOpusData.fromJson(Map<String, dynamic> json) => SpaceOpusData(
|
||||
hasMore: json['has_more'] as bool?,
|
||||
items: (json['items'] as List<dynamic>?)
|
||||
?.map((e) => SpaceOpusItemModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
offset: json['offset'] as String?,
|
||||
updateNum: json['update_num'] as int?,
|
||||
);
|
||||
}
|
||||
26
lib/models_new/space/space_opus/item.dart
Normal file
26
lib/models_new/space/space_opus/item.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'package:PiliPlus/models_new/space/space_opus/cover.dart';
|
||||
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});
|
||||
|
||||
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
|
||||
: Stat.fromJson(json['stat'] as Map<String, dynamic>),
|
||||
cover: json['cover'] == null
|
||||
? null
|
||||
: Cover.fromJson(json['cover'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
9
lib/models_new/space/space_opus/stat.dart
Normal file
9
lib/models_new/space/space_opus/stat.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
class Stat {
|
||||
String? like;
|
||||
|
||||
Stat({this.like});
|
||||
|
||||
factory Stat.fromJson(Map<String, dynamic> json) => Stat(
|
||||
like: json['like'] as String?,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user