2020-06-29 23:58:10 +02:00
|
|
|
//
|
|
|
|
// SidebarItemView.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 6/29/20.
|
|
|
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
2020-06-30 03:09:11 +02:00
|
|
|
import Account
|
2020-06-29 23:58:10 +02:00
|
|
|
|
|
|
|
struct SidebarItemView: View {
|
|
|
|
|
2020-07-01 23:37:20 +02:00
|
|
|
@StateObject var feedIconImageLoader = FeedIconImageLoader()
|
2020-06-29 23:58:10 +02:00
|
|
|
var sidebarItem: SidebarItem
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
HStack {
|
2020-07-01 23:37:20 +02:00
|
|
|
if let image = feedIconImageLoader.image {
|
2020-06-30 03:09:11 +02:00
|
|
|
IconImageView(iconImage: image)
|
2020-07-02 00:21:58 +02:00
|
|
|
.frame(width: 20, height: 20, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
2020-06-30 03:09:11 +02:00
|
|
|
}
|
2020-06-29 23:58:10 +02:00
|
|
|
Text(verbatim: sidebarItem.nameForDisplay)
|
|
|
|
Spacer()
|
|
|
|
if sidebarItem.unreadCount > 0 {
|
|
|
|
UnreadCountView(count: sidebarItem.unreadCount)
|
|
|
|
}
|
2020-07-06 02:09:23 +02:00
|
|
|
#if os(iOS)
|
|
|
|
if sidebarItem.representedType == .webFeed || sidebarItem.representedType == .pseudoFeed {
|
|
|
|
Spacer()
|
|
|
|
.frame(width: 16)
|
|
|
|
}
|
|
|
|
#endif
|
2020-06-29 23:58:10 +02:00
|
|
|
}
|
2020-06-30 03:09:11 +02:00
|
|
|
.onAppear {
|
2020-06-30 06:37:29 +02:00
|
|
|
if let feed = sidebarItem.feed {
|
2020-07-01 23:37:20 +02:00
|
|
|
feedIconImageLoader.loadImage(for: feed)
|
2020-06-30 03:09:11 +02:00
|
|
|
}
|
2020-06-30 04:31:50 +02:00
|
|
|
}.contextMenu(menuItems: {
|
2020-06-30 06:37:29 +02:00
|
|
|
menuItems
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
@ViewBuilder var menuItems: some View {
|
|
|
|
if sidebarItem.representedType == .account {
|
2020-07-04 21:13:12 +02:00
|
|
|
Button(action: {}) {
|
|
|
|
Text("Get Info")
|
2020-07-08 00:02:17 +02:00
|
|
|
#if os(iOS)
|
2020-07-04 21:13:12 +02:00
|
|
|
AppAssets.getInfoImage
|
2020-07-08 00:02:17 +02:00
|
|
|
#endif
|
2020-07-04 21:13:12 +02:00
|
|
|
}
|
2020-06-30 06:37:29 +02:00
|
|
|
Button(action: {}) {
|
2020-07-04 19:16:21 +02:00
|
|
|
Text("Mark All As Read")
|
2020-07-08 00:02:17 +02:00
|
|
|
#if os(iOS)
|
2020-07-04 19:16:21 +02:00
|
|
|
AppAssets.markAllAsReadImage
|
2020-07-08 00:02:17 +02:00
|
|
|
#endif
|
2020-06-30 06:37:29 +02:00
|
|
|
}
|
|
|
|
}
|
2020-07-04 19:16:21 +02:00
|
|
|
|
|
|
|
if sidebarItem.representedType == .pseudoFeed {
|
2020-06-30 06:37:29 +02:00
|
|
|
Button(action: {}) {
|
2020-07-04 19:16:21 +02:00
|
|
|
Text("Mark All As Read")
|
2020-07-08 00:02:17 +02:00
|
|
|
#if os(iOS)
|
2020-07-04 19:16:21 +02:00
|
|
|
AppAssets.markAllAsReadImage
|
2020-07-08 00:02:17 +02:00
|
|
|
#endif
|
2020-07-04 19:16:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if sidebarItem.representedType == .webFeed {
|
2020-07-04 21:13:12 +02:00
|
|
|
Button(action: {}) {
|
|
|
|
Text("Get Info")
|
2020-07-08 00:02:17 +02:00
|
|
|
#if os(iOS)
|
2020-07-04 21:13:12 +02:00
|
|
|
AppAssets.getInfoImage
|
2020-07-08 00:02:17 +02:00
|
|
|
#endif
|
2020-07-04 21:13:12 +02:00
|
|
|
}
|
2020-07-04 19:16:21 +02:00
|
|
|
Button(action: {}) {
|
|
|
|
Text("Mark All As Read")
|
2020-07-08 00:02:17 +02:00
|
|
|
#if os(iOS)
|
2020-07-04 19:16:21 +02:00
|
|
|
AppAssets.markAllAsReadImage
|
2020-07-08 00:02:17 +02:00
|
|
|
#endif
|
2020-06-30 06:37:29 +02:00
|
|
|
}
|
|
|
|
Divider()
|
2020-07-04 21:13:12 +02:00
|
|
|
Button(action: {}) {
|
2020-07-04 19:16:21 +02:00
|
|
|
Text("Open Home Page")
|
2020-07-08 00:02:17 +02:00
|
|
|
#if os(iOS)
|
2020-07-04 19:16:21 +02:00
|
|
|
AppAssets.openInBrowserImage
|
2020-07-08 00:02:17 +02:00
|
|
|
#endif
|
2020-06-30 06:37:29 +02:00
|
|
|
}
|
2020-07-13 18:43:27 +02:00
|
|
|
Divider()
|
2020-06-30 06:37:29 +02:00
|
|
|
Button(action: {}) {
|
2020-07-04 19:16:21 +02:00
|
|
|
Text("Copy Feed URL")
|
2020-07-08 00:02:17 +02:00
|
|
|
#if os(iOS)
|
2020-07-04 19:16:21 +02:00
|
|
|
AppAssets.copyImage
|
2020-07-08 00:02:17 +02:00
|
|
|
#endif
|
2020-06-30 06:37:29 +02:00
|
|
|
}
|
|
|
|
Button(action: {}) {
|
2020-07-04 19:16:21 +02:00
|
|
|
Text("Copy Home Page URL")
|
2020-07-08 00:02:17 +02:00
|
|
|
#if os(iOS)
|
2020-07-04 19:16:21 +02:00
|
|
|
AppAssets.copyImage
|
2020-07-08 00:02:17 +02:00
|
|
|
#endif
|
2020-06-30 06:37:29 +02:00
|
|
|
}
|
|
|
|
Divider()
|
|
|
|
Button(action: {}) {
|
2020-07-04 19:16:21 +02:00
|
|
|
Text("Rename")
|
2020-07-08 00:02:17 +02:00
|
|
|
#if os(iOS)
|
2020-07-04 19:16:21 +02:00
|
|
|
AppAssets.renameImage
|
2020-07-08 00:02:17 +02:00
|
|
|
#endif
|
2020-06-30 06:37:29 +02:00
|
|
|
}
|
|
|
|
Button(action: {}) {
|
2020-07-04 19:16:21 +02:00
|
|
|
Text("Delete")
|
2020-07-08 00:02:17 +02:00
|
|
|
#if os(iOS)
|
2020-07-04 19:16:21 +02:00
|
|
|
AppAssets.deleteImage
|
2020-07-08 00:02:17 +02:00
|
|
|
#endif
|
2020-06-30 06:37:29 +02:00
|
|
|
}
|
|
|
|
}
|
2020-07-04 19:16:21 +02:00
|
|
|
|
|
|
|
if sidebarItem.representedType == .folder {
|
|
|
|
Button(action: {}) {
|
|
|
|
Text("Mark All As Read")
|
2020-07-08 00:02:17 +02:00
|
|
|
#if os(iOS)
|
2020-07-04 19:16:21 +02:00
|
|
|
AppAssets.markAllAsReadImage
|
2020-07-08 00:02:17 +02:00
|
|
|
#endif
|
2020-07-04 19:16:21 +02:00
|
|
|
}
|
|
|
|
Divider()
|
|
|
|
Button(action: {}) {
|
|
|
|
Text("Rename")
|
2020-07-08 00:02:17 +02:00
|
|
|
#if os(iOS)
|
2020-07-04 19:16:21 +02:00
|
|
|
AppAssets.renameImage
|
2020-07-08 00:02:17 +02:00
|
|
|
#endif
|
2020-07-04 19:16:21 +02:00
|
|
|
}
|
2020-06-30 06:37:29 +02:00
|
|
|
Button(action: {}) {
|
2020-07-04 19:16:21 +02:00
|
|
|
Text("Delete")
|
2020-07-08 00:02:17 +02:00
|
|
|
#if os(iOS)
|
2020-07-04 19:16:21 +02:00
|
|
|
AppAssets.deleteImage
|
2020-07-08 00:02:17 +02:00
|
|
|
#endif
|
2020-06-30 04:31:50 +02:00
|
|
|
}
|
2020-06-30 06:37:29 +02:00
|
|
|
}
|
|
|
|
}
|
2020-06-29 23:58:10 +02:00
|
|
|
}
|