From 2f4d1145f4efb94d8412cd341e9bd7a0c72ac474 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Sun, 16 Jun 2019 07:23:32 +0800 Subject: [PATCH] Opens Settings option in SFSafariViewController Fixes #754 Fixes #756 --- NetNewsWire.xcodeproj/project.pbxproj | 12 ++++--- iOS/Settings/SafariView.swift | 52 +++++++++++++++++++++++++++ iOS/Settings/SettingsView.swift | 35 +++++++----------- 3 files changed, 72 insertions(+), 27 deletions(-) create mode 100644 iOS/Settings/SafariView.swift diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index a6cd26935..5b7f782c1 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -318,6 +318,7 @@ D5F4EDB5200744A700B9E363 /* ScriptingObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5F4EDB4200744A700B9E363 /* ScriptingObject.swift */; }; D5F4EDB720074D6500B9E363 /* Feed+Scriptability.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5F4EDB620074D6500B9E363 /* Feed+Scriptability.swift */; }; D5F4EDB920074D7C00B9E363 /* Folder+Scriptability.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5F4EDB820074D7C00B9E363 /* Folder+Scriptability.swift */; }; + DF999FF722B5AEFA0064B687 /* SafariView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF999FF622B5AEFA0064B687 /* SafariView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -926,6 +927,7 @@ D5F4EDB4200744A700B9E363 /* ScriptingObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptingObject.swift; sourceTree = ""; }; D5F4EDB620074D6500B9E363 /* Feed+Scriptability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Feed+Scriptability.swift"; sourceTree = ""; }; D5F4EDB820074D7C00B9E363 /* Folder+Scriptability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Folder+Scriptability.swift"; sourceTree = ""; }; + DF999FF622B5AEFA0064B687 /* SafariView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariView.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -1040,6 +1042,7 @@ 5183CCEB227117C70010922C /* Settings */ = { isa = PBXGroup; children = ( + DF999FF622B5AEFA0064B687 /* SafariView.swift */, 510D708122B041CC004E8F65 /* SettingsAccountLabelView.swift */, 510D707322B028E1004E8F65 /* SettingsAddAccountView.swift */, 51F772EC22B2789B0087D9D1 /* SettingsDetailAccountView.swift */, @@ -1935,12 +1938,12 @@ ORGANIZATIONNAME = "Ranchero Software"; TargetAttributes = { 6581C73220CED60000F4AD34 = { - DevelopmentTeam = SHJK2V3AJG; + DevelopmentTeam = M8L2WTLA8W; ProvisioningStyle = Manual; }; 840D617B2029031C009BC708 = { CreatedOnToolsVersion = 9.3; - DevelopmentTeam = SHJK2V3AJG; + DevelopmentTeam = M8L2WTLA8W; ProvisioningStyle = Automatic; SystemCapabilities = { com.apple.BackgroundModes = { @@ -1950,7 +1953,7 @@ }; 849C645F1ED37A5D003D8FC0 = { CreatedOnToolsVersion = 8.2.1; - DevelopmentTeam = SHJK2V3AJG; + DevelopmentTeam = M8L2WTLA8W; ProvisioningStyle = Manual; SystemCapabilities = { com.apple.HardenedRuntime = { @@ -1960,7 +1963,7 @@ }; 849C64701ED37A5D003D8FC0 = { CreatedOnToolsVersion = 8.2.1; - DevelopmentTeam = SHJK2V3AJG; + DevelopmentTeam = 9C84TZ7Q6Z; ProvisioningStyle = Automatic; TestTargetID = 849C645F1ED37A5D003D8FC0; }; @@ -2365,6 +2368,7 @@ 51C452762265091600C03939 /* MasterTimelineViewController.swift in Sources */, 5183CCE9226F68D90010922C /* AccountRefreshTimer.swift in Sources */, 51C452882265093600C03939 /* AddFeedViewController.swift in Sources */, + DF999FF722B5AEFA0064B687 /* SafariView.swift in Sources */, 51C4529B22650A1000C03939 /* FaviconDownloader.swift in Sources */, 5183CCE3226F314C0010922C /* ProgressTableViewController.swift in Sources */, 512E09012268907400BDCFDD /* MasterFeedTableViewSectionHeader.swift in Sources */, diff --git a/iOS/Settings/SafariView.swift b/iOS/Settings/SafariView.swift new file mode 100644 index 000000000..6b5d78334 --- /dev/null +++ b/iOS/Settings/SafariView.swift @@ -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) -> SFSafariViewController { + let safari = SFSafariViewController(url: url) + safari.delegate = context.coordinator + return safari + } + + func updateUIViewController(_ uiViewController: SFSafariViewController, context: UIViewControllerRepresentableContext) { + // + } + + 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) { + + } + } +} + + diff --git a/iOS/Settings/SettingsView.swift b/iOS/Settings/SettingsView.swift index d0ddae653..82b1cbe07 100644 --- a/iOS/Settings/SettingsView.swift +++ b/iOS/Settings/SettingsView.swift @@ -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")