Rename Pref -> Prefs
This commit is contained in:
@@ -1,58 +1,58 @@
|
||||
import Foundation
|
||||
|
||||
enum Pref {
|
||||
static func Int(_ key: String) -> Int { UserDefaults.standard.integer(forKey: key) }
|
||||
static func Int(_ val: Int, _ key: String) { UserDefaults.standard.set(val, forKey: key) }
|
||||
static func Bool(_ key: String) -> Bool { UserDefaults.standard.bool(forKey: key) }
|
||||
static func Bool(_ val: Bool, _ key: String) { UserDefaults.standard.set(val, forKey: key) }
|
||||
static func `Any`(_ key: String) -> Any? { UserDefaults.standard.object(forKey: key) }
|
||||
static func `Any`(_ val: Any?, _ key: String) { UserDefaults.standard.set(val, forKey: key) }
|
||||
enum Prefs {
|
||||
private static func Int(_ key: String) -> Int { UserDefaults.standard.integer(forKey: key) }
|
||||
private static func Int(_ val: Int, _ key: String) { UserDefaults.standard.set(val, forKey: key) }
|
||||
private static func Bool(_ key: String) -> Bool { UserDefaults.standard.bool(forKey: key) }
|
||||
private static func Bool(_ val: Bool, _ key: String) { UserDefaults.standard.set(val, forKey: key) }
|
||||
private static func `Any`(_ key: String) -> Any? { UserDefaults.standard.object(forKey: key) }
|
||||
private static func `Any`(_ val: Any?, _ key: String) { UserDefaults.standard.set(val, forKey: key) }
|
||||
|
||||
enum DidShowTutorial {
|
||||
static var Welcome: Bool {
|
||||
get { Pref.Bool("didShowTutorialAppWelcome") }
|
||||
set { Pref.Bool(newValue, "didShowTutorialAppWelcome") }
|
||||
get { Prefs.Bool("didShowTutorialAppWelcome") }
|
||||
set { Prefs.Bool(newValue, "didShowTutorialAppWelcome") }
|
||||
}
|
||||
static var Recordings: Bool {
|
||||
get { Pref.Bool("didShowTutorialRecordings") }
|
||||
set { Pref.Bool(newValue, "didShowTutorialRecordings") }
|
||||
get { Prefs.Bool("didShowTutorialRecordings") }
|
||||
set { Prefs.Bool(newValue, "didShowTutorialRecordings") }
|
||||
}
|
||||
}
|
||||
enum ContextAnalyis {
|
||||
static var CoOccurrenceTime: Int? {
|
||||
get { Pref.Any("contextAnalyisCoOccurrenceTime") as? Int }
|
||||
set { Pref.Any(newValue, "contextAnalyisCoOccurrenceTime") }
|
||||
get { Prefs.Any("contextAnalyisCoOccurrenceTime") as? Int }
|
||||
set { Prefs.Any(newValue, "contextAnalyisCoOccurrenceTime") }
|
||||
}
|
||||
}
|
||||
enum DateFilter {
|
||||
static var Kind: DateFilterKind {
|
||||
get { DateFilterKind(rawValue: Pref.Int("dateFilterType"))! }
|
||||
set { Pref.Int(newValue.rawValue, "dateFilterType") }
|
||||
get { DateFilterKind(rawValue: Prefs.Int("dateFilterType"))! }
|
||||
set { Prefs.Int(newValue.rawValue, "dateFilterType") }
|
||||
}
|
||||
/// Default: `0` (disabled)
|
||||
static var LastXMin: Int {
|
||||
get { Pref.Int("dateFilterLastXMin") }
|
||||
set { Pref.Int(newValue, "dateFilterLastXMin") }
|
||||
get { Prefs.Int("dateFilterLastXMin") }
|
||||
set { Prefs.Int(newValue, "dateFilterLastXMin") }
|
||||
}
|
||||
/// Default: `nil` (disabled)
|
||||
static var RangeA: Timestamp? {
|
||||
get { Pref.Any("dateFilterRangeA") as? Timestamp }
|
||||
set { Pref.Any(newValue, "dateFilterRangeA") }
|
||||
get { Prefs.Any("dateFilterRangeA") as? Timestamp }
|
||||
set { Prefs.Any(newValue, "dateFilterRangeA") }
|
||||
}
|
||||
/// Default: `nil` (disabled)
|
||||
static var RangeB: Timestamp? {
|
||||
get { Pref.Any("dateFilterRangeB") as? Timestamp }
|
||||
set { Pref.Any(newValue, "dateFilterRangeB") }
|
||||
get { Prefs.Any("dateFilterRangeB") as? Timestamp }
|
||||
set { Prefs.Any(newValue, "dateFilterRangeB") }
|
||||
}
|
||||
/// default: `.Date`
|
||||
static var OrderBy: DateFilterOrderBy {
|
||||
get { DateFilterOrderBy(rawValue: Pref.Int("dateFilterOderType"))! }
|
||||
set { Pref.Int(newValue.rawValue, "dateFilterOderType") }
|
||||
get { DateFilterOrderBy(rawValue: Prefs.Int("dateFilterOderType"))! }
|
||||
set { Prefs.Int(newValue.rawValue, "dateFilterOderType") }
|
||||
}
|
||||
/// default: `false` (Desc)
|
||||
static var OrderAsc: Bool {
|
||||
get { Pref.Bool("dateFilterOderAsc") }
|
||||
set { Pref.Bool(newValue, "dateFilterOderAsc") }
|
||||
get { Prefs.Bool("dateFilterOderAsc") }
|
||||
set { Prefs.Bool(newValue, "dateFilterOderAsc") }
|
||||
}
|
||||
|
||||
/// - Returns: Timestamp restriction depending on current selected date filter.
|
||||
@@ -63,8 +63,8 @@ enum Pref {
|
||||
let type = Kind
|
||||
switch type {
|
||||
case .Off: return (type, nil, nil)
|
||||
case .LastXMin: return (type, Timestamp.past(minutes: Pref.DateFilter.LastXMin), nil)
|
||||
case .ABRange: return (type, Pref.DateFilter.RangeA, Pref.DateFilter.RangeB)
|
||||
case .LastXMin: return (type, Timestamp.past(minutes: Prefs.DateFilter.LastXMin), nil)
|
||||
case .ABRange: return (type, Prefs.DateFilter.RangeA, Prefs.DateFilter.RangeB)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user