NetNewsWire/Multiplatform/Shared/Timeline/TimelineView.swift

64 lines
1.7 KiB
Swift
Raw Normal View History

2020-06-30 18:03:33 +02:00
//
// TimelineView.swift
// NetNewsWire
//
// Created by Maurice Parker on 6/30/20.
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import SwiftUI
struct TimelineView: View {
2020-07-01 18:13:11 +02:00
@EnvironmentObject private var timelineModel: TimelineModel
@State var navigate = true
2020-07-01 18:13:11 +02:00
2020-07-12 01:22:47 +02:00
@ViewBuilder var body: some View {
#if os(macOS)
2020-07-12 21:43:52 +02:00
VStack {
HStack {
2020-07-13 02:43:25 +02:00
TimelineSortOrderView()
2020-07-12 21:43:52 +02:00
Spacer()
Button (action: {
withAnimation {
timelineModel.toggleReadFilter()
2020-07-12 21:43:52 +02:00
}
}, label: {
if timelineModel.isReadFiltered ?? false {
2020-07-12 21:43:52 +02:00
AppAssets.filterActiveImage
} else {
AppAssets.filterInactiveImage
}
})
.hidden(timelineModel.isReadFiltered == nil)
2020-07-12 21:43:52 +02:00
.padding(.top, 8).padding(.trailing)
.buttonStyle(PlainButtonStyle())
.help(timelineModel.isReadFiltered ?? false ? "Show Read Articles" : "Filter Read Articles")
2020-07-12 21:43:52 +02:00
}
ZStack {
2020-07-16 18:14:05 +02:00
NavigationLink(destination: ArticleContainerView(), isActive: $navigate) {
2020-07-12 21:43:52 +02:00
EmptyView()
}.hidden()
List(timelineModel.timelineItems, selection: $timelineModel.selectedArticleIDs) { timelineItem in
TimelineItemView(timelineItem: timelineItem)
}
}
2020-07-12 01:22:47 +02:00
}
.navigationTitle(Text(verbatim: timelineModel.nameForDisplay))
2020-07-12 01:22:47 +02:00
#else
List(timelineModel.timelineItems) { timelineItem in
ZStack {
TimelineItemView(timelineItem: timelineItem)
2020-07-16 18:42:07 +02:00
NavigationLink(destination: ArticleContainerView(),
tag: timelineItem.article.articleID,
selection: $timelineModel.selectedArticleID) {
EmptyView()
}.buttonStyle(PlainButtonStyle())
}
2020-07-12 01:22:47 +02:00
}
.navigationBarTitle(Text(verbatim: timelineModel.nameForDisplay), displayMode: .inline)
2020-07-12 01:22:47 +02:00
#endif
2020-06-30 18:03:33 +02:00
}
2020-07-12 01:22:47 +02:00
2020-06-30 18:03:33 +02:00
}