Download Controller

This commit is contained in:
Chris Li 2016-08-24 15:18:42 -04:00
parent 6fc9d1bc59
commit fdab1bdf1f
9 changed files with 85 additions and 29 deletions

View File

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "down-arrow.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -46,12 +46,13 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate {
hasIndexIndicator.backgroundColor = book.hasIndex ? AppColors.hasIndexTintColor : UIColor.lightGrayColor() hasIndexIndicator.backgroundColor = book.hasIndex ? AppColors.hasIndexTintColor : UIColor.lightGrayColor()
hasIndexLabel.text = book.hasIndex ? LocalizedStrings.BookDetail.hasIndex : LocalizedStrings.BookDetail.noIndex hasIndexLabel.text = book.hasIndex ? LocalizedStrings.BookDetail.hasIndex : LocalizedStrings.BookDetail.noIndex
cellTitles.append([String]())
if book.isLocal?.boolValue == false { if book.isLocal?.boolValue == false {
cellTitles.append([Strings.downloadNow, Strings.downloadSchedule]) cellTitles.append([Strings.downloadNow, Strings.downloadSchedule])
} else { } else {
cellTitles.append([Strings.remove]) cellTitles.append([Strings.remove])
} }
cellTitles.append([Strings.size, Strings.createDate, Strings.arcitleCount, Strings.creator, Strings.publisher]) cellTitles.append([Strings.size, Strings.createDate, Strings.arcitleCount, Strings.language, Strings.creator, Strings.publisher])
} }
// MARK: - Delegates // MARK: - Delegates
@ -80,6 +81,7 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate {
let cell = tableView.dequeueReusableCellWithIdentifier("CenterButtonCell", forIndexPath: indexPath) as! CenterButtonCell let cell = tableView.dequeueReusableCellWithIdentifier("CenterButtonCell", forIndexPath: indexPath) as! CenterButtonCell
cell.button.setTitle(title, forState: .Normal) cell.button.setTitle(title, forState: .Normal)
cell.delegate = self cell.delegate = self
if title == Strings.remove { cell.button.tintColor = UIColor.redColor() } if title == Strings.remove { cell.button.tintColor = UIColor.redColor() }
return cell return cell
default: default:
@ -91,7 +93,9 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate {
case Strings.createDate: case Strings.createDate:
cell.detailTextLabel?.text = book?.dateFormatted cell.detailTextLabel?.text = book?.dateFormatted
case Strings.arcitleCount: case Strings.arcitleCount:
cell.detailTextLabel?.text = book?.articleCountFormatted cell.detailTextLabel?.text = book?.articleCountString
case Strings.language:
cell.detailTextLabel?.text = book?.language?.nameInCurrentLocale
case Strings.creator: case Strings.creator:
cell.detailTextLabel?.text = book?.creator cell.detailTextLabel?.text = book?.creator
case Strings.publisher: case Strings.publisher:
@ -109,30 +113,30 @@ class BookDetailController: UITableViewController, CenterButtonCellDelegate {
} }
// override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
// switch section { switch section {
// case 0: case 1:
// return "You probably already know that Facebook shows you ads based on what it thinks you like and dislike, but you might not be aware that it also labels your political preferences even if you don't state them yourself. " return Strings.download
// case 1: case 2:
// return NSLocalizedString("Book Info", comment: LocalizedStrings.BookDetail.comment) return Strings.bookInfo
// default: default:
// return nil return nil
// } }
// } }
// override func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { override func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? {
// guard section == 0 else {return nil} switch section {
// let button = UIButton() case 0:
// button.titleLabel?.font = UIFont.systemFontOfSize(12.0) return book?.desc
// button.tintColor = UIColor.greenColor() default:
// button.setTitle("What is this?", forState: .Normal) return nil
// return button }
// } }
// override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { override func tableView(tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) {
// if section == 0 {return 25.0} guard let view = view as? UITableViewHeaderFooterView where section == 0 else {return}
// return super.tableView(tableView, heightForHeaderInSection: section) view.textLabel?.textAlignment = .Center
// } }
} }
extension LocalizedStrings { extension LocalizedStrings {
@ -143,6 +147,9 @@ extension LocalizedStrings {
static let noIndex = NSLocalizedString("No Index", 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 bookInfo = NSLocalizedString("Book Info", comment: comment)
static let downloadNow = NSLocalizedString("Download Now", comment: comment) static let downloadNow = NSLocalizedString("Download Now", comment: comment)
static let downloadSchedule = NSLocalizedString("Schedule Download", comment: comment) static let downloadSchedule = NSLocalizedString("Schedule Download", comment: comment)
static let remove = NSLocalizedString("Remove", comment: comment) static let remove = NSLocalizedString("Remove", comment: comment)
@ -150,7 +157,7 @@ extension LocalizedStrings {
static let size = NSLocalizedString("Size", comment: comment) static let size = NSLocalizedString("Size", comment: comment)
static let createDate = NSLocalizedString("Creation Date", comment: comment) static let createDate = NSLocalizedString("Creation Date", comment: comment)
static let arcitleCount = NSLocalizedString("Article Count", comment: comment) static let arcitleCount = NSLocalizedString("Article Count", 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)
} }

View File

@ -0,0 +1,14 @@
//
// DownloadController.swift
// Kiwix
//
// Created by Chris Li on 8/24/16.
// Copyright © 2016 Chris. All rights reserved.
//
import UIKit
class DownloadController: UITableViewController {
}

View File

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

View File

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

View File

@ -185,6 +185,7 @@
97D452BC1D16FF010033666F /* RecentSearchCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D452BB1D16FF010033666F /* RecentSearchCVC.swift */; }; 97D452BC1D16FF010033666F /* RecentSearchCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D452BB1D16FF010033666F /* RecentSearchCVC.swift */; };
97D452BE1D1723FF0033666F /* CollectionViewCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D452BD1D1723FF0033666F /* CollectionViewCells.swift */; }; 97D452BE1D1723FF0033666F /* CollectionViewCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D452BD1D1723FF0033666F /* CollectionViewCells.swift */; };
97D55EF61D2075180081B523 /* TableOfContentsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D55EF51D2075180081B523 /* TableOfContentsController.swift */; }; 97D55EF61D2075180081B523 /* TableOfContentsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D55EF51D2075180081B523 /* TableOfContentsController.swift */; };
97D6811B1D6E2A7100E5FA99 /* DownloadController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D6811A1D6E2A7100E5FA99 /* DownloadController.swift */; };
97DB65DA1D4576B600A2CC42 /* BookmarkWidgetCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97DB65D91D4576B600A2CC42 /* BookmarkWidgetCell.swift */; }; 97DB65DA1D4576B600A2CC42 /* BookmarkWidgetCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97DB65D91D4576B600A2CC42 /* BookmarkWidgetCell.swift */; };
97E60A021D10423A00EBCB9D /* ShadowViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E60A011D10423A00EBCB9D /* ShadowViews.swift */; }; 97E60A021D10423A00EBCB9D /* ShadowViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E60A011D10423A00EBCB9D /* ShadowViews.swift */; };
97E60A061D10504000EBCB9D /* LibraryBackupTBVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E60A051D10504000EBCB9D /* LibraryBackupTBVC.swift */; }; 97E60A061D10504000EBCB9D /* LibraryBackupTBVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97E60A051D10504000EBCB9D /* LibraryBackupTBVC.swift */; };
@ -441,6 +442,7 @@
97D452C01D1871E70033666F /* SearchLocalBooksCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SearchLocalBooksCVC.swift; path = "Kiwix-iOS/Controller/Search/SearchLocalBooksCVC.swift"; sourceTree = SOURCE_ROOT; }; 97D452C01D1871E70033666F /* SearchLocalBooksCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SearchLocalBooksCVC.swift; path = "Kiwix-iOS/Controller/Search/SearchLocalBooksCVC.swift"; sourceTree = SOURCE_ROOT; };
97D452C11D1871E70033666F /* SearchTabController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SearchTabController.swift; path = "Kiwix-iOS/Controller/Search/SearchTabController.swift"; sourceTree = SOURCE_ROOT; }; 97D452C11D1871E70033666F /* SearchTabController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SearchTabController.swift; path = "Kiwix-iOS/Controller/Search/SearchTabController.swift"; sourceTree = SOURCE_ROOT; };
97D55EF51D2075180081B523 /* TableOfContentsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TableOfContentsController.swift; path = "Kiwix-iOS/Controller/TableOfContentsController.swift"; sourceTree = SOURCE_ROOT; }; 97D55EF51D2075180081B523 /* TableOfContentsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TableOfContentsController.swift; path = "Kiwix-iOS/Controller/TableOfContentsController.swift"; sourceTree = SOURCE_ROOT; };
97D6811A1D6E2A7100E5FA99 /* DownloadController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DownloadController.swift; sourceTree = "<group>"; };
97DB65D91D4576B600A2CC42 /* BookmarkWidgetCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkWidgetCell.swift; sourceTree = "<group>"; }; 97DB65D91D4576B600A2CC42 /* BookmarkWidgetCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkWidgetCell.swift; sourceTree = "<group>"; };
97E609F01D103DED00EBCB9D /* NotificationCenter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NotificationCenter.framework; path = System/Library/Frameworks/NotificationCenter.framework; sourceTree = SDKROOT; }; 97E609F01D103DED00EBCB9D /* NotificationCenter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NotificationCenter.framework; path = System/Library/Frameworks/NotificationCenter.framework; sourceTree = SDKROOT; };
97E60A011D10423A00EBCB9D /* ShadowViews.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShadowViews.swift; sourceTree = "<group>"; }; 97E60A011D10423A00EBCB9D /* ShadowViews.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShadowViews.swift; sourceTree = "<group>"; };
@ -1060,9 +1062,10 @@
97C005D71D64B99E004352E8 /* LibrarySplitViewController.swift */, 97C005D71D64B99E004352E8 /* LibrarySplitViewController.swift */,
97C005DB1D64BEFE004352E8 /* CloudBooksController.swift */, 97C005DB1D64BEFE004352E8 /* CloudBooksController.swift */,
97A8AD831D6C951A00584ED1 /* LocalBooksController.swift */, 97A8AD831D6C951A00584ED1 /* LocalBooksController.swift */,
97D6811A1D6E2A7100E5FA99 /* DownloadController.swift */,
9763275D1D64FE0F0034F120 /* BookDetailController.swift */, 9763275D1D64FE0F0034F120 /* BookDetailController.swift */,
97A8AD861D6CF38000584ED1 /* EmptyTableConfigExtension.swift */,
970722A91D6B4D1700A45620 /* LanguageFilterController.swift */, 970722A91D6B4D1700A45620 /* LanguageFilterController.swift */,
97A8AD861D6CF38000584ED1 /* EmptyTableConfigExtension.swift */,
); );
path = Library; path = Library;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1690,6 +1693,7 @@
971A10401D022C42007FC62C /* LibraryUseCellularDataTBVC.swift in Sources */, 971A10401D022C42007FC62C /* LibraryUseCellularDataTBVC.swift in Sources */,
977998761C1E0B7900B1DD5E /* DownloadTask.swift in Sources */, 977998761C1E0B7900B1DD5E /* DownloadTask.swift in Sources */,
9752279C1D020C00001D1DDE /* pathTools.cpp in Sources */, 9752279C1D020C00001D1DDE /* pathTools.cpp in Sources */,
97D6811B1D6E2A7100E5FA99 /* DownloadController.swift in Sources */,
971A10381D022C15007FC62C /* WebViewController.swift in Sources */, 971A10381D022C15007FC62C /* WebViewController.swift in Sources */,
971046321D19B96E002141C0 /* XapianSearcher.mm in Sources */, 971046321D19B96E002141C0 /* XapianSearcher.mm in Sources */,
973C8D5C1C25F945007272F9 /* Preference.swift in Sources */, 973C8D5C1C25F945007272F9 /* Preference.swift in Sources */,

View File

@ -117,6 +117,10 @@ class Book: NSManagedObject {
} }
var articleCountFormatted: String? { var articleCountFormatted: String? {
return articleCountString + (articleCount > 1 ? " articles" : " article")
}
var articleCountString: String {
func formattedNumberStringFromDouble(num: Double) -> String { func formattedNumberStringFromDouble(num: Double) -> String {
let sign = ((num < 0) ? "-" : "" ) let sign = ((num < 0) ? "-" : "" )
let abs = fabs(num) let abs = fabs(num)
@ -132,7 +136,7 @@ class Book: NSManagedObject {
let roundedNum: Double = round(10 * abs / pow(1000.0,Double(exp))) / 10; let roundedNum: Double = round(10 * abs / pow(1000.0,Double(exp))) / 10;
return "\(sign)\(roundedNum)\(units[exp-1])" return "\(sign)\(roundedNum)\(units[exp-1])"
} }
return formattedNumberStringFromDouble(Double(articleCount)) + (articleCount >= 1 ? " articles" : " article") return formattedNumberStringFromDouble(Double(articleCount))
} }
// MARK: - Description Label // MARK: - Description Label