mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-25 21:05:09 -04:00
Book detail view
include pid and reorder
This commit is contained in:
parent
a9abbbc797
commit
fcaaeed355
@ -23,6 +23,8 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate, DZN
|
||||
typealias Strings = LocalizedStrings.BookDetail
|
||||
|
||||
var book: Book?
|
||||
var sectionHeaders = [String?]()
|
||||
var sectionFooters = [String?]()
|
||||
var cellTitles = [[String]]()
|
||||
|
||||
override func viewDidLoad() {
|
||||
@ -43,12 +45,12 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate, DZN
|
||||
override func viewWillAppear(animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
configureViews()
|
||||
book?.downloadTask?.addObserver(self, forKeyPath: "stateRaw", options: .New, context: context)
|
||||
//book?.downloadTask?.addObserver(self, forKeyPath: "stateRaw", options: .New, context: context)
|
||||
}
|
||||
|
||||
override func viewWillDisappear(animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
book?.downloadTask?.removeObserver(self, forKeyPath: "stateRaw", context: context)
|
||||
//book?.downloadTask?.removeObserver(self, forKeyPath: "stateRaw", context: context)
|
||||
}
|
||||
|
||||
override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
|
||||
@ -76,7 +78,14 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate, DZN
|
||||
hasIndexLabel.hidden = false
|
||||
|
||||
// Generate table structure
|
||||
// Book desc
|
||||
sectionHeaders.append(nil)
|
||||
sectionFooters.append(book.desc)
|
||||
cellTitles.append([String]())
|
||||
|
||||
// Action Cells
|
||||
sectionHeaders.append(nil)
|
||||
sectionFooters.append(nil)
|
||||
if book.isLocal?.boolValue == false {
|
||||
if book.spaceState == .NotEnough {
|
||||
cellTitles.append([Strings.spaceNotEnough])
|
||||
@ -86,9 +95,27 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate, DZN
|
||||
} else {
|
||||
cellTitles.append([Strings.remove])
|
||||
}
|
||||
|
||||
// Book Info
|
||||
sectionHeaders.append(Strings.bookInfo)
|
||||
sectionFooters.append(nil)
|
||||
cellTitles.append([Strings.size, Strings.createDate, Strings.arcitleCount, Strings.language, Strings.creator, Strings.publisher])
|
||||
|
||||
if let _ = book.url { cellTitles.append([Strings.copyURL]) }
|
||||
// PID
|
||||
if let _ = book.pid {
|
||||
sectionHeaders.append(Strings.pid)
|
||||
sectionFooters.append(Strings.pidNote)
|
||||
cellTitles.append([Strings.pid])
|
||||
}
|
||||
|
||||
// URL
|
||||
if let _ = book.url {
|
||||
sectionHeaders.append(nil)
|
||||
sectionFooters.append(nil)
|
||||
cellTitles.append([Strings.copyURL])
|
||||
}
|
||||
|
||||
tableView.reloadEmptyDataSet()
|
||||
}
|
||||
|
||||
// MARK: - Delegates
|
||||
@ -155,6 +182,10 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate, DZN
|
||||
if book?.spaceState == .Caution { cell.button.tintColor = UIColor.orangeColor() }
|
||||
}
|
||||
return cell
|
||||
case Strings.pid:
|
||||
let cell = tableView.dequeueReusableCellWithIdentifier("BasicCell", forIndexPath: indexPath)
|
||||
cell.textLabel?.text = book?.pid
|
||||
return cell
|
||||
case Strings.copyURL:
|
||||
let cell = tableView.dequeueReusableCellWithIdentifier("CenterButtonCell", forIndexPath: indexPath) as! CenterButtonCell
|
||||
cell.button.setTitle(title, forState: .Normal)
|
||||
@ -184,23 +215,11 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate, DZN
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||
switch section {
|
||||
case 1:
|
||||
return Strings.download
|
||||
case 2:
|
||||
return Strings.bookInfo
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
return sectionHeaders[section]
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? {
|
||||
switch section {
|
||||
case 0:
|
||||
return book?.desc
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
return sectionFooters[section]
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) {
|
||||
@ -217,9 +236,11 @@ extension LocalizedStrings {
|
||||
static let noIndex = NSLocalizedString("No Index", comment: comment)
|
||||
static let noPic = NSLocalizedString("No Picture", comment: comment)
|
||||
|
||||
static let download = NSLocalizedString("Download", comment: comment)
|
||||
static let pid = NSLocalizedString("Persistent ID", comment: comment)
|
||||
static let bookInfo = NSLocalizedString("Book Info", comment: comment)
|
||||
|
||||
static let pidNote = NSLocalizedString("This ID does not change in different versions of the same book.", comment: comment)
|
||||
|
||||
static let downloadNow = NSLocalizedString("Download Now", comment: comment)
|
||||
static let spaceNotEnough = NSLocalizedString("Space Not Enough", comment: comment)
|
||||
static let pause = NSLocalizedString("Pause", comment: comment)
|
||||
|
@ -161,9 +161,9 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel
|
||||
self.refreshFetchedResultController()
|
||||
})
|
||||
}
|
||||
alert.preferredAction = action
|
||||
alert.addAction(action)
|
||||
alert.addAction(UIAlertAction(title: LocalizedStrings.Common.cancel, style: .Cancel, handler: nil))
|
||||
alert.preferredAction = action
|
||||
presentViewController(alert, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.8.74</string>
|
||||
<string>1.8.112</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11198.2" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="niz-KF-P8W">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A319" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="niz-KF-P8W">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
|
||||
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
|
||||
@ -21,7 +21,7 @@
|
||||
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="CVW-Rc-hA9" id="xiL-PL-4ko">
|
||||
<frame key="frameInset" width="375" height="43.5"/>
|
||||
<frame key="frameInset" width="375" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" minimumFontSize="8" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="epH-ai-QrA">
|
||||
@ -219,22 +219,39 @@
|
||||
</constraints>
|
||||
</view>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="BasicCell" textLabel="6tS-82-XO3" style="IBUITableViewCellStyleDefault" id="8cM-hK-Jlc">
|
||||
<rect key="frame" x="0.0" y="185" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="8cM-hK-Jlc" id="g3P-LY-Hiw">
|
||||
<frame key="frameInset" width="375" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="6tS-82-XO3">
|
||||
<frame key="frameInset" minX="15" width="345" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="RightDetailCell" textLabel="iyO-rf-lDN" detailTextLabel="iHv-oK-qrR" style="IBUITableViewCellStyleValue1" id="eB8-dt-BPR">
|
||||
<rect key="frame" x="0.0" y="184.5" width="375" height="44"/>
|
||||
<rect key="frame" x="0.0" y="229" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="eB8-dt-BPR" id="KR4-kV-SZd">
|
||||
<frame key="frameInset" width="375" height="43.5"/>
|
||||
<frame key="frameInset" width="375" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="iyO-rf-lDN">
|
||||
<frame key="frameInset" minX="15" minY="12" width="31.5" height="19.5"/>
|
||||
<frame key="frameInset" minX="15" minY="12" width="32" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="iHv-oK-qrR">
|
||||
<frame key="frameInset" minX="318.5" minY="12" width="41.5" height="19.5"/>
|
||||
<frame key="frameInset" minX="318" minY="12" width="42" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
@ -244,16 +261,13 @@
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="CenterButtonCell" id="B0D-Hu-sVM" customClass="CenterButtonCell" customModule="Kiwix" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="228.5" width="375" height="44"/>
|
||||
<rect key="frame" x="0.0" y="273" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="B0D-Hu-sVM" id="Fhf-jb-Urf">
|
||||
<frame key="frameInset" width="375" height="43.5"/>
|
||||
<frame key="frameInset" width="375" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="TLs-eg-B0R">
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="44" id="K1j-tL-2bu"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="15"/>
|
||||
<state key="normal" title="Button"/>
|
||||
<connections>
|
||||
@ -262,9 +276,9 @@
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottomMargin" secondItem="TLs-eg-B0R" secondAttribute="bottom" id="0Am-c4-o6J"/>
|
||||
<constraint firstItem="TLs-eg-B0R" firstAttribute="centerX" secondItem="Fhf-jb-Urf" secondAttribute="centerX" id="jDi-3Z-ZSt"/>
|
||||
<constraint firstItem="TLs-eg-B0R" firstAttribute="top" secondItem="Fhf-jb-Urf" secondAttribute="top" id="jGB-KT-vvT"/>
|
||||
<constraint firstAttribute="bottom" secondItem="TLs-eg-B0R" secondAttribute="bottom" id="lqB-8O-N7x"/>
|
||||
<constraint firstItem="TLs-eg-B0R" firstAttribute="top" secondItem="Fhf-jb-Urf" secondAttribute="topMargin" id="pp5-Yz-bo4"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
@ -272,10 +286,10 @@
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="TextSwitchCell" id="c4v-9p-eEF" customClass="TextSwitchCell" customModule="Kiwix" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="272.5" width="375" height="44"/>
|
||||
<rect key="frame" x="0.0" y="317" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="c4v-9p-eEF" id="Lt6-0C-r4i">
|
||||
<frame key="frameInset" width="375" height="43.5"/>
|
||||
<frame key="frameInset" width="375" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ksx-E1-lZ2">
|
||||
@ -352,10 +366,10 @@
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="82" id="ekT-ed-PU9" customClass="DownloadBookCell" customModule="Kiwix" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="92" width="1000" height="82"/>
|
||||
<rect key="frame" x="0.0" y="92" width="600" height="82"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ekT-ed-PU9" id="oM4-Hy-Mkf">
|
||||
<frame key="frameInset" width="1000" height="81.5"/>
|
||||
<frame key="frameInset" width="600" height="81"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" minimumFontSize="8" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Hji-3G-yaJ">
|
||||
@ -451,7 +465,7 @@
|
||||
<rect key="frame" x="0.0" y="92" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="nka-b0-ZmD" id="8e2-Je-FJO">
|
||||
<frame key="frameInset" width="375" height="43.5"/>
|
||||
<frame key="frameInset" width="375" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" minimumFontSize="8" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="oQE-dD-h38">
|
||||
@ -607,21 +621,21 @@
|
||||
</view>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" textLabel="qXz-1G-wA2" detailTextLabel="AMO-pu-z25" style="IBUITableViewCellStyleValue1" id="Zpf-Mi-m0A">
|
||||
<rect key="frame" x="0.0" y="109.5" width="375" height="44"/>
|
||||
<rect key="frame" x="0.0" y="110" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Zpf-Mi-m0A" id="S9T-Ce-Uax">
|
||||
<frame key="frameInset" width="375" height="43.5"/>
|
||||
<frame key="frameInset" width="375" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="qXz-1G-wA2">
|
||||
<frame key="frameInset" minX="15" minY="12" width="33.5" height="20.5"/>
|
||||
<frame key="frameInset" minX="15" minY="11" width="34" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="AMO-pu-z25">
|
||||
<frame key="frameInset" minX="316" minY="12" width="44" height="20.5"/>
|
||||
<frame key="frameInset" minX="316" minY="11" width="44" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.8.76</string>
|
||||
<string>1.8.114</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionMainStoryboard</key>
|
||||
|
Loading…
x
Reference in New Issue
Block a user