From 90b41995ebaa009bd8be5fc565248f2d8a3d9b10 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Sat, 5 Feb 2022 10:47:26 +0800 Subject: [PATCH] moves nav bar config to SceneCoordinator --- iOS/Article/ArticleViewController.swift | 17 ---------------- iOS/MasterFeed/MasterFeedViewController.swift | 17 ---------------- .../MasterTimelineViewController.swift | 18 +---------------- iOS/SceneCoordinator.swift | 20 ++++++++++++------- 4 files changed, 14 insertions(+), 58 deletions(-) diff --git a/iOS/Article/ArticleViewController.swift b/iOS/Article/ArticleViewController.swift index 100e12e40..9ae9c52b7 100644 --- a/iOS/Article/ArticleViewController.swift +++ b/iOS/Article/ArticleViewController.swift @@ -101,7 +101,6 @@ class ArticleViewController: UIViewController, MainControllerIdentifiable { ]) fullScreenTapZone.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(didTapNavigationBar))) navigationItem.titleView = fullScreenTapZone - configureNavbar() articleExtractorButton.addTarget(self, action: #selector(toggleArticleExtractor(_:)), for: .touchUpInside) toolbarItems?.insert(UIBarButtonItem(customView: articleExtractorButton), at: 6) @@ -234,22 +233,6 @@ class ArticleViewController: UIViewController, MainControllerIdentifiable { return currentWebViewController?.webView?.scrollView } - func configureNavbar() { - let scrollEdge = UINavigationBarAppearance() - scrollEdge.configureWithOpaqueBackground() - scrollEdge.shadowColor = nil - scrollEdge.shadowImage = UIImage() - - let standard = UINavigationBarAppearance() - standard.shadowColor = .opaqueSeparator - standard.shadowImage = UIImage() - - navigationController?.navigationBar.standardAppearance = standard - navigationController?.navigationBar.compactAppearance = standard - navigationController?.navigationBar.scrollEdgeAppearance = scrollEdge - navigationController?.navigationBar.compactScrollEdgeAppearance = scrollEdge - } - // MARK: Notifications diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index 60338f2de..3b8faf264 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -76,7 +76,6 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner, Ma refreshControl!.addTarget(self, action: #selector(refreshAccounts(_:)), for: .valueChanged) configureToolbar() - configureNavbar() becomeFirstResponder() } @@ -716,22 +715,6 @@ private extension MasterFeedViewController { toolbarItems?.insert(refreshProgressItemButton, at: 2) } - func configureNavbar() { - let scrollEdge = UINavigationBarAppearance() - scrollEdge.configureWithOpaqueBackground() - scrollEdge.shadowColor = nil - scrollEdge.shadowImage = UIImage() - - let standard = UINavigationBarAppearance() - standard.shadowColor = .opaqueSeparator - standard.shadowImage = UIImage() - - navigationController?.navigationBar.standardAppearance = standard - navigationController?.navigationBar.compactAppearance = standard - navigationController?.navigationBar.scrollEdgeAppearance = scrollEdge - navigationController?.navigationBar.compactScrollEdgeAppearance = scrollEdge - } - func setFilterButtonToActive() { filterButton?.image = AppAssets.filterActiveImage filterButton?.accLabelText = NSLocalizedString("Selected - Filter Read Feeds", comment: "Selected - Filter Read Feeds") diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index 78e720341..ae0a14d4b 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -93,9 +93,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner refreshControl = UIRefreshControl() refreshControl!.addTarget(self, action: #selector(refreshAccounts(_:)), for: .valueChanged) - configureToolbar() - configureNavbar() refreshProgressView = Bundle.main.loadNibNamed("RefreshProgressView", owner: self, options: nil)?[0] as? RefreshProgressView refreshProgressItemButton = UIBarButtonItem(customView: refreshProgressView!) @@ -631,21 +629,7 @@ private extension MasterTimelineViewController { toolbarItems?.insert(refreshProgressItemButton, at: 2) } - func configureNavbar() { - let scrollEdge = UINavigationBarAppearance() - scrollEdge.configureWithOpaqueBackground() - scrollEdge.shadowColor = nil - scrollEdge.shadowImage = UIImage() - - let standard = UINavigationBarAppearance() - standard.shadowColor = .opaqueSeparator - standard.shadowImage = UIImage() - - navigationController?.navigationBar.standardAppearance = standard - navigationController?.navigationBar.compactAppearance = standard - navigationController?.navigationBar.scrollEdgeAppearance = scrollEdge - navigationController?.navigationBar.compactScrollEdgeAppearance = scrollEdge - } + func resetUI(resetScroll: Bool) { diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 1b20e86d4..173b7f16d 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -1365,14 +1365,20 @@ extension SceneCoordinator: UINavigationControllerDelegate { private extension SceneCoordinator { func configureNavigationController(_ navController: UINavigationController) { - let navigationStandardAppearance = UINavigationBarAppearance() - navigationStandardAppearance.titleTextAttributes = [.foregroundColor: UIColor.label] - navigationStandardAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.label] - navController.navigationBar.standardAppearance = navigationStandardAppearance - let scrollEdgeStandardAppearance = UINavigationBarAppearance() - scrollEdgeStandardAppearance.backgroundColor = .systemBackground - navController.navigationBar.scrollEdgeAppearance = scrollEdgeStandardAppearance + let scrollEdge = UINavigationBarAppearance() + scrollEdge.configureWithOpaqueBackground() + scrollEdge.shadowColor = nil + scrollEdge.shadowImage = UIImage() + + let standard = UINavigationBarAppearance() + standard.shadowColor = .opaqueSeparator + standard.shadowImage = UIImage() + + navController.navigationBar.standardAppearance = standard + navController.navigationBar.compactAppearance = standard + navController.navigationBar.scrollEdgeAppearance = scrollEdge + navController.navigationBar.compactScrollEdgeAppearance = scrollEdge navController.navigationBar.tintColor = AppAssets.primaryAccentColor