From f122383d0bff47e155ecedfa0ceec2a73b15b62e Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 3 Feb 2024 12:03:41 -0500 Subject: [PATCH] visionOS: Disable in-app Safari --- Tusker/Screens/Preferences/BehaviorPrefsView.swift | 2 ++ Tusker/TuskerNavigationDelegate.swift | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Tusker/Screens/Preferences/BehaviorPrefsView.swift b/Tusker/Screens/Preferences/BehaviorPrefsView.swift index 0a68fdb235..a2d9ea58b1 100644 --- a/Tusker/Screens/Preferences/BehaviorPrefsView.swift +++ b/Tusker/Screens/Preferences/BehaviorPrefsView.swift @@ -57,12 +57,14 @@ struct BehaviorPrefsView: View { Toggle(isOn: $preferences.openLinksInApps) { Text("Open Links in Apps") } + #if !os(visionOS) Toggle(isOn: $preferences.useInAppSafari) { Text("Use In-App Safari") } Toggle(isOn: $preferences.inAppSafariAutomaticReaderMode) { Text("Always Use Reader Mode in In-App Safari") }.disabled(!preferences.useInAppSafari) + #endif } .appGroupedListRowBackground() } diff --git a/Tusker/TuskerNavigationDelegate.swift b/Tusker/TuskerNavigationDelegate.swift index 9ee7ee84b6..eb3be9c0cb 100644 --- a/Tusker/TuskerNavigationDelegate.swift +++ b/Tusker/TuskerNavigationDelegate.swift @@ -46,14 +46,15 @@ extension TuskerNavigationDelegate { func selected(url: URL, allowResolveStatuses: Bool = true, allowUniversalLinks: Bool = true) { func openSafari() { + #if os(visionOS) + UIApplication.shared.open(url) + #else if Preferences.shared.useInAppSafari, url.scheme == "https" || url.scheme == "http" { let config = SFSafariViewController.Configuration() config.entersReaderIfAvailable = Preferences.shared.inAppSafariAutomaticReaderMode let vc = SFSafariViewController(url: url, configuration: config) - #if !os(visionOS) vc.preferredControlTintColor = Preferences.shared.accentColor.color - #endif present(vc, animated: true) } else if UIApplication.shared.canOpenURL(url) { UIApplication.shared.open(url, options: [:]) @@ -66,6 +67,7 @@ extension TuskerNavigationDelegate { alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) present(alert, animated: true) } + #endif } if allowResolveStatuses,