mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-23 08:09:41 +01:00
48c721a468
Feature/sidebar context menus
65 lines
1.6 KiB
Swift
65 lines
1.6 KiB
Swift
//
|
|
// SidebarItemView.swift
|
|
// NetNewsWire
|
|
//
|
|
// Created by Maurice Parker on 6/29/20.
|
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
import Account
|
|
|
|
struct SidebarItemView: View {
|
|
|
|
@StateObject var feedIconImageLoader = FeedIconImageLoader()
|
|
@EnvironmentObject private var sidebarModel: SidebarModel
|
|
@State private var showInspector: Bool = false
|
|
var sidebarItem: SidebarItem
|
|
|
|
var body: some View {
|
|
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)
|
|
}
|
|
Spacer()
|
|
if sidebarItem.unreadCount > 0 {
|
|
UnreadCountView(count: sidebarItem.unreadCount)
|
|
}
|
|
if sidebarItem.representedType == .webFeed || sidebarItem.representedType == .pseudoFeed {
|
|
Spacer()
|
|
.frame(width: 16)
|
|
}
|
|
#endif
|
|
}
|
|
.onAppear {
|
|
if let feed = sidebarItem.feed {
|
|
feedIconImageLoader.loadImage(for: feed)
|
|
}
|
|
}.contextMenu {
|
|
SidebarContextMenu(showInspector: $showInspector, sidebarItem: sidebarItem)
|
|
.environmentObject(sidebarModel)
|
|
}
|
|
.sheet(isPresented: $showInspector, onDismiss: { showInspector = false}) {
|
|
InspectorView(sidebarItem: sidebarItem)
|
|
}
|
|
}
|
|
|
|
}
|