Skip to content

Commit

Permalink
Bug Fixed: Manga page Routes (#31)
Browse files Browse the repository at this point in the history
* Bug Fixed: Manga page Routes
  • Loading branch information
DattatreyaReddy authored Mar 30, 2022
1 parent 5507c9a commit fd3ad74
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 37 deletions.
12 changes: 8 additions & 4 deletions lib/app/core/utils/chapter/apply_chapter_filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ import '../../../data/chapter_model.dart';
import '../../../data/enums/chapter/chapter_filter.dart';

bool applyChapterFilter(Map<ChapterFilter, bool?> 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;
}
15 changes: 9 additions & 6 deletions lib/app/core/utils/manga/apply_manga_filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ import '../../../data/enums/manga/manga_filter.dart';
import '../../../data/manga_model.dart';

bool applyMangaFilter(Map<MangaFilter, bool?> 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;
}
11 changes: 5 additions & 6 deletions lib/app/data/providers/category_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ class CategoryProvider extends GetConnect {
}

Future<List<Manga>> getMangaListFromCategoryId(int id) async {
final response = await get("/$id",
decoder: (map) {
if(map is List) {
return map.map<Manga>((item) => Manga.fromMap(item)).toList();
}
});
final response = await get("/$id", decoder: (map) {
if (map is List) {
return map.map<Manga>((item) => Manga.fromMap(item)).toList();
}
});
return response.body ?? <Manga>[];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class GlobalSearchBinding extends Bindings {
void dependencies() {
Get.lazyPut<GlobalSearchController>(
() => GlobalSearchController(),
tag: Get.parameters["query"],
);
}
}
2 changes: 2 additions & 0 deletions lib/app/modules/global_search/views/global_search_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import '../widgets/global_search_field.dart';
import '../widgets/source_search_grid.dart';

class GlobalSearchView extends GetView<GlobalSearchController> {
@override
String? get tag => Get.parameters["query"];
@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down
36 changes: 18 additions & 18 deletions lib/app/modules/library/views/library_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,25 @@ class LibraryView extends GetView<LibraryController> {
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(),
Expand Down
5 changes: 2 additions & 3 deletions lib/app/modules/manga/bindings/manga_binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import '../controllers/manga_controller.dart';
class MangaBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<MangaController>(
() => MangaController(),
);
Get.lazyPut<MangaController>(() => MangaController(),
tag: Get.parameters["mangaId"]);
}
}
3 changes: 3 additions & 0 deletions lib/app/modules/manga/views/manga_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ import '../widgets/manga_chapter_sort_list_view.dart';
import '../widgets/manga_description.dart';

class MangaView extends GetView<MangaController> {
@override
String? get tag => Get.parameters["mangaId"];
@override
Widget build(BuildContext context) {
print(tag);
return Scaffold(
appBar: AppBar(
title: Obx(
Expand Down

0 comments on commit fd3ad74

Please sign in to comment.