NetNewsWire/Multiplatform/Shared/SceneModel.swift

86 lines
1.8 KiB
Swift
Raw Normal View History

2020-06-28 21:21:43 +02:00
//
// SceneModel.swift
// NetNewsWire
//
// Created by Maurice Parker on 6/28/20.
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import Foundation
import Account
import Articles
2020-06-28 21:21:43 +02:00
final class SceneModel: ObservableObject {
@Published var refreshProgressState = RefreshProgressModel.State.none
2020-06-28 21:21:43 +02:00
var sidebarModel: SidebarModel?
2020-06-30 18:03:33 +02:00
var timelineModel: TimelineModel?
2020-07-02 22:30:50 +02:00
var articleModel: ArticleModel?
2020-06-28 21:21:43 +02:00
private var refreshProgressModel: RefreshProgressModel? = nil
private var _webViewProvider: WebViewProvider? = nil
// MARK: API
func startup() {
self.refreshProgressModel = RefreshProgressModel()
self.refreshProgressModel!.$state.assign(to: self.$refreshProgressState)
self._webViewProvider = WebViewProvider(sceneModel: self)
}
func articleFor(_ articleID: String) -> Article? {
return timelineModel?.articleFor(articleID)
}
2020-06-28 21:21:43 +02:00
}
// MARK: SidebarModelDelegate
extension SceneModel: SidebarModelDelegate {
2020-06-29 13:16:48 +02:00
func unreadCount(for feed: Feed) -> Int {
// TODO: Get the count from the timeline if Feed is the current timeline
return feed.unreadCount
}
}
2020-06-30 18:03:33 +02:00
// MARK: TimelineModelDelegate
extension SceneModel: TimelineModelDelegate {
func timelineRequestedWebFeedSelection(_: TimelineModel, webFeed: WebFeed) {
}
}
2020-07-02 22:30:50 +02:00
// MARK: ArticleModelDelegate
extension SceneModel: ArticleModelDelegate {
var webViewProvider: WebViewProvider? {
return _webViewProvider
}
func findPrevArticle(_: ArticleModel, article: Article) -> Article? {
return timelineModel?.findPrevArticle(article)
}
func findNextArticle(_: ArticleModel, article: Article) -> Article? {
return timelineModel?.findNextArticle(article)
}
func selectArticle(_: ArticleModel, article: Article) {
timelineModel?.selectArticle(article)
}
}
// MARK: Private
2020-07-02 22:30:50 +02:00
private extension SceneModel {
2020-07-02 22:30:50 +02:00
}