diff --git a/Kiwix-iOS/Controller/Library/BookDetailController.swift b/Kiwix-iOS/Controller/Library/BookDetailController.swift
index adfcd8e2..26920652 100644
--- a/Kiwix-iOS/Controller/Library/BookDetailController.swift
+++ b/Kiwix-iOS/Controller/Library/BookDetailController.swift
@@ -9,7 +9,7 @@
import UIKit
import DZNEmptyDataSet
-class BookDetailController: UITableViewController, CenterButtonCellDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate {
+class BookDetailController: UITableViewController, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate {
@IBOutlet weak var favIconImageView: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
@@ -123,44 +123,7 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate, DZN
cellTitles[1] = book.spaceState == .NotEnough ? [Strings.spaceNotEnough] : [Strings.downloadNow]
}
} else {
- cellTitles[1] = ["Cancel Download"]
- }
- }
-
- // MARK: - Delegates
-
- func buttonTapped(cell: CenterButtonCell) {
-
- guard let title = cell.button.titleLabel?.text,
- let book = book else {return}
-
- switch title {
- case Strings.downloadNow:
- func startDownload() {
- guard let download = DownloadBookOperation(bookID: book.id) else {return}
- Network.shared.queue.addOperation(download)
- }
-
- if book.spaceState == .Caution {
- let cancel = UIAlertAction(title: Strings.cancel, style: .Cancel, handler: nil)
- let download = UIAlertAction(title: Strings.SpaceAlert.downloadAnyway, style: .Destructive, handler: { (alert) in
- startDownload()
- })
- let alertController = UIAlertController(title: Strings.SpaceAlert.spaceAlert, message: Strings.SpaceAlert.message, preferredStyle: .Alert)
- [download, cancel].forEach({ alertController.addAction($0) })
- presentViewController(alertController, animated: true, completion: nil)
- } else {
- startDownload()
- }
- case Strings.copyURL:
- guard let url = book.url else {return}
- UIPasteboard.generalPasteboard().string = url.absoluteString
- let action = UIAlertAction(title: LocalizedStrings.Common.ok, style: .Cancel, handler: nil)
- let alertController = UIAlertController(title: Strings.CopyURLAlert.succeed, message: nil, preferredStyle: .Alert)
- alertController.addAction(action)
- presentViewController(alertController, animated: true, completion: nil)
- default:
- return
+ cellTitles[1] = [Strings.cancel]
}
}
@@ -177,18 +140,19 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate, DZN
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let title = cellTitles[indexPath.section][indexPath.row]
switch title {
- case Strings.downloadNow, Strings.spaceNotEnough, Strings.remove:
- let cell = tableView.dequeueReusableCellWithIdentifier("CenterButtonCell", forIndexPath: indexPath) as! CenterButtonCell
- cell.button.setTitle(title, forState: .Normal)
- cell.delegate = self
+ case Strings.downloadNow, Strings.spaceNotEnough, Strings.cancel, Strings.remove:
+ let cell = tableView.dequeueReusableCellWithIdentifier("CenterTextCell", forIndexPath: indexPath)
+ cell.textLabel?.text = title
switch title {
+ case Strings.downloadNow:
+ if book?.spaceState == .Caution {cell.textLabel?.textColor = UIColor.orangeColor()}
case Strings.spaceNotEnough:
- cell.button.tintColor = UIColor.grayColor()
- case Strings.remove:
- cell.button.tintColor = UIColor.redColor()
+ cell.textLabel?.textColor = UIColor.grayColor()
+ case Strings.cancel, Strings.remove:
+ cell.textLabel?.textColor = UIColor.redColor()
default:
- if book?.spaceState == .Caution { cell.button.tintColor = UIColor.orangeColor() }
+ break
}
return cell
case Strings.pid:
@@ -196,9 +160,8 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate, DZN
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)
- cell.delegate = self
+ let cell = tableView.dequeueReusableCellWithIdentifier("CenterTextCell", forIndexPath: indexPath)
+ cell.textLabel?.text = title
return cell
default:
let cell = tableView.dequeueReusableCellWithIdentifier("RightDetailCell", forIndexPath: indexPath)
@@ -231,10 +194,48 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate, DZN
return sectionFooters[section]
}
+ // MARK: - Table view delegate
+
override func tableView(tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) {
guard let view = view as? UITableViewHeaderFooterView where section == 0 else {return}
view.textLabel?.textAlignment = .Center
}
+
+ override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
+ tableView.deselectRowAtIndexPath(indexPath, animated: true)
+ guard let cell = tableView.cellForRowAtIndexPath(indexPath),
+ let title = cell.textLabel?.text,
+ let book = book else {return}
+ switch title {
+ case Strings.downloadNow:
+ func startDownload() {
+ guard let download = DownloadBookOperation(bookID: book.id) else {return}
+ Network.shared.queue.addOperation(download)
+ }
+
+ if book.spaceState == .Caution {
+ let cancel = UIAlertAction(title: Strings.cancel, style: .Cancel, handler: nil)
+ let download = UIAlertAction(title: Strings.SpaceAlert.downloadAnyway, style: .Destructive, handler: { (alert) in
+ startDownload()
+ })
+ let alertController = UIAlertController(title: Strings.SpaceAlert.spaceAlert, message: Strings.SpaceAlert.message, preferredStyle: .Alert)
+ [download, cancel].forEach({ alertController.addAction($0) })
+ presentViewController(alertController, animated: true, completion: nil)
+ } else {
+ startDownload()
+ }
+
+ case Strings.copyURL:
+ guard let url = book.url else {return}
+ UIPasteboard.generalPasteboard().string = url.absoluteString
+ let action = UIAlertAction(title: LocalizedStrings.Common.ok, style: .Cancel, handler: nil)
+ let alertController = UIAlertController(title: Strings.CopyURLAlert.succeed, message: nil, preferredStyle: .Alert)
+ alertController.addAction(action)
+ presentViewController(alertController, animated: true, completion: nil)
+ default:
+ return
+ }
+ }
}
extension LocalizedStrings {
diff --git a/Kiwix-iOS/Controller/Library/DownloadTasksController.swift b/Kiwix-iOS/Controller/Library/DownloadTasksController.swift
index e6fa3d0b..ad41388f 100644
--- a/Kiwix-iOS/Controller/Library/DownloadTasksController.swift
+++ b/Kiwix-iOS/Controller/Library/DownloadTasksController.swift
@@ -193,7 +193,6 @@ class DownloadTasksController: UIViewController, UITableViewDelegate, UITableVie
}
actions.insert(pause, atIndex: 0)
case .Paused:
-
if let book = downloadTask.book,
let resumeData = Preference.resumeData[book.id] {
let resume = UITableViewRowAction(style: .Normal, title: "Resume") { (action, indexPath) in
diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist
index 258c432c..8bd91af2 100644
--- a/Kiwix-iOS/Info.plist
+++ b/Kiwix-iOS/Info.plist
@@ -49,7 +49,7 @@
CFBundleVersion
- 1.8.434
+ 1.8.454
ITSAppUsesNonExemptEncryption
LSRequiresIPhoneOS
diff --git a/Kiwix-iOS/Storyboard/Library.storyboard b/Kiwix-iOS/Storyboard/Library.storyboard
index 64b86658..37f7fb4f 100644
--- a/Kiwix-iOS/Storyboard/Library.storyboard
+++ b/Kiwix-iOS/Storyboard/Library.storyboard
@@ -1,5 +1,5 @@
-
+
@@ -260,30 +260,22 @@
-
+
-
+
+
+
-
-
-
-
-
-
-
-
@@ -366,10 +358,10 @@
-
+
-
+