From 364bcf9d4d555c97632ae8794cd524a945c578f2 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 16 Jul 2020 11:42:07 -0500 Subject: [PATCH] Implement new ArticleView API for iOS --- Multiplatform/Shared/Timeline/TimelineView.swift | 2 +- Multiplatform/iOS/Article/ArticleView.swift | 2 -- Multiplatform/iOS/Article/ArticleViewController.swift | 8 ++++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Multiplatform/Shared/Timeline/TimelineView.swift b/Multiplatform/Shared/Timeline/TimelineView.swift index f1a48eda5..b028f4b46 100644 --- a/Multiplatform/Shared/Timeline/TimelineView.swift +++ b/Multiplatform/Shared/Timeline/TimelineView.swift @@ -52,7 +52,7 @@ struct TimelineView: View { List(timelineModel.timelineItems) { timelineItem in ZStack { TimelineItemView(timelineItem: timelineItem) - NavigationLink(destination: ArticleContainerView(articles: timelineModel.selectedArticles), + NavigationLink(destination: ArticleContainerView(), tag: timelineItem.article.articleID, selection: $timelineModel.selectedArticleID) { EmptyView() diff --git a/Multiplatform/iOS/Article/ArticleView.swift b/Multiplatform/iOS/Article/ArticleView.swift index edf1cf31a..6e05b0fd9 100644 --- a/Multiplatform/iOS/Article/ArticleView.swift +++ b/Multiplatform/iOS/Article/ArticleView.swift @@ -12,12 +12,10 @@ import Articles struct ArticleView: UIViewControllerRepresentable { var sceneModel: SceneModel - var articles: [Article] func makeUIViewController(context: Context) -> ArticleViewController { let controller = ArticleViewController() controller.sceneModel = sceneModel - controller.articles = articles return controller } diff --git a/Multiplatform/iOS/Article/ArticleViewController.swift b/Multiplatform/iOS/Article/ArticleViewController.swift index 51508ed82..cf73cc428 100644 --- a/Multiplatform/iOS/Article/ArticleViewController.swift +++ b/Multiplatform/iOS/Article/ArticleViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import Combine import WebKit import Account import Articles @@ -41,6 +42,8 @@ class ArticleViewController: UIViewController { } } + private var selectedArticlesCancellable: AnyCancellable? + override func viewDidLoad() { super.viewDidLoad() @@ -58,8 +61,13 @@ class ArticleViewController: UIViewController { 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) self.pageViewController.setViewControllers([controller], direction: .forward, animated: false, completion: nil) + } // MARK: API