diff --git a/Kiwix-iOS/Controller/Bookmark/BookmarkBooksController.swift b/Kiwix-iOS/Controller/Bookmark/BookmarkBooksController.swift index 97e27a53..9568de7e 100644 --- a/Kiwix-iOS/Controller/Bookmark/BookmarkBooksController.swift +++ b/Kiwix-iOS/Controller/Bookmark/BookmarkBooksController.swift @@ -14,6 +14,15 @@ class BookmarkBooksController: CoreDataTableBaseController, UITableViewDelegate, super.viewDidLoad() title = "Bookmarks" } + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + guard segue.identifier == "showBookmarks", + let navController = segue.destination as? UINavigationController, + let controller = navController.topViewController as? BookmarkCollectionController else {return} + guard let cell = sender as? UITableViewCell, + let indexPath = tableView.indexPath(for: cell) else {return} + controller.book = fetchedResultController.object(at: indexPath) + } @IBAction func dismiss(_ sender: UIBarButtonItem) { @@ -53,6 +62,12 @@ class BookmarkBooksController: CoreDataTableBaseController, UITableViewDelegate, return BookState(rawValue: stateInt)?.description } + // MARK: - TableView Delegate + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + tableView.deselectRow(at: indexPath, animated: true) + } + // MARK: - Fetched Results Controller let managedObjectContext = AppDelegate.persistentContainer.viewContext diff --git a/Kiwix-iOS/Controller/Bookmark/BookmarkCollectionController.swift b/Kiwix-iOS/Controller/Bookmark/BookmarkCollectionController.swift new file mode 100644 index 00000000..253d45f2 --- /dev/null +++ b/Kiwix-iOS/Controller/Bookmark/BookmarkCollectionController.swift @@ -0,0 +1,32 @@ +// +// BookmarkCollectionController.swift +// Kiwix +// +// Created by Chris Li on 1/12/17. +// Copyright © 2017 Chris Li. All rights reserved. +// + +import UIKit + +class BookmarkCollectionController: UIViewController { + + @IBOutlet weak var colectionView: UICollectionView! + + var book: Book? { + didSet { + if let book = book { + title = book.title + } else { + title = "All" + } + + } + } + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + +} diff --git a/Kiwix-iOS/Controller/Bookmark/BookmarkSplitController.swift b/Kiwix-iOS/Controller/Bookmark/BookmarkSplitController.swift index 5c7ba1c0..3f7246ef 100644 --- a/Kiwix-iOS/Controller/Bookmark/BookmarkSplitController.swift +++ b/Kiwix-iOS/Controller/Bookmark/BookmarkSplitController.swift @@ -31,6 +31,14 @@ class BookmarkSplitController: UISplitViewController, UISplitViewControllerDeleg } func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController) -> Bool { - return true + if let nav = secondaryViewController as? UINavigationController, + let controller = nav.topViewController as? BookmarkCollectionController, + let _ = controller.book { + // show detail + return false + } else { + // show master + return true + } } } diff --git a/Kiwix-iOS/Storyboard/Bookmark.storyboard b/Kiwix-iOS/Storyboard/Bookmark.storyboard index ac99dd4e..4d3301d0 100644 --- a/Kiwix-iOS/Storyboard/Bookmark.storyboard +++ b/Kiwix-iOS/Storyboard/Bookmark.storyboard @@ -157,10 +157,10 @@ - + - + @@ -168,13 +168,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -238,7 +269,7 @@ - + @@ -274,6 +305,7 @@ + @@ -479,4 +511,7 @@ + + + diff --git a/Kiwix.xcodeproj/project.pbxproj b/Kiwix.xcodeproj/project.pbxproj index 7b502a30..83a36bd1 100644 --- a/Kiwix.xcodeproj/project.pbxproj +++ b/Kiwix.xcodeproj/project.pbxproj @@ -67,6 +67,7 @@ 9757C74C1E106958008A9469 /* BackgroundDownload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9757C74B1E106958008A9469 /* BackgroundDownload.swift */; }; 97599AA21E26D3B000BA15EF /* BookmarkBooksController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97599AA11E26D3B000BA15EF /* BookmarkBooksController.swift */; }; 97599AE01E28031A00BA15EF /* BookmarkSplitController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97599ADF1E28031A00BA15EF /* BookmarkSplitController.swift */; }; + 97599AE21E28193D00BA15EF /* BookmarkCollectionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97599AE11E28193D00BA15EF /* BookmarkCollectionController.swift */; }; 975B90FE1CEB909100D13906 /* iOSExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 975B90FD1CEB909100D13906 /* iOSExtensions.swift */; }; 9764CBD11D806AD800072D6A /* RefreshLibControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9764CBD01D806AD800072D6A /* RefreshLibControl.swift */; }; 9764F5931D830EF200E0B1C4 /* liblzma.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 9764F5921D830EF200E0B1C4 /* liblzma.tbd */; }; @@ -226,6 +227,7 @@ 9757C74B1E106958008A9469 /* BackgroundDownload.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackgroundDownload.swift; sourceTree = ""; }; 97599AA11E26D3B000BA15EF /* BookmarkBooksController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkBooksController.swift; sourceTree = ""; }; 97599ADF1E28031A00BA15EF /* BookmarkSplitController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkSplitController.swift; sourceTree = ""; }; + 97599AE11E28193D00BA15EF /* BookmarkCollectionController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkCollectionController.swift; sourceTree = ""; }; 975B90FD1CEB909100D13906 /* iOSExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = iOSExtensions.swift; path = "Kiwix-iOS/iOSExtensions.swift"; sourceTree = SOURCE_ROOT; }; 9763275D1D64FE0F0034F120 /* BookDetailController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookDetailController.swift; sourceTree = ""; }; 9764CBD01D806AD800072D6A /* RefreshLibControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RefreshLibControl.swift; sourceTree = ""; }; @@ -537,6 +539,7 @@ children = ( 97599ADF1E28031A00BA15EF /* BookmarkSplitController.swift */, 97599AA11E26D3B000BA15EF /* BookmarkBooksController.swift */, + 97599AE11E28193D00BA15EF /* BookmarkCollectionController.swift */, 97C5BD4A1D9AF4B5009692CF /* BookmarkController.swift */, 97219DBC1D383A00009FDFF1 /* BookmarkHUD.swift */, ); @@ -1167,6 +1170,7 @@ 973207A41DD1983D00EDD3DC /* EmptyTableConfigExtension.swift in Sources */, 97A127C91D777CF100FB204D /* RecentSearchController.swift in Sources */, 970E7F7B1DA0069600741290 /* FontSizeController.swift in Sources */, + 97599AE21E28193D00BA15EF /* BookmarkCollectionController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };