Added horizontal continous

This commit is contained in:
kodjomoustapha 2024-04-15 12:51:20 +01:00
parent d0ee7d3260
commit 0d94154223
6 changed files with 132 additions and 99 deletions

View file

@ -696,7 +696,14 @@ class PersonalPageMode {
{'mangaId': mangaId, 'pageMode': pageMode.index};
}
enum ReaderMode { vertical, ltr, rtl, verticalContinuous, webtoon }
enum ReaderMode {
vertical,
ltr,
rtl,
verticalContinuous,
webtoon,
horizontalContinuous
}
enum PageMode { onePage, doublePage }

View file

@ -1418,6 +1418,7 @@ const _SettingsdefaultReaderModeEnumValueMap = {
'rtl': 2,
'verticalContinuous': 3,
'webtoon': 4,
'horizontalContinuous': 5,
};
const _SettingsdefaultReaderModeValueEnumMap = {
0: ReaderMode.vertical,
@ -1425,6 +1426,7 @@ const _SettingsdefaultReaderModeValueEnumMap = {
2: ReaderMode.rtl,
3: ReaderMode.verticalContinuous,
4: ReaderMode.webtoon,
5: ReaderMode.horizontalContinuous,
};
const _SettingsdisplayTypeEnumValueMap = {
'compactGrid': 0,
@ -12038,6 +12040,7 @@ const _PersonalReaderModereaderModeEnumValueMap = {
'rtl': 2,
'verticalContinuous': 3,
'webtoon': 4,
'horizontalContinuous': 5,
};
const _PersonalReaderModereaderModeValueEnumMap = {
0: ReaderMode.vertical,
@ -12045,6 +12048,7 @@ const _PersonalReaderModereaderModeValueEnumMap = {
2: ReaderMode.rtl,
3: ReaderMode.verticalContinuous,
4: ReaderMode.webtoon,
5: ReaderMode.horizontalContinuous,
};
extension PersonalReaderModeQueryFilter

View file

@ -18,6 +18,7 @@ class ImageViewVertical extends ConsumerWidget {
final UChapDataPreload data;
final Function(UChapDataPreload data) onLongPressData;
final bool cropBorders;
final bool isHorizontal;
final Function(bool) failedToLoadImage;
@ -26,7 +27,8 @@ class ImageViewVertical extends ConsumerWidget {
required this.data,
required this.onLongPressData,
required this.cropBorders,
required this.failedToLoadImage});
required this.failedToLoadImage,
required this.isHorizontal});
@override
Widget build(BuildContext context, WidgetRef ref) {
@ -52,85 +54,85 @@ class ImageViewVertical extends ConsumerWidget {
lang: data.chapter!.manga.value!.lang!)));
final scaleType = ref.watch(scaleTypeStateProvider);
final l10n = l10nLocalizations(context)!;
final imageWidget = ExtendedImage(
image: image as ImageProvider<Object>,
filterQuality: FilterQuality.medium,
handleLoadingProgress: true,
fit: getBoxFit(scaleType),
enableMemoryCache: true,
enableLoadState: true,
loadStateChanged: (state) {
if (state.extendedImageLoadState == LoadState.completed) {
failedToLoadImage(false);
}
if (state.extendedImageLoadState == LoadState.loading) {
final ImageChunkEvent? loadingProgress = state.loadingProgress;
final double progress = loadingProgress?.expectedTotalBytes != null
? loadingProgress!.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes!
: 0;
return Container(
color: Colors.black,
height: context.mediaHeight(0.8),
width: isHorizontal ? context.mediaWidth(0.8) : null,
child: CircularProgressIndicatorAnimateRotate(progress: progress),
);
}
if (state.extendedImageLoadState == LoadState.failed) {
failedToLoadImage(true);
return Container(
color: Colors.black,
height: context.mediaHeight(0.8),
width: isHorizontal ? context.mediaWidth(0.8) : null,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(l10n.image_loading_error,
style: TextStyle(color: Colors.white.withOpacity(0.7))),
Padding(
padding: const EdgeInsets.all(8.0),
child: GestureDetector(
onLongPress: () {
state.reLoadImage();
failedToLoadImage(false);
},
onTap: () {
state.reLoadImage();
failedToLoadImage(false);
},
child: Container(
decoration: BoxDecoration(
color: context.primaryColor,
borderRadius: BorderRadius.circular(30)),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 8, horizontal: 16),
child: Text(
l10n.retry,
),
),
)),
),
],
));
}
return null;
});
return GestureDetector(
onLongPress: () => onLongPressData.call(data),
child: ColorFilterWidget(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (data.index == 0)
SizedBox(
height: MediaQuery.of(context).padding.top,
child: isHorizontal
? imageWidget
: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (data.index == 0)
SizedBox(
height: MediaQuery.of(context).padding.top,
),
imageWidget
],
),
ExtendedImage(
image: image as ImageProvider<Object>,
filterQuality: FilterQuality.medium,
handleLoadingProgress: true,
fit: getBoxFit(scaleType),
enableMemoryCache: true,
enableLoadState: true,
loadStateChanged: (state) {
if (state.extendedImageLoadState == LoadState.completed) {
failedToLoadImage(false);
}
if (state.extendedImageLoadState == LoadState.loading) {
final ImageChunkEvent? loadingProgress =
state.loadingProgress;
final double progress =
loadingProgress?.expectedTotalBytes != null
? loadingProgress!.cumulativeBytesLoaded /
loadingProgress.expectedTotalBytes!
: 0;
return Container(
color: Colors.black,
height: context.mediaHeight(0.8),
child: CircularProgressIndicatorAnimateRotate(
progress: progress),
);
}
if (state.extendedImageLoadState == LoadState.failed) {
failedToLoadImage(true);
return Container(
color: Colors.black,
height: context.mediaHeight(0.8),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(l10n.image_loading_error,
style: TextStyle(
color: Colors.white.withOpacity(0.7))),
Padding(
padding: const EdgeInsets.all(8.0),
child: GestureDetector(
onLongPress: () {
state.reLoadImage();
failedToLoadImage(false);
},
onTap: () {
state.reLoadImage();
failedToLoadImage(false);
},
child: Container(
decoration: BoxDecoration(
color: context.primaryColor,
borderRadius:
BorderRadius.circular(30)),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 8, horizontal: 16),
child: Text(
l10n.retry,
),
),
)),
),
],
));
}
return null;
}),
],
),
),
);
}

View file

@ -478,7 +478,7 @@ class _MangaChapterPageGalleryState
builder: (context, failedToLoadImage, child) {
return Stack(
children: [
_isVerticalContinous()
_isVerticalOrHorizontalContinous()
? PhotoViewGallery.builder(
itemCount: 1,
builder: (_, __) =>
@ -489,6 +489,11 @@ class _MangaChapterPageGalleryState
basePosition: _scalePosition,
onScaleEnd: _onScaleEnd,
child: ScrollablePositionedList.separated(
scrollDirection: ref
.watch(_currentReaderMode) ==
ReaderMode.horizontalContinuous
? Axis.horizontal
: Axis.vertical,
minCacheExtent: pagePreloadAmount *
context.mediaHeight(1),
initialScrollIndex:
@ -560,6 +565,10 @@ class _MangaChapterPageGalleryState
_onLongPressImageDialog(
datas, context);
},
isHorizontal: ref.watch(
_currentReaderMode) ==
ReaderMode
.horizontalContinuous,
),
);
},
@ -567,10 +576,17 @@ class _MangaChapterPageGalleryState
ref.watch(_currentReaderMode) ==
ReaderMode.webtoon
? const SizedBox.shrink()
: Divider(
color: getBackgroundColor(
backgroundColor),
height: 6),
: ref.watch(_currentReaderMode) ==
ReaderMode
.horizontalContinuous
? VerticalDivider(
color: getBackgroundColor(
backgroundColor),
width: 6)
: Divider(
color: getBackgroundColor(
backgroundColor),
height: 6),
)),
)
: Material(
@ -1005,7 +1021,7 @@ class _MangaChapterPageGalleryState
ref.read(currentIndexProvider(chapter).notifier).setCurrentIndex(
_uChapDataPreload[_currentIndex!].index!,
);
if (!(_isVerticalContinous())) {
if (!(_isVerticalOrHorizontalContinous())) {
for (var i = 1; i < pagePreloadAmount + 1; i++) {
_precacheImages(_currentIndex! + i);
_precacheImages(_currentIndex! - i);
@ -1069,7 +1085,7 @@ class _MangaChapterPageGalleryState
ValueNotifier(_readerController.autoScrollValues().$2);
void autoPagescroll() async {
if (_isVerticalContinous()) {
if (_isVerticalOrHorizontalContinous()) {
for (int i = 0; i < 1; i++) {
await Future.delayed(const Duration(milliseconds: 100));
if (!_autoScroll.value) {
@ -1400,7 +1416,7 @@ class _MangaChapterPageGalleryState
}
Widget _autoScrollPlayPauseBtn() {
return _isVerticalContinous()
return _isVerticalOrHorizontalContinous()
? Positioned(
bottom: 0,
right: 0,
@ -1856,12 +1872,12 @@ class _MangaChapterPageGalleryState
_isViewFunction();
}
},
onDoubleTapDown: _isVerticalContinous()
onDoubleTapDown: _isVerticalOrHorizontalContinous()
? (TapDownDetails details) {
_toggleScale(details.globalPosition);
}
: null,
onDoubleTap: _isVerticalContinous() ? () {} : null,
onDoubleTap: _isVerticalOrHorizontalContinous() ? () {} : null,
),
),
@ -1878,12 +1894,13 @@ class _MangaChapterPageGalleryState
onTap: () {
_isViewFunction();
},
onDoubleTapDown: _isVerticalContinous()
onDoubleTapDown: _isVerticalOrHorizontalContinous()
? (TapDownDetails details) {
_toggleScale(details.globalPosition);
}
: null,
onDoubleTap: _isVerticalContinous() ? () {} : null,
onDoubleTap:
_isVerticalOrHorizontalContinous() ? () {} : null,
),
),
@ -1903,12 +1920,12 @@ class _MangaChapterPageGalleryState
_isViewFunction();
}
},
onDoubleTapDown: _isVerticalContinous()
onDoubleTapDown: _isVerticalOrHorizontalContinous()
? (TapDownDetails details) {
_toggleScale(details.globalPosition);
}
: null,
onDoubleTap: _isVerticalContinous() ? () {} : null,
onDoubleTap: _isVerticalOrHorizontalContinous() ? () {} : null,
),
),
],
@ -1934,12 +1951,12 @@ class _MangaChapterPageGalleryState
? _onBtnTapped(_currentIndex! - 1, true)
: _isViewFunction();
},
onDoubleTapDown: _isVerticalContinous()
onDoubleTapDown: _isVerticalOrHorizontalContinous()
? (TapDownDetails details) {
_toggleScale(details.globalPosition);
}
: null,
onDoubleTap: _isVerticalContinous() ? () {} : null,
onDoubleTap: _isVerticalOrHorizontalContinous() ? () {} : null,
),
),
@ -1958,12 +1975,12 @@ class _MangaChapterPageGalleryState
? _onBtnTapped(_currentIndex! + 1, false)
: _isViewFunction();
},
onDoubleTapDown: _isVerticalContinous()
onDoubleTapDown: _isVerticalOrHorizontalContinous()
? (TapDownDetails details) {
_toggleScale(details.globalPosition);
}
: null,
onDoubleTap: _isVerticalContinous() ? () {} : null,
onDoubleTap: _isVerticalOrHorizontalContinous() ? () {} : null,
),
),
],
@ -1972,10 +1989,11 @@ class _MangaChapterPageGalleryState
);
}
bool _isVerticalContinous() {
bool _isVerticalOrHorizontalContinous() {
final readerMode = ref.watch(_currentReaderMode);
return readerMode == ReaderMode.verticalContinuous ||
readerMode == ReaderMode.webtoon;
readerMode == ReaderMode.webtoon ||
readerMode == ReaderMode.horizontalContinuous;
}
void _showModalSettings() async {
@ -2040,7 +2058,8 @@ class _MangaChapterPageGalleryState
.set(value);
}),
if (readerMode == ReaderMode.verticalContinuous ||
readerMode == ReaderMode.webtoon)
readerMode == ReaderMode.webtoon ||
readerMode == ReaderMode.horizontalContinuous)
ValueListenableBuilder(
valueListenable: _autoScrollPage,
builder: (context, valueT, child) {

View file

@ -368,6 +368,7 @@ String getReaderModeName(ReaderMode readerMode, BuildContext context) {
context.l10n.reading_mode_vertical_continuous,
ReaderMode.ltr => context.l10n.reading_mode_left_to_right,
ReaderMode.rtl => context.l10n.reading_mode_right_to_left,
ReaderMode.horizontalContinuous => "Horizontal Continuous",
_ => context.l10n.reading_mode_webtoon
};
}

View file

@ -6,7 +6,7 @@ part of 'headers.dart';
// RiverpodGenerator
// **************************************************************************
String _$headersHash() => r'b329d905b62e8d5fa8e8a1e22d7f6c7f8d115c51';
String _$headersHash() => r'c01fac2f30fa852565e9fca36f3a921f9bf3c112';
/// Copied from Dart SDK
class _SystemHash {