From bb67b0ce98c87a91ad26394df78d7491f3cc3d1a Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Wed, 14 May 2025 21:04:00 +0100 Subject: [PATCH] =?UTF-8?q?YESSSSSSSSS=20ok=20now=20jsut=20have=20ot=20mak?= =?UTF-8?q?e=20this=20scalabel=20=F0=9F=98=AD=20=F0=9F=98=AD=F0=9F=98=AD?= =?UTF-8?q?=F0=9F=98=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NearFuture/Item.swift | 17 +++++---- NearFuture/Views/Settings/SettingsView.swift | 38 ++++++++------------ 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/NearFuture/Item.swift b/NearFuture/Item.swift index f56dd49..e428f19 100644 --- a/NearFuture/Item.swift +++ b/NearFuture/Item.swift @@ -163,6 +163,13 @@ class SettingsViewModel: ObservableObject { } } + func changeTint(to: String) { + if let uicolor = UIColor(named: "uiColors/\(to)") { + self.settings.tint = ColorCodable(uiColor: uicolor) + saveSettings() + } + } + let appGroupSettingsStore = UserDefaults(suiteName: "group.NearFuture") ?? UserDefaults.standard let icSettStore = NSUbiquitousKeyValueStore.default @@ -182,9 +189,9 @@ class SettingsViewModel: ObservableObject { } // - for color in accentChoices { - self.colorChoices.append(AccentIcon(color)) - } +// for color in accentChoices { +// self.colorChoices.append(AccentIcon(color)) +// } } func saveSettings() { @@ -196,10 +203,6 @@ class SettingsViewModel: ObservableObject { loadSettings() } } - - func changeAccent(to color: AccentIcon) { - - } } class EventViewModel: ObservableObject { diff --git a/NearFuture/Views/Settings/SettingsView.swift b/NearFuture/Views/Settings/SettingsView.swift index f19b051..3b24b25 100644 --- a/NearFuture/Views/Settings/SettingsView.swift +++ b/NearFuture/Views/Settings/SettingsView.swift @@ -40,6 +40,14 @@ struct SettingsView: View { } } + func changeIcon(to: String) { + guard !(to == "orange") else { + UIApplication.shared.setAlternateIconName(nil) + return + } + UIApplication.shared.setAlternateIconName(to) + } + var body: some View { NavigationStack { ZStack { @@ -48,41 +56,24 @@ struct SettingsView: View { ScrollView(.horizontal) { HStack { ForEach(settingsModel.accentChoices, id: \.self) { choice in + let color = Color(uiColor: UIColor(named: "uiColors/\(choice)")!) ZStack { Button() { - settingsModel.changeAccent(to: choice) + settingsModel.changeTint(to: choice) + changeIcon(to: choice) } label: { Circle() - .foregroundStyle(choice.color) + .foregroundStyle(color) .frame(width: 30) } - if ColorCodable(choice.color) == settingsModel.settings.tint { - let needContrast: Bool = ColorCodable(choice.color) == settingsModel.settings.tint + if ColorCodable(color) == settingsModel.settings.tint { + let needContrast: Bool = ColorCodable(color) == settingsModel.settings.tint Circle() .foregroundStyle(needContrast ? .two : .one) .frame(width: 10) } } } - - -// ForEach(settingsModel.accentChoices, id: \.self) { color in -// ZStack { -// Button() { -// -// } label: { -// Circle() -// .foregroundStyle(color) -// .frame(width: 30) -// } -// if ColorCodable(color) == settingsModel.settings.tint { -// let needContrast: Bool = ColorCodable(color) == settingsModel.settings.tint -// Circle() -// .foregroundStyle(needContrast ? .two : .one) -// .frame(width: 10) -// } -// } -// } } } Toggle("Show completed Events in Home", isOn: $settingsModel.settings.showCompletedInHome) @@ -194,4 +185,3 @@ struct SettingsView: View { settingsModel: dummySettingsViewModel() ) } -