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-07-21 10:05:31 +02:00
|
|
|
@EnvironmentObject private var sidebarModel: SidebarModel
|
2020-07-18 11:34:04 +02:00
|
|
|
@State private var showInspector: Bool = false
|
2020-06-29 23:58:10 +02:00
|
|
|
var sidebarItem: SidebarItem
|
|
|
|
|
|
|
|
var body: some View {
|
2020-07-22 00:40:51 +02: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-30 03:09:11 +02:00
|
|
|
}
|
2020-06-29 23:58:10 +02:00
|
|
|
Spacer()
|
|
|
|
if sidebarItem.unreadCount > 0 {
|
|
|
|
UnreadCountView(count: sidebarItem.unreadCount)
|
|
|
|
}
|
2020-07-06 02:09:23 +02:00
|
|
|
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-07-18 01:05:26 +02:00
|
|
|
}.contextMenu {
|
2020-07-18 11:34:04 +02:00
|
|
|
SidebarContextMenu(showInspector: $showInspector, sidebarItem: sidebarItem)
|
2020-07-21 10:05:31 +02:00
|
|
|
.environmentObject(sidebarModel)
|
2020-07-18 11:34:04 +02:00
|
|
|
}
|
|
|
|
.sheet(isPresented: $showInspector, onDismiss: { showInspector = false}) {
|
|
|
|
InspectorView(sidebarItem: sidebarItem)
|
2020-07-18 01:05:26 +02:00
|
|
|
}
|
2020-06-30 06:37:29 +02:00
|
|
|
}
|
|
|
|
|
2020-06-29 23:58:10 +02:00
|
|
|
}
|