diff --git a/analysis_options.yaml b/analysis_options.yaml index f79c5e0..d707ec5 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -28,3 +28,32 @@ linter: # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options + +analyzer: + plugins: + - dart_code_linter + +dart_code_linter: + metrics: + cyclomatic-complexity: 20 + number-of-parameters: 4 + maximum-nesting-level: 5 + metrics-exclude: + - test/** + rules: + - avoid-dynamic + - avoid-passing-async-when-sync-expected + - avoid-redundant-async + - avoid-unnecessary-type-assertions + - avoid-unnecessary-type-casts + - avoid-unrelated-type-assertions + - avoid-unused-parameters + - avoid-nested-conditional-expressions + - newline-before-return + - no-boolean-literal-compare + - no-empty-block + - prefer-trailing-comma + - prefer-conditional-expressions + - no-equal-then-else + - prefer-moving-to-variable + - prefer-match-file-name diff --git a/lib/providers/ComicInfoXML.dart b/lib/providers/ComicInfoXML.dart index 71265dc..515ea32 100644 --- a/lib/providers/ComicInfoXML.dart +++ b/lib/providers/ComicInfoXML.dart @@ -2,11 +2,8 @@ import 'dart:io'; import 'package:xml/xml.dart' as xml; -import 'dart:convert'; -import 'package:archive/archive.dart'; import 'package:jellybook/variables.dart'; import 'package:isar/isar.dart'; -import 'package:isar_flutter_libs/isar_flutter_libs.dart'; import 'package:jellybook/models/entry.dart'; Future parseXML(Entry entry) async { @@ -34,55 +31,55 @@ Future parseXML(Entry entry) async { if (xmlFileContent.findAllElements('Writer').isNotEmpty) { final author = xmlFileContent.findAllElements('Writer'); // add the author - entry.writer = author.first.text; + entry.writer = author.first.innerText; logger.d('writer: ${entry.writer}'); } if (xmlFileContent.findAllElements('Penciller').isNotEmpty) { final author = xmlFileContent.findAllElements('Penciller'); // add the author - entry.penciller = author.first.text; + entry.penciller = author.first.innerText; logger.d('penciller: ${entry.penciller}'); } if (xmlFileContent.findAllElements('Inker').isNotEmpty) { final author = xmlFileContent.findAllElements('Inker'); // add the author - entry.inker = author.first.text; + entry.inker = author.first.innerText; logger.d('inker: ${entry.inker}'); } if (xmlFileContent.findAllElements('Colorist').isNotEmpty) { final author = xmlFileContent.findAllElements('Colorist'); // add the author - entry.colorist = author.first.text; + entry.colorist = author.first.innerText; logger.d('colorist: ${entry.colorist}'); } if (xmlFileContent.findAllElements('Letterer').isNotEmpty) { final author = xmlFileContent.findAllElements('Letterer'); // add the author - entry.letterer = author.first.text; + entry.letterer = author.first.innerText; logger.d('letterer: ${entry.letterer}'); } if (xmlFileContent.findAllElements('CoverArtist').isNotEmpty) { final author = xmlFileContent.findAllElements('CoverArtist'); // add the author - entry.coverArtist = author.first.text; + entry.coverArtist = author.first.innerText; logger.d('coverArtist: ${entry.coverArtist}'); } if (xmlFileContent.findAllElements('Editor').isNotEmpty) { final author = xmlFileContent.findAllElements('Editor'); // add the author - entry.editor = author.first.text; + entry.editor = author.first.innerText; logger.d('editor: ${entry.editor}'); } if (xmlFileContent.findAllElements('Publisher').isNotEmpty) { final author = xmlFileContent.findAllElements('Publisher'); // add the author - entry.publisher = author.first.text; + entry.publisher = author.first.innerText; logger.d('publisher: ${entry.publisher}'); } if (xmlFileContent.findAllElements('Imprint').isNotEmpty) { final author = xmlFileContent.findAllElements('Imprint'); // add the author - entry.imprint = author.first.text; + entry.imprint = author.first.innerText; logger.d('imprint: ${entry.imprint}'); } diff --git a/lib/providers/deleteComic.dart b/lib/providers/deleteComic.dart index 7d147bd..ed7179c 100644 --- a/lib/providers/deleteComic.dart +++ b/lib/providers/deleteComic.dart @@ -1,28 +1,28 @@ // The purpose of this file is to delete a comic from the client import 'package:flutter/material.dart'; import 'package:isar/isar.dart'; -import 'package:isar_flutter_libs/isar_flutter_libs.dart'; import 'package:jellybook/models/entry.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'dart:io'; import 'package:jellybook/variables.dart'; Future deleteComic(String id, context) async { - bool delete = false; await showDialog( context: context, builder: (BuildContext context) { return AlertDialog( - title: Text("Delete Comic"), - content: Text("Are you sure you want to delete this comic?"), + title: Text(AppLocalizations.of(context)?.delete ?? "Delete Comic"), + content: Text(AppLocalizations.of(context)?.deleteConfirm ?? + "Are you sure you want to delete this comic?"), actions: [ TextButton( - child: Text("Cancel"), + child: Text(AppLocalizations.of(context)?.cancel ?? "Cancel"), onPressed: () { Navigator.of(context).pop(); }, ), TextButton( - child: Text("Delete"), + child: Text(AppLocalizations.of(context)?.delete ?? "Delete"), onPressed: () { confirmedDelete(id, context); Navigator.of(context).pop(); @@ -64,12 +64,12 @@ Future confirmedDelete(String id, context) async { await isar.writeTxn(() async { await isar.entrys.put(entry); }); - } else { logger.d("Comic not downloaded"); ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("Comic not downloaded"), + SnackBar( + content: Text( + AppLocalizations.of(context)?.noContent ?? "Comic not downloaded"), ), ); } diff --git a/lib/providers/downloader.dart b/lib/providers/downloader.dart deleted file mode 100644 index 455ec82..0000000 --- a/lib/providers/downloader.dart +++ /dev/null @@ -1,26 +0,0 @@ -// The purpose of this file is to allow the user to download the book/comic they have selected - -import 'package:logger/logger.dart'; - -// database imports -import 'package:jellybook/models/entry.dart'; -import 'package:isar/isar.dart'; -import 'package:isar_flutter_libs/isar_flutter_libs.dart'; -import 'package:jellybook/variables.dart'; - -// first we need to check if its already downloaded -Future checkDownloaded(String id) async { - // open the database - final isar = Isar.getInstance(); - - // get the entry - final entry = await isar!.entrys.where().idEqualTo(id).findFirst(); - - // get the entry - - // print the entry - logger.d(entry.toString()); - - // check if the entry is downloaded - return entry?.downloaded ?? false; -} diff --git a/lib/providers/fetchBooks.dart b/lib/providers/fetchBooks.dart index 88c2496..c130bca 100644 --- a/lib/providers/fetchBooks.dart +++ b/lib/providers/fetchBooks.dart @@ -1,17 +1,13 @@ // the purpose of this file is to fetch books from the database to be displayed in the app import 'package:shared_preferences/shared_preferences.dart'; -import 'package:logger/logger.dart'; import 'package:openapi/openapi.dart'; -import 'dart:convert'; import 'package:built_collection/built_collection.dart'; // database imports import 'package:jellybook/models/entry.dart'; import 'package:jellybook/models/folder.dart'; import 'package:isar/isar.dart'; - -import 'package:isar_flutter_libs/isar_flutter_libs.dart'; import 'package:jellybook/variables.dart'; // get comics @@ -70,7 +66,6 @@ Future> getComics(String comicsId, String etag) async { logger.d("Now saving comics to database"); final isar = Isar.getInstance(); - Entry entry; // get entries from the database try { final entries = await isar!.entrys.where().idEqualTo(comicsId).findAll(); @@ -85,7 +80,6 @@ Future> getComics(String comicsId, String etag) async { logger.d("got entries"); // List> comics = []; - List comics = []; responseData.forEach((element) { Entry entry = Entry( id: element.id ?? '', @@ -205,13 +199,6 @@ Future updateFolders() async { Map getHeaders(String url, String client, String device, String deviceId, String version, String token) { - logger.d("getting headers"); - logger.d(url); - logger.d(client); - logger.d(device); - logger.d(deviceId); - logger.d(version); - logger.d(token); var uri = Uri.parse(url); var headers = { 'Accept': 'application/json', diff --git a/lib/providers/fetchCategories.dart b/lib/providers/fetchCategories.dart index 298d698..e66855b 100644 --- a/lib/providers/fetchCategories.dart +++ b/lib/providers/fetchCategories.dart @@ -1,21 +1,13 @@ // The purpose of this file is to fetch the categories from the database -import 'dart:io'; - -import 'package:flutter/cupertino.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:openapi/openapi.dart'; -import 'dart:convert'; import 'package:jellybook/providers/fetchBooks.dart'; -import 'package:flutter/material.dart'; import 'package:jellybook/providers/folderProvider.dart'; import 'package:jellybook/models/entry.dart'; import 'package:jellybook/models/folder.dart'; import 'package:isar/isar.dart'; -import 'package:isar_flutter_libs/isar_flutter_libs.dart'; import 'package:package_info_plus/package_info_plus.dart' as p_info; -import 'package:jellybook/providers/pair.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:jellybook/variables.dart'; // have optional perameter to have the function return the list of folders @@ -222,82 +214,14 @@ Future removeEntriesFromDatabase( }); } -Future> chooseCategories(List categories, context) async { - List selected = []; - List wantedCategories = []; - - // pop up a dialog to choose categories - // use stateful builder to rebuild the dialog when the list changes - - showDialog( - context: context, - builder: (BuildContext context) { - return StatefulBuilder( - builder: (BuildContext context, StateSetter setState) { - return AlertDialog( - title: Text("Choose Categories"), - content: Container( - width: MediaQuery.of(context).size.width * 0.8, - height: MediaQuery.of(context).size.height * 0.8, - child: ListView.builder( - itemCount: categories.length, - itemBuilder: (BuildContext context, int index) { - return CheckboxListTile( - title: Text(categories[index]), - value: selected.contains(categories[index]), - onChanged: (bool? value) { - if (value == true) { - wantedCategories.add(categories[index]); - } else { - wantedCategories.remove(categories[index]); - } - setState(() {}); - }, - ); - }, - ), - ), - actions: [ - TextButton( - child: Text("Cancel"), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - TextButton( - child: Text("Ok"), - onPressed: () { - Navigator.of(context).pop(wantedCategories); - }, - ), - ], - ); - }, - ); - }, - ); - return wantedCategories; -} - Future<(List, List)> getServerCategoriesOffline(context) async { logger.d("getting server categories"); - // final p_info.PackageInfo packageInfo = - // await p_info.PackageInfo.fromPlatform(); - // final prefs = await SharedPreferences.getInstance(); - // final token = prefs.getString('accessToken') ?? ""; - // final url = prefs.getString('server') ?? ""; - // final userId = prefs.getString('UserId') ?? ""; - // final client = prefs.getString('client') ?? "JellyBook"; - // final device = prefs.getString('device') ?? ""; - // final deviceId = prefs.getString('deviceId') ?? ""; - // final version = prefs.getString('version') ?? packageInfo.version; - logger.d("got prefs"); bool hasComics = true; if (hasComics) { // get the comics and folders from the database final isar = Isar.getInstance(); - List unlikedEntries = await isar!.entrys + List entries = await isar!.entrys .where() .filter() .group((q) { @@ -314,8 +238,7 @@ Future<(List, List)> getServerCategoriesOffline(context) async { .isFavoritedEqualTo(false) .sortByTitle() .findAll(); - - List likedEntries = await isar.entrys + entries.addAll(await isar.entrys .where() .filter() .group((q) { @@ -331,9 +254,7 @@ Future<(List, List)> getServerCategoriesOffline(context) async { .and() .isFavoritedEqualTo(true) .sortByTitle() - .findAll(); - - List entries = likedEntries + unlikedEntries; + .findAll()); List folders = await isar.folders.where().findAll(); logger.d("got entries and folders"); diff --git a/lib/providers/folderProvider.dart b/lib/providers/folderProvider.dart index 17a78f5..eda5570 100644 --- a/lib/providers/folderProvider.dart +++ b/lib/providers/folderProvider.dart @@ -3,10 +3,8 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:isar/isar.dart'; -import 'package:isar_flutter_libs/isar_flutter_libs.dart'; import 'package:jellybook/models/folder.dart'; import 'package:jellybook/models/entry.dart'; -import 'package:jellybook/variables.dart'; // This function takes the list of entries and creates folders if their parentId is not one of the categories // It adds the folder to the list of folders in a isar box diff --git a/lib/providers/languageProvider.dart b/lib/providers/languageProvider.dart index 433e457..c59467f 100644 --- a/lib/providers/languageProvider.dart +++ b/lib/providers/languageProvider.dart @@ -1,8 +1,6 @@ // the purpose of this file is to write a extension to the Localizations class to set a new locale import 'package:flutter/material.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:shared_preferences/shared_preferences.dart'; class LocaleChangeNotifier extends ChangeNotifier { diff --git a/lib/providers/login.dart b/lib/providers/login.dart index bcdfe0b..e47dc73 100644 --- a/lib/providers/login.dart +++ b/lib/providers/login.dart @@ -8,7 +8,6 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:package_info_plus/package_info_plus.dart' as package_info; import 'package:isar/isar.dart'; -import 'package:isar_flutter_libs/isar_flutter_libs.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:jellybook/models/login.dart'; import 'package:openapi/openapi.dart'; @@ -51,13 +50,11 @@ class LoginProvider { _deviceId = "Unknown Device id"; if (Platform.isAndroid) { AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; - _device = androidInfo.model ?? "Unknown Device"; - _deviceId = androidInfo.version.release != null - ? "Android ${androidInfo.version.release}" - : "Unknown Device id"; + _device = androidInfo.model; + _deviceId = "Android ${androidInfo.version.release}"; } else if (Platform.isIOS) { IosDeviceInfo iosInfo = await deviceInfo.iosInfo; - _device = iosInfo.name ?? "Unknown Device"; + _device = iosInfo.name; _device = iosInfo.identifierForVendor ?? "Unknown Device id"; } diff --git a/lib/providers/pair.dart b/lib/providers/pair.dart deleted file mode 100644 index 018b600..0000000 --- a/lib/providers/pair.dart +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/// A pair of values. Used for testing custom codecs. -class Pair { - Pair(this.left, this.right); - - final dynamic left; - final dynamic right; - - @override - String toString() => 'Pair[$left, $right]'; -} diff --git a/lib/providers/parseEpub.dart b/lib/providers/parseEpub.dart index 06876ff..e1667ad 100644 --- a/lib/providers/parseEpub.dart +++ b/lib/providers/parseEpub.dart @@ -1,15 +1,11 @@ // the purpose of this file is to parse information from an epub file import 'dart:io'; -// import 'dart:math'; import 'dart:convert'; import 'package:archive/archive.dart'; -// import 'package:flutter/material.dart'; -// import 'package:jellybook/providers/fileNameFromTitle.dart'; import 'package:jellybook/variables.dart'; import 'package:xml/xml.dart' as xml; import 'package:isar/isar.dart'; -import 'package:isar_flutter_libs/isar_flutter_libs.dart'; import 'package:jellybook/models/entry.dart'; Future parseEpub(Entry entry) async { @@ -29,7 +25,7 @@ Future parseEpub(Entry entry) async { // get the tags from the opf file final subjects = opfFileContent.findAllElements('dc:subject'); for (var subject in subjects) { - tags.add(subject.text); + tags.add(subject.innerText); } logger.d("tags: $tags"); diff --git a/lib/providers/progress.dart b/lib/providers/progress.dart index 269329e..27cf420 100644 --- a/lib/providers/progress.dart +++ b/lib/providers/progress.dart @@ -2,7 +2,6 @@ // import 'package:hive_flutter/hive_flutter.dart'; import 'package:isar/isar.dart'; -import 'package:isar_flutter_libs/isar_flutter_libs.dart'; import 'package:jellybook/models/entry.dart'; import 'package:jellybook/variables.dart'; import 'package:jellybook/providers/updatePagenum.dart'; diff --git a/lib/providers/themeProvider.dart b/lib/providers/themeProvider.dart index 5082cb7..059cfe4 100644 --- a/lib/providers/themeProvider.dart +++ b/lib/providers/themeProvider.dart @@ -9,11 +9,6 @@ class ThemeChangeNotifier extends ChangeNotifier { } late ThemeData _theme; - // ThemeData _theme = ThemeData( - // primarySwatch: Colors.blue, - // visualDensity: VisualDensity.adaptivePlatformDensity, - // // useMaterial3: true, - // ); // late BuildContext _context; late BuildContext _context; @@ -48,7 +43,7 @@ class ThemeChangeNotifier extends ChangeNotifier { return _theme; } - Future get getThemeName async{ + Future get getThemeName async { SharedPreferences prefs = await SharedPreferences.getInstance(); String theme = prefs.getString("theme") ?? "dark"; switch (theme.toLowerCase()) { diff --git a/lib/providers/updateLike.dart b/lib/providers/updateLike.dart index dd90753..f12043c 100644 --- a/lib/providers/updateLike.dart +++ b/lib/providers/updateLike.dart @@ -1,11 +1,9 @@ // The purpose of this file is to update the like status of a book/comic entry in the database import 'package:isar/isar.dart'; -import 'package:isar_flutter_libs/isar_flutter_libs.dart'; import 'package:jellybook/models/entry.dart'; import 'package:openapi/openapi.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:package_info_plus/package_info_plus.dart' as p_info; import 'package:jellybook/variables.dart'; @@ -18,7 +16,6 @@ Future updateLike(String id) async { p_info.PackageInfo packageInfo = await p_info.PackageInfo.fromPlatform(); final prefs = await SharedPreferences.getInstance(); - final storage = FlutterSecureStorage(); final server = prefs.getString('server')!; final userId = prefs.getString('UserId')!; final token = prefs.getString('accessToken')!; diff --git a/lib/providers/updatePagenum.dart b/lib/providers/updatePagenum.dart index 9cff346..6901476 100644 --- a/lib/providers/updatePagenum.dart +++ b/lib/providers/updatePagenum.dart @@ -1,22 +1,15 @@ // the purpose of this file is to update the page number of the current page on jellyfin -import 'package:isar/isar.dart'; -import 'package:isar_flutter_libs/isar_flutter_libs.dart'; -import 'package:jellybook/models/entry.dart'; import 'package:openapi/openapi.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:package_info_plus/package_info_plus.dart' as p_info; import 'package:jellybook/variables.dart'; Future updatePagenum(String id, int pagenum) async { - final isar = Isar.getInstance(); - final entries = await isar!.entrys.where().idEqualTo(id).findFirst(); pagenum *= 1000; // update the entry on the server p_info.PackageInfo packageInfo = await p_info.PackageInfo.fromPlatform(); final prefs = await SharedPreferences.getInstance(); - final storage = FlutterSecureStorage(); final server = prefs.getString('server')!; final userId = prefs.getString('UserId')!; final token = prefs.getString('accessToken')!; diff --git a/lib/screens/AudioPicker.dart b/lib/screens/AudioPicker.dart index 3474b8c..58c59b3 100644 --- a/lib/screens/AudioPicker.dart +++ b/lib/screens/AudioPicker.dart @@ -1,12 +1,8 @@ // The purpose of this file is to provide a audio picker for the user to select an audio file to play along side the book they are reading -import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:jellybook/screens/downloaderScreen.dart'; -import 'package:jellybook/providers/fileNameFromTitle.dart'; import 'package:isar/isar.dart'; import 'package:jellybook/models/entry.dart'; -import 'package:fancy_shimmer_image/fancy_shimmer_image.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:jellybook/widgets/roundedImageWithShadow.dart'; @@ -28,6 +24,7 @@ class _AudioPickerState extends State { .and() .downloadedEqualTo(true) .findAll(); + return entries; } diff --git a/lib/screens/collectionScreen.dart b/lib/screens/collectionScreen.dart index 8429c1e..08d9041 100644 --- a/lib/screens/collectionScreen.dart +++ b/lib/screens/collectionScreen.dart @@ -12,7 +12,6 @@ import 'package:jellybook/providers/fixRichText.dart'; import 'package:fancy_shimmer_image/fancy_shimmer_image.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:jellybook/variables.dart'; -import 'package:jellybook/providers/pair.dart'; import 'package:jellybook/widgets/roundedImageWithShadow.dart'; class collectionScreen extends StatefulWidget { diff --git a/lib/screens/infoScreen.dart b/lib/screens/infoScreen.dart index 90ef3b3..4198cf0 100644 --- a/lib/screens/infoScreen.dart +++ b/lib/screens/infoScreen.dart @@ -10,15 +10,12 @@ import 'package:jellybook/screens/downloaderScreen.dart'; import 'package:jellybook/screens/readingScreen.dart'; import 'package:jellybook/widgets/roundedImageWithShadow.dart'; import 'package:like_button/like_button.dart'; -import 'package:fancy_shimmer_image/fancy_shimmer_image.dart'; import 'package:jellybook/providers/updateLike.dart'; import 'package:isar/isar.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; -import 'package:isar_flutter_libs/isar_flutter_libs.dart'; import 'package:jellybook/models/entry.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:jellybook/variables.dart'; -import 'package:jellybook/providers/pair.dart'; import 'package:package_info_plus/package_info_plus.dart' as p_info; import 'package:openapi/openapi.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -298,7 +295,7 @@ class _InfoScreenState extends State { void handleImageSize(Size imageSize) { // Do something with the image size obtained from the callback - logger.wtf('Image size: ${imageSize.width} x ${imageSize.height}'); + logger.f('Image size: ${imageSize.width} x ${imageSize.height}'); // wait until build is done then set state but do it only once if (!updatedImageWidth) { setState(() { @@ -310,6 +307,7 @@ class _InfoScreenState extends State { bool isTablet(BuildContext context) { final shortestSide = MediaQuery.of(context).size.shortestSide; + return shortestSide > 600; } @@ -346,8 +344,9 @@ class _InfoScreenState extends State { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - AppLocalizations.of(context)?.downloadFirst ?? - "You need to download the comic first"), + AppLocalizations.of(context)?.downloadFirst ?? + "You need to download the comic first", + ), ), ); } @@ -469,14 +468,13 @@ class _InfoScreenState extends State { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - AppLocalizations.of(context)?.downloadOffline ?? - "You are offline, please connect to the internet & reload this app to download this comic", - style: TextStyle( - color: Theme.of(context) - .textTheme - .bodyLarge - ?.color ?? - Colors.white)), + AppLocalizations.of(context)?.downloadOffline ?? + "You are offline, please connect to the internet & reload this app to download this comic", + style: TextStyle( + color: Theme.of(context).textTheme.bodyLarge?.color ?? + Colors.white, + ), + ), backgroundColor: Theme.of(context).dialogBackgroundColor, duration: const Duration(seconds: 5), ), @@ -512,7 +510,8 @@ class _InfoScreenState extends State { const Icon(Icons.delete_rounded), const SizedBox(width: 10), Text( - AppLocalizations.of(context)?.delete ?? "Delete"), + AppLocalizations.of(context)?.delete ?? "Delete", + ), ], ), ), @@ -535,7 +534,10 @@ class _InfoScreenState extends State { onPressed: () async { // update the page so that the liked comics are at the top bool isLiked = await checkLiked(entry.id); - Navigator.pop(context, (isLiked, entry.downloaded)); + Navigator.pop( + context, + (isLiked, entry.downloaded), + ); }, ), ), @@ -782,7 +784,7 @@ class _InfoScreenState extends State { ); }, ), - ) + ), ], ), ); diff --git a/lib/screens/readingScreens/cbrCbzReader.dart b/lib/screens/readingScreens/cbrCbzReader.dart index 0577729..6e2dd08 100644 --- a/lib/screens/readingScreens/cbrCbzReader.dart +++ b/lib/screens/readingScreens/cbrCbzReader.dart @@ -54,7 +54,7 @@ class _CbrCbzReaderState extends State { void setDirection() async { SharedPreferences prefs = await SharedPreferences.getInstance(); direction = prefs.getString('readingDirection') ?? 'ltr'; - logger.wtf("direction: $direction"); + logger.f("direction: $direction"); } Future createPageList() async { diff --git a/lib/variables.dart b/lib/variables.dart index 92fe13c..6a8a428 100644 --- a/lib/variables.dart +++ b/lib/variables.dart @@ -14,7 +14,7 @@ late String localPath; String logStoragePath = "/storage/emulated/0/Documents/"; Logger logger = Logger( - output: kDebugMode == true + output: kDebugMode ? ConsoleOutput() : FileOutput( file: File(logStoragePath + "jellybook.log"), @@ -24,7 +24,7 @@ Logger logger = Logger( .openWrite(mode: FileMode.writeOnlyAppend, encoding: utf8)), ), level: Level.debug, - printer: kDebugMode == true + printer: kDebugMode ? PrettyPrinter() : PrettyPrinter( methodCount: 5, @@ -36,31 +36,6 @@ Logger logger = Logger( ), ); -// class FileOutput extends LogOutput { -// FileOutput({ -// required this.file, -// }); -// -// File file; -// -// @override -// void init() { -// super.init(); -// if (!file.existsSync()) { -// file.createSync(); -// } -// } -// -// @override -// void output(OutputEvent event) async { -// print(event.lines); -// for (var line in event.lines) { -// await file.writeAsString("${line.toString()}\n", -// mode: FileMode.writeOnlyAppend); -// } -// } -// } - class FileOutput extends LogOutput { final File file; final bool overrideExisting; @@ -81,14 +56,6 @@ class FileOutput extends LogOutput { ); } - // @override - // void init() { - // sink = file.openWrite( - // mode: overrideExisting ? FileMode.writeOnly : FileMode.writeOnlyAppend, - // encoding: encoding, - // ); - // } - @override void output(OutputEvent event) { sink.writeAll(event.lines, '\n'); diff --git a/lib/widgets/SettingsItem.dart b/lib/widgets/SettingsItem.dart index d857404..4d1cc90 100644 --- a/lib/widgets/SettingsItem.dart +++ b/lib/widgets/SettingsItem.dart @@ -107,7 +107,6 @@ class _SettingsItemState extends State { widget.onChange!(newValue); }); }, - // }, ), ), ), diff --git a/lib/widgets/popover.dart b/lib/widgets/popover.dart deleted file mode 100644 index 22f58bc..0000000 --- a/lib/widgets/popover.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'package:flutter/material.dart'; - -class Popover extends StatelessWidget { - const Popover({ - required Key key, - required this.child, - }) : super(key: key); - - final Widget child; - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - - return Container( - margin: const EdgeInsets.all(16.0), - clipBehavior: Clip.antiAlias, - decoration: BoxDecoration( - color: theme.cardColor, - borderRadius: const BorderRadius.all(Radius.circular(16.0)), - ), - child: child, - ); - } -} diff --git a/lib/widgets/roundedImageWithShadow.dart b/lib/widgets/roundedImageWithShadow.dart index c62d554..b3846e0 100644 --- a/lib/widgets/roundedImageWithShadow.dart +++ b/lib/widgets/roundedImageWithShadow.dart @@ -6,19 +6,18 @@ class RoundedImageWithShadow extends StatefulWidget { final double ratio; final double radius; final Color shadowColor; - final Key? key; final Function(Size)? onImageSizeAvailable; final String errorWidgetAsset; const RoundedImageWithShadow({ - this.key, + super.key, required this.imageUrl, this.ratio = 0.64, this.radius = 10, this.shadowColor = Colors.black, this.onImageSizeAvailable, this.errorWidgetAsset = 'assets/images/NoCoverArt.png', - }) : super(key: key); + }); @override _RoundedImageWithShadowState createState() => _RoundedImageWithShadowState(); @@ -30,13 +29,11 @@ class _RoundedImageWithShadowState extends State { @override void initState() { super.initState(); - WidgetsBinding.instance?.addPostFrameCallback((_) { - // The callback will be executed after the widget has finished building. + WidgetsBinding.instance.addPostFrameCallback((_) { if (widget.onImageSizeAvailable != null) { widget.onImageSizeAvailable!(imageSize!); } }); - } @override @@ -54,7 +51,7 @@ class _RoundedImageWithShadowState extends State { color: widget.shadowColor.withOpacity(0.2), spreadRadius: 2, blurRadius: 5, - offset: Offset(0, 3), + offset: const Offset(0, 3), ), ], ), @@ -66,11 +63,8 @@ class _RoundedImageWithShadowState extends State { widget.imageUrl == '' || widget.imageUrl.toLowerCase() == 'asset' ? LayoutBuilder( builder: (context, constraints) { - // callback to get the image size once rendered - // if (widget.onImageSizeAvailable != null) { - imageSize = constraints.biggest; - // widget.onImageSizeAvailable!(imageSize!); - // } + imageSize = constraints.biggest; + return Image.asset( widget.errorWidgetAsset, fit: BoxFit.cover, @@ -79,16 +73,14 @@ class _RoundedImageWithShadowState extends State { ) : LayoutBuilder( builder: (context, constraints) { - // if (widget.onImageSizeAvailable != null) { - imageSize = constraints.biggest; - // widget.onImageSizeAvailable!(imageSize!); - // } + imageSize = constraints.biggest; + return FancyShimmerImage( width: constraints.biggest.width, imageUrl: widget.imageUrl, boxFit: BoxFit.cover, errorWidget: Image.asset( - widget.errorWidgetAsset, + widget.errorWidgetAsset, ), ); }, diff --git a/pubspec.lock b/pubspec.lock index 6f6e821..4be928d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -17,6 +17,22 @@ packages: url: "https://pub.dev" source: hosted version: "5.13.0" + analyzer_plugin: + dependency: transitive + description: + name: analyzer_plugin + sha256: c1d5f167683de03d5ab6c3b53fc9aeefc5d59476e7810ba7bbddff50c6f4392d + url: "https://pub.dev" + source: hosted + version: "0.11.2" + ansicolor: + dependency: transitive + description: + name: ansicolor + sha256: "8bf17a8ff6ea17499e40a2d2542c2f481cd7615760c6d34065cb22bfd22e6880" + url: "https://pub.dev" + source: hosted + version: "2.0.2" archive: dependency: "direct main" description: @@ -297,6 +313,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.6" + dart_code_linter: + dependency: "direct dev" + description: + name: dart_code_linter + sha256: e9c2764a39033ad808269092d8ae90b7c696598d2cd2138681550edf85be735f + url: "https://pub.dev" + source: hosted + version: "1.1.1" dart_style: dependency: transitive description: @@ -405,10 +429,10 @@ packages: dependency: transitive description: name: file - sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" url: "https://pub.dev" source: hosted - version: "7.0.0" + version: "6.1.4" fixnum: dependency: transitive description: @@ -617,10 +641,10 @@ packages: dependency: transitive description: name: http - sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525" + sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "0.13.6" http_multi_server: dependency: transitive description: @@ -1063,6 +1087,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + process: + dependency: transitive + description: + name: process + sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + url: "https://pub.dev" + source: hosted + version: "4.2.4" provider: dependency: "direct main" description: @@ -1079,6 +1111,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + pub_updater: + dependency: transitive + description: + name: pub_updater + sha256: "05ae70703e06f7fdeb05f7f02dd680b8aad810e87c756a618f33e1794635115c" + url: "https://pub.dev" + source: hosted + version: "0.3.0" pubspec_parse: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 0563c1c..9b768b0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -100,6 +100,7 @@ dev_dependencies: build_runner: ^2.3.2 isar_generator: ^3.0.5 test: ^1.24.3 + dart_code_linter: ^1.1.1 # objectbox_generator: ^1.6.2 # For information on the generic Dart part of this file, see the