Add open in system browser iOS setting
Also fixes issue where the incorrect URL could be used when doing open operation.
This commit is contained in:
@ -136,6 +136,9 @@ struct ProfileView: View {
|
||||
|
||||
#if os(iOS)
|
||||
Section {
|
||||
NavigationLink(destination: ReaderSettingsView()) {
|
||||
Text(LocalText.readerSettingsGeneric)
|
||||
}
|
||||
NavigationLink(destination: PushNotificationSettingsView()) {
|
||||
Text(LocalText.pushNotificationsGeneric)
|
||||
}
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
import Services
|
||||
import SwiftUI
|
||||
import Views
|
||||
import Utils
|
||||
|
||||
enum OpenLinkIn: String {
|
||||
case insideApp
|
||||
case systemBrowser
|
||||
}
|
||||
|
||||
struct ReaderSettingsView: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@AppStorage(UserDefaultKey.openExternalLinksIn.rawValue) var openExternalLinksIn = OpenLinkIn.insideApp.rawValue
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
Picker(selection: $openExternalLinksIn, content: {
|
||||
Text("Inside app").tag(OpenLinkIn.insideApp.rawValue)
|
||||
Text("Use system browser").tag(OpenLinkIn.systemBrowser.rawValue)
|
||||
}, label: { Text("Open links:") })
|
||||
.pickerStyle(MenuPickerStyle())
|
||||
}.navigationTitle(LocalText.readerSettingsGeneric)
|
||||
.onReceive(NotificationCenter.default.publisher(for: Notification.Name("ScrollToTop"))) { _ in
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -414,16 +414,24 @@ struct WebReaderContainerView: View {
|
||||
titleVisibility: .visible) {
|
||||
Button(action: {
|
||||
if let linkToOpen = linkToOpen {
|
||||
safariWebLink = SafariWebLink(id: UUID(), url: linkToOpen)
|
||||
if UserDefaults.standard.string(forKey: UserDefaultKey.openExternalLinksIn.rawValue) == OpenLinkIn.systemBrowser.rawValue, UIApplication.shared.canOpenURL(linkToOpen) {
|
||||
UIApplication.shared.open(linkToOpen)
|
||||
} else {
|
||||
safariWebLink = SafariWebLink(id: UUID(), url: linkToOpen)
|
||||
}
|
||||
}
|
||||
}, label: { Text(LocalText.genericOpen) })
|
||||
Button(action: {
|
||||
#if os(iOS)
|
||||
UIPasteboard.general.string = item.unwrappedPageURLString
|
||||
#else
|
||||
// Pasteboard.general.string = item.unwrappedPageURLString TODO: fix for mac
|
||||
#endif
|
||||
Snackbar.show(message: "Link copied", dismissAfter: 2000)
|
||||
if let linkToOpen = linkToOpen?.absoluteString {
|
||||
#if os(iOS)
|
||||
UIPasteboard.general.string = linkToOpen
|
||||
#else
|
||||
// Pasteboard.general.string = item.unwrappedPageURLString TODO: fix for mac
|
||||
#endif
|
||||
Snackbar.show(message: "Link copied", dismissAfter: 2000)
|
||||
} else {
|
||||
Snackbar.show(message: "Error copying link", dismissAfter: 2000)
|
||||
}
|
||||
}, label: { Text(LocalText.readerCopyLink) })
|
||||
Button(action: {
|
||||
if let linkToOpen = linkToOpen {
|
||||
|
||||
@ -35,6 +35,7 @@ public enum UserDefaultKey: String {
|
||||
case hideFeatureSection
|
||||
case hideSystemLabels
|
||||
case justifyText
|
||||
case openExternalLinksIn
|
||||
case prefersHideStatusBarInReader
|
||||
case visibleShareExtensionTab
|
||||
}
|
||||
|
||||
@ -201,4 +201,5 @@ public enum LocalText {
|
||||
public static let dismissButton = localText(key: "dismissButton")
|
||||
public static let errorNetwork = localText(key: "errorNetwork")
|
||||
public static let documentationGeneric = localText(key: "documentationGeneric")
|
||||
public static let readerSettingsGeneric = localText(key: "readerSettingsGeneric")
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@
|
||||
"labelsGeneric" = "Labels";
|
||||
"emailsGeneric" = "Emails";
|
||||
"subscriptionsGeneric" = "Subscriptions";
|
||||
"textToSpeechGeneric" = "Text to Speech";
|
||||
"textToSpeechGeneric" = "Text to speech";
|
||||
"privacyPolicyGeneric" = "Privacy Policy";
|
||||
"termsAndConditionsGeneric" = "Terms and Conditions";
|
||||
"feedbackGeneric" = "Feedback";
|
||||
@ -196,7 +196,8 @@
|
||||
"clubsGeneric" = "Clubs";
|
||||
"filterGeneric" = "Filters";
|
||||
"errorGeneric" = "Something went wrong, please try again.";
|
||||
"pushNotificationsGeneric" = "Push Notifications";
|
||||
"readerSettingsGeneric" = "Reader settings";
|
||||
"pushNotificationsGeneric" = "Push notifications";
|
||||
"dismissButton" = "Dismiss";
|
||||
"errorNetwork" = "We are having trouble connecting to the internet.";
|
||||
"documentationGeneric" = "Documentation";
|
||||
|
||||
Reference in New Issue
Block a user