Skip to content

Commit

Permalink
Merge pull request #153 from JellyBookOrg/113-seamless-vertical-scrol…
Browse files Browse the repository at this point in the history
…ling-1

Add Seamless vertical scrolling
  • Loading branch information
Kara-Zor-El authored Jan 12, 2024
2 parents c35ad00 + 9fbf35d commit 6e5486d
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 23 deletions.
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/full_description.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p><i>JellyBook</i> is a book and comic reading app for Jellyfin. Its a app thats meant to allow you to read your files from Jellyfin on mobile. Supported file formats include:</p><ul><li><code>.cbr</code> &amp; <code>.rar</code>: cbr (Comic Book aRchive) is a proprietary file format so is not necessarily encouraged.</li><li><code>.cbz</code> &amp; <code>.zip</code>: another Comic book format</li><li><code>.pdf</code>: the Portable Document Format as you know it</li><li><code>.epub</code>: Electronic PUBlication is a wide-spread eBook format</li></ul><p>More formats will be added over time.</p>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fastlane/metadata/android/en-US/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/short_description.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a nice way to read books and comics from Jellyfin
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/title.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
JellyBook
57 changes: 34 additions & 23 deletions lib/screens/readingScreens/cbrCbzReader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -338,30 +338,41 @@ class _CbrCbzReaderState extends State<CbrCbzReader> {
return Column(
children: [
Expanded(
child: PageView.builder(
scrollDirection:
direction.toLowerCase() == 'vertical'
? Axis.vertical
: Axis.horizontal,
reverse: direction == 'rtl',
// scrollDirection: Axis.vertical,
itemCount: pages.length,
controller: PageController(
initialPage: pageNum,
),
itemBuilder: (context, index) {
return InteractiveViewer(
child: Image.file(
File(pages[index]),
fit: BoxFit.contain,
child: direction.toLowerCase() == 'vertical'
? InteractiveViewer(
child: SingleChildScrollView(
child: Column(
children: [
for (var page in pages)
Image.file(
File(page),
fit: BoxFit.fitHeight,
),
],
),
),
)
: PageView.builder(
scrollDirection: Axis.horizontal,
reverse: direction == 'rtl',
// scrollDirection: Axis.vertical,
itemCount: pages.length,
controller: PageController(
initialPage: pageNum,
),
itemBuilder: (context, index) {
return InteractiveViewer(
child: Image.file(
File(pages[index]),
fit: BoxFit.contain,
),
);
},
onPageChanged: (index) {
saveProgress(index);
progress = index / pageNums;
},
),
);
},
onPageChanged: (index) {
saveProgress(index);
progress = index / pageNums;
},
),
),
],
);
Expand Down
13 changes: 13 additions & 0 deletions lib/screens/readingScreens/pdfReader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'package:audioplayers/audioplayers.dart';
import 'package:jellybook/screens/AudioPicker.dart';
import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:jellybook/widgets/AudioPlayerWidget.dart';
import 'package:shared_preferences/shared_preferences.dart';

class PdfReader extends StatefulWidget {
final String comicId;
Expand Down Expand Up @@ -56,19 +57,27 @@ class _PdfReaderState extends State<PdfReader> {
// pages
int _totalPages = 0;
late PdfController pdfController;
late String direction;

_PdfReaderState({
required this.comicId,
required this.title,
});

void setDirection() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
direction = prefs.getString('readingDirection') ?? 'ltr';
logger.f("direction: $direction");
}

// first, we want to see if the user has given us permission to access their files
// if they have, we want to check if the comic has been downloaded
// if it has, we want to get the file extension to determine how to read it
// if it hasn't, we want to tell the user to download it first
@override
void initState() {
super.initState();
setDirection();
}

@override
Expand Down Expand Up @@ -135,6 +144,10 @@ class _PdfReaderState extends State<PdfReader> {
body: Center(
child: Container(
child: PdfView(
scrollDirection: direction.toLowerCase() == 'vertical'
? Axis.vertical
: Axis.horizontal,
reverse: direction.toLowerCase() == 'rtl' ? true : false,
controller: pdfController,
onPageChanged: (page) {
saveProgress(page: page, comicId: comicId);
Expand Down

0 comments on commit 6e5486d

Please sign in to comment.