Refactor website links to make code clearer and more concise

This commit is contained in:
Maurice Parker 2019-09-07 14:10:20 -05:00
parent 22553b661d
commit 3b4ec7262f
1 changed files with 27 additions and 32 deletions

View File

@ -15,10 +15,7 @@ struct SettingsView : View {
@ObservedObject var viewModel: ViewModel @ObservedObject var viewModel: ViewModel
@State var isWebsitePresented: Bool = false @State var isWebsitePresented: Bool = false
@State var isGithubRepoPresented: Bool = false @State var website: String? = nil
@State var isBugTrackerPresented: Bool = false
@State var isTechnotesPresented: Bool = false
@State var isHowToSupportPresented: Bool = false
var body: some View { var body: some View {
NavigationView { NavigationView {
@ -70,47 +67,45 @@ struct SettingsView : View {
Section(header: Text("ABOUT"), footer: buildFooter) { Section(header: Text("ABOUT"), footer: buildFooter) {
Text("About NetNewsWire") Text("About NetNewsWire")
Button(action: { self.isWebsitePresented.toggle() }) { Button(action: {
self.isWebsitePresented.toggle()
self.website = "https://ranchero.com/netnewswire/"
}) {
Text("Website") Text("Website")
}
}.sheet(isPresented: $isWebsitePresented) {
SafariView(url: URL(string: "https://ranchero.com/netnewswire/")!)
} }
VStack { Button(action: {
Button(action: { self.isGithubRepoPresented.toggle() }) { self.isWebsitePresented.toggle()
Text("Github Repository") self.website = "https://github.com/brentsimmons/NetNewsWire"
} }) {
}.sheet(isPresented: $isGithubRepoPresented) { Text("Github Repository")
SafariView(url: URL(string: "https://github.com/brentsimmons/NetNewsWire")!)
} }
VStack { Button(action: {
Button(action: { self.isBugTrackerPresented.toggle() }) { self.isWebsitePresented.toggle()
Text("Bug Tracker") self.website = "https://github.com/brentsimmons/NetNewsWire/issues"
} }) {
}.sheet(isPresented: $isBugTrackerPresented) { Text("Bug Tracker")
SafariView(url: URL(string: "https://github.com/brentsimmons/NetNewsWire/issues")!)
} }
VStack { Button(action: {
Button(action: { self.isTechnotesPresented.toggle() }) { self.isWebsitePresented.toggle()
Text("Technotes") self.website = "https://github.com/brentsimmons/NetNewsWire/tree/master/Technotes"
} }) {
}.sheet(isPresented: $isTechnotesPresented) { Text("Technotes")
SafariView(url: URL(string: "https://github.com/brentsimmons/NetNewsWire/tree/master/Technotes")!)
} }
VStack { Button(action: {
Button(action: { self.isHowToSupportPresented.toggle() }) { self.isWebsitePresented.toggle()
Text("Technotes") self.website = "https://github.com/brentsimmons/NetNewsWire/blob/master/Technotes/HowToSupportNetNewsWire.markdown"
} }) {
}.sheet(isPresented: $isHowToSupportPresented) { Text("How To Support NetNewsWire")
SafariView(url: URL(string: "hhttps://github.com/brentsimmons/NetNewsWire/blob/master/Technotes/HowToSupportNetNewsWire.markdown")!)
} }
Text("Add NetNewsWire News Feed") Text("Add NetNewsWire News Feed")
}.sheet(isPresented: $isWebsitePresented) {
SafariView(url: URL(string: self.website!)!)
} }
.foregroundColor(.primary) .foregroundColor(.primary)