mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-07-08 01:30:28 +08:00
feat: 添加画廊列表显示模式和合并功能,优化画廊列表卡片组件
This commit is contained in:
@@ -27,6 +27,14 @@ class ApiResult<T> {
|
||||
}
|
||||
}
|
||||
|
||||
T? unwrapOrNull() {
|
||||
if (ok) {
|
||||
return data;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
(int, String) unwrapErr() {
|
||||
if (ok) {
|
||||
return throw 'unwrap_err called on ok ApiResult';
|
||||
|
||||
@@ -41,8 +41,8 @@ class EhFileExtend {
|
||||
}
|
||||
|
||||
class EhFiles {
|
||||
const EhFiles({required this.files});
|
||||
final Map<String, List<EhFileBasic>> files;
|
||||
EhFiles({required this.files});
|
||||
Map<String, List<EhFileBasic>> files;
|
||||
factory EhFiles.fromJson(Map<String, dynamic> json) => EhFiles(
|
||||
files: (json).map(
|
||||
(k, e) => MapEntry(
|
||||
@@ -52,4 +52,7 @@ class EhFiles {
|
||||
.toList()),
|
||||
),
|
||||
);
|
||||
void merge(EhFiles another) {
|
||||
files.addAll(another.files);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,10 +239,10 @@ class GMetaSearchInfo {
|
||||
}
|
||||
|
||||
class GalleryThumbnails {
|
||||
const GalleryThumbnails({
|
||||
GalleryThumbnails({
|
||||
required this.thumbnails,
|
||||
});
|
||||
final Map<int, ApiResult<ExtendedPMeta>> thumbnails;
|
||||
Map<int, ApiResult<ExtendedPMeta>> thumbnails;
|
||||
factory GalleryThumbnails.fromJson(Map<String, dynamic> json) =>
|
||||
GalleryThumbnails(
|
||||
thumbnails: json.map((key, value) => MapEntry(
|
||||
@@ -251,4 +251,17 @@ class GalleryThumbnails {
|
||||
value as Map<String, dynamic>,
|
||||
(json) =>
|
||||
ExtendedPMeta.fromJson(json as Map<String, dynamic>)))));
|
||||
void merge(GalleryThumbnails another) {
|
||||
another.thumbnails.forEach((key, value) {
|
||||
if (thumbnails.containsKey(key)) {
|
||||
if (value.ok) {
|
||||
thumbnails[key] = value;
|
||||
} else if (!thumbnails[key]!.ok) {
|
||||
thumbnails[key] = value;
|
||||
}
|
||||
} else {
|
||||
thumbnails[key] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user