mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-25 12:56:13 -04:00
Cloud Controller preferredAction
This commit is contained in:
parent
f3816746de
commit
f69701e2ad
@ -152,7 +152,7 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel
|
||||
let alert = UIAlertController(title: NSLocalizedString("Only Show Preferred Language?", comment: comment),
|
||||
message: NSLocalizedString(String(format: "Would you like to filter the library by %@?", string), comment: comment),
|
||||
preferredStyle: .Alert)
|
||||
alert.addAction(UIAlertAction(title: LocalizedStrings.Common.yes, style: .Default) { (action) in
|
||||
let action = UIAlertAction(title: LocalizedStrings.Common.yes, style: .Default) { (action) in
|
||||
self.managedObjectContext.performBlock({
|
||||
let codes = NSLocale.preferredLangCodes
|
||||
Language.fetchAll(self.managedObjectContext).forEach({ (language) in
|
||||
@ -161,7 +161,9 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel
|
||||
})
|
||||
self.refreshFetchedResultController()
|
||||
})
|
||||
})
|
||||
}
|
||||
alert.preferredAction = action
|
||||
alert.addAction(action)
|
||||
alert.addAction(UIAlertAction(title: LocalizedStrings.Common.cancel, style: .Cancel, handler: nil))
|
||||
presentViewController(alert, animated: true, completion: nil)
|
||||
}
|
||||
@ -329,31 +331,3 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel
|
||||
tableView.endUpdates()
|
||||
}
|
||||
}
|
||||
|
||||
class RefreshLibControl: UIRefreshControl {
|
||||
|
||||
static let pullDownToRefresh = NSLocalizedString("Pull Down To Refresh", comment: "Refresh Library Control")
|
||||
static let lastRefresh = NSLocalizedString("Last Refresh: %@ ago", comment: "Refresh Library Control")
|
||||
|
||||
override var hidden: Bool {
|
||||
didSet {
|
||||
guard hidden != oldValue && hidden == false else {return}
|
||||
updateTitle()
|
||||
}
|
||||
}
|
||||
|
||||
private func updateTitle() {
|
||||
let string: String = {
|
||||
guard let lastRefreshTime = Preference.libraryLastRefreshTime else {return RefreshLibControl.pullDownToRefresh}
|
||||
let interval = lastRefreshTime.timeIntervalSinceNow * -1
|
||||
let formatter = NSDateComponentsFormatter()
|
||||
formatter.unitsStyle = .Abbreviated
|
||||
formatter.allowedUnits = interval < 60.0 ? [.Second] : [.Day, .Hour, .Minute]
|
||||
let string = formatter.stringFromTimeInterval(interval) ?? ""
|
||||
return String(format: RefreshLibControl.lastRefresh, string)
|
||||
}()
|
||||
let attributes = [NSForegroundColorAttributeName: UIColor.blackColor()]
|
||||
attributedTitle = NSAttributedString(string: string, attributes: attributes)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.7.1807</string>
|
||||
<string>1.7.1809</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
|
36
Kiwix-iOS/View/RefreshLibControl.swift
Normal file
36
Kiwix-iOS/View/RefreshLibControl.swift
Normal file
@ -0,0 +1,36 @@
|
||||
//
|
||||
// RefreshLibControl.swift
|
||||
// Kiwix
|
||||
//
|
||||
// Created by Chris Li on 9/7/16.
|
||||
// Copyright © 2016 Chris. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class RefreshLibControl: UIRefreshControl {
|
||||
|
||||
static let pullDownToRefresh = NSLocalizedString("Pull Down To Refresh", comment: "Refresh Library Control")
|
||||
static let lastRefresh = NSLocalizedString("Last Refresh: %@ ago", comment: "Refresh Library Control")
|
||||
|
||||
override var hidden: Bool {
|
||||
didSet {
|
||||
guard hidden != oldValue && hidden == false else {return}
|
||||
updateTitle()
|
||||
}
|
||||
}
|
||||
|
||||
private func updateTitle() {
|
||||
let string: String = {
|
||||
guard let lastRefreshTime = Preference.libraryLastRefreshTime else {return RefreshLibControl.pullDownToRefresh}
|
||||
let interval = lastRefreshTime.timeIntervalSinceNow * -1
|
||||
let formatter = NSDateComponentsFormatter()
|
||||
formatter.unitsStyle = .Abbreviated
|
||||
formatter.allowedUnits = interval < 60.0 ? [.Second] : [.Day, .Hour, .Minute]
|
||||
let string = formatter.stringFromTimeInterval(interval) ?? ""
|
||||
return String(format: RefreshLibControl.lastRefresh, string)
|
||||
}()
|
||||
let attributes = [NSForegroundColorAttributeName: UIColor.blackColor()]
|
||||
attributedTitle = NSAttributedString(string: string, attributes: attributes)
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.7.2361</string>
|
||||
<string>1.7.2363</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionMainStoryboard</key>
|
||||
|
@ -74,6 +74,7 @@
|
||||
975B90FE1CEB909100D13906 /* iOSExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 975B90FD1CEB909100D13906 /* iOSExtensions.swift */; };
|
||||
9763275E1D64FE0F0034F120 /* BookDetailController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9763275D1D64FE0F0034F120 /* BookDetailController.swift */; };
|
||||
9763A6291CEB9E55008A2718 /* OSXExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9763A6281CEB9E55008A2718 /* OSXExtensions.swift */; };
|
||||
9764CBD11D806AD800072D6A /* RefreshLibControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9764CBD01D806AD800072D6A /* RefreshLibControl.swift */; };
|
||||
9779C3141D4575AD0064CC8E /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 97E609F01D103DED00EBCB9D /* NotificationCenter.framework */; };
|
||||
9779C3171D4575AE0064CC8E /* TodayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9779C3161D4575AE0064CC8E /* TodayViewController.swift */; };
|
||||
9779C31A1D4575AE0064CC8E /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9779C3181D4575AE0064CC8E /* MainInterface.storyboard */; };
|
||||
@ -289,6 +290,7 @@
|
||||
975B90FD1CEB909100D13906 /* iOSExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = iOSExtensions.swift; path = "Kiwix-iOS/iOSExtensions.swift"; sourceTree = SOURCE_ROOT; };
|
||||
9763275D1D64FE0F0034F120 /* BookDetailController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookDetailController.swift; sourceTree = "<group>"; };
|
||||
9763A6281CEB9E55008A2718 /* OSXExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OSXExtensions.swift; path = "Kiwix-OSX/OSXExtensions.swift"; sourceTree = SOURCE_ROOT; };
|
||||
9764CBD01D806AD800072D6A /* RefreshLibControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RefreshLibControl.swift; sourceTree = "<group>"; };
|
||||
976A0C801D41619C0006A742 /* DZNEmptyDataSet.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DZNEmptyDataSet.framework; path = "../../../../Users/chrisli/Library/Developer/Xcode/DerivedData/Kiwix-ayxrfhaqnfxzendihdolvkklkmhk/Build/Products/Debug-iphoneos/DZNEmptyDataSet/DZNEmptyDataSet.framework"; sourceTree = "<group>"; };
|
||||
9779C3131D4575AD0064CC8E /* Bookmarks.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = Bookmarks.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
9779C3161D4575AE0064CC8E /* TodayViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayViewController.swift; sourceTree = "<group>"; };
|
||||
@ -601,6 +603,7 @@
|
||||
97D452BD1D1723FF0033666F /* CollectionViewCells.swift */,
|
||||
971A10271D022AD5007FC62C /* Logo.swift */,
|
||||
971A10281D022AD5007FC62C /* LTBarButtonItem.swift */,
|
||||
9764CBD01D806AD800072D6A /* RefreshLibControl.swift */,
|
||||
971A10291D022AD5007FC62C /* RefreshHUD.swift */,
|
||||
971A102A1D022AD5007FC62C /* SearchBar.swift */,
|
||||
97E60A011D10423A00EBCB9D /* ShadowViews.swift */,
|
||||
@ -1527,6 +1530,7 @@
|
||||
97D681321D6F70EC00E5FA99 /* MigrationPolicy.swift in Sources */,
|
||||
97D6811B1D6E2A7100E5FA99 /* DownloadTasksController.swift in Sources */,
|
||||
97D681261D6F70AC00E5FA99 /* SearchOperation.swift in Sources */,
|
||||
9764CBD11D806AD800072D6A /* RefreshLibControl.swift in Sources */,
|
||||
971A10381D022C15007FC62C /* WebViewController.swift in Sources */,
|
||||
97C601DE1D7F342100362D4F /* HTMLHeading.swift in Sources */,
|
||||
97D681271D6F70AC00E5FA99 /* UIOperations.swift in Sources */,
|
||||
|
Loading…
x
Reference in New Issue
Block a user