diff --git a/Kiwix-iOS/Controller/Library/LibraryBooksController.swift b/Kiwix-iOS/Controller/Library/LibraryBooksController.swift
index f1bcdbb3..f0f4b1be 100644
--- a/Kiwix-iOS/Controller/Library/LibraryBooksController.swift
+++ b/Kiwix-iOS/Controller/Library/LibraryBooksController.swift
@@ -54,8 +54,8 @@ class LibraryBooksController: CoreDataCollectionBaseController, UICollectionView
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
- configureItemWidth(collectionViewWidth: collectionView.frame.width)
- collectionView.collectionViewLayout.invalidateLayout()
+ configureItemWidth(collectionViewWidth: size.width)
+ collectionView?.collectionViewLayout.invalidateLayout()
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
diff --git a/Kiwix-iOS/Controller/Library/LibraryDownloadController.swift b/Kiwix-iOS/Controller/Library/LibraryDownloadController.swift
index 803f4462..7ba789e7 100644
--- a/Kiwix-iOS/Controller/Library/LibraryDownloadController.swift
+++ b/Kiwix-iOS/Controller/Library/LibraryDownloadController.swift
@@ -10,9 +10,12 @@ import UIKit
import CoreData
class LibraryDownloadController: CoreDataTableBaseController, UITableViewDelegate, UITableViewDataSource {
+
+ let progressFormatter = Progress()
override func viewDidLoad() {
super.viewDidLoad()
+ progressFormatter.kind = .file
}
@IBAction func dismissButtonTapped(_ sender: UIBarButtonItem) {
@@ -35,10 +38,18 @@ class LibraryDownloadController: CoreDataTableBaseController, UITableViewDelegat
}
override func configureCell(_ cell: UITableViewCell, atIndexPath indexPath: IndexPath) {
+ guard let cell = cell as? DownloadTaskCell else {return}
+
let downloadTask = fetchedResultController.object(at: indexPath)
- let book = downloadTask.book
- cell.textLabel?.text = book?.title
- cell.detailTextLabel?.text = "\(downloadTask.totalBytesWritten)"
+ guard let book = downloadTask.book else {return}
+
+ progressFormatter.completedUnitCount = downloadTask.totalBytesWritten
+ progressFormatter.totalUnitCount = book.fileSize
+
+ if let data = book.favIcon {cell.thumbImageView.image = UIImage(data: data)}
+ cell.titleLabel.text = book.title
+ cell.subtitleLabel.text = progressFormatter.localizedAdditionalDescription
+ cell.progressView.setProgress(Float(downloadTask.totalBytesWritten) / Float(book.fileSize), animated: true)
}
// MARK: - NSFetchedResultsController
diff --git a/Kiwix-iOS/Storyboard/Library.storyboard b/Kiwix-iOS/Storyboard/Library.storyboard
index dc059f24..79aaa041 100644
--- a/Kiwix-iOS/Storyboard/Library.storyboard
+++ b/Kiwix-iOS/Storyboard/Library.storyboard
@@ -157,7 +157,7 @@
-
+
@@ -311,52 +311,74 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
-
-
-
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
@@ -372,7 +394,7 @@
-
+
diff --git a/Kiwix-iOS/View/Cells.swift b/Kiwix-iOS/View/Cells.swift
index ce19a02a..165bcdc7 100644
--- a/Kiwix-iOS/View/Cells.swift
+++ b/Kiwix-iOS/View/Cells.swift
@@ -175,6 +175,7 @@ class LibraryCollectionHeader: UICollectionReusableView {
+
// MARK: - last time refactor
// MARK: - Bookmark Cell
diff --git a/Kiwix-iOS/View/LibraryCells.swift b/Kiwix-iOS/View/LibraryCells.swift
new file mode 100644
index 00000000..4d7b4378
--- /dev/null
+++ b/Kiwix-iOS/View/LibraryCells.swift
@@ -0,0 +1,16 @@
+//
+// LibraryCells.swift
+// Kiwix
+//
+// Created by Chris Li on 1/26/17.
+// Copyright © 2017 Chris Li. All rights reserved.
+//
+
+import UIKit
+
+class DownloadTaskCell: UITableViewCell {
+ @IBOutlet weak var thumbImageView: UIImageView!
+ @IBOutlet weak var titleLabel: UILabel!
+ @IBOutlet weak var subtitleLabel: UILabel!
+ @IBOutlet weak var progressView: UIProgressView!
+}
diff --git a/Kiwix.xcodeproj/project.pbxproj b/Kiwix.xcodeproj/project.pbxproj
index 69401177..97117cd7 100644
--- a/Kiwix.xcodeproj/project.pbxproj
+++ b/Kiwix.xcodeproj/project.pbxproj
@@ -76,6 +76,7 @@
9779C31E1D4575AE0064CC8E /* Bookmarks.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 9779C3131D4575AD0064CC8E /* Bookmarks.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
977A458C1E14EA140089C596 /* Cloud.swift in Sources */ = {isa = PBXBuildFile; fileRef = 977A458B1E14EA140089C596 /* Cloud.swift */; };
977AE7F91DD8F22400F1E581 /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 971A102A1D022AD5007FC62C /* SearchBar.swift */; };
+ 977B121C1E3A5E8D00981890 /* LibraryCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = 977B121B1E3A5E8D00981890 /* LibraryCells.swift */; };
977B954D1DD4C40400F6F62B /* ScanLocalBook.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D6811E1D6F70AC00E5FA99 /* ScanLocalBook.swift */; };
97A08C151DD263B90070D0E4 /* Book.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97D681341D6F711A00E5FA99 /* Book.swift */; };
97A127C91D777CF100FB204D /* RecentSearchController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97A127C51D777CF100FB204D /* RecentSearchController.swift */; };
@@ -236,6 +237,7 @@
9779C3161D4575AE0064CC8E /* TodayViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayViewController.swift; sourceTree = ""; };
9779C31B1D4575AE0064CC8E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
977A458B1E14EA140089C596 /* Cloud.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cloud.swift; sourceTree = ""; };
+ 977B121B1E3A5E8D00981890 /* LibraryCells.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LibraryCells.swift; sourceTree = ""; };
9788419C1DA2FF2A00D22D3C /* MainInterface.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = MainInterface.storyboard; sourceTree = ""; };
97A127C51D777CF100FB204D /* RecentSearchController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecentSearchController.swift; sourceTree = ""; };
97A127C61D777CF100FB204D /* SearchScopeAndHistoryController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchScopeAndHistoryController.swift; sourceTree = ""; };
@@ -442,6 +444,7 @@
children = (
971A10241D022AD5007FC62C /* BarButtonItems.swift */,
971A10261D022AD5007FC62C /* Cells.swift */,
+ 977B121B1E3A5E8D00981890 /* LibraryCells.swift */,
971A10271D022AD5007FC62C /* Logo.swift */,
9764CBD01D806AD800072D6A /* RefreshLibControl.swift */,
971A102A1D022AD5007FC62C /* SearchBar.swift */,
@@ -1087,6 +1090,7 @@
972F81571DDBFC79008D7289 /* Search.swift in Sources */,
970E7F831DA0305000741290 /* WelcomeController.swift in Sources */,
97A1FD3B1D6F724E00A80EE2 /* stringTools.cpp in Sources */,
+ 977B121C1E3A5E8D00981890 /* LibraryCells.swift in Sources */,
970E7F741D9DB0FC00741290 /* 1.8.xcmappingmodel in Sources */,
977A458C1E14EA140089C596 /* Cloud.swift in Sources */,
97599AA21E26D3B000BA15EF /* BookmarkBooksController.swift in Sources */,