NetNewsWire/Multiplatform/Shared/Timeline/TimelineView.swift

52 lines
1.4 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
2020-07-12 01:22:47 +02:00
@State var navigate = false
2020-07-01 18:13:11 +02:00
2020-07-12 01:22:47 +02:00
@ViewBuilder var body: some View {
#if os(macOS)
ZStack {
NavigationLink(destination: ArticleContainerView(articles: timelineModel.selectedArticles), isActive: $navigate) {
EmptyView()
}.hidden()
List(timelineModel.timelineItems, selection: $timelineModel.selectedArticleIDs) { timelineItem in
buildTimelineItemNavigation(timelineItem)
2020-07-06 01:53:18 +02:00
}
2020-07-01 19:30:55 +02:00
}
2020-07-12 01:22:47 +02:00
.onChange(of: timelineModel.selectedArticleIDs) { value in
navigate = !timelineModel.selectedArticleIDs.isEmpty
}
#else
List(timelineModel.timelineItems) { timelineItem in
buildTimelineItemNavigation(timelineItem)
}
#endif
2020-06-30 18:03:33 +02:00
}
2020-07-12 01:22:47 +02:00
func buildTimelineItemNavigation(_ timelineItem: TimelineItem) -> some View {
#if os(macOS)
return TimelineItemView(timelineItem: timelineItem) //.tag(timelineItem.article.articleID)
#else
return ZStack {
TimelineItemView(timelineItem: timelineItem)
NavigationLink(destination: ArticleContainerView(articles: timelineModel.selectedArticles),
tag: timelineItem.article.articleID,
selection: $timelineModel.selectedArticleID) {
EmptyView()
}.buttonStyle(PlainButtonStyle())
}
#endif
}
2020-07-01 19:30:55 +02:00
2020-06-30 18:03:33 +02:00
}