mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-26 05:18:31 -04:00
Bookmark collection controller setup
This commit is contained in:
parent
a3f1687e54
commit
9fece8a0f7
@ -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
|
||||
|
@ -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.
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -157,10 +157,10 @@
|
||||
</objects>
|
||||
<point key="canvasLocation" x="2402" y="1764"/>
|
||||
</scene>
|
||||
<!--View Controller-->
|
||||
<!--Bookmark Collection Controller-->
|
||||
<scene sceneID="cHE-4Y-51R">
|
||||
<objects>
|
||||
<viewController id="oLN-7t-Pr8" sceneMemberID="viewController">
|
||||
<viewController id="oLN-7t-Pr8" customClass="BookmarkCollectionController" customModule="Kiwix" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="f18-bT-5eI"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="ZaM-mS-Ov3"/>
|
||||
@ -168,13 +168,44 @@
|
||||
<view key="view" contentMode="scaleToFill" id="CNz-v0-bW2">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="2uy-xe-2Xa">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="FG6-Px-7sh">
|
||||
<size key="itemSize" width="50" height="50"/>
|
||||
<size key="headerReferenceSize" width="0.0" height="0.0"/>
|
||||
<size key="footerReferenceSize" width="0.0" height="0.0"/>
|
||||
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
|
||||
</collectionViewFlowLayout>
|
||||
<cells>
|
||||
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="8Ym-GP-ecI">
|
||||
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</view>
|
||||
</collectionViewCell>
|
||||
</cells>
|
||||
</collectionView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstItem="ZaM-mS-Ov3" firstAttribute="top" secondItem="2uy-xe-2Xa" secondAttribute="bottom" id="E2R-BE-Zo3"/>
|
||||
<constraint firstAttribute="trailing" secondItem="2uy-xe-2Xa" secondAttribute="trailing" id="aAH-yb-eXm"/>
|
||||
<constraint firstItem="2uy-xe-2Xa" firstAttribute="leading" secondItem="CNz-v0-bW2" secondAttribute="leading" id="dgF-e0-hE3"/>
|
||||
<constraint firstItem="2uy-xe-2Xa" firstAttribute="top" secondItem="CNz-v0-bW2" secondAttribute="top" id="nk4-pm-kWp"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" id="Wqn-bE-ueD"/>
|
||||
<connections>
|
||||
<outlet property="colectionView" destination="2uy-xe-2Xa" id="eGI-rk-sWH"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="9Ru-B3-FcT" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="3289.8550724637685" y="3196.467391304348"/>
|
||||
<point key="canvasLocation" x="3244.9275362318845" y="3196.467391304348"/>
|
||||
</scene>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="i96-PS-3ib">
|
||||
@ -238,7 +269,7 @@
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vCd-Vo-NUE">
|
||||
<rect key="frame" x="42" y="6" width="2" height="31.5"/>
|
||||
<rect key="frame" x="42" y="6" width="2" height="31.666666666666664"/>
|
||||
<color key="backgroundColor" red="1" green="0.40000000000000002" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="2" id="mUe-cP-6T5"/>
|
||||
@ -274,6 +305,7 @@
|
||||
<outlet property="hasPicIndicator" destination="vCd-Vo-NUE" id="oxG-mF-2gO"/>
|
||||
<outlet property="subtitleLabel" destination="wUN-Co-X2K" id="tJG-Vg-Ctp"/>
|
||||
<outlet property="titleLabel" destination="F5J-kg-p5Y" id="SGC-oq-RQ6"/>
|
||||
<segue destination="hDm-kh-ZLk" kind="showDetail" identifier="showBookmarks" id="vG1-Ih-Ag7"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
@ -479,4 +511,7 @@
|
||||
<image name="BookmarkRemoved" width="348" height="331"/>
|
||||
<image name="Cross" width="16" height="16"/>
|
||||
</resources>
|
||||
<inferredMetricsTieBreakers>
|
||||
<segue reference="ipW-qc-ph3"/>
|
||||
</inferredMetricsTieBreakers>
|
||||
</document>
|
||||
|
@ -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 = "<group>"; };
|
||||
97599AA11E26D3B000BA15EF /* BookmarkBooksController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkBooksController.swift; sourceTree = "<group>"; };
|
||||
97599ADF1E28031A00BA15EF /* BookmarkSplitController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkSplitController.swift; sourceTree = "<group>"; };
|
||||
97599AE11E28193D00BA15EF /* BookmarkCollectionController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkCollectionController.swift; sourceTree = "<group>"; };
|
||||
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 = "<group>"; };
|
||||
9764CBD01D806AD800072D6A /* RefreshLibControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RefreshLibControl.swift; sourceTree = "<group>"; };
|
||||
@ -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;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user