Add navigation and toolbar theming for light mode. Issue #698

This commit is contained in:
Maurice Parker 2019-08-23 12:27:45 -05:00
parent 5a5a66d59f
commit 7f024586bb
9 changed files with 142 additions and 10 deletions

View File

@ -46,6 +46,7 @@
5183CCE9226F68D90010922C /* AccountRefreshTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5183CCE7226F68D90010922C /* AccountRefreshTimer.swift */; };
5183CCED22711DCE0010922C /* Settings.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5183CCEC22711DCE0010922C /* Settings.storyboard */; };
5183CCEF227125970010922C /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5183CCEE227125970010922C /* SettingsViewController.swift */; };
51934CCB230F599B006127BE /* ThemedNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51934CC1230F5963006127BE /* ThemedNavigationController.swift */; };
519B8D332143397200FA689C /* SharingServiceDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519B8D322143397200FA689C /* SharingServiceDelegate.swift */; };
519E743D22C663F900A78E47 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519E743422C663F900A78E47 /* SceneDelegate.swift */; };
51C451A9226377C200C03939 /* ArticlesDatabase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8407167F2262A61100344432 /* ArticlesDatabase.framework */; };
@ -699,6 +700,7 @@
5183CCE7226F68D90010922C /* AccountRefreshTimer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountRefreshTimer.swift; sourceTree = "<group>"; };
5183CCEC22711DCE0010922C /* Settings.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Settings.storyboard; sourceTree = "<group>"; };
5183CCEE227125970010922C /* SettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
51934CC1230F5963006127BE /* ThemedNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemedNavigationController.swift; sourceTree = "<group>"; };
5194B5ED22B6965300144881 /* SettingsSubscriptionsImportDocumentPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsSubscriptionsImportDocumentPickerView.swift; sourceTree = "<group>"; };
5194B5F122B69FCC00144881 /* SettingsSubscriptionsExportDocumentPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsSubscriptionsExportDocumentPickerView.swift; sourceTree = "<group>"; };
519B8D322143397200FA689C /* SharingServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingServiceDelegate.swift; sourceTree = "<group>"; };
@ -1098,10 +1100,11 @@
5183CCD9226E31A50010922C /* NonIntrinsicImageView.swift */,
5183CCCF226E1E880010922C /* NonIntrinsicLabel.swift */,
51C45250226506F400C03939 /* String-Extensions.swift */,
51934CC1230F5963006127BE /* ThemedNavigationController.swift */,
51F85BF82274AA7B00C787DC /* UIBarButtonItem-Extensions.swift */,
51F85BF622749FA100C787DC /* UIFont-Extensions.swift */,
51C4524E226506F400C03939 /* UIStoryboard-Extensions.swift */,
512E092B2268B25500BDCFDD /* UISplitViewController-Extensions.swift */,
51C4524E226506F400C03939 /* UIStoryboard-Extensions.swift */,
);
path = Extensions;
sourceTree = "<group>";
@ -1982,7 +1985,7 @@
TargetAttributes = {
6581C73220CED60000F4AD34 = {
DevelopmentTeam = SHJK2V3AJG;
ProvisioningStyle = Manual;
ProvisioningStyle = Automatic;
};
840D617B2029031C009BC708 = {
CreatedOnToolsVersion = 9.3;
@ -1997,7 +2000,7 @@
849C645F1ED37A5D003D8FC0 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = SHJK2V3AJG;
ProvisioningStyle = Manual;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.HardenedRuntime = {
enabled = 1;
@ -2445,6 +2448,7 @@
51C452782265091600C03939 /* MasterTimelineCellData.swift in Sources */,
51C45259226508D300C03939 /* AppDefaults.swift in Sources */,
51C45293226509C800C03939 /* StarredFeedDelegate.swift in Sources */,
51934CCB230F599B006127BE /* ThemedNavigationController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -14,6 +14,18 @@ struct AppAssets {
return UIColor(named: "avatarBackgroundColor")!
}()
static var barBackgroundColor: UIColor = {
return UIColor(named: "barBackgroundColor")!
}()
static var barTintColor: UIColor = {
return UIColor(named: "barTintColor")!
}()
static var barTitleColor: UIColor = {
return UIColor(named: "barTitleColor")!
}()
static var circleClosedImage: UIImage = {
return UIImage(systemName: "circle.fill")!
}()

View File

@ -237,6 +237,7 @@ class AppCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
rootSplitViewController.delegate = self
masterNavigationController = (rootSplitViewController.viewControllers.first as! UINavigationController)
masterFeedViewController = UIStoryboard.main.instantiateController(ofType: MasterFeedViewController.self)
masterFeedViewController.coordinator = self
masterNavigationController.pushViewController(masterFeedViewController, animated: false)
@ -1063,7 +1064,7 @@ private extension AppCoordinator {
if rootSplitViewController.isCollapsed {
return controller
} else {
let navController = UINavigationController(rootViewController: controller)
let navController = ThemedNavigationController.template(rootViewController: controller)
navController.isToolbarHidden = false
if showButton {
controller.navigationItem.leftBarButtonItem = rootSplitViewController.displayModeButtonItem

View File

@ -0,0 +1,56 @@
//
// ThemedNavigationController.swift
// NetNewsWire
//
// Created by Maurice Parker on 8/22/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import UIKit
class ThemedNavigationController: UINavigationController {
static func template() -> UINavigationController {
let navController = ThemedNavigationController()
navController.configure()
return navController
}
static func template(rootViewController: UIViewController) -> UINavigationController {
let navController = ThemedNavigationController(rootViewController: rootViewController)
navController.configure()
return navController
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
if traitCollection.userInterfaceStyle != previousTraitCollection?.userInterfaceStyle {
configure()
}
}
private func configure() {
isToolbarHidden = false
if traitCollection.userInterfaceStyle == .dark {
navigationBar.standardAppearance = UINavigationBarAppearance()
navigationBar.tintColor = view.tintColor
toolbar.standardAppearance = UIToolbarAppearance()
toolbar.tintColor = view.tintColor
} else {
let navigationAppearance = UINavigationBarAppearance()
navigationAppearance.backgroundColor = AppAssets.barBackgroundColor
navigationAppearance.titleTextAttributes = [.foregroundColor: AppAssets.barTitleColor]
navigationAppearance.largeTitleTextAttributes = [.foregroundColor: AppAssets.barTitleColor]
navigationBar.standardAppearance = navigationAppearance
navigationBar.tintColor = AppAssets.barTintColor
let toolbarAppearance = UIToolbarAppearance()
toolbarAppearance.backgroundColor = UIColor.white
toolbar.standardAppearance = toolbarAppearance
toolbar.tintColor = AppAssets.barTintColor
}
}
}

View File

@ -13,11 +13,7 @@ extension UISplitViewController {
static func template() -> UISplitViewController {
let splitViewController = UISplitViewController()
splitViewController.preferredDisplayMode = .automatic
let navController = UINavigationController()
navController.isToolbarHidden = false
splitViewController.viewControllers = [navController]
splitViewController.viewControllers = [ThemedNavigationController.template()]
return splitViewController
}

View File

@ -29,7 +29,10 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
super.viewDidLoad()
navigationController?.navigationBar.prefersLargeTitles = true
if traitCollection.userInterfaceIdiom == .phone {
navigationController?.navigationBar.prefersLargeTitles = true
}
navigationItem.rightBarButtonItem = editButtonItem
tableView.register(MasterFeedTableViewSectionHeader.self, forHeaderFooterViewReuseIdentifier: "SectionHeader")

View File

@ -0,0 +1,20 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
},
"colors" : [
{
"idiom" : "universal",
"color" : {
"color-space" : "srgb",
"components" : {
"red" : "1.000",
"alpha" : "1.000",
"blue" : "1.000",
"green" : "1.000"
}
}
}
]
}

View File

@ -0,0 +1,20 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
},
"colors" : [
{
"idiom" : "universal",
"color" : {
"color-space" : "srgb",
"components" : {
"red" : "0x08",
"alpha" : "1.000",
"blue" : "0xEE",
"green" : "0x6A"
}
}
}
]
}

View File

@ -0,0 +1,20 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
},
"colors" : [
{
"idiom" : "universal",
"color" : {
"color-space" : "srgb",
"components" : {
"red" : "0x08",
"alpha" : "1.000",
"blue" : "0xEE",
"green" : "0x6A"
}
}
}
]
}