diff --git a/NearFuture/Item.swift b/NearFuture/Item.swift index 4392705..77ff9d2 100644 --- a/NearFuture/Item.swift +++ b/NearFuture/Item.swift @@ -130,7 +130,11 @@ class SettingsViewModel: ObservableObject { Color(UIColor(named: "uiColors/basic")!) ] + @Published var device: (sf: String, label: String) + init(load: Bool = true) { + self.device = getDevice() + if load { loadSettings() Task { @@ -549,3 +553,16 @@ func getBuildID() -> String { } return "\(build)" } + +func getDevice() -> (sf: String, label: String) { + let asi = ProcessInfo().isiOSAppOnMac + let model = UIDevice().model + if asi { + return (sf: "laptopcomputer", label: "Computer") + } else if model == "iPhone" { + return (sf: model.lowercased(), label: model) + } else if model == "iPad" { + return (sf: model.lowercased(), label: model) + } + return (sf: "iphone", label: "iPhone") +} diff --git a/NearFuture/Views/Home/HomeView.swift b/NearFuture/Views/Home/HomeView.swift index febbc88..d551fd4 100644 --- a/NearFuture/Views/Home/HomeView.swift +++ b/NearFuture/Views/Home/HomeView.swift @@ -66,11 +66,6 @@ struct HomeView: View { if filteredEvents.isEmpty && !searchInput.isEmpty { HelpView(searchInput: $searchInput, focusedField: focusedField) } else { - Button("hiiiiiiiiiiiiiii") { - withAnimation() { - settingsModel.settings.showCompletedInHome.toggle() - } - } ScrollView { ForEach(filteredEvents) { event in EventListView(viewModel: viewModel, event: event) diff --git a/NearFuture/Views/Settings/SettingsView.swift b/NearFuture/Views/Settings/SettingsView.swift index 6f64963..1a64204 100644 --- a/NearFuture/Views/Settings/SettingsView.swift +++ b/NearFuture/Views/Settings/SettingsView.swift @@ -89,6 +89,7 @@ struct SettingsView: View { NavigationLink() { iCloudSettingsView( viewModel: viewModel, + settingsModel: settingsModel, hasUbiquitous: $hasUbiquitous, lastSyncWasSuccessful: $lastSyncWasSuccessful, lastSyncWasNormalAgo: $lastSyncWasNormalAgo, diff --git a/NearFuture/Views/Settings/WhatsNewView.swift b/NearFuture/Views/Settings/WhatsNewView.swift index e7bf1d0..8a03ff5 100644 --- a/NearFuture/Views/Settings/WhatsNewView.swift +++ b/NearFuture/Views/Settings/WhatsNewView.swift @@ -16,23 +16,25 @@ struct WhatsNewView: View { var title: String var subtitle: String } - var whatsNew: [WhatsNew] = [ - WhatsNew( - symbol: "bell.badge.fill", - title: "Notifications", - subtitle: "Events now have notifications, reminding you to complete them!" - ), - WhatsNew( - symbol: "list.bullet.indent", - title: "Animations!", - subtitle: "I added animations for adding, removing and ticking events, fixing " - ), - WhatsNew( - symbol: "list.bullet.indent", - title: "Animations!", - subtitle: "I added animations for adding, removing and ticking events, fixing " - ) - ] + var whatsNew: [WhatsNew] { + return [ + WhatsNew( + symbol: settingsModel.device.sf, + title: "This Screen", + subtitle: "This update add a Whats New page that will tell you (suprise!) What's New" + ), + WhatsNew( + symbol: "bell.badge.fill", + title: "Notifications", + subtitle: "Events now have notifications, reminding you to complete them!" + ), + WhatsNew( + symbol: "list.bullet.indent", + title: "Animations!", + subtitle: "I added animations for adding, removing and ticking events" + ) + ] + } var body: some View { NavigationStack { List { @@ -52,6 +54,7 @@ struct WhatsNewView: View { } .onDisappear { + settingsModel.settings.showWhatsNew = false settingsModel.saveSettings() } } diff --git a/NearFuture/Views/Settings/iCloudSettingsView.swift b/NearFuture/Views/Settings/iCloudSettingsView.swift index 4f016a3..973e803 100644 --- a/NearFuture/Views/Settings/iCloudSettingsView.swift +++ b/NearFuture/Views/Settings/iCloudSettingsView.swift @@ -8,7 +8,8 @@ import SwiftUI struct iCloudSettingsView: View { - @State var viewModel: EventViewModel + @ObservedObject var viewModel: EventViewModel + @ObservedObject var settingsModel: SettingsViewModel @State var showPushAlert: Bool = false @State var showPullAlert: Bool = false @@ -18,19 +19,6 @@ struct iCloudSettingsView: View { @Binding var localCountEqualToiCloud: Bool @Binding var icloudCountEqualToLocal: Bool - let asi = ProcessInfo().isiOSAppOnMac - let model = UIDevice().model - var device: (sf: String, label: String) { - if asi { - return (sf: "laptopcomputer", label: "Computer") - } else if model == "iPhone" { - return (sf: model.lowercased(), label: model) - } else if model == "iPad" { - return (sf: model.lowercased(), label: model) - } - return (sf: "iphone", label: "iPhone") - } - var updateStatus: () -> Void var body: some View { @@ -107,7 +95,7 @@ struct iCloudSettingsView: View { } } ZStack { - Image(systemName: device.sf) + Image(systemName: settingsModel.device.sf) .resizable() .scaledToFit() .frame(width: 75, height: 75) @@ -117,7 +105,7 @@ struct iCloudSettingsView: View { .monospaced() .bold() } - Text(device.label) + Text(settingsModel.device.label) } Spacer() } @@ -196,6 +184,7 @@ struct iCloudSettingsView: View { #Preview("iCloudSettingsView") { iCloudSettingsView( viewModel: dummyEventViewModel(), + settingsModel: dummySettingsViewModel(), hasUbiquitous: .constant(true), lastSyncWasSuccessful: .constant(true), lastSyncWasNormalAgo: .constant(true),