update book detail controller

This commit is contained in:
Chris Li 2016-09-27 17:23:15 -04:00
parent 380f740bfc
commit f49ffb5259
5 changed files with 31 additions and 50 deletions

View File

@ -17,8 +17,6 @@ class BookDetailController: UITableViewController, DZNEmptyDataSetSource, DZNEmp
@IBOutlet weak var hasPicIndicator: UILabel! @IBOutlet weak var hasPicIndicator: UILabel!
@IBOutlet weak var hasPicLabel: UILabel! @IBOutlet weak var hasPicLabel: UILabel!
@IBOutlet weak var hasIndexIndicator: UILabel!
@IBOutlet weak var hasIndexLabel: UILabel!
private(set) var context: UnsafeMutablePointer<Void> = nil private(set) var context: UnsafeMutablePointer<Void> = nil
@ -38,9 +36,7 @@ class BookDetailController: UITableViewController, DZNEmptyDataSetSource, DZNEmp
tableView.rowHeight = UITableViewAutomaticDimension tableView.rowHeight = UITableViewAutomaticDimension
hasPicIndicator.layer.cornerRadius = 2.0 hasPicIndicator.layer.cornerRadius = 2.0
hasIndexIndicator.layer.cornerRadius = 2.0
hasPicIndicator.layer.masksToBounds = true hasPicIndicator.layer.masksToBounds = true
hasIndexIndicator.layer.masksToBounds = true
} }
override func viewWillAppear(animated: Bool) { override func viewWillAppear(animated: Bool) {
@ -74,13 +70,8 @@ class BookDetailController: UITableViewController, DZNEmptyDataSetSource, DZNEmp
func configureIndicators(with book: Book) { func configureIndicators(with book: Book) {
hasPicIndicator.backgroundColor = book.hasPic ? AppColors.hasPicTintColor : UIColor.lightGrayColor() hasPicIndicator.backgroundColor = book.hasPic ? AppColors.hasPicTintColor : UIColor.lightGrayColor()
hasPicLabel.text = book.hasPic ? LocalizedStrings.hasPic : LocalizedStrings.noPic hasPicLabel.text = book.hasPic ? LocalizedStrings.hasPic : LocalizedStrings.noPic
hasIndexIndicator.backgroundColor = book.hasIndex ? AppColors.hasIndexTintColor : UIColor.lightGrayColor()
hasIndexLabel.text = book.hasIndex ? LocalizedStrings.hasIndex : LocalizedStrings.noIndex
hasPicIndicator.hidden = false hasPicIndicator.hidden = false
hasPicLabel.hidden = false hasPicLabel.hidden = false
hasIndexIndicator.hidden = false
hasIndexLabel.hidden = false
} }
func configureDescriptionSection(with book: Book) { func configureDescriptionSection(with book: Book) {
@ -123,14 +114,18 @@ class BookDetailController: UITableViewController, DZNEmptyDataSetSource, DZNEmp
func configureBookInfoSection(with book: Book) { func configureBookInfoSection(with book: Book) {
sectionHeaders.append(LocalizedStrings.bookInfo) sectionHeaders.append(LocalizedStrings.bookInfo)
sectionFooters.append(nil) sectionFooters.append(nil)
cellTitles.append([ var titles = [
LocalizedStrings.size, LocalizedStrings.size,
LocalizedStrings.createDate, LocalizedStrings.createDate,
LocalizedStrings.arcitleCount, LocalizedStrings.arcitleCount,
LocalizedStrings.language, LocalizedStrings.language,
LocalizedStrings.creator, LocalizedStrings.creator,
LocalizedStrings.publisher LocalizedStrings.publisher,
]) ]
if let _ = ZimMultiReader.shared.readers[book.id] {
titles.append(LocalizedStrings.index)
}
cellTitles.append(titles)
} }
func configurePIDSection(with book: Book) { func configurePIDSection(with book: Book) {
@ -217,6 +212,19 @@ class BookDetailController: UITableViewController, DZNEmptyDataSetSource, DZNEmp
cell.detailTextLabel?.text = book?.creator cell.detailTextLabel?.text = book?.creator
case LocalizedStrings.publisher: case LocalizedStrings.publisher:
cell.detailTextLabel?.text = book?.publisher cell.detailTextLabel?.text = book?.publisher
case LocalizedStrings.index:
guard let book = book, let reader = ZimMultiReader.shared.readers[book.id] else {break}
cell.detailTextLabel?.text = {
if reader.hasIndex() {
if reader.idxFolderURL != nil {
return LocalizedStrings.external
} else {
return LocalizedStrings.embedded
}
} else {
return LocalizedStrings.none
}
}()
default: default:
break break
} }
@ -273,9 +281,7 @@ class BookDetailController: UITableViewController, DZNEmptyDataSetSource, DZNEmp
class LocalizedStrings { class LocalizedStrings {
private static let comment = "Library, Book Detail" private static let comment = "Library, Book Detail"
static let hasIndex = NSLocalizedString("Index", comment: comment)
static let hasPic = NSLocalizedString("Pictures", comment: comment) static let hasPic = NSLocalizedString("Pictures", comment: comment)
static let noIndex = NSLocalizedString("No Index", comment: comment)
static let noPic = NSLocalizedString("No Picture", comment: comment) static let noPic = NSLocalizedString("No Picture", comment: comment)
static let download = NSLocalizedString("Download", comment: comment) static let download = NSLocalizedString("Download", comment: comment)
@ -295,6 +301,11 @@ class BookDetailController: UITableViewController, DZNEmptyDataSetSource, DZNEmp
static let language = NSLocalizedString("Language", comment: comment) static let language = NSLocalizedString("Language", comment: comment)
static let creator = NSLocalizedString("Creator", comment: comment) static let creator = NSLocalizedString("Creator", comment: comment)
static let publisher = NSLocalizedString("Publisher", comment: comment) static let publisher = NSLocalizedString("Publisher", comment: comment)
static let index = NSLocalizedString("Index", comment: comment)
static let none = NSLocalizedString("None", comment: comment)
static let embedded = NSLocalizedString("Embedded", comment: comment)
static let external = NSLocalizedString("External", comment: comment)
static let pid = NSLocalizedString("Persistent ID", comment: comment) static let pid = NSLocalizedString("Persistent ID", comment: comment)
static let pidNote = NSLocalizedString("This ID does not change in different versions of the same book.", comment: comment) static let pidNote = NSLocalizedString("This ID does not change in different versions of the same book.", comment: comment)

View File

@ -49,7 +49,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.8.1211</string> <string>1.8.1249</string>
<key>ITSAppUsesNonExemptEncryption</key> <key>ITSAppUsesNonExemptEncryption</key>
<false/> <false/>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>

View File

@ -155,13 +155,6 @@
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FxJ-Aa-5Pk">
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="13" id="JEt-Ru-hK6"/>
<constraint firstAttribute="width" constant="10" id="gY9-B0-Fnc"/>
</constraints>
</view>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="P" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HJc-XE-GVe"> <label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="P" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HJc-XE-GVe">
<color key="backgroundColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints> <constraints>
@ -177,21 +170,6 @@
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="I" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JQU-Gb-xqS">
<color key="backgroundColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="13" id="Vas-0R-Wil"/>
<constraint firstAttribute="width" constant="13" id="rIh-7j-6mY"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yJh-4P-l8s">
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="vSn-bw-OUc"> <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="vSn-bw-OUc">
<constraints> <constraints>
<constraint firstAttribute="width" constant="44" id="9k1-yP-9Cx"/> <constraint firstAttribute="width" constant="44" id="9k1-yP-9Cx"/>
@ -201,21 +179,15 @@
</subviews> </subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints> <constraints>
<constraint firstItem="FxJ-Aa-5Pk" firstAttribute="leading" secondItem="fEt-eR-ago" secondAttribute="trailing" constant="2" id="2yd-GZ-OCp"/>
<constraint firstAttribute="trailing" secondItem="4e2-XW-fS5" secondAttribute="trailing" constant="60" id="5RV-Re-G6u"/> <constraint firstAttribute="trailing" secondItem="4e2-XW-fS5" secondAttribute="trailing" constant="60" id="5RV-Re-G6u"/>
<constraint firstItem="FxJ-Aa-5Pk" firstAttribute="top" secondItem="4e2-XW-fS5" secondAttribute="bottom" constant="4" id="71o-Ca-P9X"/>
<constraint firstItem="JQU-Gb-xqS" firstAttribute="centerY" secondItem="FxJ-Aa-5Pk" secondAttribute="centerY" id="7Ll-MR-EtC"/>
<constraint firstItem="4e2-XW-fS5" firstAttribute="leading" secondItem="vSn-bw-OUc" secondAttribute="trailing" constant="8" id="C3D-hA-EFf"/> <constraint firstItem="4e2-XW-fS5" firstAttribute="leading" secondItem="vSn-bw-OUc" secondAttribute="trailing" constant="8" id="C3D-hA-EFf"/>
<constraint firstItem="fEt-eR-ago" firstAttribute="leading" secondItem="HJc-XE-GVe" secondAttribute="trailing" constant="2.5" id="Sp7-bB-IwY"/> <constraint firstItem="fEt-eR-ago" firstAttribute="leading" secondItem="HJc-XE-GVe" secondAttribute="trailing" constant="2.5" id="Sp7-bB-IwY"/>
<constraint firstItem="fEt-eR-ago" firstAttribute="centerY" secondItem="FxJ-Aa-5Pk" secondAttribute="centerY" id="edK-jm-Q1f"/>
<constraint firstItem="yJh-4P-l8s" firstAttribute="centerY" secondItem="JQU-Gb-xqS" secondAttribute="centerY" id="fnQ-CU-vOb"/>
<constraint firstItem="HJc-XE-GVe" firstAttribute="centerY" secondItem="fEt-eR-ago" secondAttribute="centerY" id="lm2-XF-U29"/> <constraint firstItem="HJc-XE-GVe" firstAttribute="centerY" secondItem="fEt-eR-ago" secondAttribute="centerY" id="lm2-XF-U29"/>
<constraint firstItem="JQU-Gb-xqS" firstAttribute="leading" secondItem="FxJ-Aa-5Pk" secondAttribute="trailing" constant="2" id="naO-NP-qyM"/> <constraint firstItem="fEt-eR-ago" firstAttribute="top" secondItem="4e2-XW-fS5" secondAttribute="bottom" constant="2" id="mty-r0-zh5"/>
<constraint firstItem="4e2-XW-fS5" firstAttribute="top" secondItem="xW2-eb-wOa" secondAttribute="top" constant="16" id="qmA-Nb-RFY"/> <constraint firstItem="4e2-XW-fS5" firstAttribute="top" secondItem="xW2-eb-wOa" secondAttribute="top" constant="16" id="qmA-Nb-RFY"/>
<constraint firstItem="vSn-bw-OUc" firstAttribute="leading" secondItem="xW2-eb-wOa" secondAttribute="leading" constant="8" id="rOL-t3-qNG"/> <constraint firstItem="vSn-bw-OUc" firstAttribute="leading" secondItem="xW2-eb-wOa" secondAttribute="leading" constant="8" id="rOL-t3-qNG"/>
<constraint firstItem="yJh-4P-l8s" firstAttribute="leading" secondItem="JQU-Gb-xqS" secondAttribute="trailing" constant="2" id="s0x-bK-qks"/>
<constraint firstItem="vSn-bw-OUc" firstAttribute="top" secondItem="xW2-eb-wOa" secondAttribute="top" constant="20" id="ubP-iG-piZ"/> <constraint firstItem="vSn-bw-OUc" firstAttribute="top" secondItem="xW2-eb-wOa" secondAttribute="top" constant="20" id="ubP-iG-piZ"/>
<constraint firstItem="FxJ-Aa-5Pk" firstAttribute="centerX" secondItem="xW2-eb-wOa" secondAttribute="centerX" constant="10" id="wDl-Hb-oK4"/> <constraint firstItem="fEt-eR-ago" firstAttribute="centerX" secondItem="xW2-eb-wOa" secondAttribute="centerX" constant="6" id="z11-dR-UXi"/>
</constraints> </constraints>
</view> </view>
<prototypes> <prototypes>
@ -337,8 +309,6 @@
<navigationItem key="navigationItem" id="BcQ-LZ-SEM"/> <navigationItem key="navigationItem" id="BcQ-LZ-SEM"/>
<connections> <connections>
<outlet property="favIconImageView" destination="vSn-bw-OUc" id="Bp4-vZ-ArU"/> <outlet property="favIconImageView" destination="vSn-bw-OUc" id="Bp4-vZ-ArU"/>
<outlet property="hasIndexIndicator" destination="JQU-Gb-xqS" id="XqK-s5-UXe"/>
<outlet property="hasIndexLabel" destination="yJh-4P-l8s" id="u74-JG-tnh"/>
<outlet property="hasPicIndicator" destination="HJc-XE-GVe" id="nXH-vm-kZ2"/> <outlet property="hasPicIndicator" destination="HJc-XE-GVe" id="nXH-vm-kZ2"/>
<outlet property="hasPicLabel" destination="fEt-eR-ago" id="QVd-5h-ouQ"/> <outlet property="hasPicLabel" destination="fEt-eR-ago" id="QVd-5h-ouQ"/>
<outlet property="titleLabel" destination="4e2-XW-fS5" id="fQS-5f-4VT"/> <outlet property="titleLabel" destination="4e2-XW-fS5" id="fQS-5f-4VT"/>

View File

@ -21,7 +21,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.8.1215</string> <string>1.8.1253</string>
<key>NSExtension</key> <key>NSExtension</key>
<dict> <dict>
<key>NSExtensionMainStoryboard</key> <key>NSExtensionMainStoryboard</key>

View File

@ -56,7 +56,7 @@
moduleName = "Kiwix" moduleName = "Kiwix"
usesParentBreakpointCondition = "Yes" usesParentBreakpointCondition = "Yes"
urlString = "file:///Volumes/Data/Developer/Kiwix/Kiwix/Operations/BookmarkMigrationOperation.swift" urlString = "file:///Volumes/Data/Developer/Kiwix/Kiwix/Operations/BookmarkMigrationOperation.swift"
timestampString = "496693865.757662" timestampString = "496704126.923131"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "27" startingLineNumber = "27"
@ -71,7 +71,7 @@
moduleName = "Kiwix" moduleName = "Kiwix"
usesParentBreakpointCondition = "Yes" usesParentBreakpointCondition = "Yes"
urlString = "file:///Volumes/Data/Developer/Kiwix/Kiwix/Operations/BookmarkMigrationOperation.swift" urlString = "file:///Volumes/Data/Developer/Kiwix/Kiwix/Operations/BookmarkMigrationOperation.swift"
timestampString = "496693865.758711" timestampString = "496704126.924306"
startingColumnNumber = "9223372036854775807" startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "27" startingLineNumber = "27"