Fixes for library space detection

This commit is contained in:
Chris Li 2017-02-07 13:40:15 -05:00
parent d841c3b982
commit f4bd73e477
4 changed files with 24 additions and 4 deletions

View File

@ -192,7 +192,7 @@ class LibraryBooksController: CoreDataCollectionBaseController, UICollectionView
].flatMap({$0}).joined(separator: " ")
cell.descriptionLabel.text = book.desc
cell.hasPicLabel.isHidden = !book.hasPic
cell.spaceStatus = getBookSpaceStatus(fileSize: book.fileSize)
if isCloudTab {cell.spaceStatus = getBookSpaceStatus(fileSize: book.fileSize)}
return cell
}

View File

@ -154,8 +154,9 @@ class LibraryCollectionCell: UICollectionViewCell {
delegate?.didTapMoreButton(cell: self)
}
var spaceStatus: SpaceStatus = .enough {
var spaceStatus: SpaceStatus? {
didSet {
guard let spaceStatus = spaceStatus else {return}
switch spaceStatus {
case .enough:
titleLabel.textColor = UIColor.black

View File

@ -2,4 +2,22 @@
<Bucket
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Kiwix/libkiwix/ZimReader.mm"
timestampString = "508185579.868817"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "43"
endingLineNumber = "43"
landmarkName = "-initWithZIMFileURL:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

View File

@ -114,11 +114,12 @@ extension AlertProcedure {
return alert
}
static func more(context: UIViewController, book: Book, spaceStatus: SpaceStatus) -> AlertProcedure {
static func more(context: UIViewController, book: Book, spaceStatus: SpaceStatus?) -> AlertProcedure {
assert(Thread.isMainThread)
let alert = AlertProcedure(presentAlertFrom: context, withPreferredStyle: .actionSheet, waitForDismissal: true)
alert.title = book.title
alert.message = {
guard let spaceStatus = spaceStatus else {return book.desc}
switch spaceStatus {
case .enough:
return book.desc
@ -146,7 +147,7 @@ extension AlertProcedure {
}
alert.add(actionWithTitle: Localized.Common.cancel, style: .cancel) { _ in alert.finish() }
alert.actions.first?.isEnabled = spaceStatus != .notEnough
if let _ = spaceStatus {alert.actions.first?.isEnabled = spaceStatus != .notEnough}
return alert
}