From 78fb059138b9036bed83af509a600e38f3965032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=85=B1=E5=A4=A9=E5=B0=8F=E7=A6=BD=E5=85=BD?= Date: Sat, 30 Dec 2023 17:23:19 +0800 Subject: [PATCH] =?UTF-8?q?Support=20customizing=20the=20number=20of=20thu?= =?UTF-8?q?mbnail=20columns=20in=20the=20details=20page=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E7=BC=A9=E7=95=A5=E5=9B=BE=E5=88=97=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog/v7.4.8+147.md | 4 +++- lib/src/config/ui_config.dart | 3 +-- lib/src/l18n/en_US.dart | 1 + lib/src/l18n/ko_KR.dart | 1 + lib/src/l18n/pt_BR.dart | 1 + lib/src/l18n/zh_CN.dart | 1 + lib/src/l18n/zh_TW.dart | 1 + lib/src/pages/details/details_page.dart | 19 +++++++++++------ .../setting/style/setting_style_page.dart | 21 +++++++++++++++++++ lib/src/setting/style_setting.dart | 9 ++++++++ 10 files changed, 52 insertions(+), 9 deletions(-) diff --git a/changelog/v7.4.8+147.md b/changelog/v7.4.8+147.md index dd2c9650..13cf52bb 100644 --- a/changelog/v7.4.8+147.md +++ b/changelog/v7.4.8+147.md @@ -5,6 +5,7 @@ - 收藏页和关注页搜索不再继承关键字 - 去除自动重定向至表站的是设置,现在会强制优先访问表站画廊链接 - 去除下载超时设置,现在下载图片不会超时中断 +- 支持自定义详情页缩略图列数 ------------------------------------------------------------------------------------------ @@ -14,4 +15,5 @@ - Optimize the icon display when decompressing archives - The search in favorites and following page no longer inherits keywords - Remove the setting of automatically redirecting to the EH site, now it is enabled by default -- Remove the download timeout setting, now the download will not be interrupted due to timeout \ No newline at end of file +- Remove the download timeout setting, now the download will not be interrupted due to timeout +- Support customizing the number of thumbnail columns in the details page \ No newline at end of file diff --git a/lib/src/config/ui_config.dart b/lib/src/config/ui_config.dart index d531dbbe..b41bc4dc 100644 --- a/lib/src/config/ui_config.dart +++ b/lib/src/config/ui_config.dart @@ -65,11 +65,9 @@ class UIConfig { static const double tabBarHeight = 36; static const double searchBarHeight = 40; static const double refreshTriggerPullDistance = 100; - static Color layoutDividerColor(BuildContext context) => Theme.of(context).colorScheme.surfaceVariant; - static Color desktopLeftTabIconColor(BuildContext context) => Theme.of(context).colorScheme.onBackground; static const double desktopTitleBarHeight = 32; static const double desktopFullScreenTopPadding = 12; @@ -186,6 +184,7 @@ class UIConfig { static const double detailsPageThumbnailHeight = 200; static const double detailsPageThumbnailWidth = 150; + static const double detailsPageGridViewCardAspectRatio = 0.75; static const int detailsPageAnimationDuration = 150; diff --git a/lib/src/l18n/en_US.dart b/lib/src/l18n/en_US.dart index 10659795..9e3585cb 100644 --- a/lib/src/l18n/en_US.dart +++ b/lib/src/l18n/en_US.dart @@ -286,6 +286,7 @@ class en_US { 'pageListStyle': 'Gallery List Style (Page)', 'crossAxisCountInGridDownloadPageForGroup': 'Download Page Grid Column Count(Group)', 'crossAxisCountInGridDownloadPageForGallery': 'Download Page Grid Column Count(Gallery)', + 'crossAxisCountInDetailPage': 'Detail Page Thumbnail Column Count', 'global': 'Global', 'auto': 'Auto', 'moveCover2RightSide': 'Move Cover to Right Side', diff --git a/lib/src/l18n/ko_KR.dart b/lib/src/l18n/ko_KR.dart index 5ec81ece..f3bafc74 100644 --- a/lib/src/l18n/ko_KR.dart +++ b/lib/src/l18n/ko_KR.dart @@ -286,6 +286,7 @@ class ko_KR { 'pageListStyle': '갤러리 리스트 스타일 (개별)', 'crossAxisCountInGridDownloadPageForGroup': '다운로드 페이지 그리드 정렬 세로줄 개수(폴더)', 'crossAxisCountInGridDownloadPageForGallery': '다운로드 페이지 그리드 정렬 세로줄 개수(폴더 내부)', + 'crossAxisCountInDetailPage': 'Detail Page Thumbnail Column Count', 'global': '기본값', 'auto': '자동', 'moveCover2RightSide': '섬네일을 오른쪽으로 배치', diff --git a/lib/src/l18n/pt_BR.dart b/lib/src/l18n/pt_BR.dart index dc74a078..a89d754b 100644 --- a/lib/src/l18n/pt_BR.dart +++ b/lib/src/l18n/pt_BR.dart @@ -288,6 +288,7 @@ class pt_BR { 'pageListStyle': 'Gallery List Style (Page)', 'crossAxisCountInGridDownloadPageForGroup': 'Download Page Grid Column Count(Group)', 'crossAxisCountInGridDownloadPageForGallery': 'Download Page Grid Column Count(Gallery)', + 'crossAxisCountInDetailPage': 'Detail Page Thumbnail Column Count', 'global': 'Global', 'auto': 'Auto', 'moveCover2RightSide': 'Mover a tampa para o lado direito', diff --git a/lib/src/l18n/zh_CN.dart b/lib/src/l18n/zh_CN.dart index 3a86700b..e5a79bf7 100644 --- a/lib/src/l18n/zh_CN.dart +++ b/lib/src/l18n/zh_CN.dart @@ -286,6 +286,7 @@ class zh_CN { 'crossAxisCountInGridDownloadPage': '下载页网格布局列数', 'crossAxisCountInGridDownloadPageForGroup': '下载页网格布局列数(分组)', 'crossAxisCountInGridDownloadPageForGallery': '下载页网格布局列数(画廊)', + 'crossAxisCountInDetailPage': '详情页缩略图列数', 'global': '全局', 'auto': '自动', 'moveCover2RightSide': '移动封面图至右侧', diff --git a/lib/src/l18n/zh_TW.dart b/lib/src/l18n/zh_TW.dart index ab1d3a00..903e06c7 100644 --- a/lib/src/l18n/zh_TW.dart +++ b/lib/src/l18n/zh_TW.dart @@ -285,6 +285,7 @@ class zh_TW { 'pageListStyle': '畫廊列表樣式(頁面)', 'crossAxisCountInGridDownloadPageForGroup': '下載頁網格布局列數(分組)', 'crossAxisCountInGridDownloadPageForGallery': '下載頁網格布局列數(畫廊)', + 'crossAxisCountInDetailPage': '詳情頁縮略圖列數', 'global': '全局', 'auto': '自動', 'moveCover2RightSide': '移動封面圖至右側', diff --git a/lib/src/pages/details/details_page.dart b/lib/src/pages/details/details_page.dart index 75b729c8..f512009e 100644 --- a/lib/src/pages/details/details_page.dart +++ b/lib/src/pages/details/details_page.dart @@ -1154,12 +1154,19 @@ class DetailsPage extends StatelessWidget with Scroll2TopPageMixin { }, childCount: state.galleryDetails?.thumbnails.length ?? 0, ), - gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( - mainAxisExtent: UIConfig.detailsPageThumbnailHeight, - maxCrossAxisExtent: UIConfig.detailsPageThumbnailWidth, - mainAxisSpacing: 20, - crossAxisSpacing: 5, - ), + gridDelegate: StyleSetting.crossAxisCountInDetailPage.value == null + ? const SliverGridDelegateWithMaxCrossAxisExtent( + mainAxisExtent: UIConfig.detailsPageThumbnailHeight, + maxCrossAxisExtent: UIConfig.detailsPageThumbnailWidth, + mainAxisSpacing: 20, + crossAxisSpacing: 5, + ) + : SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: StyleSetting.crossAxisCountInDetailPage.value!, + mainAxisSpacing: 20, + crossAxisSpacing: 5, + childAspectRatio: UIConfig.detailsPageGridViewCardAspectRatio, + ), ), ), ), diff --git a/lib/src/pages/setting/style/setting_style_page.dart b/lib/src/pages/setting/style/setting_style_page.dart index 4492d532..2a2ea9d2 100644 --- a/lib/src/pages/setting/style/setting_style_page.dart +++ b/lib/src/pages/setting/style/setting_style_page.dart @@ -26,6 +26,7 @@ class SettingStylePage extends StatelessWidget { _buildPageListMode(), _buildCrossAxisCountInGridDownloadPageForGroup(), _buildCrossAxisCountInGridDownloadPageForGallery(), + _buildCrossAxisCountInDetailPage(), if (!StyleSetting.isInWaterFlowListMode) _buildMoveCover2RightSide().fadeIn(), _buildLayout(context), ], @@ -139,6 +140,26 @@ class SettingStylePage extends StatelessWidget { ), ); } + + Widget _buildCrossAxisCountInDetailPage() { + return ListTile( + title: Text('crossAxisCountInDetailPage'.tr), + trailing: DropdownButton( + value: StyleSetting.crossAxisCountInDetailPage.value, + elevation: 4, + alignment: AlignmentDirectional.centerEnd, + onChanged: StyleSetting.saveCrossAxisCountInDetailPage, + items: [ + DropdownMenuItem(child: Text('auto'.tr), value: null), + DropdownMenuItem(child: Text('2'.tr), value: 2), + DropdownMenuItem(child: Text('3'.tr), value: 3), + DropdownMenuItem(child: Text('4'.tr), value: 4), + DropdownMenuItem(child: Text('5'.tr), value: 5), + DropdownMenuItem(child: Text('6'.tr), value: 6), + ], + ), + ); + } Widget _buildPageListMode() { return ListTile( diff --git a/lib/src/setting/style_setting.dart b/lib/src/setting/style_setting.dart index cdf2ebd2..6bc94452 100644 --- a/lib/src/setting/style_setting.dart +++ b/lib/src/setting/style_setting.dart @@ -26,6 +26,7 @@ class StyleSetting { static RxnInt crossAxisCountInWaterFallFlow = RxnInt(null); static RxnInt crossAxisCountInGridDownloadPageForGroup = RxnInt(null); static RxnInt crossAxisCountInGridDownloadPageForGallery = RxnInt(null); + static RxnInt crossAxisCountInDetailPage = RxnInt(null); static RxMap pageListMode = {}.obs; static RxBool moveCover2RightSide = false.obs; static Rx layout = @@ -110,6 +111,12 @@ class StyleSetting { StyleSetting.crossAxisCountInGridDownloadPageForGallery.value = crossAxisCountInGridDownloadPageForGallery; _save(); } + + static saveCrossAxisCountInDetailPage(int? crossAxisCountInDetailPage) { + Log.debug('saveCrossAxisCountInDetailPage:$crossAxisCountInDetailPage'); + StyleSetting.crossAxisCountInDetailPage.value = crossAxisCountInDetailPage; + _save(); + } static savePageListMode(String routeName, ListMode? listMode) { Log.debug('savePageListMode:$routeName, $listMode'); @@ -146,6 +153,7 @@ class StyleSetting { 'crossAxisCountInWaterFallFlow': crossAxisCountInWaterFallFlow.value, 'crossAxisCountInGridDownloadPageForGroup': crossAxisCountInGridDownloadPageForGroup.value, 'crossAxisCountInGridDownloadPageForGallery': crossAxisCountInGridDownloadPageForGallery.value, + 'crossAxisCountInDetailPage': crossAxisCountInDetailPage.value, 'pageListMode': pageListMode.map((route, listMode) => MapEntry(route, listMode.index)), 'moveCover2RightSide': moveCover2RightSide.value, 'layout': layout.value.index, @@ -160,6 +168,7 @@ class StyleSetting { crossAxisCountInWaterFallFlow.value = map['crossAxisCountInWaterFallFlow']; crossAxisCountInGridDownloadPageForGroup.value = map['crossAxisCountInGridDownloadPageForGroup']; crossAxisCountInGridDownloadPageForGallery.value = map['crossAxisCountInGridDownloadPageForGallery']; + crossAxisCountInDetailPage.value = map['crossAxisCountInDetailPage']; pageListMode.value = Map.from(map['pageListMode']?.map((route, listModeIndex) => MapEntry(route, ListMode.values[listModeIndex])) ?? {}); moveCover2RightSide.value = map['moveCover2RightSide'] ?? moveCover2RightSide.value; layout.value = LayoutMode.values[map['layout'] ?? layout.value.index];