mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-24 12:13:32 -04:00
Remove sheet safari presentation for iOS, to be able to handle all types of links
This commit is contained in:
parent
4c6fc186a7
commit
edc71f660e
@ -1,29 +0,0 @@
|
||||
// This file is part of Kiwix for iOS & macOS.
|
||||
//
|
||||
// Kiwix is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// Kiwix is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Kiwix; If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
import SafariServices
|
||||
import SwiftUI
|
||||
|
||||
#if os(iOS)
|
||||
struct SafariView: UIViewControllerRepresentable {
|
||||
let url: URL
|
||||
|
||||
func makeUIViewController(context: Context) -> SFSafariViewController {
|
||||
SFSafariViewController(url: url)
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: SFSafariViewController, context: Context) { }
|
||||
}
|
||||
#endif
|
@ -81,7 +81,10 @@ struct About: View {
|
||||
}
|
||||
.navigationTitle("settings.about.title".localized)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.sheet(item: $externalLinkURL) { SafariView(url: $0) }
|
||||
.onChange(of: externalLinkURL) { url in
|
||||
guard let url = url else { return }
|
||||
UIApplication.shared.open(url)
|
||||
}
|
||||
.task { await getDependencies() }
|
||||
#endif
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import Defaults
|
||||
struct ExternalLinkHandler: ViewModifier {
|
||||
@State private var isAlertPresented = false
|
||||
@State private var activeAlert: ActiveAlert?
|
||||
@State private var activeSheet: ActiveSheet?
|
||||
@Binding var externalURL: URL?
|
||||
|
||||
enum ActiveAlert {
|
||||
@ -67,20 +66,13 @@ struct ExternalLinkHandler: ViewModifier {
|
||||
Text("external_link_handler.alert.not_loading.description".localized)
|
||||
}
|
||||
}
|
||||
#if os(iOS)
|
||||
.sheet(item: $activeSheet) { sheet in
|
||||
if case .safari(let url) = sheet {
|
||||
SafariView(url: url)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private func load(url: URL) {
|
||||
#if os(macOS)
|
||||
NSWorkspace.shared.open(url)
|
||||
#elseif os(iOS)
|
||||
activeSheet = .safari(url: url)
|
||||
UIApplication.shared.open(url)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user