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
|
2020-07-16 19:27:40 +02:00
|
|
|
@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 {
|
2020-07-12 23:48:39 +02:00
|
|
|
timelineModel.toggleReadFilter()
|
2020-07-12 21:43:52 +02:00
|
|
|
}
|
|
|
|
}, label: {
|
2020-07-12 23:48:39 +02:00
|
|
|
if timelineModel.isReadFiltered ?? false {
|
2020-07-12 21:43:52 +02:00
|
|
|
AppAssets.filterActiveImage
|
|
|
|
} else {
|
|
|
|
AppAssets.filterInactiveImage
|
|
|
|
}
|
|
|
|
})
|
2020-07-12 23:48:39 +02:00
|
|
|
.hidden(timelineModel.isReadFiltered == nil)
|
2020-07-12 21:43:52 +02:00
|
|
|
.padding(.top, 8).padding(.trailing)
|
|
|
|
.buttonStyle(PlainButtonStyle())
|
2020-07-12 23:48:39 +02:00
|
|
|
.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
|
|
|
}
|
2020-07-13 00:45:38 +02:00
|
|
|
.navigationTitle(Text(verbatim: timelineModel.nameForDisplay))
|
2020-07-12 01:22:47 +02:00
|
|
|
#else
|
|
|
|
List(timelineModel.timelineItems) { timelineItem in
|
2020-07-12 03:11:01 +02:00
|
|
|
ZStack {
|
|
|
|
TimelineItemView(timelineItem: timelineItem)
|
2020-07-16 18:42:07 +02:00
|
|
|
NavigationLink(destination: ArticleContainerView(),
|
2020-07-12 03:11:01 +02:00
|
|
|
tag: timelineItem.article.articleID,
|
|
|
|
selection: $timelineModel.selectedArticleID) {
|
|
|
|
EmptyView()
|
|
|
|
}.buttonStyle(PlainButtonStyle())
|
|
|
|
}
|
2020-07-12 01:22:47 +02:00
|
|
|
}
|
2020-07-13 18:37:21 +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
|
|
|
}
|