Skip to content

Commit

Permalink
Add PageViewType selector and SlideOutPage switch item
Browse files Browse the repository at this point in the history
  • Loading branch information
3003h committed Oct 31, 2024
1 parent 2131d9d commit 8d86de1
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 127 deletions.
4 changes: 3 additions & 1 deletion jsons/eh_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,7 @@
"showGalleryTags?": true,
"hideGalleryThumbnails?": false,
"horizontalThumbnails?": false,
"pHashThreshold?" : 10
"pHashThreshold?": 10,
"pageViewType?": "",
"enableSlideOutPage?": true
}
7 changes: 7 additions & 0 deletions lib/common/enum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,10 @@ enum BlockType {
commentator,
comment,
}

enum PageViewType {
photoView,
preloadPhotoView,
preloadPageView,
extendedImageGesturePageView,
}
24 changes: 22 additions & 2 deletions lib/common/service/ehsetting_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,16 @@ class EhSettingService extends ProfileService {
}

// readViewCompatibleModes
final _readViewCompatibleMode = false.obs;
final _readViewCompatibleMode = true.obs;
// bool get readViewCompatibleMode => _readViewCompatibleMode.value;
bool get readViewCompatibleMode => false;
bool get readViewCompatibleMode => true;
set readViewCompatibleMode(bool val) => _readViewCompatibleMode.value = val;

// pageViewType
final _pageViewType = PageViewType.extendedImageGesturePageView.obs;
PageViewType get pageViewType => _pageViewType.value;
set pageViewType(PageViewType val) => _pageViewType.value = val;

// translateSearchHistory
final _translateSearchHistory = true.obs;
bool get translateSearchHistory => _translateSearchHistory.value;
Expand Down Expand Up @@ -332,7 +337,20 @@ class EhSettingService extends ProfileService {
int get pHashThreshold => _pHashThreshold.value;
set pHashThreshold(int val) => _pHashThreshold.value = val;

// enableSlideOutPage
final _enableSlideOutPage = true.obs;
bool get enableSlideOutPage => _enableSlideOutPage.value;
set enableSlideOutPage(bool val) => _enableSlideOutPage.value = val;

void _initEhConfig() {
// pageViewType
pageViewType = EnumToString.fromString(
PageViewType.values, ehConfig.pageViewType ?? '') ??
pageViewType;
everFromEnum(_pageViewType, (String value) {
ehConfig = ehConfig.copyWith(pageViewType: value.oN);
});

// pHashThreshold
pHashThreshold = ehConfig.pHashThreshold ?? pHashThreshold;
everProfile<int>(_pHashThreshold, (val) {
Expand Down Expand Up @@ -773,6 +791,8 @@ class EhSettingService extends ProfileService {
everProfile<bool>(_showCommentAvatar, (value) {
ehConfig = ehConfig.copyWith(showCommentAvatar: value.oN);
});

// _enableSlideOutPage
}

///
Expand Down
26 changes: 20 additions & 6 deletions lib/models/eh_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class EhConfig {
this.hideGalleryThumbnails,
this.horizontalThumbnails,
this.pHashThreshold,
this.pageViewType,
this.enableSlideOutPage,
});

final bool? jpnTitleInGalleryPage;
Expand Down Expand Up @@ -145,6 +147,8 @@ class EhConfig {
final bool? hideGalleryThumbnails;
final bool? horizontalThumbnails;
final int? pHashThreshold;
final String? pageViewType;
final bool? enableSlideOutPage;

factory EhConfig.fromJson(Map<String,dynamic> json) => EhConfig(
jpnTitleInGalleryPage: json['jpnTitleInGalleryPage'] != null ? bool.tryParse('${json['jpnTitleInGalleryPage']}', caseSensitive: false) ?? false : null,
Expand Down Expand Up @@ -214,7 +218,9 @@ class EhConfig {
showGalleryTags: json['showGalleryTags'] != null ? bool.tryParse('${json['showGalleryTags']}', caseSensitive: false) ?? false : null,
hideGalleryThumbnails: json['hideGalleryThumbnails'] != null ? bool.tryParse('${json['hideGalleryThumbnails']}', caseSensitive: false) ?? false : null,
horizontalThumbnails: json['horizontalThumbnails'] != null ? bool.tryParse('${json['horizontalThumbnails']}', caseSensitive: false) ?? false : null,
pHashThreshold: json['pHashThreshold'] != null ? int.tryParse('${json['pHashThreshold']}') ?? 0 : null
pHashThreshold: json['pHashThreshold'] != null ? int.tryParse('${json['pHashThreshold']}') ?? 0 : null,
pageViewType: json['pageViewType']?.toString(),
enableSlideOutPage: json['enableSlideOutPage'] != null ? bool.tryParse('${json['enableSlideOutPage']}', caseSensitive: false) ?? false : null
);

Map<String, dynamic> toJson() => {
Expand Down Expand Up @@ -285,7 +291,9 @@ class EhConfig {
'showGalleryTags': showGalleryTags,
'hideGalleryThumbnails': hideGalleryThumbnails,
'horizontalThumbnails': horizontalThumbnails,
'pHashThreshold': pHashThreshold
'pHashThreshold': pHashThreshold,
'pageViewType': pageViewType,
'enableSlideOutPage': enableSlideOutPage
};

EhConfig clone() => EhConfig(
Expand Down Expand Up @@ -356,7 +364,9 @@ class EhConfig {
showGalleryTags: showGalleryTags,
hideGalleryThumbnails: hideGalleryThumbnails,
horizontalThumbnails: horizontalThumbnails,
pHashThreshold: pHashThreshold
pHashThreshold: pHashThreshold,
pageViewType: pageViewType,
enableSlideOutPage: enableSlideOutPage
);


Expand Down Expand Up @@ -428,7 +438,9 @@ class EhConfig {
Optional<bool?>? showGalleryTags,
Optional<bool?>? hideGalleryThumbnails,
Optional<bool?>? horizontalThumbnails,
Optional<int?>? pHashThreshold
Optional<int?>? pHashThreshold,
Optional<String?>? pageViewType,
Optional<bool?>? enableSlideOutPage
}) => EhConfig(
jpnTitleInGalleryPage: checkOptional(jpnTitleInGalleryPage, () => this.jpnTitleInGalleryPage),
tagTranslat: checkOptional(tagTranslat, () => this.tagTranslat),
Expand Down Expand Up @@ -498,12 +510,14 @@ class EhConfig {
hideGalleryThumbnails: checkOptional(hideGalleryThumbnails, () => this.hideGalleryThumbnails),
horizontalThumbnails: checkOptional(horizontalThumbnails, () => this.horizontalThumbnails),
pHashThreshold: checkOptional(pHashThreshold, () => this.pHashThreshold),
pageViewType: checkOptional(pageViewType, () => this.pageViewType),
enableSlideOutPage: checkOptional(enableSlideOutPage, () => this.enableSlideOutPage),
);

@override
bool operator ==(Object other) => identical(this, other)
|| other is EhConfig && jpnTitleInGalleryPage == other.jpnTitleInGalleryPage && tagTranslat == other.tagTranslat && tagTranslatVer == other.tagTranslatVer && favoritesOrder == other.favoritesOrder && siteEx == other.siteEx && galleryImgBlur == other.galleryImgBlur && favPicker == other.favPicker && favLongTap == other.favLongTap && lastFavcat == other.lastFavcat && lastShowFavcat == other.lastShowFavcat && lastShowFavTitle == other.lastShowFavTitle && listMode == other.listMode && safeMode == other.safeMode && catFilter == other.catFilter && maxHistory == other.maxHistory && searchBarComp == other.searchBarComp && pureDarkTheme == other.pureDarkTheme && viewModel == other.viewModel && clipboardLink == other.clipboardLink && commentTrans == other.commentTrans && autoLockTimeOut == other.autoLockTimeOut && showPageInterval == other.showPageInterval && orientation == other.orientation && vibrate == other.vibrate && tagIntroImgLv == other.tagIntroImgLv && debugMode == other.debugMode && debugCount == other.debugCount && autoRead == other.autoRead && turnPageInv == other.turnPageInv && toplist == other.toplist && tabletLayout == other.tabletLayout && tabletLayoutValue == other.tabletLayoutValue && enableTagTranslateCDN == other.enableTagTranslateCDN && autoSelectProfile == other.autoSelectProfile && turnPageAnimations == other.turnPageAnimations && selectProfile == other.selectProfile && linkRedirect == other.linkRedirect && viewColumnMode == other.viewColumnMode && fixedHeightOfListItems == other.fixedHeightOfListItems && tagTranslateDataUpdateMode == other.tagTranslateDataUpdateMode && showCommentAvatar == other.showCommentAvatar && avatarType == other.avatarType && boringAvatarsType == other.boringAvatarsType && textAvatarsType == other.textAvatarsType && avatarBorderRadiusType == other.avatarBorderRadiusType && enablePHashCheck == other.enablePHashCheck && enableQRCodeCheck == other.enableQRCodeCheck && viewFullscreen == other.viewFullscreen && blurringOfCoverBackground == other.blurringOfCoverBackground && listViewTagLimit == other.listViewTagLimit && redirectThumbLink == other.redirectThumbLink && volumnTurnPage == other.volumnTurnPage && proxyType == other.proxyType && proxyHost == other.proxyHost && proxyPort == other.proxyPort && proxyUsername == other.proxyUsername && proxyPassword == other.proxyPassword && webDAVMaxConnections == other.webDAVMaxConnections && hideTopBarOnScroll == other.hideTopBarOnScroll && readViewCompatibleMode == other.readViewCompatibleMode && translateSearchHistory == other.translateSearchHistory && nativeHttpClientAdapter == other.nativeHttpClientAdapter && showComments == other.showComments && showOnlyUploaderComment == other.showOnlyUploaderComment && showGalleryTags == other.showGalleryTags && hideGalleryThumbnails == other.hideGalleryThumbnails && horizontalThumbnails == other.horizontalThumbnails && pHashThreshold == other.pHashThreshold;
|| other is EhConfig && jpnTitleInGalleryPage == other.jpnTitleInGalleryPage && tagTranslat == other.tagTranslat && tagTranslatVer == other.tagTranslatVer && favoritesOrder == other.favoritesOrder && siteEx == other.siteEx && galleryImgBlur == other.galleryImgBlur && favPicker == other.favPicker && favLongTap == other.favLongTap && lastFavcat == other.lastFavcat && lastShowFavcat == other.lastShowFavcat && lastShowFavTitle == other.lastShowFavTitle && listMode == other.listMode && safeMode == other.safeMode && catFilter == other.catFilter && maxHistory == other.maxHistory && searchBarComp == other.searchBarComp && pureDarkTheme == other.pureDarkTheme && viewModel == other.viewModel && clipboardLink == other.clipboardLink && commentTrans == other.commentTrans && autoLockTimeOut == other.autoLockTimeOut && showPageInterval == other.showPageInterval && orientation == other.orientation && vibrate == other.vibrate && tagIntroImgLv == other.tagIntroImgLv && debugMode == other.debugMode && debugCount == other.debugCount && autoRead == other.autoRead && turnPageInv == other.turnPageInv && toplist == other.toplist && tabletLayout == other.tabletLayout && tabletLayoutValue == other.tabletLayoutValue && enableTagTranslateCDN == other.enableTagTranslateCDN && autoSelectProfile == other.autoSelectProfile && turnPageAnimations == other.turnPageAnimations && selectProfile == other.selectProfile && linkRedirect == other.linkRedirect && viewColumnMode == other.viewColumnMode && fixedHeightOfListItems == other.fixedHeightOfListItems && tagTranslateDataUpdateMode == other.tagTranslateDataUpdateMode && showCommentAvatar == other.showCommentAvatar && avatarType == other.avatarType && boringAvatarsType == other.boringAvatarsType && textAvatarsType == other.textAvatarsType && avatarBorderRadiusType == other.avatarBorderRadiusType && enablePHashCheck == other.enablePHashCheck && enableQRCodeCheck == other.enableQRCodeCheck && viewFullscreen == other.viewFullscreen && blurringOfCoverBackground == other.blurringOfCoverBackground && listViewTagLimit == other.listViewTagLimit && redirectThumbLink == other.redirectThumbLink && volumnTurnPage == other.volumnTurnPage && proxyType == other.proxyType && proxyHost == other.proxyHost && proxyPort == other.proxyPort && proxyUsername == other.proxyUsername && proxyPassword == other.proxyPassword && webDAVMaxConnections == other.webDAVMaxConnections && hideTopBarOnScroll == other.hideTopBarOnScroll && readViewCompatibleMode == other.readViewCompatibleMode && translateSearchHistory == other.translateSearchHistory && nativeHttpClientAdapter == other.nativeHttpClientAdapter && showComments == other.showComments && showOnlyUploaderComment == other.showOnlyUploaderComment && showGalleryTags == other.showGalleryTags && hideGalleryThumbnails == other.hideGalleryThumbnails && horizontalThumbnails == other.horizontalThumbnails && pHashThreshold == other.pHashThreshold && pageViewType == other.pageViewType && enableSlideOutPage == other.enableSlideOutPage;

@override
int get hashCode => jpnTitleInGalleryPage.hashCode ^ tagTranslat.hashCode ^ tagTranslatVer.hashCode ^ favoritesOrder.hashCode ^ siteEx.hashCode ^ galleryImgBlur.hashCode ^ favPicker.hashCode ^ favLongTap.hashCode ^ lastFavcat.hashCode ^ lastShowFavcat.hashCode ^ lastShowFavTitle.hashCode ^ listMode.hashCode ^ safeMode.hashCode ^ catFilter.hashCode ^ maxHistory.hashCode ^ searchBarComp.hashCode ^ pureDarkTheme.hashCode ^ viewModel.hashCode ^ clipboardLink.hashCode ^ commentTrans.hashCode ^ autoLockTimeOut.hashCode ^ showPageInterval.hashCode ^ orientation.hashCode ^ vibrate.hashCode ^ tagIntroImgLv.hashCode ^ debugMode.hashCode ^ debugCount.hashCode ^ autoRead.hashCode ^ turnPageInv.hashCode ^ toplist.hashCode ^ tabletLayout.hashCode ^ tabletLayoutValue.hashCode ^ enableTagTranslateCDN.hashCode ^ autoSelectProfile.hashCode ^ turnPageAnimations.hashCode ^ selectProfile.hashCode ^ linkRedirect.hashCode ^ viewColumnMode.hashCode ^ fixedHeightOfListItems.hashCode ^ tagTranslateDataUpdateMode.hashCode ^ showCommentAvatar.hashCode ^ avatarType.hashCode ^ boringAvatarsType.hashCode ^ textAvatarsType.hashCode ^ avatarBorderRadiusType.hashCode ^ enablePHashCheck.hashCode ^ enableQRCodeCheck.hashCode ^ viewFullscreen.hashCode ^ blurringOfCoverBackground.hashCode ^ listViewTagLimit.hashCode ^ redirectThumbLink.hashCode ^ volumnTurnPage.hashCode ^ proxyType.hashCode ^ proxyHost.hashCode ^ proxyPort.hashCode ^ proxyUsername.hashCode ^ proxyPassword.hashCode ^ webDAVMaxConnections.hashCode ^ hideTopBarOnScroll.hashCode ^ readViewCompatibleMode.hashCode ^ translateSearchHistory.hashCode ^ nativeHttpClientAdapter.hashCode ^ showComments.hashCode ^ showOnlyUploaderComment.hashCode ^ showGalleryTags.hashCode ^ hideGalleryThumbnails.hashCode ^ horizontalThumbnails.hashCode ^ pHashThreshold.hashCode;
int get hashCode => jpnTitleInGalleryPage.hashCode ^ tagTranslat.hashCode ^ tagTranslatVer.hashCode ^ favoritesOrder.hashCode ^ siteEx.hashCode ^ galleryImgBlur.hashCode ^ favPicker.hashCode ^ favLongTap.hashCode ^ lastFavcat.hashCode ^ lastShowFavcat.hashCode ^ lastShowFavTitle.hashCode ^ listMode.hashCode ^ safeMode.hashCode ^ catFilter.hashCode ^ maxHistory.hashCode ^ searchBarComp.hashCode ^ pureDarkTheme.hashCode ^ viewModel.hashCode ^ clipboardLink.hashCode ^ commentTrans.hashCode ^ autoLockTimeOut.hashCode ^ showPageInterval.hashCode ^ orientation.hashCode ^ vibrate.hashCode ^ tagIntroImgLv.hashCode ^ debugMode.hashCode ^ debugCount.hashCode ^ autoRead.hashCode ^ turnPageInv.hashCode ^ toplist.hashCode ^ tabletLayout.hashCode ^ tabletLayoutValue.hashCode ^ enableTagTranslateCDN.hashCode ^ autoSelectProfile.hashCode ^ turnPageAnimations.hashCode ^ selectProfile.hashCode ^ linkRedirect.hashCode ^ viewColumnMode.hashCode ^ fixedHeightOfListItems.hashCode ^ tagTranslateDataUpdateMode.hashCode ^ showCommentAvatar.hashCode ^ avatarType.hashCode ^ boringAvatarsType.hashCode ^ textAvatarsType.hashCode ^ avatarBorderRadiusType.hashCode ^ enablePHashCheck.hashCode ^ enableQRCodeCheck.hashCode ^ viewFullscreen.hashCode ^ blurringOfCoverBackground.hashCode ^ listViewTagLimit.hashCode ^ redirectThumbLink.hashCode ^ volumnTurnPage.hashCode ^ proxyType.hashCode ^ proxyHost.hashCode ^ proxyPort.hashCode ^ proxyUsername.hashCode ^ proxyPassword.hashCode ^ webDAVMaxConnections.hashCode ^ hideTopBarOnScroll.hashCode ^ readViewCompatibleMode.hashCode ^ translateSearchHistory.hashCode ^ nativeHttpClientAdapter.hashCode ^ showComments.hashCode ^ showOnlyUploaderComment.hashCode ^ showGalleryTags.hashCode ^ hideGalleryThumbnails.hashCode ^ horizontalThumbnails.hashCode ^ pHashThreshold.hashCode ^ pageViewType.hashCode ^ enableSlideOutPage.hashCode;
}
17 changes: 7 additions & 10 deletions lib/pages/image_view/controller/view_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@ const String idProcess = 'Process';
const int _speedMaxCount = 50;
const int _speedInv = 10;

enum PageViewType {
photoView,
preloadPhotoView,
preloadPageView,
extendedImageGesturePageView,
}

/// 支持在线以及本地(已下载)阅读的组件
class ViewExtController extends GetxController {
ViewExtController();
Expand All @@ -105,9 +98,13 @@ class ViewExtController extends GetxController {
late final ArchiverDownloadController archiverDownloadController;

// 使用 PhotoView
PageViewType get pageViewType => _ehSettingService.readViewCompatibleMode
? PageViewType.extendedImageGesturePageView
: PageViewType.preloadPageView;
// PageViewType get pageViewType => _ehSettingService.readViewCompatibleMode
// ? PageViewType.extendedImageGesturePageView
// : PageViewType.preloadPageView;
PageViewType get pageViewType => _ehSettingService.pageViewType;

// enableSlideOutPage
bool get enableSlideOutPage => _ehSettingService.enableSlideOutPage;

Map<String, DownloadArchiverTaskInfo> get archiverTaskMap =>
archiverDownloadController.archiverTaskMap;
Expand Down
16 changes: 5 additions & 11 deletions lib/pages/image_view/view/image_page_view.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:math';

import 'package:eros_fe/index.dart';
import 'package:eros_fe/pages/image_view/view/view_page.dart';
import 'package:eros_fe/utils/logger.dart';
import 'package:eros_fe/widget/preload_photo_view_gallery.dart';
import 'package:extended_image/extended_image.dart';
import 'package:flutter/cupertino.dart';
Expand Down Expand Up @@ -117,7 +117,7 @@ class ImagePageView extends GetView<ViewExtController> {
imageSer: pageIndex + 1,
mode: ExtendedImageMode.none,
// enableSlideOutPage: !GetPlatform.isAndroid,
enableSlideOutPage: false,
enableSlideOutPage: logic.enableSlideOutPage,
),
);
});
Expand Down Expand Up @@ -149,7 +149,7 @@ class ImagePageView extends GetView<ViewExtController> {
imageSer: index + 1,
mode: ExtendedImageMode.gesture,
// enableSlideOutPage: !GetPlatform.isAndroid,
enableSlideOutPage: false,
enableSlideOutPage: logic.enableSlideOutPage,
),
);
});
Expand All @@ -158,8 +158,7 @@ class ImagePageView extends GetView<ViewExtController> {
case PageViewType.extendedImageGesturePageView:

/// ExtendedImageGesturePageView 的看图功能
/// 存在问题。更新 flutter3 后,Android系统下手势操作异常,不能正常进行滑动
/// 6.2.1 好像可以滑动了
/// 20241031 测试
return ExtendedImageGesturePageView.builder(
controller: logic.extendedPageController,
itemCount: logic.vState.pageCount,
Expand All @@ -171,11 +170,6 @@ class ImagePageView extends GetView<ViewExtController> {
logger.t('pageIndex $index ser ${index + 1}');

/// 单页
///
/// 20220519 initialScale 设置默认超过1的比例,暂时能解决手势不能滑动的问题
/// 但是 enableSlideOutPage 的效果会丢失
///
/// 更新:extended_image 6.2.1 好像已经解决 不设置超过 1.0 的 initialScale也能滑动了
return ViewImage(
imageSer: index + 1,
// enableDoubleTap: false,
Expand All @@ -184,7 +178,7 @@ class ImagePageView extends GetView<ViewExtController> {
// initialScale: GetPlatform.isAndroid ? 1.000001 : 1.0,
mode: ExtendedImageMode.gesture,
// enableSlideOutPage: !GetPlatform.isAndroid,
enableSlideOutPage: false,
enableSlideOutPage: logic.enableSlideOutPage,
);
},
);
Expand Down
Loading

0 comments on commit 8d86de1

Please sign in to comment.