mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-01-11 22:40:36 +00:00
Fix preloadPages when reading
This commit is contained in:
parent
c69dfebd51
commit
02f3458ee0
8 changed files with 161 additions and 173 deletions
|
|
@ -26,6 +26,6 @@ subprojects {
|
|||
project.evaluationDependsOn(':app')
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
tasks.register("clean", Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,13 +167,15 @@ class Mmrcms extends MangaYomiServices {
|
|||
.first
|
||||
.group(1)!
|
||||
.replaceAll('//', 'https://')
|
||||
.replaceAll(RegExp(r"\s+\b|\b\s"), "");
|
||||
.replaceAll(RegExp(r"\s+\b|\b\s"), "")
|
||||
.replaceAll("https:https://", "https://");
|
||||
}
|
||||
return regexx
|
||||
.allMatches(e.outerHtml)
|
||||
.first
|
||||
.group(1)!
|
||||
.replaceAll(RegExp(r"\s+\b|\b\s"), "");
|
||||
.replaceAll(RegExp(r"\s+\b|\b\s"), "")
|
||||
.replaceAll("https:https://", "https://");
|
||||
}).toList();
|
||||
}
|
||||
return pageUrls;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
|
|
@ -19,22 +18,6 @@ class MangaReaderDetail extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _MangaReaderDetailState extends ConsumerState<MangaReaderDetail> {
|
||||
@override
|
||||
void initState() {
|
||||
SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.portraitUp,
|
||||
DeviceOrientation.portraitDown,
|
||||
]);
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
SystemChrome.setPreferredOrientations(DeviceOrientation.values);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final manga =
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import 'package:mangayomi/utils/media_query.dart';
|
|||
import 'package:mangayomi/utils/utils.dart';
|
||||
import 'package:mangayomi/views/manga/detail/providers/isar_providers.dart';
|
||||
import 'package:mangayomi/views/manga/detail/providers/state_providers.dart';
|
||||
import 'package:mangayomi/views/manga/detail/readmore.dart';
|
||||
import 'package:mangayomi/views/manga/detail/widgets/readmore.dart';
|
||||
import 'package:mangayomi/views/manga/detail/widgets/chapter_filter_list_tile_widget.dart';
|
||||
import 'package:mangayomi/views/manga/detail/widgets/chapter_list_tile_widget.dart';
|
||||
import 'package:mangayomi/views/manga/detail/widgets/chapter_sort_list_tile_widget.dart';
|
||||
|
|
@ -181,12 +181,24 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
width: mediaWidth(context, 1),
|
||||
height: 410,
|
||||
fit: BoxFit.cover),
|
||||
Container(
|
||||
width: mediaWidth(context, 1),
|
||||
height: 465,
|
||||
color: Theme.of(context)
|
||||
.scaffoldBackgroundColor
|
||||
.withOpacity(0.9),
|
||||
Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: mediaWidth(context, 1),
|
||||
height: 465,
|
||||
color: Theme.of(context)
|
||||
.scaffoldBackgroundColor
|
||||
.withOpacity(0.9),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
width: mediaWidth(context, 1),
|
||||
height: 100,
|
||||
color: Theme.of(context)
|
||||
.scaffoldBackgroundColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import 'package:isar/isar.dart';
|
|||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/category.dart';
|
||||
import 'package:mangayomi/views/history/providers/isar_providers.dart';
|
||||
import 'package:mangayomi/views/manga/detail/widgets/custom_floating_action_btn.dart';
|
||||
import 'package:mangayomi/views/manga/reader/providers/push_router.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/utils/colors.dart';
|
||||
|
|
@ -53,109 +54,29 @@ class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
|||
(element) => element.mangaId == widget.manga.id)
|
||||
.toList();
|
||||
if (entries.isNotEmpty && !incognitoMode) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
AnimatedContainer(
|
||||
height: 55,
|
||||
width: !isExtended ? 63 : 130,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeIn,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: primaryColor(context),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(15))),
|
||||
onPressed: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
chapter: entries.first.chapter.value!,
|
||||
);
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.play_arrow,
|
||||
color: Colors.white,
|
||||
),
|
||||
AnimatedContainer(
|
||||
curve: Curves.easeIn,
|
||||
width: !isExtended ? 0 : 8,
|
||||
duration:
|
||||
const Duration(milliseconds: 500),
|
||||
),
|
||||
AnimatedContainer(
|
||||
curve: Curves.easeIn,
|
||||
width: !isExtended ? 0 : 60,
|
||||
duration:
|
||||
const Duration(milliseconds: 200),
|
||||
child: const Text(
|
||||
"Resume",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
return CustomFloatingActionBtn(
|
||||
isExtended: !isExtended,
|
||||
label: 'Resume',
|
||||
onPressed: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
chapter: entries.first.chapter.value!,
|
||||
);
|
||||
},
|
||||
textWidth: 70,
|
||||
width: 110,
|
||||
);
|
||||
}
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
AnimatedContainer(
|
||||
height: 55,
|
||||
width: !isExtended ? 60 : 105,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeIn,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: primaryColor(context),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(15))),
|
||||
onPressed: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
chapter: widget.manga.chapters.last);
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.play_arrow,
|
||||
color: Colors.white,
|
||||
),
|
||||
AnimatedContainer(
|
||||
curve: Curves.easeIn,
|
||||
width: !isExtended ? 0 : 5,
|
||||
duration:
|
||||
const Duration(milliseconds: 300),
|
||||
),
|
||||
AnimatedContainer(
|
||||
curve: Curves.easeIn,
|
||||
width: !isExtended ? 0 : 40,
|
||||
duration:
|
||||
const Duration(milliseconds: 300),
|
||||
child: const Text(
|
||||
"Read",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
return CustomFloatingActionBtn(
|
||||
isExtended: !isExtended,
|
||||
label: 'Read',
|
||||
onPressed: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
chapter: widget.manga.chapters.last);
|
||||
},
|
||||
textWidth: 40,
|
||||
width: 90,
|
||||
);
|
||||
},
|
||||
error: (Object error, StackTrace stackTrace) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:mangayomi/utils/colors.dart';
|
||||
|
||||
class CustomFloatingActionBtn extends StatelessWidget {
|
||||
final bool isExtended;
|
||||
final VoidCallback onPressed;
|
||||
final String label;
|
||||
final double width;
|
||||
final double textWidth;
|
||||
|
||||
const CustomFloatingActionBtn(
|
||||
{super.key,
|
||||
required this.isExtended,
|
||||
required this.onPressed,
|
||||
required this.label,
|
||||
required this.width,
|
||||
required this.textWidth});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedContainer(
|
||||
height: 55,
|
||||
width: !isExtended ? 63 : width,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeIn,
|
||||
child: FloatingActionButton(
|
||||
backgroundColor: primaryColor(context),
|
||||
onPressed: onPressed,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.play_arrow,
|
||||
color: Colors.white,
|
||||
),
|
||||
AnimatedContainer(
|
||||
curve: Curves.easeIn,
|
||||
width: !isExtended ? 0 : 5,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
),
|
||||
],
|
||||
),
|
||||
AnimatedContainer(
|
||||
curve: Curves.easeIn,
|
||||
width: !isExtended ? 0 : textWidth,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: Text(
|
||||
label,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 14, color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -190,7 +190,7 @@ class _MangaChapterPageGalleryState
|
|||
}
|
||||
}
|
||||
|
||||
void _onAddButtonTapped(int index, bool isPrev, {bool isSlide = false}) {
|
||||
void _onBtnTapped(int index, bool isPrev, {bool isSlide = false}) {
|
||||
if (isPrev) {
|
||||
if (_selectedValue == ReaderMode.verticalContinuous ||
|
||||
_selectedValue == ReaderMode.webtoon) {
|
||||
|
|
@ -355,6 +355,10 @@ class _MangaChapterPageGalleryState
|
|||
return Consumer(
|
||||
builder: (context, ref, child) {
|
||||
final currentIndex = ref.watch(currentIndexProvider(widget.chapter));
|
||||
bool isNotFirstChapter =
|
||||
widget.readerController.getChapterIndex() + 1 !=
|
||||
widget.readerController.getChaptersLength();
|
||||
bool isNotLastChapter = widget.readerController.getChapterIndex() != 0;
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
|
|
@ -429,30 +433,27 @@ class _MangaChapterPageGalleryState
|
|||
radius: 23,
|
||||
backgroundColor: colorsBlack(context),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
pushReplacementMangaReaderView(
|
||||
context: context,
|
||||
chapter: widget.readerController
|
||||
.getNextChapter());
|
||||
},
|
||||
onPressed: isNotFirstChapter
|
||||
? () {
|
||||
pushReplacementMangaReaderView(
|
||||
context: context,
|
||||
chapter: widget.readerController
|
||||
.getNextChapter());
|
||||
}
|
||||
: null,
|
||||
icon: Transform.scale(
|
||||
scaleX: 1,
|
||||
child: Icon(Icons.skip_previous_rounded,
|
||||
color:
|
||||
widget.readerController
|
||||
.getChapterIndex() +
|
||||
1 !=
|
||||
widget.readerController
|
||||
.getChaptersLength()
|
||||
? Theme.of(context)
|
||||
.textTheme
|
||||
.bodyLarge!
|
||||
.color
|
||||
: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyLarge!
|
||||
.color!
|
||||
.withOpacity(0.4)),
|
||||
color: isNotFirstChapter
|
||||
? Theme.of(context)
|
||||
.textTheme
|
||||
.bodyLarge!
|
||||
.color
|
||||
: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyLarge!
|
||||
.color!
|
||||
.withOpacity(0.4)),
|
||||
)),
|
||||
),
|
||||
),
|
||||
|
|
@ -487,8 +488,7 @@ class _MangaChapterPageGalleryState
|
|||
Flexible(
|
||||
child: Slider(
|
||||
onChanged: (newValue) {
|
||||
_onAddButtonTapped(
|
||||
newValue.toInt(), true,
|
||||
_onBtnTapped(newValue.toInt(), true,
|
||||
isSlide: true);
|
||||
},
|
||||
divisions: max(
|
||||
|
|
@ -536,20 +536,20 @@ class _MangaChapterPageGalleryState
|
|||
radius: 23,
|
||||
backgroundColor: colorsBlack(context),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
pushReplacementMangaReaderView(
|
||||
context: context,
|
||||
chapter:
|
||||
widget.readerController.getPrevChapter(),
|
||||
);
|
||||
},
|
||||
onPressed: isNotLastChapter
|
||||
? () {
|
||||
pushReplacementMangaReaderView(
|
||||
context: context,
|
||||
chapter: widget.readerController
|
||||
.getPrevChapter(),
|
||||
);
|
||||
}
|
||||
: null,
|
||||
icon: Transform.scale(
|
||||
scaleX: 1,
|
||||
child: Icon(
|
||||
Icons.skip_next_rounded,
|
||||
color: widget.readerController
|
||||
.getChapterIndex() !=
|
||||
0
|
||||
color: isNotLastChapter
|
||||
? Theme.of(context)
|
||||
.textTheme
|
||||
.bodyLarge!
|
||||
|
|
@ -695,9 +695,9 @@ class _MangaChapterPageGalleryState
|
|||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
if (_isReversHorizontal) {
|
||||
_onAddButtonTapped(_currentIndex + 1, false);
|
||||
_onBtnTapped(_currentIndex + 1, false);
|
||||
} else {
|
||||
_onAddButtonTapped(_currentIndex - 1, true);
|
||||
_onBtnTapped(_currentIndex - 1, true);
|
||||
}
|
||||
},
|
||||
onDoubleTapDown: _isVerticalContinous()
|
||||
|
|
@ -733,9 +733,9 @@ class _MangaChapterPageGalleryState
|
|||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
if (_isReversHorizontal) {
|
||||
_onAddButtonTapped(_currentIndex - 1, true);
|
||||
_onBtnTapped(_currentIndex - 1, true);
|
||||
} else {
|
||||
_onAddButtonTapped(_currentIndex + 1, false);
|
||||
_onBtnTapped(_currentIndex + 1, false);
|
||||
}
|
||||
},
|
||||
onDoubleTapDown: _isVerticalContinous()
|
||||
|
|
@ -763,7 +763,7 @@ class _MangaChapterPageGalleryState
|
|||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
_onAddButtonTapped(_currentIndex - 1, true);
|
||||
_onBtnTapped(_currentIndex - 1, true);
|
||||
},
|
||||
onDoubleTapDown: _isVerticalContinous()
|
||||
? (TapDownDetails details) {
|
||||
|
|
@ -783,7 +783,7 @@ class _MangaChapterPageGalleryState
|
|||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
_onAddButtonTapped(_currentIndex + 1, false);
|
||||
_onBtnTapped(_currentIndex + 1, false);
|
||||
},
|
||||
onDoubleTapDown: _isVerticalContinous()
|
||||
? (TapDownDetails details) {
|
||||
|
|
@ -799,6 +799,7 @@ class _MangaChapterPageGalleryState
|
|||
);
|
||||
}
|
||||
|
||||
bool isDoubleTap = false;
|
||||
bool _isVerticalContinous() {
|
||||
return _selectedValue == ReaderMode.verticalContinuous ||
|
||||
_selectedValue == ReaderMode.webtoon;
|
||||
|
|
@ -879,6 +880,7 @@ class _MangaChapterPageGalleryState
|
|||
scrollDirection: _scrollDirection,
|
||||
reverse: _isReversHorizontal,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
preloadPagesCount: isDoubleTap ? 0 : 5,
|
||||
canScrollPage: (GestureDetails? gestureDetails) {
|
||||
return gestureDetails != null
|
||||
? !(gestureDetails.totalScale! > 1.0)
|
||||
|
|
@ -981,7 +983,7 @@ class _MangaChapterPageGalleryState
|
|||
maxScale: 8,
|
||||
animationMaxScale: 8,
|
||||
initialAlignment: InitialAlignment.center,
|
||||
cacheGesture: false,
|
||||
cacheGesture: true,
|
||||
hitTestBehavior: HitTestBehavior.translucent,
|
||||
);
|
||||
},
|
||||
|
|
@ -1003,20 +1005,28 @@ class _MangaChapterPageGalleryState
|
|||
_doubleClickAnimationController.reset();
|
||||
|
||||
if (begin == doubleTapScales[0]) {
|
||||
setState(() {
|
||||
isDoubleTap = true;
|
||||
});
|
||||
end = doubleTapScales[1];
|
||||
} else {
|
||||
setState(() {
|
||||
isDoubleTap = false;
|
||||
});
|
||||
end = doubleTapScales[0];
|
||||
}
|
||||
|
||||
_doubleClickAnimationListener = () {
|
||||
//print(_animation.value);
|
||||
state.handleDoubleTap(
|
||||
scale: _doubleClickAnimation!.value,
|
||||
doubleTapPosition: pointerDownPosition);
|
||||
};
|
||||
_doubleClickAnimation =
|
||||
_doubleClickAnimationController.drive(
|
||||
Tween<double>(begin: begin, end: end));
|
||||
|
||||
_doubleClickAnimation = Tween(
|
||||
begin: begin, end: end)
|
||||
.animate(CurvedAnimation(
|
||||
curve: Curves.ease,
|
||||
parent: _doubleClickAnimationController));
|
||||
|
||||
_doubleClickAnimation!
|
||||
.addListener(_doubleClickAnimationListener);
|
||||
|
|
|
|||
Loading…
Reference in a new issue