Hide home url section if one isn't available

This commit is contained in:
Maurice Parker 2020-07-18 20:18:57 -05:00
parent 86a38edabd
commit 68f4ea88c9

View File

@ -52,47 +52,47 @@ struct InspectorView: View {
Toggle("Always Show Reader View", isOn: $inspectorModel.alwaysShowReaderView) Toggle("Always Show Reader View", isOn: $inspectorModel.alwaysShowReaderView)
}) })
#if os(macOS) if let homePageURL = (sidebarItem.feed as? WebFeed)?.homePageURL {
Divider() #if os(macOS)
#endif Divider()
#endif
Section(header: Text("Home Page URL")) {
HStack { Section(header: Text("Home Page URL")) {
Text((sidebarItem.feed as? WebFeed)?.homePageURL ?? "") HStack {
.fixedSize(horizontal: false, vertical: true) Text(verbatim: homePageURL)
Spacer() .fixedSize(horizontal: false, vertical: true)
AppAssets.openInBrowserImage Spacer()
.foregroundColor(.accentColor) AppAssets.openInBrowserImage
} .foregroundColor(.accentColor)
.onTapGesture {
if let url = URL(string: (sidebarItem.feed as? WebFeed)?.homePageURL ?? "") {
#if os(macOS)
NSWorkspace.shared.open(url)
#else
inspectorModel.showHomePage = true
#endif
} }
} .onTapGesture {
.contextMenu(ContextMenu(menuItems: { if let url = URL(string: homePageURL) {
Button(action: {
if let urlString = (sidebarItem.feed as? WebFeed)?.homePageURL {
#if os(macOS) #if os(macOS)
URLPasteboardWriter.write(urlString: urlString, to: NSPasteboard.general) NSWorkspace.shared.open(url)
#else #else
UIPasteboard.general.string = urlString inspectorModel.showHomePage = true
#endif #endif
} }
}, label: { }
Text("Copy Home Page URL") .contextMenu(ContextMenu(menuItems: {
}) Button(action: {
})) #if os(macOS)
} URLPasteboardWriter.write(urlString: homePageURL, to: NSPasteboard.general)
.sheet(isPresented: $inspectorModel.showHomePage, onDismiss: { inspectorModel.showHomePage = false }) { #else
#if os(macOS) UIPasteboard.general.string = homePageURL
EmptyView() #endif
#else }, label: {
SafariView(url: URL(string: (sidebarItem.feed as! WebFeed).homePageURL!)!) Text("Copy Home Page URL")
#endif })
}))
}
.sheet(isPresented: $inspectorModel.showHomePage, onDismiss: { inspectorModel.showHomePage = false }) {
#if os(macOS)
EmptyView()
#else
SafariView(url: URL(string: (sidebarItem.feed as! WebFeed).homePageURL!)!)
#endif
}
} }
#if os(macOS) #if os(macOS)
@ -100,7 +100,7 @@ struct InspectorView: View {
#endif #endif
Section(header: Text("Feed URL")) { Section(header: Text("Feed URL")) {
Text((sidebarItem.feed as? WebFeed)?.url ?? "") Text(verbatim: (sidebarItem.feed as? WebFeed)?.url ?? "")
.fixedSize(horizontal: false, vertical: true) .fixedSize(horizontal: false, vertical: true)
.contextMenu(ContextMenu(menuItems: { .contextMenu(ContextMenu(menuItems: {
Button(action: { Button(action: {