Implement new ArticleView API for iOS

This commit is contained in:
Maurice Parker 2020-07-16 11:42:07 -05:00
parent 5f573fc985
commit 364bcf9d4d
3 changed files with 9 additions and 3 deletions

View File

@ -52,7 +52,7 @@ struct TimelineView: View {
List(timelineModel.timelineItems) { timelineItem in List(timelineModel.timelineItems) { timelineItem in
ZStack { ZStack {
TimelineItemView(timelineItem: timelineItem) TimelineItemView(timelineItem: timelineItem)
NavigationLink(destination: ArticleContainerView(articles: timelineModel.selectedArticles), NavigationLink(destination: ArticleContainerView(),
tag: timelineItem.article.articleID, tag: timelineItem.article.articleID,
selection: $timelineModel.selectedArticleID) { selection: $timelineModel.selectedArticleID) {
EmptyView() EmptyView()

View File

@ -12,12 +12,10 @@ import Articles
struct ArticleView: UIViewControllerRepresentable { struct ArticleView: UIViewControllerRepresentable {
var sceneModel: SceneModel var sceneModel: SceneModel
var articles: [Article]
func makeUIViewController(context: Context) -> ArticleViewController { func makeUIViewController(context: Context) -> ArticleViewController {
let controller = ArticleViewController() let controller = ArticleViewController()
controller.sceneModel = sceneModel controller.sceneModel = sceneModel
controller.articles = articles
return controller return controller
} }

View File

@ -7,6 +7,7 @@
// //
import UIKit import UIKit
import Combine
import WebKit import WebKit
import Account import Account
import Articles import Articles
@ -41,6 +42,8 @@ class ArticleViewController: UIViewController {
} }
} }
private var selectedArticlesCancellable: AnyCancellable?
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
@ -58,8 +61,13 @@ class ArticleViewController: UIViewController {
view.bottomAnchor.constraint(equalTo: pageViewController.view.bottomAnchor) view.bottomAnchor.constraint(equalTo: pageViewController.view.bottomAnchor)
]) ])
selectedArticlesCancellable = sceneModel?.timelineModel.$selectedArticles.sink { [weak self] articles in
self?.articles = articles
}
let controller = createWebViewController(currentArticle, updateView: true) let controller = createWebViewController(currentArticle, updateView: true)
self.pageViewController.setViewControllers([controller], direction: .forward, animated: false, completion: nil) self.pageViewController.setViewControllers([controller], direction: .forward, animated: false, completion: nil)
} }
// MARK: API // MARK: API