diff --git a/nym-vpn-apple/Services/Sources/Services/AppSettings/AppSettings.swift b/nym-vpn-apple/Services/Sources/Services/AppSettings/AppSettings.swift index 000f14319e..d59fc287b9 100644 --- a/nym-vpn-apple/Services/Sources/Services/AppSettings/AppSettings.swift +++ b/nym-vpn-apple/Services/Sources/Services/AppSettings/AppSettings.swift @@ -8,8 +8,8 @@ public final class AppSettings: ObservableObject { @AppStorage(AppSettingKey.currentAppearance.rawValue) public var currentAppearance: AppSetting.Appearance = .automatic { didSet { -// guard let keyWindow = AppSettings.keyWindow else { return } -// keyWindow.rootViewController?.overrideUserInterfaceStyle = currentAppearance.userInterfaceStyle + guard let keyWindow = AppSettings.keyWindow else { return } + keyWindow.rootViewController?.overrideUserInterfaceStyle = currentAppearance.userInterfaceStyle } } #else @@ -75,18 +75,20 @@ public final class AppSettings: ObservableObject { } } +#if os(iOS) private extension AppSettings { -// static var keyWindow: UIWindow? { -// guard let window = UIApplication.shared.connectedScenes -// .compactMap({ $0 as? UIWindowScene }) -// .flatMap({ $0.windows }) -// .first(where: { $0.isKeyWindow }) -// else { -// return nil -// } -// return window -// } + static var keyWindow: UIWindow? { + guard let window = UIApplication.shared.connectedScenes + .compactMap({ $0 as? UIWindowScene }) + .flatMap({ $0.windows }) + .first(where: { $0.isKeyWindow }) + else { + return nil + } + return window + } } +#endif enum AppSettingKey: String { case currentAppearance diff --git a/nym-vpn-apple/Services/Sources/Services/AppSettings/Settings/AppSetting.swift b/nym-vpn-apple/Services/Sources/Services/AppSettings/Settings/AppSetting.swift index 3a576d6510..95910e7797 100644 --- a/nym-vpn-apple/Services/Sources/Services/AppSettings/Settings/AppSetting.swift +++ b/nym-vpn-apple/Services/Sources/Services/AppSettings/Settings/AppSetting.swift @@ -11,14 +11,11 @@ public struct AppSetting { public var colorScheme: ColorScheme? { switch self { case .light: - print("light") return .light case .dark: - print("dark") return .dark #if os(iOS) case .automatic: - print("system") return nil #endif } diff --git a/nym-vpn-apple/Services/Sources/Services/Modifiers/AppearanceUpdate.swift b/nym-vpn-apple/Services/Sources/Services/Modifiers/AppearanceUpdate.swift index 5420e13c24..77beb36075 100644 --- a/nym-vpn-apple/Services/Sources/Services/Modifiers/AppearanceUpdate.swift +++ b/nym-vpn-apple/Services/Sources/Services/Modifiers/AppearanceUpdate.swift @@ -6,8 +6,9 @@ public struct AppearanceUpdate: ViewModifier { public func body(content: Content) -> some View { content -// .preferredColorScheme(appSettings.currentAppearance.colorScheme) -// .environment(\.colorScheme, appSettings.currentAppearance.colorScheme) +#if os(macOS) + .preferredColorScheme(appSettings.currentAppearance.colorScheme) +#endif } }