diff --git a/Sources/About/AboutController.swift b/Sources/About/AboutController.swift index 5c2df1a0cf03c26f8eaac2b358c5a2d1123d685e..1ba209bd63db1fb9b7bb517fb3f1f7e255153b1e 100644 --- a/Sources/About/AboutController.swift +++ b/Sources/About/AboutController.swift @@ -97,9 +97,10 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI } private func loadWebsite() { + let webTheme = PresentationTheme.current.webEquivalentTheme let mainBundle = Bundle.main - let textColor = PresentationTheme.current.colors.cellTextColor.toHex ?? "#000000" - let backgroundColor = PresentationTheme.current.colors.background.toHex ?? "#FFFFFF" + let textColor = webTheme.colors.cellTextColor.toHex ?? "#000000" + let backgroundColor = webTheme.colors.background.toHex ?? "#FFFFFF" guard let bundleShortVersionString = mainBundle.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String else { return } diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index a7b6ffbe598ddc6c2906c0d78aae9d2ab5a88f9c..5897ba3c261327b615fc54b91157c47ec1c5e602 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -177,10 +177,12 @@ enum MainOptions { } static func section() -> SettingsSection? { - .init(title: nil, items: [ - privacy, - appearance, - ]) + var items = [privacy] + #if !os(visionOS) + // visionOS uses a standard system appearance and doesn't have light/dark mode. + items.append(appearance) + #endif + return .init(title: nil, items: items) } } diff --git a/Sources/UI Elements/PresentationTheme.swift b/Sources/UI Elements/PresentationTheme.swift index 10585824d615117d0918763f826bdb617a6c728d..ff47383046499936e073a897bdc17a68278b9a8f 100644 --- a/Sources/UI Elements/PresentationTheme.swift +++ b/Sources/UI Elements/PresentationTheme.swift @@ -112,10 +112,24 @@ enum PresentationThemeType: Int { static let darkTheme = PresentationTheme(colors: darkPalette) static let blackTheme = PresentationTheme(colors: blackPalette) + #if os(visionOS) + static let visionTheme = PresentationTheme(colors: visionPalette) + #endif + var isDark: Bool { return colors.isDark } + var webEquivalentTheme: PresentationTheme { + #if os(visionOS) + // Since visionOS uses semantic colors for many of these, there will not be equivalent + // web hex colors. Fault back to the dark theme + return .darkTheme + #else + return self + #endif + } + var isBlack: Bool { return UserDefaults.standard.bool(forKey: kVLCSettingAppThemeBlack) } @@ -150,6 +164,9 @@ enum PresentationThemeType: Int { } static func respectiveTheme(for theme: PresentationThemeType?, excludingBlackTheme: Bool = false) -> PresentationTheme { +#if os(visionOS) + return .visionTheme +#else guard let theme = theme else { return PresentationTheme.brightTheme } @@ -173,9 +190,10 @@ enum PresentationThemeType: Int { } #else presentationTheme = darkTheme -#endif +#endif // os(iOS) } return presentationTheme +#endif // os(visionOS) } let colors: ColorPalette @@ -188,7 +206,7 @@ enum PresentationThemeType: Int { let r = CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0 let g = CGFloat((rgbValue & 0xFF00) >> 8) / 255.0 let b = CGFloat(rgbValue & 0xFF) / 255.0 - self.init(red: r, green: g, blue: b, alpha: 1.0) + self.init(red: r, green: g, blue: b, alpha: alpha) } private func toHex(alpha: Bool = false) -> String? { @@ -286,6 +304,31 @@ let blackPalette = ColorPalette(isDark: true, textfieldPlaceholderColor: UIColor(0x737373), thumbnailBackgroundColor: UIColor(0x1C1E21)) +#if os(visionOS) +let visionPalette = ColorPalette(isDark: true, + name: "visionOS", + statusBarStyle: .lightContent, + navigationbarColor: .clear, + navigationbarTextColor: .label, + background: .clear, + cellBackgroundA: .clear, + cellBackgroundB: UIColor(0x494B4D, 0.2), + cellDetailTextColor: .tertiaryLabel, + cellTextColor: .label, + lightTextColor: .secondaryLabel, + sectionHeaderTextColor: .secondaryLabel, + separatorColor: .tertiarySystemFill, + mediaCategorySeparatorColor: .tertiarySystemFill, + tabBarColor: .clear, + orangeUI: UIColor(0xFF8800), + orangeDarkAccent: UIColor(0xD57200), + toolBarStyle: UIBarStyle.black, + blurStyle: .dark, + textfieldBorderColor: UIColor(0x84929C), + textfieldPlaceholderColor: UIColor(0x737373), + thumbnailBackgroundColor: UIColor(0x1C1E21)) +#endif + let defaultFont = Typography(tableHeaderFont: UIFont.systemFont(ofSize: 24, weight: .semibold)) // MARK: - UIStatusBarStyle - autoDarkContent