NetNewsWire/Multiplatform/Shared/Timeline/TimelineContainerView.swift

50 lines
1.4 KiB
Swift
Raw Normal View History

2020-06-30 18:03:33 +02:00
//
// TimelineContainerView.swift
// NetNewsWire
//
// Created by Maurice Parker on 6/30/20.
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import SwiftUI
2020-07-01 18:13:11 +02:00
import Account
2020-06-30 18:03:33 +02:00
struct TimelineContainerView: View {
2020-07-12 01:22:47 +02:00
@Environment(\.undoManager) var undoManager
2020-06-30 18:03:33 +02:00
@EnvironmentObject private var sceneModel: SceneModel
@State private var timelineItems = TimelineItems()
@State private var isReadFiltered: Bool? = nil
2020-08-12 15:04:56 +02:00
var body: some View {
TimelineView(timelineItems: $timelineItems, isReadFiltered: $isReadFiltered)
.modifier(TimelineToolbarModifier())
.environmentObject(sceneModel.timelineModel)
.onAppear {
sceneModel.timelineModel.undoManager = undoManager
}
.onReceive(sceneModel.timelineModel.readFilterAndFeedsPublisher!) { (_, filtered) in
isReadFiltered = filtered
}
.onReceive(sceneModel.timelineModel.timelineItemsSelectPublisher!) { (items, selectTimelineItemID) in
timelineItems = items
if let selectID = selectTimelineItemID {
#if os(macOS)
sceneModel.timelineModel.selectedTimelineItemIDs = Set([selectID])
#else
sceneModel.timelineModel.selectedTimelineItemID = selectID
#endif
}
}
.onReceive(sceneModel.timelineModel.articleStatusChangePublisher!) { articleIDs in
articleIDs.forEach { articleID in
if let position = timelineItems.index[articleID] {
timelineItems.items[position].updateStatus()
}
}
}
2020-06-30 18:03:33 +02:00
}
}