diff --git a/changelog/v7.4.8+147.md b/changelog/v7.4.8+147.md index 8fbe145f..b12bc7b4 100644 --- a/changelog/v7.4.8+147.md +++ b/changelog/v7.4.8+147.md @@ -2,6 +2,7 @@ - 现在所有平台和布局模式下均可以自定义鼠标滚轮滚动速度 - 阅读页在从上至下布局模式下,现在可以支持自定义图片区域宽度 - 下载设置中支持自定义默认下载分组 +- 单页和双列阅读方向下,支持鼠标滚轮翻页 - 优化保存图片时的图片命名规则 - 优化解压归档时的icon显示 - 收藏页和关注页搜索不再继承关键字 @@ -12,6 +13,7 @@ - 现在改变下载路径时只会自动复制由JHenTai下载的画廊图片,不再移动其他文件 - 修复下载已被版权删除的画廊时,不会自动停止下载的bug - 修复在部分场景下,自动阅读模式无法滚动到末尾的bug +- 修复阅读页修改图片间隔时,无法立即生效的bug ------------------------------------------------------------------------------------------ @@ -19,6 +21,7 @@ - Now you can customize the mouse wheel scrolling speed in all platforms and layout modes - In the top to bottom layout mode, the reading page can now support customizing the width of the image area - The download settings support customizing the default download group +- In the single page and double column reading direction, support mouse wheel page turning - Optimize the toast message when canceling favorites - Optimize the image naming rules when saving images - Optimize the icon display when decompressing archives @@ -29,4 +32,5 @@ - No longer support automatically creating Profile, change to select the profile to be used in the application by yourself - Now when changing the download path, only the gallery images downloaded by JHenTai will be automatically copied, and other files will no longer be moved - Fix the bug that when downloading a gallery that has been deleted due to copyright, the download will not be automatically stopped -- Fix the bug that auto reading mode cannot scroll to the end in some scenes \ No newline at end of file +- Fix the bug that auto reading mode cannot scroll to the end in some scenes +- Fix the bug that the modification of the image interval on the reading page does not take effect immediately \ No newline at end of file diff --git a/lib/src/pages/read/layout/base/base_layout_logic.dart b/lib/src/pages/read/layout/base/base_layout_logic.dart index 623aebba..a0f381d0 100644 --- a/lib/src/pages/read/layout/base/base_layout_logic.dart +++ b/lib/src/pages/read/layout/base/base_layout_logic.dart @@ -5,6 +5,7 @@ import 'dart:typed_data'; import 'package:clipboard/clipboard.dart'; import 'package:extended_image/extended_image.dart'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/gestures.dart'; import 'package:get/get.dart'; import 'package:image_save/image_save.dart'; import 'package:jhentai/src/consts/eh_consts.dart'; @@ -98,6 +99,14 @@ abstract class BaseLayoutLogic extends GetxController with GetTickerProviderStat autoModeTimer?.cancel(); } + void onPointerScroll(PointerScrollEvent value) { + if (value.scrollDelta.dy > 0) { + toNext(); + } else if (value.scrollDelta.dy < 0) { + toPrev(); + } + } + void showBottomMenuInOnlineMode(int index, BuildContext context) { showCupertinoModalPopup( context: context, diff --git a/lib/src/pages/read/layout/horizontal_double_column/horizontal_double_column_layout.dart b/lib/src/pages/read/layout/horizontal_double_column/horizontal_double_column_layout.dart index 99cf58ec..0e50508e 100644 --- a/lib/src/pages/read/layout/horizontal_double_column/horizontal_double_column_layout.dart +++ b/lib/src/pages/read/layout/horizontal_double_column/horizontal_double_column_layout.dart @@ -5,6 +5,7 @@ import 'package:get/get.dart'; import 'package:jhentai/src/extension/get_logic_extension.dart'; import 'package:jhentai/src/model/read_page_info.dart'; import 'package:jhentai/src/pages/read/layout/horizontal_double_column/horizontal_double_column_layout_state.dart'; +import 'package:jhentai/src/widget/eh_wheel_scroll_listener.dart'; import 'package:photo_view/photo_view_gallery.dart'; import '../../../../setting/read_setting.dart'; @@ -21,23 +22,26 @@ class HorizontalDoubleColumnLayout extends BaseLayout { @override Widget buildBody(BuildContext context) { - return PhotoViewGallery.builder( - scrollPhysics: const ClampingScrollPhysics(), - pageController: state.pageController, - cacheExtent: (ReadSetting.preloadPageCount.value.toDouble() + 1) / 2, - reverse: ReadSetting.isInRight2LeftDirection, - itemCount: state.pageCount, - builder: (context, index) => PhotoViewGalleryPageOptions.customChild( - initialScale: 1.0, - minScale: 1.0, - maxScale: 2.5, - scaleStateCycle: ReadSetting.enableDoubleTapToScaleUp.isTrue ? logic.scaleStateCycle : null, - enableTapDragZoom: ReadSetting.enableTapDragToScaleUp.isTrue, - child: index < 0 || index >= state.pageCount - ? null - : readPageState.readPageInfo.mode == ReadMode.online - ? _buildDoubleColumnItemInOnlineMode(context, index) - : _buildDoubleColumnItemInLocalMode(context, index), + return EHWheelListener( + onPointerScroll: logic.onPointerScroll, + child: PhotoViewGallery.builder( + scrollPhysics: const ClampingScrollPhysics(), + pageController: state.pageController, + cacheExtent: (ReadSetting.preloadPageCount.value.toDouble() + 1) / 2, + reverse: ReadSetting.isInRight2LeftDirection, + itemCount: state.pageCount, + builder: (context, index) => PhotoViewGalleryPageOptions.customChild( + initialScale: 1.0, + minScale: 1.0, + maxScale: 2.5, + scaleStateCycle: ReadSetting.enableDoubleTapToScaleUp.isTrue ? logic.scaleStateCycle : null, + enableTapDragZoom: ReadSetting.enableTapDragToScaleUp.isTrue, + child: index < 0 || index >= state.pageCount + ? null + : readPageState.readPageInfo.mode == ReadMode.online + ? _buildDoubleColumnItemInOnlineMode(context, index) + : _buildDoubleColumnItemInLocalMode(context, index), + ), ), ); } diff --git a/lib/src/pages/read/layout/horizontal_page/horizontal_page_layout.dart b/lib/src/pages/read/layout/horizontal_page/horizontal_page_layout.dart index f793ecef..2411813e 100644 --- a/lib/src/pages/read/layout/horizontal_page/horizontal_page_layout.dart +++ b/lib/src/pages/read/layout/horizontal_page/horizontal_page_layout.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:jhentai/src/model/read_page_info.dart'; +import 'package:jhentai/src/widget/eh_wheel_scroll_listener.dart'; import 'package:photo_view/photo_view_gallery.dart'; import '../../../../setting/read_setting.dart'; @@ -18,27 +19,30 @@ class HorizontalPageLayout extends BaseLayout { @override Widget buildBody(BuildContext context) { - return PhotoViewGallery.builder( - itemCount: readPageState.readPageInfo.pageCount, - scrollPhysics: const ClampingScrollPhysics(), - pageController: logic.pageController, - cacheExtent: ReadSetting.preloadPageCount.value.toDouble(), - reverse: ReadSetting.isInRight2LeftDirection, - builder: (context, index) => PhotoViewGalleryPageOptions.customChild( - initialScale: 1.0, - minScale: 1.0, - maxScale: 2.5, - scaleStateCycle: ReadSetting.enableDoubleTapToScaleUp.isTrue ? logic.scaleStateCycle : null, - enableTapDragZoom: ReadSetting.enableTapDragToScaleUp.isTrue, - child: Obx(() { - Widget item = readPageState.readPageInfo.mode == ReadMode.online ? buildItemInOnlineMode(context, index) : buildItemInLocalMode(context, index); + return EHWheelListener( + onPointerScroll: ReadSetting.isInFitWidthReadDirection ? null : logic.onPointerScroll, + child: PhotoViewGallery.builder( + itemCount: readPageState.readPageInfo.pageCount, + scrollPhysics: const ClampingScrollPhysics(), + pageController: logic.pageController, + cacheExtent: ReadSetting.preloadPageCount.value.toDouble(), + reverse: ReadSetting.isInRight2LeftDirection, + builder: (context, index) => PhotoViewGalleryPageOptions.customChild( + initialScale: 1.0, + minScale: 1.0, + maxScale: 2.5, + scaleStateCycle: ReadSetting.enableDoubleTapToScaleUp.isTrue ? logic.scaleStateCycle : null, + enableTapDragZoom: ReadSetting.enableTapDragToScaleUp.isTrue, + child: Obx(() { + Widget item = readPageState.readPageInfo.mode == ReadMode.online ? buildItemInOnlineMode(context, index) : buildItemInLocalMode(context, index); - if (ReadSetting.isInFitWidthReadDirection) { - item = Center(child: SingleChildScrollView(controller: ScrollController(), child: item)); - } + if (ReadSetting.isInFitWidthReadDirection) { + item = Center(child: SingleChildScrollView(controller: ScrollController(), child: item)); + } - return item; - }), + return item; + }), + ), ), ); } diff --git a/lib/src/pages/read/read_page_logic.dart b/lib/src/pages/read/read_page_logic.dart index 8915ae05..93f8a9fa 100644 --- a/lib/src/pages/read/read_page_logic.dart +++ b/lib/src/pages/read/read_page_logic.dart @@ -76,6 +76,7 @@ class ReadPageLogic extends GetxController { late Worker toggleCurrentImmersiveModeLister; late Worker toggleDeviceOrientationLister; late Worker readDirectionLister; + late Worker imageSpaceLister; late Worker displayFirstPageAloneListener; late Worker enableCustomBrightnessListener; late Worker customBrightnessListener; @@ -113,6 +114,10 @@ class ReadPageLogic extends GetxController { updateSafely([layoutId]); }); + imageSpaceLister = ever(ReadSetting.imageSpace, (_) { + updateSafely([layoutId]); + }); + displayFirstPageAloneListener = ever(ReadSetting.displayFirstPageAlone, (value) { if (state.displayFirstPageAlone != value) { state.displayFirstPageAlone = value; @@ -168,6 +173,7 @@ class ReadPageLogic extends GetxController { refreshCurrentTimeAndBatteryLevelTimer.cancel(); toggleCurrentImmersiveModeLister.dispose(); readDirectionLister.dispose(); + imageSpaceLister.dispose(); flushReadProgressTimer.cancel(); displayFirstPageAloneListener.dispose(); enableCustomBrightnessListener.dispose(); diff --git a/lib/src/widget/eh_wheel_scroll_listener.dart b/lib/src/widget/eh_wheel_scroll_listener.dart new file mode 100644 index 00000000..56c1a592 --- /dev/null +++ b/lib/src/widget/eh_wheel_scroll_listener.dart @@ -0,0 +1,21 @@ +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; + +class EHWheelListener extends StatelessWidget { + final Widget child; + final ValueChanged? onPointerScroll; + + const EHWheelListener({Key? key, required this.child, this.onPointerScroll}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Listener( + onPointerSignal: (PointerSignalEvent event) { + if (event is PointerScrollEvent) { + onPointerScroll?.call(event); + } + }, + child: child, + ); + } +} diff --git a/lib/src/widget/eh_wheel_speed_controller_for_read_page.dart b/lib/src/widget/eh_wheel_speed_controller_for_read_page.dart index ad540a9c..6d466e53 100644 --- a/lib/src/widget/eh_wheel_speed_controller_for_read_page.dart +++ b/lib/src/widget/eh_wheel_speed_controller_for_read_page.dart @@ -17,10 +17,6 @@ class EHWheelSpeedControllerForReadPage extends StatelessWidget { @override Widget build(BuildContext context) { - if (!GetPlatform.isDesktop) { - return child; - } - return Listener( /// For some reason (probably because of the high resolution monitor), scroll by mouse wheel is very slow, /// so i call [animateTo] to simulate a faster scroll speed.