Skip to content

Commit

Permalink
Swipe_to_change_chapter (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
DattatreyaReddy authored Mar 26, 2023
1 parent 0d0b78e commit de4c9d9
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 81 deletions.
32 changes: 16 additions & 16 deletions .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@
# This file should be version controlled.

version:
revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
channel: beta
revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
base_revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
- platform: android
create_revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
base_revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
- platform: ios
create_revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
base_revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
- platform: linux
create_revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
base_revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
- platform: macos
create_revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
base_revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
- platform: web
create_revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
base_revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
- platform: windows
create_revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
base_revision: e599f02c7af4aa8aba0e8e96f71c737f85be3c6e
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da

# User provided section

Expand Down
6 changes: 3 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ SPEC CHECKSUMS:
fluttertoast: eb263d302cc92e04176c053d2385237e9f43fad0
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852
path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9
permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce
SDWebImage: 23d714cd599354ee7906dbae26dff89b421c4370
share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca
shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
SwiftyGif: 6c3eafd0ce693cad58bb63d2b2fb9bacb8552780
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
url_launcher_ios: fb12c43172927bb5cf75aeebd073f883801f1993
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import 'dart:math';

import 'package:flutter/material.dart';

import '../../../../../utils/extensions/custom_extensions.dart';

class PageNumberSlider extends StatelessWidget {
const PageNumberSlider({
super.key,
Expand All @@ -21,7 +23,7 @@ class PageNumberSlider extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Card(
color: Colors.black.withOpacity(.7),
color: context.theme.appBarTheme.backgroundColor?.withOpacity(.7),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import '../../../../../constants/db_keys.dart';
import '../../../../../constants/enum.dart';

import '../../../../../routes/router_config.dart';
import '../../../../../utils/classes/pair/pair_model.dart';
import '../../../../../utils/extensions/custom_extensions.dart';
import '../../../../../utils/launch_url_in_web.dart';
import '../../../../../utils/misc/toast/toast.dart';
Expand Down Expand Up @@ -161,7 +162,6 @@ class ReaderWrapper extends HookConsumerWidget {
: null,
),
elevation: 0,
backgroundColor: Colors.black.withOpacity(.7),
actions: [
chapter.realUrl.isBlank
? const SizedBox.shrink()
Expand Down Expand Up @@ -247,14 +247,16 @@ class ReaderWrapper extends HookConsumerWidget {
Row(
children: [
Card(
color: Colors.black.withOpacity(.7),
shape: const CircleBorder(),
child: IconButton(
onPressed: prevNextChapterPair?.second != null
? () => context.pushReplacement(
Routes.getReader(
"${prevNextChapterPair!.second!.mangaId}",
"${prevNextChapterPair.second!.index}",
toPrev: true,
transVertical:
scrollDirection != Axis.vertical,
),
)
: null,
Expand All @@ -271,14 +273,15 @@ class ReaderWrapper extends HookConsumerWidget {
),
),
Card(
color: Colors.black.withOpacity(.7),
shape: const CircleBorder(),
child: IconButton(
onPressed: prevNextChapterPair?.first != null
? () => context.pushReplacement(
Routes.getReader(
"${prevNextChapterPair!.first!.mangaId}",
"${prevNextChapterPair.first!.index}",
transVertical:
scrollDirection != Axis.vertical,
),
)
: null,
Expand All @@ -288,44 +291,52 @@ class ReaderWrapper extends HookConsumerWidget {
],
),
KSizedBox.h8.size,
Container(
color: Colors.black.withOpacity(.7),
padding: KEdgeInsets.h16v8.size,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
if (chapter.index != null &&
chapter.bookmarked != null)
SingleChapterActionIcon(
icon: chapter.bookmarked!
? Icons.bookmark_rounded
: Icons.bookmark_outline_rounded,
chapterIndex: "${chapter.index!}",
mangaId: "${manga.id}",
chapterPut: ChapterPut(
bookmarked: !chapter.bookmarked!,
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: KRadius.r8.radius,
),
),
margin: EdgeInsets.zero,
child: Padding(
padding: KEdgeInsets.h16v8.size,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
if (chapter.index != null &&
chapter.bookmarked != null)
SingleChapterActionIcon(
icon: chapter.bookmarked!
? Icons.bookmark_rounded
: Icons.bookmark_outline_rounded,
chapterIndex: "${chapter.index!}",
mangaId: "${manga.id}",
chapterPut: ChapterPut(
bookmarked: !chapter.bookmarked!,
),
refresh: () async {
if (manga.id != null &&
chapter.index != null) {
return ref.refresh(chapterProvider(
mangaId: "${manga.id!}",
chapterIndex: "${chapter.index!}",
).future);
}
},
),
refresh: () async {
if (manga.id != null && chapter.index != null) {
return ref.refresh(chapterProvider(
mangaId: "${manga.id!}",
chapterIndex: "${chapter.index!}",
).future);
}
},
IconButton(
icon: const Icon(Icons.app_settings_alt_outlined),
onPressed: () => showReaderModePopup(),
),
IconButton(
icon: const Icon(Icons.app_settings_alt_outlined),
onPressed: () => showReaderModePopup(),
),
Builder(builder: (context) {
return IconButton(
onPressed: () =>
Scaffold.of(context).openEndDrawer(),
icon: const Icon(Icons.settings_rounded),
);
}),
],
Builder(builder: (context) {
return IconButton(
onPressed: () =>
Scaffold.of(context).openEndDrawer(),
icon: const Icon(Icons.settings_rounded),
);
}),
],
),
),
),
],
Expand All @@ -352,20 +363,20 @@ class ReaderWrapper extends HookConsumerWidget {
: NextChapterIntent(),
const SingleActivator(LogicalKeyboardKey.arrowUp):
scrollDirection == Axis.vertical
? PreviousScrollIntent()
: PreviousChapterIntent(),
? NextScrollIntent()
: NextChapterIntent(),
const SingleActivator(LogicalKeyboardKey.keyW):
scrollDirection == Axis.vertical
? PreviousScrollIntent()
: PreviousChapterIntent(),
const SingleActivator(LogicalKeyboardKey.arrowDown):
scrollDirection == Axis.vertical
? NextScrollIntent()
: NextChapterIntent(),
const SingleActivator(LogicalKeyboardKey.arrowDown):
scrollDirection == Axis.vertical
? PreviousScrollIntent()
: PreviousChapterIntent(),
const SingleActivator(LogicalKeyboardKey.keyS):
scrollDirection == Axis.vertical
? NextScrollIntent()
: NextChapterIntent(),
? PreviousScrollIntent()
: PreviousChapterIntent(),
},
child: Actions(
actions: {
Expand All @@ -381,6 +392,8 @@ class ReaderWrapper extends HookConsumerWidget {
Routes.getReader(
"${prevNextChapterPair!.second!.mangaId}",
"${prevNextChapterPair.second!.index}",
toPrev: true,
transVertical: scrollDirection != Axis.vertical,
),
)
: onPrevious(),
Expand All @@ -391,6 +404,7 @@ class ReaderWrapper extends HookConsumerWidget {
Routes.getReader(
"${prevNextChapterPair!.first!.mangaId}",
"${prevNextChapterPair.first!.index}",
transVertical: scrollDirection != Axis.vertical,
),
)
: onNext(),
Expand All @@ -407,6 +421,7 @@ class ReaderWrapper extends HookConsumerWidget {
onNext: onNext,
onPrevious: onPrevious,
mangaReaderNavigationLayout: mangaReaderNavigationLayout,
prevNextChapterPair: prevNextChapterPair,
child: child,
),
),
Expand All @@ -428,6 +443,7 @@ class ReaderView extends HookWidget {
required this.child,
required this.onNext,
required this.onPrevious,
required this.prevNextChapterPair,
required this.mangaReaderNavigationLayout,
});

Expand All @@ -438,6 +454,7 @@ class ReaderView extends HookWidget {
final Widget child;
final VoidCallback onNext;
final VoidCallback onPrevious;
final Pair<Chapter?, Chapter?>? prevNextChapterPair;
final ReaderNavigationLayout mangaReaderNavigationLayout;

@override
Expand All @@ -449,6 +466,25 @@ class ReaderView extends HookWidget {
context.mediaQuerySize,
mangaReaderMagnifierSize,
);
nextChapter() => prevNextChapterPair?.first != null
? context.pushReplacement(
Routes.getReader(
"${prevNextChapterPair!.first!.mangaId}",
"${prevNextChapterPair!.first!.index}",
transVertical: scrollDirection != Axis.vertical,
),
)
: null;
prevChapter() => prevNextChapterPair?.second != null
? context.pushReplacement(
Routes.getReader(
"${prevNextChapterPair!.second!.mangaId}",
"${prevNextChapterPair!.second!.index}",
transVertical: scrollDirection != Axis.vertical,
toPrev: true,
),
)
: null;
return Stack(
children: [
GestureDetector(
Expand All @@ -464,6 +500,28 @@ class ReaderView extends HookWidget {
dragGesturePosition.value = details.localPosition,
onTap: toggleVisibility,
behavior: HitTestBehavior.translucent,
onHorizontalDragEnd: (details) {
if (scrollDirection == Axis.vertical) {
if (details.primaryVelocity == null) {
return;
} else if (details.primaryVelocity! > 0) {
nextChapter();
} else {
prevChapter();
}
}
},
onVerticalDragEnd: (details) {
if (scrollDirection == Axis.horizontal) {
if (details.primaryVelocity == null) {
return;
} else if (details.primaryVelocity! > 0) {
prevChapter();
} else {
nextChapter();
}
}
},
child: Padding(
padding: EdgeInsets.symmetric(
vertical: context.height *
Expand Down
Loading

0 comments on commit de4c9d9

Please sign in to comment.