-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
890cd6d
commit 89724f7
Showing
13 changed files
with
418 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,19 @@ | ||
import 'package:epubx/epubx.dart'; | ||
import 'package:flipub/book_service.dart'; | ||
import 'package:flipub/views/book_view.dart'; | ||
import 'package:flipub/views/library_view.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
const sharedPreferencesFontSizeKey = 'fontSize'; | ||
|
||
class Flipub extends StatelessWidget { | ||
const Flipub({ | ||
super.key, | ||
required this.bookService, | ||
}); | ||
|
||
final BookService bookService; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
debugShowCheckedModeBanner: false, | ||
theme: ThemeData.dark(), | ||
home: FutureBuilder<EpubBook>( | ||
future: bookService.parseBook( | ||
'book_1.epub', | ||
), | ||
builder: (context, snapshot) { | ||
if (snapshot.hasData) { | ||
return BookView( | ||
book: snapshot.data!, | ||
); | ||
} | ||
return const Center( | ||
child: CircularProgressIndicator(), | ||
); | ||
}, | ||
), | ||
home: const LibrayView(), | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class BookLibrary { | ||
const BookLibrary({ | ||
required this.bookFileNames, | ||
}); | ||
|
||
final List<String> bookFileNames; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
import 'package:flipub/book_service.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flipub/app.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
||
Future<void> main() async { | ||
final BookService bookService = BookService(); | ||
runApp( | ||
ProviderScope( | ||
child: Flipub( | ||
bookService: bookService, | ||
), | ||
const ProviderScope( | ||
child: Flipub(), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:epubx/epubx.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'book_provider.g.dart'; | ||
|
||
@riverpod | ||
Future<EpubBook> book(BookRef ref, String fileName) async { | ||
String fullPath = 'assets/books/$fileName'; | ||
ByteData byteData = await rootBundle.load(fullPath); | ||
List<int> bytes = byteData.buffer.asUint8List(); | ||
return EpubReader.readBook(bytes); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flipub/data/book_library.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'library_provider.g.dart'; | ||
|
||
@riverpod | ||
Future<BookLibrary> bookLibrary(BookLibraryRef ref) async { | ||
return const BookLibrary( | ||
bookFileNames: [ | ||
'book_1.epub', | ||
'book_2.epub', | ||
'book_3.epub', | ||
], | ||
); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'dart:typed_data'; | ||
|
||
import 'package:epubx/epubx.dart' show EpubBook; | ||
import 'package:flutter/material.dart'; | ||
import 'package:image/image.dart' as image; | ||
|
||
class BookCover extends StatelessWidget { | ||
const BookCover({ | ||
super.key, | ||
required this.book, | ||
}); | ||
|
||
final EpubBook book; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return book.CoverImage != null | ||
? Image.memory( | ||
Uint8List.fromList( | ||
image.encodePng(book.CoverImage!), | ||
), | ||
width: 200, | ||
height: 200, | ||
) | ||
: const SizedBox( | ||
height: 200, | ||
width: 200, | ||
child: Center( | ||
child: Text('No cover'), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.