Skip to content

Commit

Permalink
version upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
dstark5 committed Nov 1, 2024
1 parent 7b6394f commit 659b342
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/ui/about_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AboutPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
const version = "1.0.9";
const version = "1.0.10";

return Scaffold(
appBar: AppBar(
Expand Down
46 changes: 37 additions & 9 deletions lib/ui/epub_viewer.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Dart imports:
import 'dart:convert';
import 'dart:io';

// Flutter imports:
Expand All @@ -8,6 +9,8 @@ import 'package:flutter/material.dart';
import 'package:epub_view/epub_view.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:open_file/open_file.dart';
import 'package:openlib/services/database.dart';
import 'package:vocsy_epub_viewer/epub_viewer.dart';

// Project imports:
import 'package:openlib/services/files.dart' show getFilePath;
Expand All @@ -24,23 +27,48 @@ Future<void> launchEpubViewer(
required BuildContext context,
required WidgetRef ref}) async {
if (Platform.isAndroid || Platform.isIOS) {
MyLibraryDb dataBase = MyLibraryDb.instance;
String path = await getFilePath(fileName);
bool openWithExternalApp = ref.watch(openEpubWithExternalAppProvider);
String? epubConfig = await dataBase.getBookState(fileName);

if (openWithExternalApp) {
await OpenFile.open(path, linuxByProcess: true);
} else {
try {
// ignore: use_build_context_synchronously
Navigator.push(context,
MaterialPageRoute(builder: (BuildContext context) {
return EpubViewerWidget(
fileName: fileName,
);
}));
VocsyEpub.setConfig(
// ignore: use_build_context_synchronously
themeColor: Theme.of(context).colorScheme.secondary,
identifier: "iosBook",
scrollDirection: EpubScrollDirection.HORIZONTAL,
);

if ((epubConfig?.isNotEmpty ?? true) &&
(epubConfig != null) &&
(!(epubConfig.startsWith('epubcfi')))) {
VocsyEpub.open(path,
lastLocation: EpubLocator.fromJson(json.decode(epubConfig)));
} else {
VocsyEpub.open(path);
}

VocsyEpub.locatorStream.listen((locator) async {
await saveEpubState(fileName, locator, ref);
// convert locator from string to json and save to your database to be retrieved later
});
} catch (e) {
// ignore: use_build_context_synchronously
showSnackBar(context: context, message: 'Unable to open pdf!');
try {
// ignore: use_build_context_synchronously
Navigator.push(context,
MaterialPageRoute(builder: (BuildContext context) {
return EpubViewerWidget(
fileName: fileName,
);
}));
} catch (e) {
// ignore: use_build_context_synchronously
showSnackBar(context: context, message: 'Unable to open pdf!');
}
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PelletContainer extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
height: 30,
width: 115,
width: 105,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Theme.of(context).colorScheme.secondary,
Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "14.2.5"
vocsy_epub_viewer:
dependency: "direct main"
description:
name: vocsy_epub_viewer
sha256: "4fe32c3f3e2841448423e3c309d12793146bc96f25571153a1d618ddb352b90a"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
web:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.9+12
version: 1.0.10+13

environment:
sdk: ">=3.3.0 <4.0.0"
Expand All @@ -36,7 +36,7 @@ dependencies:

flutter_pdfview: ^1.2.7
epub_view: ^3.2.0
# vocsy_epub_viewer: ^3.0.0
vocsy_epub_viewer: ^3.0.0
# syncfusion_flutter_pdfviewer: ^22.2.5
# pdfx: ^2.4.0

Expand Down

0 comments on commit 659b342

Please sign in to comment.