From 9275024050db66adb45f95ce8884b0f8a124bd24 Mon Sep 17 00:00:00 2001 From: wgh19 Date: Fri, 31 May 2024 19:32:46 +0800 Subject: [PATCH] add a setting for original image --- assets/tr.json | 6 ++++-- lib/appdata.dart | 1 + lib/pages/illust_page.dart | 7 +++++-- lib/pages/settings_page.dart | 10 ++++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/assets/tr.json b/assets/tr.json index 4acc7af..f6e357d 100644 --- a/assets/tr.json +++ b/assets/tr.json @@ -159,7 +159,8 @@ "Follow the artist": "关注画师", "Manga": "漫画", "Actions": "操作", - "Current quantity": "当前数量" + "Current quantity": "当前数量", + "Display the original image on the details page": "在详情页显示原图" }, "zh_TW": { "Search": "搜索", @@ -321,6 +322,7 @@ "Follow the artist": "關注畫師", "Manga": "漫畫", "Actions": "操作", - "Current quantity": "當前數量" + "Current quantity": "當前數量", + "Display the original image on the details page": "在詳情頁顯示原圖" } } \ No newline at end of file diff --git a/lib/appdata.dart b/lib/appdata.dart index da750df..3825469 100644 --- a/lib/appdata.dart +++ b/lib/appdata.dart @@ -33,6 +33,7 @@ class _Appdata { LogicalKeyboardKey.keyD.keyId, LogicalKeyboardKey.keyF.keyId, ], + "showOriginalImage": false, }; bool lock = false; diff --git a/lib/pages/illust_page.dart b/lib/pages/illust_page.dart index 104d66e..1c8b927 100644 --- a/lib/pages/illust_page.dart +++ b/lib/pages/illust_page.dart @@ -318,6 +318,10 @@ class _IllustPageState extends State { } Widget image; + var imageUrl = appdata.settings["showOriginalImage"] + ? widget.illust.images[index].original + : widget.illust.images[index].large; + if (!widget.illust.isUgoira) { image = SizedBox( width: imageWidth, @@ -327,8 +331,7 @@ class _IllustPageState extends State { child: Image( key: ValueKey(index), image: downloadFile == null - ? CachedImageProvider(widget.illust.images[index].large) - as ImageProvider + ? CachedImageProvider(imageUrl) as ImageProvider : FileImage(downloadFile) as ImageProvider, width: imageWidth, fit: BoxFit.cover, diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index 79f2a9d..b15ca49 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -252,6 +252,16 @@ class _SettingsPageState extends State { context.to(() => const ShortcutsSettings()); }, )), + buildItem( + title: "Display the original image on the details page".tl, + action: ToggleSwitch( + checked: appdata.settings['showOriginalImage'], + onChanged: (value) { + setState(() { + appdata.settings['showOriginalImage'] = value; + }); + appdata.writeData(); + })), ], ), );