Opens Settings option in SFSafariViewController

Fixes #754
Fixes #756
This commit is contained in:
Stuart Breckenridge
2019-06-16 07:23:32 +08:00
parent 4887fb7f5e
commit 2f4d1145f4
3 changed files with 72 additions and 27 deletions

View File

@@ -0,0 +1,52 @@
//
// SafariView.swift
// NetNewsWire-iOS
//
// Created by Stuart Breckenridge on 16/6/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import SwiftUI
import SafariServices
struct SafariView : UIViewControllerRepresentable {
let url: URL
func makeUIViewController(context: UIViewControllerRepresentableContext<SafariView>) -> SFSafariViewController {
let safari = SFSafariViewController(url: url)
safari.delegate = context.coordinator
return safari
}
func updateUIViewController(_ uiViewController: SFSafariViewController, context: UIViewControllerRepresentableContext<SafariView>) {
//
}
func makeCoordinator() -> Coordinator {
return Coordinator(self)
}
class Coordinator : NSObject, SFSafariViewControllerDelegate {
var parent: SafariView
init(_ safariView: SafariView) {
self.parent = safariView
}
// MARK: SFSafariViewControllerDelegate
func safariViewControllerDidFinish(_ controller: SFSafariViewController) {
}
func safariViewController(_ controller: SFSafariViewController, initialLoadDidRedirectTo URL: URL) {
}
func safariViewController(_ controller: SFSafariViewController, didCompleteInitialLoad didLoadSuccessfully: Bool) {
}
}
}

View File

@@ -10,9 +10,12 @@ import SwiftUI
import Combine
import Account
struct SettingsView : View {
@ObjectBinding var viewModel: ViewModel
var body: some View {
NavigationView {
List {
@@ -31,30 +34,16 @@ struct SettingsView : View {
Section(header: Text("ABOUT")) {
Text("About NetNewsWire")
Button(action: {
UIApplication.shared.open(URL(string: "https://ranchero.com/netnewswire/")!, options: [:])
}) {
Text("Website")
}
Button(action: {
UIApplication.shared.open(URL(string: "https://github.com/brentsimmons/NetNewsWire")!, options: [:])
}) {
Text("Github Repository")
}
Button(action: {
UIApplication.shared.open(URL(string: "https://github.com/brentsimmons/NetNewsWire/issues")!, options: [:])
}) {
Text("Bug Tracker")
}
Button(action: {
UIApplication.shared.open(URL(string: "https://github.com/brentsimmons/NetNewsWire/tree/master/Technotes")!, options: [:])
}) {
Text("Technotes")
}
PresentationButton(Text("Website"), destination: SafariView(url: URL(string: "https://ranchero.com/netnewswire/")!))
PresentationButton(Text("Github Repository"), destination: SafariView(url: URL(string: "https://github.com/brentsimmons/NetNewsWire")!))
PresentationButton(Text("Bug Tracker"), destination: SafariView(url: URL(string: "https://github.com/brentsimmons/NetNewsWire/issues")!))
PresentationButton(Text("Technotes"), destination: SafariView(url: URL(string: "https://github.com/brentsimmons/NetNewsWire/tree/master/Technotes")!))
PresentationButton(Text("How to Support NetNewsWire"), destination: SafariView(url: URL(string: "https://github.com/brentsimmons/NetNewsWire/blob/master/Technotes/HowToSupportNetNewsWire.markdown")!))
Text("Add NetNewsWire News Feed")