diff --git a/lib/pages/viewer/horizontal_viewer_page.dart b/lib/pages/viewer/horizontal_viewer_page.dart index da302e4f5..f0c8a30ee 100644 --- a/lib/pages/viewer/horizontal_viewer_page.dart +++ b/lib/pages/viewer/horizontal_viewer_page.dart @@ -14,7 +14,6 @@ import 'package:violet/pages/viewer/image/file_image.dart' as f; import 'package:violet/pages/viewer/image/provider_image.dart' as p; import 'package:violet/pages/viewer/others/photo_view_gallery.dart'; import 'package:violet/pages/viewer/viewer_controller.dart'; -import 'package:violet/settings/settings.dart'; import 'package:violet/settings/settings_wrapper.dart'; class HorizontalViewerPage extends StatefulWidget { @@ -43,7 +42,8 @@ class _HorizontalViewerPageState extends State { } bool onTwoPageMode() { - return MediaQuery.of(context).orientation == Orientation.landscape; + return c.onTwoPage = + MediaQuery.of(context).orientation == Orientation.landscape; } @override @@ -161,7 +161,7 @@ class _HorizontalViewerPageState extends State { ); })), ), - if (landscapeMaxPage() > index * 2 + 1) + if (c.maxPage > index * 2 + 1) Image( image: FileImage(File(c.provider.uris[index * 2 + 1])) ..resolve(ImageConfiguration.empty) @@ -205,7 +205,7 @@ class _HorizontalViewerPageState extends State { timeRetry: const Duration(milliseconds: 300), ), ), - if (landscapeMaxPage() > index * 2 + 1) + if (c.maxPage > index * 2 + 1) Image( image: ExtendedNetworkImageProvider( c.urlCache[index * 2 + 1]!.value, diff --git a/lib/pages/viewer/viewer_controller.dart b/lib/pages/viewer/viewer_controller.dart index 7572e049c..bb09c51a2 100644 --- a/lib/pages/viewer/viewer_controller.dart +++ b/lib/pages/viewer/viewer_controller.dart @@ -25,6 +25,7 @@ class ViewerController extends GetxController { final ViewerPageProvider provider; late final int articleId; late final int maxPage; + bool onTwoPage = false; /// viewer callbacks late AsyncCallback close; @@ -138,7 +139,7 @@ class ViewerController extends GetxController { alignment: 0.12, ); } else { - horizontalPageController.jumpToPage(page); + horizontalPageController.jumpToPage(onTwoPage ? page ~/ 2 : page); } } @@ -171,15 +172,15 @@ class ViewerController extends GetxController { ); } else { horizontalPageController.animateToPage( - page, + onTwoPage ? page ~/ 2 : page, duration: const Duration(milliseconds: 200), curve: Curves.easeInOut, ); } } - prev() => move(page.value - 1); - next() => move(page.value + 1); + prev() => move(page.value - (onTwoPage ? 2 : 1)); + next() => move(page.value + (onTwoPage ? 2 : 1)); load(int index) async { if (provider.useProvider) {