mirror of
https://github.com/neon443/NearFuture.git
synced 2026-03-11 22:56:15 +00:00
basic settings done!!!
now can set accent color
This commit is contained in:
@@ -96,6 +96,40 @@ func daysUntilEvent(_ eventDate: Date) -> (long: String, short: String) {
|
||||
}
|
||||
}
|
||||
|
||||
struct Settings: Codable, Equatable {
|
||||
var showCompletedInHome: Bool
|
||||
var tint: ColorCodable
|
||||
}
|
||||
|
||||
class SettingsViewModel: ObservableObject {
|
||||
@Published var settings: Settings = Settings(
|
||||
showCompletedInHome: false,
|
||||
tint: ColorCodable(.blue)
|
||||
)
|
||||
|
||||
init(load: Bool = true) {
|
||||
if load {
|
||||
loadSettings()
|
||||
}
|
||||
}
|
||||
|
||||
let appGroupSettingsStore = UserDefaults(suiteName: "group.NearFuture") ?? UserDefaults.standard
|
||||
let icSettStore = NSUbiquitousKeyValueStore.default
|
||||
|
||||
func loadSettings() {
|
||||
let decoder = JSONDecoder()
|
||||
if let icSettings = icSettStore.data(forKey: "settings") {
|
||||
if let decodedSetts = try? decoder.decode(Settings.self, from: icSettings) {
|
||||
self.settings = decodedSetts
|
||||
}
|
||||
} else if let savedData = appGroupSettingsStore.data(forKey: "settings") {
|
||||
if let decodedSetts = try? decoder.decode(Settings.self, from: savedData) {
|
||||
self.settings = decodedSetts
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class EventViewModel: ObservableObject {
|
||||
@Published var events: [Event] = []
|
||||
@Published var icloudData: [Event] = []
|
||||
@@ -308,6 +342,12 @@ class dummyEventViewModel: EventViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
class dummySettingsViewModel: SettingsViewModel {
|
||||
override init(load: Bool = false) {
|
||||
super.init(load: false)
|
||||
}
|
||||
}
|
||||
|
||||
func describeOccurrence(date: Date, recurrence: Event.RecurrenceType) -> String {
|
||||
let dateString = date.formatted(date: .long, time: .omitted)
|
||||
let recurrenceDescription: String
|
||||
|
||||
Reference in New Issue
Block a user