From f4bd73e477c0c4a956d611356763231941d26dfa Mon Sep 17 00:00:00 2001 From: Chris Li Date: Tue, 7 Feb 2017 13:40:15 -0500 Subject: [PATCH] Fixes for library space detection --- .../Library/LibraryBooksController.swift | 2 +- Kiwix-iOS/View/Cells.swift | 3 ++- .../xcdebugger/Breakpoints_v2.xcbkptlist | 18 ++++++++++++++++++ Kiwix/Operations/UIProcedure.swift | 5 +++-- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Kiwix-iOS/Controller/Library/LibraryBooksController.swift b/Kiwix-iOS/Controller/Library/LibraryBooksController.swift index 1fd69517..b0f8252b 100644 --- a/Kiwix-iOS/Controller/Library/LibraryBooksController.swift +++ b/Kiwix-iOS/Controller/Library/LibraryBooksController.swift @@ -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 } diff --git a/Kiwix-iOS/View/Cells.swift b/Kiwix-iOS/View/Cells.swift index 1119f753..369553ad 100644 --- a/Kiwix-iOS/View/Cells.swift +++ b/Kiwix-iOS/View/Cells.swift @@ -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 diff --git a/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index ed9a9b4d..6f1afd50 100644 --- a/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Kiwix.xcworkspace/xcuserdata/chrisli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -2,4 +2,22 @@ + + + + + + diff --git a/Kiwix/Operations/UIProcedure.swift b/Kiwix/Operations/UIProcedure.swift index e6706144..b8dc3915 100644 --- a/Kiwix/Operations/UIProcedure.swift +++ b/Kiwix/Operations/UIProcedure.swift @@ -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 }