Pull Down refresh ago string

This commit is contained in:
Chris Li 2016-08-29 10:36:07 -04:00
parent 8714e2cf7d
commit 7b10fdfea9
3 changed files with 9 additions and 6 deletions

View File

@ -262,7 +262,7 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel
class RefreshLibControl: UIRefreshControl {
static let pullDownToRefresh = NSLocalizedString("Pull Down To Refresh", comment: "Refresh Library Control")
static let lastRefresh = NSLocalizedString("Last Refresh", comment: "Refresh Library Control")
static let lastRefresh = NSLocalizedString("Last Refresh: %@ ago", comment: "Refresh Library Control")
override var hidden: Bool {
didSet {
@ -274,9 +274,12 @@ class RefreshLibControl: UIRefreshControl {
private func updateTitle() {
let string: String = {
guard let lastRefreshTime = Preference.libraryLastRefreshTime else {return RefreshLibControl.pullDownToRefresh}
let formatter = NSDateFormatter()
formatter.dateFormat = "MMM d, h:mm a"
return "Last Refresh" + ": " + formatter.stringFromDate(lastRefreshTime)
let interval = lastRefreshTime.timeIntervalSinceNow * -1
let formatter = NSDateComponentsFormatter()
formatter.unitsStyle = .Abbreviated
formatter.allowedUnits = [.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)

View File

@ -49,7 +49,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.7.1486</string>
<string>1.7.1499</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>

View File

@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.7.1839</string>
<string>1.7.1856</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>