2020-06-29 16:58:10 -05:00
|
|
|
//
|
|
|
|
// SidebarItemView.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 6/29/20.
|
|
|
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
2020-06-29 20:09:11 -05:00
|
|
|
import Account
|
2020-06-29 16:58:10 -05:00
|
|
|
|
|
|
|
struct SidebarItemView: View {
|
|
|
|
|
2020-07-01 16:37:20 -05:00
|
|
|
@StateObject var feedIconImageLoader = FeedIconImageLoader()
|
2020-07-21 16:05:31 +08:00
|
|
|
@EnvironmentObject private var sidebarModel: SidebarModel
|
2020-07-18 17:34:04 +08:00
|
|
|
@State private var showInspector: Bool = false
|
2020-06-29 16:58:10 -05:00
|
|
|
var sidebarItem: SidebarItem
|
|
|
|
|
|
|
|
var body: some View {
|
2020-07-21 17:40:51 -05:00
|
|
|
HStack {
|
|
|
|
#if os(macOS)
|
|
|
|
HStack {
|
|
|
|
if let image = feedIconImageLoader.image {
|
|
|
|
IconImageView(iconImage: image)
|
|
|
|
.frame(width: 20, height: 20, alignment: .center)
|
|
|
|
}
|
|
|
|
Text(verbatim: sidebarItem.nameForDisplay)
|
|
|
|
Spacer()
|
|
|
|
if sidebarItem.unreadCount > 0 {
|
|
|
|
UnreadCountView(count: sidebarItem.unreadCount)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
HStack(alignment: .top) {
|
|
|
|
if let image = feedIconImageLoader.image {
|
|
|
|
IconImageView(iconImage: image)
|
|
|
|
.frame(width: 20, height: 20)
|
|
|
|
}
|
|
|
|
Text(verbatim: sidebarItem.nameForDisplay)
|
2020-06-29 20:09:11 -05:00
|
|
|
}
|
2020-06-29 16:58:10 -05:00
|
|
|
Spacer()
|
|
|
|
if sidebarItem.unreadCount > 0 {
|
|
|
|
UnreadCountView(count: sidebarItem.unreadCount)
|
|
|
|
}
|
2020-07-05 19:09:23 -05:00
|
|
|
if sidebarItem.representedType == .webFeed || sidebarItem.representedType == .pseudoFeed {
|
|
|
|
Spacer()
|
|
|
|
.frame(width: 16)
|
|
|
|
}
|
|
|
|
#endif
|
2020-06-29 16:58:10 -05:00
|
|
|
}
|
2020-06-29 20:09:11 -05:00
|
|
|
.onAppear {
|
2020-06-30 12:37:29 +08:00
|
|
|
if let feed = sidebarItem.feed {
|
2020-07-01 16:37:20 -05:00
|
|
|
feedIconImageLoader.loadImage(for: feed)
|
2020-06-29 20:09:11 -05:00
|
|
|
}
|
2020-07-17 18:05:26 -05:00
|
|
|
}.contextMenu {
|
2020-07-18 17:34:04 +08:00
|
|
|
SidebarContextMenu(showInspector: $showInspector, sidebarItem: sidebarItem)
|
2020-07-21 16:05:31 +08:00
|
|
|
.environmentObject(sidebarModel)
|
2020-07-18 17:34:04 +08:00
|
|
|
}
|
|
|
|
.sheet(isPresented: $showInspector, onDismiss: { showInspector = false}) {
|
|
|
|
InspectorView(sidebarItem: sidebarItem)
|
2020-07-17 18:05:26 -05:00
|
|
|
}
|
2020-06-30 12:37:29 +08:00
|
|
|
}
|
|
|
|
|
2020-06-29 16:58:10 -05:00
|
|
|
}
|