From fd3ad740cdf5768d98ce9380ac4953df276c33db Mon Sep 17 00:00:00 2001 From: DattatreyaReddy Panta <58727124+DattatreyaReddy@users.noreply.github.com> Date: Wed, 30 Mar 2022 09:31:53 +0530 Subject: [PATCH] Bug Fixed: Manga page Routes (#31) * Bug Fixed: Manga page Routes --- .../utils/chapter/apply_chapter_filter.dart | 12 ++++--- .../core/utils/manga/apply_manga_filter.dart | 15 ++++---- lib/app/data/providers/category_provider.dart | 11 +++--- .../bindings/global_search_binding.dart | 1 + .../views/global_search_view.dart | 2 ++ .../modules/library/views/library_view.dart | 36 +++++++++---------- .../modules/manga/bindings/manga_binding.dart | 5 ++- lib/app/modules/manga/views/manga_view.dart | 3 ++ 8 files changed, 48 insertions(+), 37 deletions(-) diff --git a/lib/app/core/utils/chapter/apply_chapter_filter.dart b/lib/app/core/utils/chapter/apply_chapter_filter.dart index c346d89e..934cd5c8 100644 --- a/lib/app/core/utils/chapter/apply_chapter_filter.dart +++ b/lib/app/core/utils/chapter/apply_chapter_filter.dart @@ -2,14 +2,18 @@ import '../../../data/chapter_model.dart'; import '../../../data/enums/chapter/chapter_filter.dart'; bool applyChapterFilter(Map filter, Chapter chapter) { + var result = true; if (filter[ChapterFilter.unread] != null) { - return !(filter[ChapterFilter.unread]! ^ !(chapter.read ?? false)); + result = + result && (!(filter[ChapterFilter.unread]! ^ !(chapter.read ?? false))); } if (filter[ChapterFilter.downloaded] != null) { - return !(filter[ChapterFilter.downloaded]! ^ (chapter.downloaded ?? false)); + result = result && + (!(filter[ChapterFilter.downloaded]! ^ (chapter.downloaded ?? false))); } if (filter[ChapterFilter.bookmarked] != null) { - return !(filter[ChapterFilter.bookmarked]! ^ (chapter.bookmarked ?? false)); + result = result && + (!(filter[ChapterFilter.bookmarked]! ^ (chapter.bookmarked ?? false))); } - return true; + return result; } diff --git a/lib/app/core/utils/manga/apply_manga_filter.dart b/lib/app/core/utils/manga/apply_manga_filter.dart index 2a197597..7051851c 100644 --- a/lib/app/core/utils/manga/apply_manga_filter.dart +++ b/lib/app/core/utils/manga/apply_manga_filter.dart @@ -2,16 +2,19 @@ import '../../../data/enums/manga/manga_filter.dart'; import '../../../data/manga_model.dart'; bool applyMangaFilter(Map filter, Manga manga) { + var result = true; if (filter[MangaFilter.unread] != null) { - return !(filter[MangaFilter.unread]! ^ ((manga.unreadCount ?? 0) > 0)); + result = result && + (!(filter[MangaFilter.unread]! ^ ((manga.unreadCount ?? 0) > 0))); } if (filter[MangaFilter.downloaded] != null) { - return !(filter[MangaFilter.downloaded]! ^ - ((manga.downloadCount ?? 0) > 0)); + result = result && + (!(filter[MangaFilter.downloaded]! ^ ((manga.downloadCount ?? 0) > 0))); } if (filter[MangaFilter.completed] != null) { - return !(filter[MangaFilter.completed]! ^ - ((manga.status ?? "") == "COMPLETED")); + result = result && + (!(filter[MangaFilter.completed]! ^ + ((manga.status ?? "") == "COMPLETED"))); } - return true; + return result; } diff --git a/lib/app/data/providers/category_provider.dart b/lib/app/data/providers/category_provider.dart index bc84ad1c..0e431c22 100644 --- a/lib/app/data/providers/category_provider.dart +++ b/lib/app/data/providers/category_provider.dart @@ -22,12 +22,11 @@ class CategoryProvider extends GetConnect { } Future> getMangaListFromCategoryId(int id) async { - final response = await get("/$id", - decoder: (map) { - if(map is List) { - return map.map((item) => Manga.fromMap(item)).toList(); - } - }); + final response = await get("/$id", decoder: (map) { + if (map is List) { + return map.map((item) => Manga.fromMap(item)).toList(); + } + }); return response.body ?? []; } diff --git a/lib/app/modules/global_search/bindings/global_search_binding.dart b/lib/app/modules/global_search/bindings/global_search_binding.dart index ab5f0d5c..e40085f2 100644 --- a/lib/app/modules/global_search/bindings/global_search_binding.dart +++ b/lib/app/modules/global_search/bindings/global_search_binding.dart @@ -7,6 +7,7 @@ class GlobalSearchBinding extends Bindings { void dependencies() { Get.lazyPut( () => GlobalSearchController(), + tag: Get.parameters["query"], ); } } diff --git a/lib/app/modules/global_search/views/global_search_view.dart b/lib/app/modules/global_search/views/global_search_view.dart index 567b4d6c..d1c47129 100644 --- a/lib/app/modules/global_search/views/global_search_view.dart +++ b/lib/app/modules/global_search/views/global_search_view.dart @@ -9,6 +9,8 @@ import '../widgets/global_search_field.dart'; import '../widgets/source_search_grid.dart'; class GlobalSearchView extends GetView { + @override + String? get tag => Get.parameters["query"]; @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/app/modules/library/views/library_view.dart b/lib/app/modules/library/views/library_view.dart index b58da194..c0dc88f9 100644 --- a/lib/app/modules/library/views/library_view.dart +++ b/lib/app/modules/library/views/library_view.dart @@ -45,25 +45,25 @@ class LibraryView extends GetView { return Obx( () => controller.mangaListLength != 0 ? GridView.builder( - controller: controller.scrollController, - gridDelegate: - SliverGridDelegateWithMaxCrossAxisExtent( - maxCrossAxisExtent: 200, - crossAxisSpacing: 2.0, - mainAxisSpacing: 2.0, - childAspectRatio: 0.7, - ), - itemCount: controller.mangaListLength, - itemBuilder: (context, index) => - MangaGridDesign( - manga: controller.mangaList[index], - onTap: () => Get.toNamed( - Routes.manga + - "/${controller.mangaList[index].id}", + controller: controller.scrollController, + gridDelegate: + SliverGridDelegateWithMaxCrossAxisExtent( + maxCrossAxisExtent: 200, + crossAxisSpacing: 2.0, + mainAxisSpacing: 2.0, + childAspectRatio: 0.7, ), - isLibraryScreen: true, - ), - ) + itemCount: controller.mangaListLength, + itemBuilder: (context, index) => + MangaGridDesign( + manga: controller.mangaList[index], + onTap: () => Get.toNamed( + Routes.manga + + "/${controller.mangaList[index].id}", + ), + isLibraryScreen: true, + ), + ) : (controller.isLoading ? Center( child: CircularProgressIndicator(), diff --git a/lib/app/modules/manga/bindings/manga_binding.dart b/lib/app/modules/manga/bindings/manga_binding.dart index 1824fb9f..34ab25f8 100644 --- a/lib/app/modules/manga/bindings/manga_binding.dart +++ b/lib/app/modules/manga/bindings/manga_binding.dart @@ -5,8 +5,7 @@ import '../controllers/manga_controller.dart'; class MangaBinding extends Bindings { @override void dependencies() { - Get.lazyPut( - () => MangaController(), - ); + Get.lazyPut(() => MangaController(), + tag: Get.parameters["mangaId"]); } } diff --git a/lib/app/modules/manga/views/manga_view.dart b/lib/app/modules/manga/views/manga_view.dart index 09847492..2d053e6a 100644 --- a/lib/app/modules/manga/views/manga_view.dart +++ b/lib/app/modules/manga/views/manga_view.dart @@ -14,8 +14,11 @@ import '../widgets/manga_chapter_sort_list_view.dart'; import '../widgets/manga_description.dart'; class MangaView extends GetView { + @override + String? get tag => Get.parameters["mangaId"]; @override Widget build(BuildContext context) { + print(tag); return Scaffold( appBar: AppBar( title: Obx(