From 3b4ec7262ff3217d009c6293faa64537e451be2a Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 7 Sep 2019 14:10:20 -0500 Subject: [PATCH] Refactor website links to make code clearer and more concise --- iOS/Settings/SettingsView.swift | 59 +++++++++++++++------------------ 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/iOS/Settings/SettingsView.swift b/iOS/Settings/SettingsView.swift index 005f39e4f..0bff1287f 100644 --- a/iOS/Settings/SettingsView.swift +++ b/iOS/Settings/SettingsView.swift @@ -15,10 +15,7 @@ struct SettingsView : View { @ObservedObject var viewModel: ViewModel @State var isWebsitePresented: Bool = false - @State var isGithubRepoPresented: Bool = false - @State var isBugTrackerPresented: Bool = false - @State var isTechnotesPresented: Bool = false - @State var isHowToSupportPresented: Bool = false + @State var website: String? = nil var body: some View { NavigationView { @@ -70,47 +67,45 @@ struct SettingsView : View { Section(header: Text("ABOUT"), footer: buildFooter) { Text("About NetNewsWire") - Button(action: { self.isWebsitePresented.toggle() }) { + Button(action: { + self.isWebsitePresented.toggle() + self.website = "https://ranchero.com/netnewswire/" + }) { Text("Website") - } - }.sheet(isPresented: $isWebsitePresented) { - SafariView(url: URL(string: "https://ranchero.com/netnewswire/")!) } - VStack { - Button(action: { self.isGithubRepoPresented.toggle() }) { - Text("Github Repository") - } - }.sheet(isPresented: $isGithubRepoPresented) { - SafariView(url: URL(string: "https://github.com/brentsimmons/NetNewsWire")!) + Button(action: { + self.isWebsitePresented.toggle() + self.website = "https://github.com/brentsimmons/NetNewsWire" + }) { + Text("Github Repository") } - VStack { - Button(action: { self.isBugTrackerPresented.toggle() }) { - Text("Bug Tracker") - } - }.sheet(isPresented: $isBugTrackerPresented) { - SafariView(url: URL(string: "https://github.com/brentsimmons/NetNewsWire/issues")!) + Button(action: { + self.isWebsitePresented.toggle() + self.website = "https://github.com/brentsimmons/NetNewsWire/issues" + }) { + Text("Bug Tracker") } - VStack { - Button(action: { self.isTechnotesPresented.toggle() }) { - Text("Technotes") - } - }.sheet(isPresented: $isTechnotesPresented) { - SafariView(url: URL(string: "https://github.com/brentsimmons/NetNewsWire/tree/master/Technotes")!) + Button(action: { + self.isWebsitePresented.toggle() + self.website = "https://github.com/brentsimmons/NetNewsWire/tree/master/Technotes" + }) { + Text("Technotes") } - VStack { - Button(action: { self.isHowToSupportPresented.toggle() }) { - Text("Technotes") - } - }.sheet(isPresented: $isHowToSupportPresented) { - SafariView(url: URL(string: "hhttps://github.com/brentsimmons/NetNewsWire/blob/master/Technotes/HowToSupportNetNewsWire.markdown")!) + Button(action: { + self.isWebsitePresented.toggle() + self.website = "https://github.com/brentsimmons/NetNewsWire/blob/master/Technotes/HowToSupportNetNewsWire.markdown" + }) { + Text("How To Support NetNewsWire") } Text("Add NetNewsWire News Feed") + }.sheet(isPresented: $isWebsitePresented) { + SafariView(url: URL(string: self.website!)!) } .foregroundColor(.primary)