mirror of
https://github.com/neon443/NearFuture.git
synced 2026-03-11 06:49:12 +00:00
moved icloud ui functions into viewModel
- idk why it was in the view added settings for mac fix addeventview export view pasteboard for mac move accent icon to new file Archive view reversed - new to old
This commit is contained in:
@@ -11,10 +11,8 @@ import SwiftUI
|
||||
import WidgetKit
|
||||
import UserNotifications
|
||||
import AppIntents
|
||||
import AudioToolbox
|
||||
#if canImport(AppKit)
|
||||
import AppKit
|
||||
import IOKit
|
||||
#endif
|
||||
|
||||
//@Model
|
||||
@@ -164,6 +162,25 @@ class EventViewModel: ObservableObject, @unchecked Sendable {
|
||||
@Published var localEventCount: Int = 0
|
||||
@Published var syncStatus: String = "Not Synced"
|
||||
|
||||
@Published var hasUbiquitous: Bool = false
|
||||
@Published var lastSyncWasSuccessful: Bool = false
|
||||
@Published var lastSyncWasNormalAgo: Bool = false
|
||||
@Published var localCountEqualToiCloud: Bool = false
|
||||
@Published var icloudCountEqualToLocal: Bool = false
|
||||
|
||||
var iCloudStatusColor: Color {
|
||||
let allTrue = hasUbiquitous && lastSyncWasSuccessful && lastSyncWasNormalAgo && localCountEqualToiCloud && icloudCountEqualToLocal
|
||||
let someTrue = hasUbiquitous || lastSyncWasSuccessful || lastSyncWasNormalAgo || localCountEqualToiCloud || icloudCountEqualToLocal
|
||||
|
||||
if allTrue {
|
||||
return .green
|
||||
} else if someTrue {
|
||||
return .orange
|
||||
} else {
|
||||
return .red
|
||||
}
|
||||
}
|
||||
|
||||
init(load: Bool = true) {
|
||||
self.editableTemplate = template
|
||||
if load {
|
||||
@@ -343,6 +360,14 @@ class EventViewModel: ObservableObject, @unchecked Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
func updateiCStatus() {
|
||||
hasUbiquitous = hasUbiquitousKeyValueStore()
|
||||
lastSyncWasSuccessful = syncStatus.contains("Success")
|
||||
lastSyncWasNormalAgo = lastSync?.timeIntervalSinceNow.isNormal ?? false
|
||||
localCountEqualToiCloud = localEventCount == icloudEventCount
|
||||
icloudCountEqualToLocal = icloudEventCount == localEventCount
|
||||
}
|
||||
|
||||
//MARK: Danger Zone
|
||||
func dangerClearLocalData() {
|
||||
UserDefaults.standard.removeObject(forKey: "events")
|
||||
|
||||
Reference in New Issue
Block a user