visionOS: Disable in-app Safari

This commit is contained in:
Shadowfacts 2024-02-03 12:03:41 -05:00
parent 0f6492a051
commit f122383d0b
2 changed files with 6 additions and 2 deletions

View File

@ -57,12 +57,14 @@ struct BehaviorPrefsView: View {
Toggle(isOn: $preferences.openLinksInApps) { Toggle(isOn: $preferences.openLinksInApps) {
Text("Open Links in Apps") Text("Open Links in Apps")
} }
#if !os(visionOS)
Toggle(isOn: $preferences.useInAppSafari) { Toggle(isOn: $preferences.useInAppSafari) {
Text("Use In-App Safari") Text("Use In-App Safari")
} }
Toggle(isOn: $preferences.inAppSafariAutomaticReaderMode) { Toggle(isOn: $preferences.inAppSafariAutomaticReaderMode) {
Text("Always Use Reader Mode in In-App Safari") Text("Always Use Reader Mode in In-App Safari")
}.disabled(!preferences.useInAppSafari) }.disabled(!preferences.useInAppSafari)
#endif
} }
.appGroupedListRowBackground() .appGroupedListRowBackground()
} }

View File

@ -46,14 +46,15 @@ extension TuskerNavigationDelegate {
func selected(url: URL, allowResolveStatuses: Bool = true, allowUniversalLinks: Bool = true) { func selected(url: URL, allowResolveStatuses: Bool = true, allowUniversalLinks: Bool = true) {
func openSafari() { func openSafari() {
#if os(visionOS)
UIApplication.shared.open(url)
#else
if Preferences.shared.useInAppSafari, if Preferences.shared.useInAppSafari,
url.scheme == "https" || url.scheme == "http" { url.scheme == "https" || url.scheme == "http" {
let config = SFSafariViewController.Configuration() let config = SFSafariViewController.Configuration()
config.entersReaderIfAvailable = Preferences.shared.inAppSafariAutomaticReaderMode config.entersReaderIfAvailable = Preferences.shared.inAppSafariAutomaticReaderMode
let vc = SFSafariViewController(url: url, configuration: config) let vc = SFSafariViewController(url: url, configuration: config)
#if !os(visionOS)
vc.preferredControlTintColor = Preferences.shared.accentColor.color vc.preferredControlTintColor = Preferences.shared.accentColor.color
#endif
present(vc, animated: true) present(vc, animated: true)
} else if UIApplication.shared.canOpenURL(url) { } else if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:]) UIApplication.shared.open(url, options: [:])
@ -66,6 +67,7 @@ extension TuskerNavigationDelegate {
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
present(alert, animated: true) present(alert, animated: true)
} }
#endif
} }
if allowResolveStatuses, if allowResolveStatuses,