mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-28 14:25:55 +08:00
show member collection top
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,9 +1,40 @@
|
||||
import 'package:PiliPlus/utils/parse_string.dart';
|
||||
|
||||
class Top {
|
||||
dynamic result;
|
||||
List<TopImage>? imgUrls;
|
||||
|
||||
Top({this.result});
|
||||
Top({this.imgUrls});
|
||||
|
||||
factory Top.fromJson(Map<String, dynamic> json) => Top(
|
||||
result: json['result'] as dynamic,
|
||||
);
|
||||
Top.fromJson(Map<String, dynamic> json) {
|
||||
try {
|
||||
final list = json['result'] as List<dynamic>?;
|
||||
if (list != null && list.isNotEmpty) {
|
||||
imgUrls = list.map((e) => TopImage.fromJson(e)).toList();
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
class TopImage {
|
||||
late final String cover;
|
||||
late final double dy;
|
||||
|
||||
TopImage.fromJson(Map<String, dynamic> json) {
|
||||
cover =
|
||||
noneNullOrEmptyString(json['item']?['image']?['default_image']) ??
|
||||
json['cover'];
|
||||
try {
|
||||
final Map image = json['item']['image'] ?? json['item']['animation'];
|
||||
final num halfHeight = (image['height'] as num) / 2;
|
||||
final List<num> location = (image['location'] as String)
|
||||
.split('-')
|
||||
.map(num.parse)
|
||||
.toList();
|
||||
final start = location[1];
|
||||
final end = location[2];
|
||||
dy = (start + (end - start) / 2 - halfHeight) / halfHeight;
|
||||
} catch (_) {
|
||||
dy = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user