From 5720034f19926b44f51112f9f54fbcfcd5041c28 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 1 Nov 2019 06:34:26 -0500 Subject: [PATCH] Change Feeds background color and update to emulate plain style tables more closely. Issue #1224 --- iOS/Base.lproj/Main.storyboard | 3 +- .../MasterFeedTableViewSectionHeader.swift | 2 +- .../barBackgroundColor.colorset/Contents.json | 20 ++++++--- .../ThemedNavigationController.swift | 41 ++++++++++--------- 4 files changed, 38 insertions(+), 28 deletions(-) diff --git a/iOS/Base.lproj/Main.storyboard b/iOS/Base.lproj/Main.storyboard index e767ead95..cc09703f1 100644 --- a/iOS/Base.lproj/Main.storyboard +++ b/iOS/Base.lproj/Main.storyboard @@ -173,7 +173,7 @@ - + @@ -182,6 +182,7 @@ + diff --git a/iOS/MasterFeed/Cell/MasterFeedTableViewSectionHeader.swift b/iOS/MasterFeed/Cell/MasterFeedTableViewSectionHeader.swift index 6307efb8b..7581e92ef 100644 --- a/iOS/MasterFeed/Cell/MasterFeedTableViewSectionHeader.swift +++ b/iOS/MasterFeed/Cell/MasterFeedTableViewSectionHeader.swift @@ -169,7 +169,7 @@ private extension MasterFeedTableViewSectionHeader { func addBackgroundView() { self.backgroundView = UIView(frame: self.bounds) - self.backgroundView?.backgroundColor = UIColor.systemGroupedBackground + self.backgroundView?.backgroundColor = UIColor.secondarySystemBackground } } diff --git a/iOS/Resources/Assets.xcassets/barBackgroundColor.colorset/Contents.json b/iOS/Resources/Assets.xcassets/barBackgroundColor.colorset/Contents.json index c6e5d3d43..702421056 100644 --- a/iOS/Resources/Assets.xcassets/barBackgroundColor.colorset/Contents.json +++ b/iOS/Resources/Assets.xcassets/barBackgroundColor.colorset/Contents.json @@ -7,13 +7,21 @@ { "idiom" : "universal", "color" : { - "color-space" : "srgb", - "components" : { - "red" : "1.000", - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000" + "platform" : "ios", + "reference" : "systemBackgroundColor" + } + }, + { + "idiom" : "universal", + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" } + ], + "color" : { + "platform" : "ios", + "reference" : "systemBackgroundColor" } } ] diff --git a/iOS/UIKit Extensions/ThemedNavigationController.swift b/iOS/UIKit Extensions/ThemedNavigationController.swift index 058e6afa5..ec56029a1 100644 --- a/iOS/UIKit Extensions/ThemedNavigationController.swift +++ b/iOS/UIKit Extensions/ThemedNavigationController.swift @@ -32,27 +32,28 @@ class ThemedNavigationController: UINavigationController { private func configure() { isToolbarHidden = false - if traitCollection.userInterfaceStyle == .dark { - navigationBar.standardAppearance = UINavigationBarAppearance() - navigationBar.tintColor = AppAssets.primaryAccentColor - toolbar.standardAppearance = UIToolbarAppearance() - toolbar.compactAppearance = UIToolbarAppearance() - toolbar.tintColor = AppAssets.primaryAccentColor - } else { - let navigationAppearance = UINavigationBarAppearance() - navigationAppearance.backgroundColor = AppAssets.barBackgroundColor - navigationAppearance.titleTextAttributes = [.foregroundColor: UIColor.label] - navigationAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.label] - navigationBar.standardAppearance = navigationAppearance - navigationBar.tintColor = AppAssets.primaryAccentColor - - let toolbarAppearance = UIToolbarAppearance() - toolbarAppearance.backgroundColor = UIColor.white - toolbar.standardAppearance = toolbarAppearance - toolbar.compactAppearance = toolbarAppearance - toolbar.tintColor = AppAssets.primaryAccentColor - } + let navigationAppearance = UINavigationBarAppearance() + let backgroundImage = AppAssets.barBackgroundColor.image() + navigationAppearance.backgroundImage = backgroundImage + navigationAppearance.titleTextAttributes = [.foregroundColor: UIColor.label] + navigationAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.label] + navigationBar.standardAppearance = navigationAppearance + navigationBar.tintColor = AppAssets.primaryAccentColor + let toolbarAppearance = UIToolbarAppearance() + toolbarAppearance.backgroundImage = backgroundImage + toolbar.standardAppearance = toolbarAppearance + toolbar.compactAppearance = toolbarAppearance + toolbar.tintColor = AppAssets.primaryAccentColor } } + +extension UIColor { + func image(_ size: CGSize = CGSize(width: 1, height: 1)) -> UIImage { + return UIGraphicsImageRenderer(size: size).image { rendererContext in + self.setFill() + rendererContext.fill(CGRect(origin: .zero, size: size)) + } + } +}