mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-01-11 22:40:36 +00:00
Refactor auto-scroll handling and improve tap-to-scroll settings in novel reader
This commit is contained in:
parent
c28ab14e74
commit
6eda6de614
3 changed files with 114 additions and 18 deletions
|
|
@ -2196,7 +2196,10 @@ class _MangaChapterPageGalleryState
|
|||
}
|
||||
|
||||
void _showModalSettings() async {
|
||||
_autoScroll.value = false;
|
||||
bool autoScrollAreadyFalse = _autoScroll.value == false;
|
||||
if (!autoScrollAreadyFalse) {
|
||||
_autoScroll.value = false;
|
||||
}
|
||||
final l10n = l10nLocalizations(context)!;
|
||||
await customDraggableTabBar(
|
||||
tabs: [
|
||||
|
|
@ -2512,10 +2515,11 @@ class _MangaChapterPageGalleryState
|
|||
vsync: this,
|
||||
fullWidth: true,
|
||||
);
|
||||
|
||||
if (_autoScrollPage.value) {
|
||||
_autoPagescroll();
|
||||
_autoScroll.value = true;
|
||||
if (!autoScrollAreadyFalse) {
|
||||
if (_autoScrollPage.value) {
|
||||
_autoPagescroll();
|
||||
_autoScroll.value = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,6 +86,9 @@ class _NovelWebViewState extends ConsumerState<NovelWebView>
|
|||
_scrollController.removeListener(onScroll);
|
||||
_scrollController.dispose();
|
||||
_rebuildDetail.close();
|
||||
_autoScroll.value = false;
|
||||
_autoScroll.dispose();
|
||||
_autoScrollPage.dispose();
|
||||
clearGestureDetailsCache();
|
||||
if (isDesktop) {
|
||||
setFullScreen(value: false);
|
||||
|
|
@ -298,7 +301,7 @@ class _NovelWebViewState extends ConsumerState<NovelWebView>
|
|||
chapter.lastPageRead!,
|
||||
) ??
|
||||
0),
|
||||
duration: Duration(seconds: 2),
|
||||
duration: Duration(seconds: 1),
|
||||
curve: Curves.fastOutSlowIn,
|
||||
)
|
||||
.then((value) {
|
||||
|
|
@ -498,6 +501,8 @@ class _NovelWebViewState extends ConsumerState<NovelWebView>
|
|||
),
|
||||
],
|
||||
),
|
||||
_gestureRightLeft(ref.watch(novelTapToScrollStateProvider)),
|
||||
_gestureTopBottom(ref.watch(novelTapToScrollStateProvider)),
|
||||
_appBar(),
|
||||
_bottomBar(backgroundColor),
|
||||
_autoScrollPlayPauseBtn(),
|
||||
|
|
@ -576,6 +581,88 @@ class _NovelWebViewState extends ConsumerState<NovelWebView>
|
|||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
void _onBtnTapped(double value) {
|
||||
final currentOffset = _scrollController.offset;
|
||||
final maxScroll = _scrollController.position.maxScrollExtent;
|
||||
|
||||
final newOffset = currentOffset + value;
|
||||
_scrollController.animateTo(
|
||||
min(newOffset, maxScroll),
|
||||
duration: Duration(milliseconds: 100),
|
||||
curve: Curves.linear,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _gestureRightLeft(bool usePageTapZones) {
|
||||
return Row(
|
||||
children: [
|
||||
/// left region
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
usePageTapZones ? _onBtnTapped(-100) : _isViewFunction();
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
/// center region
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
_isViewFunction();
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
/// right region
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
usePageTapZones ? _onBtnTapped(100) : _isViewFunction();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _gestureTopBottom(bool usePageTapZones) {
|
||||
return Column(
|
||||
children: [
|
||||
/// top region
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
usePageTapZones ? _onBtnTapped(-100) : _isViewFunction();
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
/// center region
|
||||
const Expanded(flex: 5, child: SizedBox.shrink()),
|
||||
|
||||
/// bottom region
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
usePageTapZones ? _onBtnTapped(100) : _isViewFunction();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _appBar() {
|
||||
if (!_isView && Platform.isIOS) {
|
||||
return const SizedBox.shrink();
|
||||
|
|
@ -971,7 +1058,11 @@ class _NovelWebViewState extends ConsumerState<NovelWebView>
|
|||
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
_autoScroll.value = false;
|
||||
bool autoScrollAreadyFalse =
|
||||
_autoScroll.value == false;
|
||||
if (!autoScrollAreadyFalse) {
|
||||
_autoScroll.value = false;
|
||||
}
|
||||
await customDraggableTabBar(
|
||||
tabs: [
|
||||
Tab(text: context.l10n.reader),
|
||||
|
|
@ -989,9 +1080,11 @@ class _NovelWebViewState extends ConsumerState<NovelWebView>
|
|||
context: context,
|
||||
vsync: this,
|
||||
);
|
||||
if (_autoScrollPage.value) {
|
||||
_autoPagescroll();
|
||||
_autoScroll.value = true;
|
||||
if (!autoScrollAreadyFalse) {
|
||||
if (_autoScrollPage.value) {
|
||||
_autoPagescroll();
|
||||
_autoScroll.value = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.settings),
|
||||
|
|
|
|||
|
|
@ -304,14 +304,13 @@ class GeneralSettingsTab extends ConsumerWidget {
|
|||
},
|
||||
),
|
||||
|
||||
// _SwitchListTileSetting(
|
||||
// title: 'Tap to Scroll',
|
||||
// subtitle: 'Tap screen to scroll up/down',
|
||||
// value: ref.watch(novelTapToScrollStateProvider),
|
||||
// onChanged: (value) {
|
||||
// ref.read(novelTapToScrollStateProvider.notifier).set(value);
|
||||
// },
|
||||
// ),
|
||||
_SwitchListTileSetting(
|
||||
title: context.l10n.use_page_tap_zones,
|
||||
value: ref.watch(novelTapToScrollStateProvider),
|
||||
onChanged: (value) {
|
||||
ref.read(novelTapToScrollStateProvider.notifier).set(value);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue