mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-27 05:49:25 -04:00
Download task controller
This commit is contained in:
parent
f1fccd37fb
commit
8864dbbf44
@ -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?) {
|
||||
|
@ -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
|
||||
|
@ -157,7 +157,7 @@
|
||||
</barButtonItem>
|
||||
</navigationItem>
|
||||
<connections>
|
||||
<outlet property="collectionView" destination="UY0-46-c3y" id="lFH-jM-jh7"/>
|
||||
<outlet property="collectionView" destination="UY0-46-c3y" id="ki9-ID-J18"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="BWN-YP-64P" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
@ -311,52 +311,74 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="VO0-cd-Axb">
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="60" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="prU-fs-X0V">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<subviews>
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="prU-fs-X0V">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" textLabel="0az-To-29T" detailTextLabel="P8A-Na-1yb" style="IBUITableViewCellStyleValue1" id="3r6-eO-Iy1">
|
||||
<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="3r6-eO-Iy1" id="nVN-8L-w1D">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="0az-To-29T">
|
||||
<rect key="frame" x="15" y="12" width="33.5" height="20.5"/>
|
||||
<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="P8A-Na-1yb">
|
||||
<rect key="frame" x="316" y="12" width="44" height="20.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="56" id="3r6-eO-Iy1" customClass="DownloadTaskCell" customModule="Kiwix" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="28" width="375" height="56"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="3r6-eO-Iy1" id="nVN-8L-w1D">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="55.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="GhC-S8-4Ak">
|
||||
<rect key="frame" x="8" y="6" width="44" height="44"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="44" id="pvZ-WG-KsC"/>
|
||||
<constraint firstAttribute="width" constant="44" id="sD0-cc-kIz"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Zkf-Od-qYs">
|
||||
<rect key="frame" x="60" y="8" width="307" height="21"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="bDK-ON-vzl">
|
||||
<rect key="frame" x="60" y="31" width="307" height="2"/>
|
||||
</progressView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kV6-Lt-E6s">
|
||||
<rect key="frame" x="60" y="35" width="307" height="15"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="GhC-S8-4Ak" firstAttribute="centerY" secondItem="nVN-8L-w1D" secondAttribute="centerY" id="1HQ-Ka-V5B"/>
|
||||
<constraint firstItem="kV6-Lt-E6s" firstAttribute="top" secondItem="bDK-ON-vzl" secondAttribute="bottom" constant="2" id="BCZ-fO-oVq"/>
|
||||
<constraint firstAttribute="leadingMargin" secondItem="GhC-S8-4Ak" secondAttribute="leading" id="KJW-gj-p94"/>
|
||||
<constraint firstItem="kV6-Lt-E6s" firstAttribute="leading" secondItem="GhC-S8-4Ak" secondAttribute="trailing" constant="8" id="MH1-8I-9h5"/>
|
||||
<constraint firstItem="bDK-ON-vzl" firstAttribute="leading" secondItem="GhC-S8-4Ak" secondAttribute="trailing" constant="8" id="Nq4-pU-ACR"/>
|
||||
<constraint firstAttribute="trailingMargin" secondItem="Zkf-Od-qYs" secondAttribute="trailing" id="Pef-Qp-ZN1"/>
|
||||
<constraint firstAttribute="topMargin" secondItem="Zkf-Od-qYs" secondAttribute="top" id="dBr-yy-eSZ"/>
|
||||
<constraint firstAttribute="trailingMargin" secondItem="bDK-ON-vzl" secondAttribute="trailing" id="giD-gR-Qou"/>
|
||||
<constraint firstAttribute="trailingMargin" secondItem="kV6-Lt-E6s" secondAttribute="trailing" id="lFV-oP-iqa"/>
|
||||
<constraint firstItem="Zkf-Od-qYs" firstAttribute="leading" secondItem="GhC-S8-4Ak" secondAttribute="trailing" constant="8" id="pm3-kg-EYD"/>
|
||||
<constraint firstItem="bDK-ON-vzl" firstAttribute="top" secondItem="Zkf-Od-qYs" secondAttribute="bottom" constant="2" id="rV9-Mq-ksX"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="n7s-WF-MFQ" id="rNc-cd-1e8"/>
|
||||
<outlet property="delegate" destination="n7s-WF-MFQ" id="Q8f-t7-tCe"/>
|
||||
<outlet property="progressView" destination="bDK-ON-vzl" id="K0z-pr-4pw"/>
|
||||
<outlet property="subtitleLabel" destination="kV6-Lt-E6s" id="LPp-11-o1V"/>
|
||||
<outlet property="thumbImageView" destination="GhC-S8-4Ak" id="5Yy-Zz-Ona"/>
|
||||
<outlet property="titleLabel" destination="Zkf-Od-qYs" id="NYe-GC-sBA"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
</subviews>
|
||||
</stackView>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="n7s-WF-MFQ" id="rNc-cd-1e8"/>
|
||||
<outlet property="delegate" destination="n7s-WF-MFQ" id="Q8f-t7-tCe"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstItem="VO0-cd-Axb" firstAttribute="top" secondItem="MOG-eQ-eA6" secondAttribute="top" id="DDC-YV-D2a"/>
|
||||
<constraint firstAttribute="trailing" secondItem="VO0-cd-Axb" secondAttribute="trailing" id="LZE-Nv-V5P"/>
|
||||
<constraint firstItem="1HO-0f-jcI" firstAttribute="top" secondItem="VO0-cd-Axb" secondAttribute="bottom" id="pSr-O1-OGq"/>
|
||||
<constraint firstItem="VO0-cd-Axb" firstAttribute="leading" secondItem="MOG-eQ-eA6" secondAttribute="leading" id="w9u-si-WcW"/>
|
||||
<constraint firstItem="prU-fs-X0V" firstAttribute="top" secondItem="MOG-eQ-eA6" secondAttribute="top" id="BM7-3Z-ME9"/>
|
||||
<constraint firstItem="1HO-0f-jcI" firstAttribute="top" secondItem="prU-fs-X0V" secondAttribute="bottom" id="I9g-RI-2Eg"/>
|
||||
<constraint firstAttribute="trailing" secondItem="prU-fs-X0V" secondAttribute="trailing" id="fba-Df-RTs"/>
|
||||
<constraint firstItem="prU-fs-X0V" firstAttribute="leading" secondItem="MOG-eQ-eA6" secondAttribute="leading" id="s9z-jW-Sud"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" id="nXq-yo-F6Y">
|
||||
@ -372,7 +394,7 @@
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Rra-HQ-Ajz" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-174" y="-658"/>
|
||||
<point key="canvasLocation" x="-175.19999999999999" y="-658.02098950524737"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
|
@ -175,6 +175,7 @@ class LibraryCollectionHeader: UICollectionReusableView {
|
||||
|
||||
|
||||
|
||||
|
||||
// MARK: - last time refactor
|
||||
|
||||
// MARK: - Bookmark Cell
|
||||
|
16
Kiwix-iOS/View/LibraryCells.swift
Normal file
16
Kiwix-iOS/View/LibraryCells.swift
Normal file
@ -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!
|
||||
}
|
@ -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 = "<group>"; };
|
||||
9779C31B1D4575AE0064CC8E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
977A458B1E14EA140089C596 /* Cloud.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cloud.swift; sourceTree = "<group>"; };
|
||||
977B121B1E3A5E8D00981890 /* LibraryCells.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LibraryCells.swift; sourceTree = "<group>"; };
|
||||
9788419C1DA2FF2A00D22D3C /* MainInterface.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = MainInterface.storyboard; sourceTree = "<group>"; };
|
||||
97A127C51D777CF100FB204D /* RecentSearchController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecentSearchController.swift; sourceTree = "<group>"; };
|
||||
97A127C61D777CF100FB204D /* SearchScopeAndHistoryController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchScopeAndHistoryController.swift; sourceTree = "<group>"; };
|
||||
@ -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 */,
|
||||
|
Loading…
x
Reference in New Issue
Block a user