diff --git a/lib/main.dart b/lib/main.dart index c8a0b1b3..511392be 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,14 +13,14 @@ Future main() async { await Hive.openBox('bookShelf'); // if running in debug mode then clear the hive box - if (kDebugMode) { - try { - await Hive.box('bookShelf').clear(); - } catch (e) { - debugPrint(e.toString()); - } - debugPrint("cleared hive box"); - } + // if (kDebugMode) { + // try { + // await Hive.box('bookShelf').clear(); + // } catch (e) { + // debugPrint(e.toString()); + // } + // debugPrint("cleared hive box"); + // } runApp(MyApp()); } diff --git a/lib/screens/databaseViewer.dart b/lib/screens/databaseViewer.dart index 1ca779e3..2997419f 100644 --- a/lib/screens/databaseViewer.dart +++ b/lib/screens/databaseViewer.dart @@ -10,12 +10,10 @@ class DatabaseViewer extends StatelessWidget { return Scaffold( appBar: AppBar( title: Text('Database Viewer'), - // button to delete all entries actions: [ IconButton( icon: Icon(Icons.delete), onPressed: () { - // confirm deletion showDialog( context: context, builder: (BuildContext context) { @@ -53,8 +51,6 @@ class DatabaseViewer extends StatelessWidget { child: Text('No entries'), ); } else { - // return a scrollable list of the entries where each entry is a row can be tapped to view the entry - // make scrollable return Scrollbar( child: ListView.builder( itemCount: box.values.length, @@ -170,8 +166,6 @@ class EntryViewer extends StatelessWidget { } Future deleteAllEntries(BuildContext context) async { - // delete all entries final box = Hive.box('bookShelf'); await box.clear(); - // refresh the database viewer } diff --git a/lib/screens/downloaderScreen.dart b/lib/screens/downloaderScreen.dart index 1ddce092..cfa5411e 100644 --- a/lib/screens/downloaderScreen.dart +++ b/lib/screens/downloaderScreen.dart @@ -55,7 +55,6 @@ class _DownloadScreenState extends State { } Future downloadFile(bool forceDown) async { - // open the database var box = Hive.box('bookShelf'); // get the entry that matches the comicId @@ -79,7 +78,6 @@ class _DownloadScreenState extends State { if (entry.folderPath != '' && forceDown == false) { return; } - // get the data from the database url = entry.url; imageUrl = entry.imagePath; @@ -141,13 +139,9 @@ class _DownloadScreenState extends State { debugPrint('Comic folder created'); debugPrint(dirLocation + '/' + fileName2); - // make directory to extract to FileUtils.mkdir([dirLocation + '/' + fileName2]); comicFolder = dirLocation + '/' + fileName2; - // check if the file is a zip or rar - // final fileType = lookupMimeType(dirLocation + '/' + fileName2 + '.zip'); if (dir.contains('.zip')) { - // if (filePath.contains('.zip')) { var bytes = File(dirLocation + '/' + fileName2 + '.zip').readAsBytesSync(); @@ -167,10 +161,8 @@ class _DownloadScreenState extends State { debugPrint('Unzipped'); File(dirLocation + '/' + fileName + '.zip').deleteSync(); - // change entry to downloaded entry.downloaded = true; - // save the location of the comic entry.folderPath = dirLocation + '/' + fileName2; debugPrint('Zip file extracted'); @@ -181,36 +173,24 @@ class _DownloadScreenState extends State { debugPrint('Rar file extracted'); debugPrint('Unzipped'); File(dirLocation + '/' + fileName + '.rar').deleteSync(); - // change entry to downloaded entry.downloaded = true; } catch (e) { debugPrint("Extraction failed " + e.toString()); } } else if (entry.path.contains('.pdf')) { debugPrint('PDF file'); - // change entry to downloaded try { var file = File(dirLocation + '/' + fileName + '.pdf'); - // make folder FileUtils.mkdir([dirLocation + '/' + fileName2]); - // move the file to the folder file.renameSync( dirLocation + '/' + fileName2 + '/' + fileName + '.pdf'); - // get the index of the entry - // save the location of the comic entry.folderPath = dirLocation + '/' + fileName2; entry.filePath = dirLocation + '/' + fileName2 + '/' + fileName + '.pdf'; debugPrint('PDF file moved'); entry.downloaded = true; - // int index = box.values.toList().indexOf(entry); - // update the entry - // box.putAt(index, entry); - - // save the location of the comic entry.folderPath = dirLocation + '/' + fileName2; - // entry.downloaded = true; } catch (e) { debugPrint(e.toString()); } @@ -228,9 +208,7 @@ class _DownloadScreenState extends State { Navigator.pop(context); }); } - // var prefs = await SharedPreferences.getInstance(); debugPrint("title: " + entry.title); - // debugPrint("path: " + filePath); debugPrint("comicFolder: " + comicFolder); // prefs.setString(title, comicFolder); } @@ -250,10 +228,8 @@ class _DownloadScreenState extends State { actions: [ if (!downloading) IconButton( - // redownload the file icon: Icon(Icons.download), onPressed: () { - // ask user to confirm showDialog( context: context, builder: (context) => AlertDialog( diff --git a/lib/screens/homeScreen.dart b/lib/screens/homeScreen.dart index 5c10f5b8..4d7b19a1 100644 --- a/lib/screens/homeScreen.dart +++ b/lib/screens/homeScreen.dart @@ -44,7 +44,6 @@ class _HomeScreenState extends State { title: Text('Home'), actions: [ IconButton( - // debug button icon: Icon(Icons.bug_report), onPressed: () { Navigator.push(