mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-06-27 06:06:51 +08:00
Add search bar
This commit is contained in:
@@ -181,3 +181,59 @@ class GMetaInfos {
|
||||
ApiResult<GMeta>.fromJson(value as Map<String, dynamic>,
|
||||
(json) => GMeta.fromJson(json as Map<String, dynamic>)))));
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class GMetaSearchInfo {
|
||||
const GMetaSearchInfo({
|
||||
required this.gid,
|
||||
required this.token,
|
||||
required this.title,
|
||||
required this.titleJpn,
|
||||
required this.category,
|
||||
required this.uploader,
|
||||
required this.posted,
|
||||
required this.filecount,
|
||||
required this.filesize,
|
||||
required this.expunged,
|
||||
required this.rating,
|
||||
required this.tags,
|
||||
this.parentGid,
|
||||
this.parentToken,
|
||||
this.firstGid,
|
||||
this.firstToken,
|
||||
});
|
||||
final int gid;
|
||||
final String token;
|
||||
final String title;
|
||||
@JsonKey(name: 'title_jpn')
|
||||
final String titleJpn;
|
||||
final String category;
|
||||
final String uploader;
|
||||
@JsonKey(fromJson: _fromJson, toJson: _toJson)
|
||||
final DateTime posted;
|
||||
final int filecount;
|
||||
final int filesize;
|
||||
final bool expunged;
|
||||
final double rating;
|
||||
final List<Tag> tags;
|
||||
@JsonKey(name: 'parent_gid')
|
||||
final int? parentGid;
|
||||
@JsonKey(name: 'parent_token')
|
||||
final String? parentToken;
|
||||
@JsonKey(name: 'first_gid')
|
||||
final int? firstGid;
|
||||
@JsonKey(name: 'first_token')
|
||||
final String? firstToken;
|
||||
|
||||
static DateTime _fromJson(int posted) =>
|
||||
DateTime.fromMillisecondsSinceEpoch(posted * 1000);
|
||||
static int _toJson(DateTime posted) => posted.millisecondsSinceEpoch ~/ 1000;
|
||||
factory GMetaSearchInfo.fromJson(Map<String, dynamic> json) =>
|
||||
_$GMetaSearchInfoFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$GMetaSearchInfoToJson(this);
|
||||
String get preferredTitle => prefs.getBool("useTitleJpn") == true
|
||||
? titleJpn.isEmpty
|
||||
? title
|
||||
: titleJpn
|
||||
: title;
|
||||
}
|
||||
|
||||
@@ -134,3 +134,45 @@ Map<String, dynamic> _$GalleryDataToJson(GalleryData instance) =>
|
||||
'tags': instance.tags,
|
||||
'pages': instance.pages,
|
||||
};
|
||||
|
||||
GMetaSearchInfo _$GMetaSearchInfoFromJson(Map<String, dynamic> json) =>
|
||||
GMetaSearchInfo(
|
||||
gid: (json['gid'] as num).toInt(),
|
||||
token: json['token'] as String,
|
||||
title: json['title'] as String,
|
||||
titleJpn: json['title_jpn'] as String,
|
||||
category: json['category'] as String,
|
||||
uploader: json['uploader'] as String,
|
||||
posted: GMetaSearchInfo._fromJson((json['posted'] as num).toInt()),
|
||||
filecount: (json['filecount'] as num).toInt(),
|
||||
filesize: (json['filesize'] as num).toInt(),
|
||||
expunged: json['expunged'] as bool,
|
||||
rating: (json['rating'] as num).toDouble(),
|
||||
tags: (json['tags'] as List<dynamic>)
|
||||
.map((e) => Tag.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
parentGid: (json['parent_gid'] as num?)?.toInt(),
|
||||
parentToken: json['parent_token'] as String?,
|
||||
firstGid: (json['first_gid'] as num?)?.toInt(),
|
||||
firstToken: json['first_token'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GMetaSearchInfoToJson(GMetaSearchInfo instance) =>
|
||||
<String, dynamic>{
|
||||
'gid': instance.gid,
|
||||
'token': instance.token,
|
||||
'title': instance.title,
|
||||
'title_jpn': instance.titleJpn,
|
||||
'category': instance.category,
|
||||
'uploader': instance.uploader,
|
||||
'posted': GMetaSearchInfo._toJson(instance.posted),
|
||||
'filecount': instance.filecount,
|
||||
'filesize': instance.filesize,
|
||||
'expunged': instance.expunged,
|
||||
'rating': instance.rating,
|
||||
'tags': instance.tags,
|
||||
'parent_gid': instance.parentGid,
|
||||
'parent_token': instance.parentToken,
|
||||
'first_gid': instance.firstGid,
|
||||
'first_token': instance.firstToken,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user