From efd56835291144f19aac30dde809b1db0b01c1c4 Mon Sep 17 00:00:00 2001 From: wgh19 Date: Thu, 16 May 2024 12:22:33 +0800 Subject: [PATCH] show pages, ai, r18, r18g --- lib/components/illust_widget.dart | 68 +++++++++++++++++++++++++++++++ lib/network/models.dart | 17 +++++++- 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/lib/components/illust_widget.dart b/lib/components/illust_widget.dart index 04857f3..9fc3b2a 100644 --- a/lib/components/illust_widget.dart +++ b/lib/components/illust_widget.dart @@ -65,6 +65,74 @@ class _IllustWidgetState extends State { ), ), )), + if(widget.illust.images.length > 1) + Positioned( + top: 12, + left: 12, + child: Container( + width: 28, + height: 20, + decoration: BoxDecoration( + color: FluentTheme.of(context).cardColor, + borderRadius: BorderRadius.circular(4), + border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6), + ), + child: Center( + child: Text("${widget.illust.images.length}P", + style: const TextStyle(fontSize: 12),), + )), + ), + if(widget.illust.isAi) + Positioned( + bottom: 12, + left: 12, + child: Container( + width: 28, + height: 20, + decoration: BoxDecoration( + color: ColorScheme.of(context).errorContainer.withOpacity(0.8), + borderRadius: BorderRadius.circular(4), + border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6), + ), + child: const Center( + child: Text("AI", + style: TextStyle(fontSize: 12),), + )), + ), + if(widget.illust.isR18) + Positioned( + bottom: 12, + right: 12, + child: Container( + width: 28, + height: 20, + decoration: BoxDecoration( + color: ColorScheme.of(context).errorContainer, + borderRadius: BorderRadius.circular(4), + border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6), + ), + child: const Center( + child: Text("R18", + style: TextStyle(fontSize: 12),), + )), + ), + if(widget.illust.isR18G) + Positioned( + bottom: 12, + right: 12, + child: Container( + width: 28, + height: 20, + decoration: BoxDecoration( + color: ColorScheme.of(context).errorContainer, + borderRadius: BorderRadius.circular(4), + border: Border.all(color: ColorScheme.of(context).outlineVariant, width: 0.6), + ), + child: const Center( + child: Text("R18G", + style: TextStyle(fontSize: 12),), + )), + ), Positioned( top: 16, right: 16, diff --git a/lib/network/models.dart b/lib/network/models.dart index 7369489..168feff 100644 --- a/lib/network/models.dart +++ b/lib/network/models.dart @@ -142,6 +142,17 @@ class Tag { String toString() { return "$name${translatedName == null ? "" : "($translatedName)"}"; } + + @override + bool operator ==(Object other) { + if (other is Tag) { + return name == other.name; + } + return false; + } + + @override + int get hashCode => name.hashCode; } class IllustImage { @@ -171,6 +182,10 @@ class Illust { bool isBookmarked; final bool isAi; + bool get isR18 => tags.contains(const Tag("R-18", null)); + + bool get isR18G => tags.contains(const Tag("R-18G", null)); + Illust.fromJson(Map json) : id = json['id'], title = json['title'], @@ -211,7 +226,7 @@ class Illust { totalView = json['total_view'], totalBookmarks = json['total_bookmarks'], isBookmarked = json['is_bookmarked'], - isAi = json['is_ai'] != 1; + isAi = json['illust_ai_type'] == 2; } class TrendingTag {