Coder Social home page Coder Social logo

jordanopos / cosmos_epub Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mamasodikov/cosmos_epub

0.0 0.0 0.0 5 MB

EPUB reader package with great UI, easy customization and awesome features

Home Page: https://pub.dev/packages/cosmos_epub

License: BSD 3-Clause "New" or "Revised" License

Shell 0.58% Ruby 1.52% Objective-C 3.71% Java 3.67% Kotlin 0.13% Dart 89.99% Swift 0.41%

cosmos_epub's Introduction

CosmosEpub ๐Ÿ’ซ

CosmosEpub is a Flutter package that allows users to open and read EPUB files easily. It provides features like opening EPUB files from assets or local path, changing themes, adjusting font styles and sizes, accessing chapter contents, and more. The reader is responsive, enabling its use with both normal-sized smartphones and tablets.

Showcase

banner

Features

  • Open EPUB files from assets or local path.
  • Change themes with 5 options: Grey, Purple, White, Black, and Pink
  • Customize font style and size
  • Access table of contents and navigate to specific chapters
  • Display current chapter name at the bottom of the screen
  • Previous and next buttons to switch between chapters
  • Adjust screen brightness
  • Save book reading progress
  • Nice page flip animation while reading
  • ...and feel free to ask for new features @ [email protected] or open an issue.

Getting Started

In your flutter project add the dependency:

dependencies:
  cosmos_epub: ^x.y.z

Run the command:

flutter pub get

For more information, check out the documentation.

Usage example

Import the package in your Dart code:

import 'package:cosmos_epub/cosmos_epub.dart';

First things first, you have to initialize databases before using any other method. Kindly, do it earlier, preferably in the main.dart file.

There are various methods to control over book progress DB too for your ease :)

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Initializer and methods return a bool
  var _initialized = await CosmosEpub.initialize();
  
  if (_initialized) {
    BookProgressModel bookProgress = CosmosEpub.getBookProgress('bookId');
    await CosmosEpub.setCurrentPageIndex('bookId', 1);
    await CosmosEpub.setCurrentChapterIndex('bookId', 2);
    await CosmosEpub.deleteBookProgress('bookId');
    await CosmosEpub.deleteAllBooksProgress();
  }

  runApp(MyApp());
}

To open an EPUB file from the assets, use the openAssetBook method:

 await CosmosEpub.openAssetBook(
     assetPath: 'assets/book.epub',
     context: context,
     // Book ID is required to save the progress for each opened book
     bookId: '3',
     // Callbacks are optional
     onPageFlip: (int currentPage, int totalPages) {
       print(currentPage);
     },
     onLastPage: (int lastPageIndex) {
       print('We arrived to the last widget');
     });

To open an EPUB file from a local storage, use the openLocalBook method:

 await CosmosEpub.openLocalBook(
     localPath: book.path,
     context: context,
     // Book ID is required to save the progress for each opened book
     bookId: '3'
     // Callbacks are optional
     onPageFlip: (int currentPage, int totalPages) {
       print(currentPage);
     },
     onLastPage: (int lastPageIndex) {
       print('We arrived to the last widget');
     });

For clearing theming cache, use this method:

  await CosmosEpub.clearThemeCache();

Note: I haven't handled all exceptions, so control it on your own side. For example, if you give same bookId to the another book, it can open page and chapter from that book's progress or may break ๐Ÿ’€

Feel free to contact me if you have any questions: https://allmylinks.com/mamasodikov

cosmos_epub's People

Contributors

mamasodikov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.