diff --git a/Kiwix-iOS/Controller/Bookmark/BookmarkCollectionController.swift b/Kiwix-iOS/Controller/Bookmark/BookmarkCollectionController.swift index 9dae5d3a..b815c180 100644 --- a/Kiwix-iOS/Controller/Bookmark/BookmarkCollectionController.swift +++ b/Kiwix-iOS/Controller/Bookmark/BookmarkCollectionController.swift @@ -84,6 +84,14 @@ class BookmarkCollectionController: UIViewController, UICollectionViewDataSource return cell } + // MARK: - UICollectionView Delegate + + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + let article = fetchedResultController.object(at: indexPath) + guard let url = article.url else {return} + GlobalQueue.shared.add(articleLoadOperation: ArticleLoadOperation(url: url)) + } + // MARK: - UICollectionViewDelegateFlowLayout func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { @@ -98,10 +106,10 @@ class BookmarkCollectionController: UIViewController, UICollectionViewDataSource let fetchRequest = Article.fetchRequest() let titleDescriptor = NSSortDescriptor(key: "title", ascending: true) fetchRequest.sortDescriptors = [titleDescriptor] -// var predicates = [NSPredicate]() -// predicates.append(NSPredicate(format: "isBookmarked = true")) -// if let book = self.book { predicates.append(NSPredicate(format: "book == %@", book)) } -// fetchRequest.predicate = NSCompoundPredicate(andPredicateWithSubpredicates: predicates) + var predicates = [NSPredicate]() + predicates.append(NSPredicate(format: "isBookmarked = true")) + if let book = self.book { predicates.append(NSPredicate(format: "book == %@", book)) } + fetchRequest.predicate = NSCompoundPredicate(andPredicateWithSubpredicates: predicates) let controller = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.managedObjectContext, sectionNameKeyPath: nil, cacheName: nil) controller.delegate = self try? controller.performFetch() diff --git a/Kiwix-iOS/Storyboard/Bookmark.storyboard b/Kiwix-iOS/Storyboard/Bookmark.storyboard index 64a1ea3d..22b59c9c 100644 --- a/Kiwix-iOS/Storyboard/Bookmark.storyboard +++ b/Kiwix-iOS/Storyboard/Bookmark.storyboard @@ -140,11 +140,12 @@ - + + @@ -162,11 +163,11 @@ - + - - + + @@ -211,13 +212,13 @@ - - + + @@ -232,10 +233,10 @@ - + - + - - + + - - + + + + + + + @@ -452,18 +458,13 @@ - - - - - - - + + @@ -475,9 +476,8 @@ - - + @@ -495,7 +495,7 @@ - + diff --git a/Kiwix/Operations/ArticleOperation.swift b/Kiwix/Operations/ArticleOperation.swift index 02bcb4ec..6d60a2a6 100644 --- a/Kiwix/Operations/ArticleOperation.swift +++ b/Kiwix/Operations/ArticleOperation.swift @@ -78,7 +78,7 @@ class ArticleLoadOperation: Procedure { OperationQueue.main.addOperation { _ = main.searchBar.resignFirstResponder() - main.presentingViewController?.dismiss(animated: self.animated, completion: nil) + main.presentedViewController?.dismiss(animated: self.animated, completion: nil) main.hideWelcome() if main.traitCollection.horizontalSizeClass == .compact {