From 4013029c04b85a384f8feadd6ae260a2ba36d34d Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Thu, 24 Oct 2019 13:04:30 -0700 Subject: [PATCH] Adds support for dark mode --- AltStore.xcodeproj/project.pbxproj | 4 + AltStore/App Detail/AppViewController.swift | 37 ++++++-- .../Authentication/Authentication.storyboard | 32 +++---- .../AuthenticationViewController.swift | 2 + .../InstructionsViewController.swift | 4 + AltStore/Base.lproj/Main.storyboard | 66 ++++++++++----- AltStore/Components/AppBannerView.xib | 16 ++-- .../ForwardingNavigationController.swift | 20 +++++ AltStore/Components/NavigationBar.swift | 49 +++++++++-- AltStore/Info.plist | 2 - AltStore/My Apps/UpdateCollectionViewCell.xib | 49 ++++++++--- .../Colors/Background.colorset/Contents.json | 38 +++++++++ .../Colors/BlurTint.colorset/Contents.json | 38 +++++++++ .../SettingsBackground.colorset/Contents.json | 38 +++++++++ .../Contents.json | 38 +++++++++ AltStore/Settings/AboutPatreonHeaderView.xib | 27 +++--- .../Settings/LicensesViewController.swift | 4 + AltStore/Settings/PatreonViewController.swift | 4 + AltStore/Settings/Settings.storyboard | 84 +++++++++---------- .../Settings/SettingsViewController.swift | 4 + 20 files changed, 426 insertions(+), 130 deletions(-) create mode 100644 AltStore/Components/ForwardingNavigationController.swift create mode 100644 AltStore/Resources/Assets.xcassets/Colors/Background.colorset/Contents.json create mode 100644 AltStore/Resources/Assets.xcassets/Colors/BlurTint.colorset/Contents.json create mode 100644 AltStore/Resources/Assets.xcassets/Colors/SettingsBackground.colorset/Contents.json create mode 100644 AltStore/Resources/Assets.xcassets/Colors/SettingsHighlighted.colorset/Contents.json diff --git a/AltStore.xcodeproj/project.pbxproj b/AltStore.xcodeproj/project.pbxproj index d4bdbee6..b6897373 100644 --- a/AltStore.xcodeproj/project.pbxproj +++ b/AltStore.xcodeproj/project.pbxproj @@ -115,6 +115,7 @@ BF54E8212315EF0D000AE0D8 /* ALTPatreonBenefitType.m in Sources */ = {isa = PBXBuildFile; fileRef = BF54E8202315EF0D000AE0D8 /* ALTPatreonBenefitType.m */; }; BF5AB3A82285FE7500DC914B /* AltSign.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF5AB3A72285FE6C00DC914B /* AltSign.framework */; }; BF5AB3A92285FE7500DC914B /* AltSign.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BF5AB3A72285FE6C00DC914B /* AltSign.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + BF74989B23621C0700CED65F /* ForwardingNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF74989A23621C0700CED65F /* ForwardingNavigationController.swift */; }; BF770E5122BB1CF6002A40FE /* InstallAppOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF770E5022BB1CF6002A40FE /* InstallAppOperation.swift */; }; BF770E5422BC044E002A40FE /* AppOperationContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF770E5322BC044E002A40FE /* AppOperationContext.swift */; }; BF770E5622BC3C03002A40FE /* Server.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF770E5522BC3C02002A40FE /* Server.swift */; }; @@ -395,6 +396,7 @@ BF54E81F2315EF0D000AE0D8 /* ALTPatreonBenefitType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ALTPatreonBenefitType.h; sourceTree = ""; }; BF54E8202315EF0D000AE0D8 /* ALTPatreonBenefitType.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ALTPatreonBenefitType.m; sourceTree = ""; }; BF5AB3A72285FE6C00DC914B /* AltSign.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = AltSign.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + BF74989A23621C0700CED65F /* ForwardingNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForwardingNavigationController.swift; sourceTree = ""; }; BF770E5022BB1CF6002A40FE /* InstallAppOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallAppOperation.swift; sourceTree = ""; }; BF770E5322BC044E002A40FE /* AppOperationContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppOperationContext.swift; sourceTree = ""; }; BF770E5522BC3C02002A40FE /* Server.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Server.swift; sourceTree = ""; }; @@ -929,6 +931,7 @@ isa = PBXGroup; children = ( BFD2478B2284C4C300981D42 /* AppIconImageView.swift */, + BF74989A23621C0700CED65F /* ForwardingNavigationController.swift */, BFD2478E2284C8F900981D42 /* Button.swift */, BF43002D22A714AF0051E2BC /* Keychain.swift */, BF770E6622BD57C3002A40FE /* BackgroundTaskManager.swift */, @@ -1448,6 +1451,7 @@ files = ( BFDB6A0F22AB2776007EA6D6 /* SendAppOperation.swift in Sources */, BFDB6A0D22AAFC1A007EA6D6 /* OperationError.swift in Sources */, + BF74989B23621C0700CED65F /* ForwardingNavigationController.swift in Sources */, BF3D649D22E7AC1B00E9056B /* PermissionPopoverViewController.swift in Sources */, BFD2478F2284C8F900981D42 /* Button.swift in Sources */, BFD5D6F6230DDB12007955AB /* Tier.swift in Sources */, diff --git a/AltStore/App Detail/AppViewController.swift b/AltStore/App Detail/AppViewController.swift index 89ac59c4..2869ae91 100644 --- a/AltStore/App Detail/AppViewController.swift +++ b/AltStore/App Detail/AppViewController.swift @@ -44,6 +44,12 @@ class AppViewController: UIViewController private var _backgroundBlurEffect: UIBlurEffect? private var _backgroundBlurTintColor: UIColor? + private var _preferredStatusBarStyle: UIStatusBarStyle = .default + + override var preferredStatusBarStyle: UIStatusBarStyle { + return _preferredStatusBarStyle + } + override func viewDidLoad() { super.viewDidLoad() @@ -122,6 +128,10 @@ class AppViewController: UIViewController super.viewWillAppear(animated) self.prepareBlur() + + // Update blur immediately. + self.view.setNeedsLayout() + self.view.layoutIfNeeded() self.transitionCoordinator?.animate(alongsideTransition: { (context) in self.hideNavigationBar() @@ -316,6 +326,12 @@ class AppViewController: UIViewController self.bannerView.backgroundEffectView.backgroundColor = .clear } + override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) + { + super.traitCollectionDidChange(previousTraitCollection) + self._shouldResetLayout = true + } + deinit { self.blurAnimator?.stopAnimation(true) @@ -376,18 +392,29 @@ private extension AppViewController func showNavigationBar(for navigationController: UINavigationController? = nil) { let navigationController = navigationController ?? self.navigationController - navigationController?.navigationBar.barStyle = .default navigationController?.navigationBar.alpha = 1.0 - navigationController?.navigationBar.barTintColor = .white navigationController?.navigationBar.tintColor = .altPrimary + navigationController?.navigationBar.setNeedsLayout() + + if self.traitCollection.userInterfaceStyle == .dark + { + self._preferredStatusBarStyle = .lightContent + } + else + { + self._preferredStatusBarStyle = .default + } + + navigationController?.setNeedsStatusBarAppearanceUpdate() } func hideNavigationBar(for navigationController: UINavigationController? = nil) { let navigationController = navigationController ?? self.navigationController - navigationController?.navigationBar.barStyle = .black navigationController?.navigationBar.alpha = 0.0 - navigationController?.navigationBar.barTintColor = .white + + self._preferredStatusBarStyle = .lightContent + navigationController?.setNeedsStatusBarAppearanceUpdate() } func prepareBlur() @@ -432,7 +459,7 @@ private extension AppViewController self.navigationBarAnimator = nil self.hideNavigationBar() - self.navigationController?.navigationBar.barTintColor = .white + self.contentViewController.view.layer.cornerRadius = self.contentViewControllerShadowView.layer.cornerRadius } } diff --git a/AltStore/Authentication/Authentication.storyboard b/AltStore/Authentication/Authentication.storyboard index 50d473c7..2ada4c02 100644 --- a/AltStore/Authentication/Authentication.storyboard +++ b/AltStore/Authentication/Authentication.storyboard @@ -1,9 +1,9 @@ - + - + @@ -17,7 +17,7 @@ - + @@ -65,7 +65,7 @@ @@ -174,13 +174,13 @@ - + @@ -445,12 +445,12 @@ - - - - + + + + diff --git a/AltStore/Authentication/AuthenticationViewController.swift b/AltStore/Authentication/AuthenticationViewController.swift index 56aefd43..ac1db12e 100644 --- a/AltStore/Authentication/AuthenticationViewController.swift +++ b/AltStore/Authentication/AuthenticationViewController.swift @@ -30,6 +30,8 @@ class AuthenticationViewController: UIViewController { super.viewDidLoad() + self.signInButton.activityIndicatorView.style = .white + for view in [self.appleIDBackgroundView!, self.passwordBackgroundView!, self.signInButton!] { view.clipsToBounds = true diff --git a/AltStore/Authentication/InstructionsViewController.swift b/AltStore/Authentication/InstructionsViewController.swift index 744da7af..0a37f2be 100644 --- a/AltStore/Authentication/InstructionsViewController.swift +++ b/AltStore/Authentication/InstructionsViewController.swift @@ -17,6 +17,10 @@ class InstructionsViewController: UIViewController @IBOutlet private var contentStackView: UIStackView! @IBOutlet private var dismissButton: UIButton! + override var preferredStatusBarStyle: UIStatusBarStyle { + return .lightContent + } + override func viewDidLoad() { super.viewDidLoad() diff --git a/AltStore/Base.lproj/Main.storyboard b/AltStore/Base.lproj/Main.storyboard index 2a44a4f2..c75bebb4 100644 --- a/AltStore/Base.lproj/Main.storyboard +++ b/AltStore/Base.lproj/Main.storyboard @@ -54,7 +54,7 @@ - + @@ -109,10 +109,9 @@ - - + @@ -141,22 +140,35 @@ - + + + + + + + + + + + - + - + @@ -212,7 +224,7 @@ - + @@ -237,6 +249,7 @@ + @@ -248,7 +261,7 @@ - + @@ -274,6 +287,7 @@ + @@ -285,7 +299,7 @@ - + @@ -297,6 +311,7 @@ + @@ -350,7 +365,7 @@ - + @@ -365,6 +380,7 @@ + @@ -385,7 +401,7 @@ - + @@ -455,6 +471,7 @@ World + @@ -509,7 +526,7 @@ World - + @@ -544,7 +561,7 @@ World - + @@ -566,7 +583,7 @@ World - + @@ -586,7 +603,7 @@ World - + @@ -611,7 +628,7 @@ World - + @@ -759,7 +776,7 @@ World - + @@ -783,8 +800,11 @@ World + + + - + diff --git a/AltStore/Components/AppBannerView.xib b/AltStore/Components/AppBannerView.xib index ad55a4aa..cb5810f4 100644 --- a/AltStore/Components/AppBannerView.xib +++ b/AltStore/Components/AppBannerView.xib @@ -4,6 +4,7 @@ + @@ -29,7 +30,7 @@ - + @@ -44,20 +45,20 @@ - + - + - + @@ -66,7 +67,7 @@ - + @@ -133,5 +134,8 @@ + + + diff --git a/AltStore/Components/ForwardingNavigationController.swift b/AltStore/Components/ForwardingNavigationController.swift new file mode 100644 index 00000000..6af0f806 --- /dev/null +++ b/AltStore/Components/ForwardingNavigationController.swift @@ -0,0 +1,20 @@ +// +// ForwardingNavigationController.swift +// AltStore +// +// Created by Riley Testut on 10/24/19. +// Copyright © 2019 Riley Testut. All rights reserved. +// + +import UIKit + +class ForwardingNavigationController: UINavigationController +{ + override var childForStatusBarStyle: UIViewController? { + return self.topViewController + } + + override var childForStatusBarHidden: UIViewController? { + return self.topViewController + } +} diff --git a/AltStore/Components/NavigationBar.swift b/AltStore/Components/NavigationBar.swift index 890813c1..a57a2599 100644 --- a/AltStore/Components/NavigationBar.swift +++ b/AltStore/Components/NavigationBar.swift @@ -32,19 +32,52 @@ class NavigationBar: UINavigationBar private func initialize() { - self.shadowImage = UIImage() - - if let tintColor = self.barTintColor + if #available(iOS 13, *) { - self.backgroundColorView.backgroundColor = tintColor + let standardAppearance = UINavigationBarAppearance() + standardAppearance.configureWithDefaultBackground() + standardAppearance.shadowColor = nil - // Top = -50 to cover status bar area above navigation bar on any device. - // Bottom = -1 to prevent a flickering gray line from appearing. - self.addSubview(self.backgroundColorView, pinningEdgesWith: UIEdgeInsets(top: -50, left: 0, bottom: -1, right: 0)) + let edgeAppearance = UINavigationBarAppearance() + edgeAppearance.configureWithOpaqueBackground() + edgeAppearance.backgroundColor = self.barTintColor + edgeAppearance.shadowColor = nil + + if let tintColor = self.barTintColor + { + let textAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white] + + standardAppearance.backgroundColor = tintColor + standardAppearance.titleTextAttributes = textAttributes + standardAppearance.largeTitleTextAttributes = textAttributes + + edgeAppearance.titleTextAttributes = textAttributes + edgeAppearance.largeTitleTextAttributes = textAttributes + } + else + { + standardAppearance.backgroundColor = nil + } + + self.scrollEdgeAppearance = edgeAppearance + self.standardAppearance = standardAppearance } else { - self.barTintColor = .white + self.shadowImage = UIImage() + + if let tintColor = self.barTintColor + { + self.backgroundColorView.backgroundColor = tintColor + + // Top = -50 to cover status bar area above navigation bar on any device. + // Bottom = -1 to prevent a flickering gray line from appearing. + self.addSubview(self.backgroundColorView, pinningEdgesWith: UIEdgeInsets(top: -50, left: 0, bottom: -1, right: 0)) + } + else + { + self.barTintColor = .white + } } } diff --git a/AltStore/Info.plist b/AltStore/Info.plist index 05c14cb4..09fb4dd1 100644 --- a/AltStore/Info.plist +++ b/AltStore/Info.plist @@ -120,7 +120,5 @@ - UIUserInterfaceStyle - Light diff --git a/AltStore/My Apps/UpdateCollectionViewCell.xib b/AltStore/My Apps/UpdateCollectionViewCell.xib index a35dd0a7..73a2f158 100644 --- a/AltStore/My Apps/UpdateCollectionViewCell.xib +++ b/AltStore/My Apps/UpdateCollectionViewCell.xib @@ -4,6 +4,7 @@ + @@ -37,18 +38,36 @@ - + + + + + + + + + + + + + + + + + + + - - + + @@ -58,7 +77,7 @@ - + @@ -79,7 +98,6 @@ - @@ -95,4 +113,9 @@ + + + + + diff --git a/AltStore/Resources/Assets.xcassets/Colors/Background.colorset/Contents.json b/AltStore/Resources/Assets.xcassets/Colors/Background.colorset/Contents.json new file mode 100644 index 00000000..1ea0e567 --- /dev/null +++ b/AltStore/Resources/Assets.xcassets/Colors/Background.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "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" + } + } + }, + { + "idiom" : "universal", + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "28", + "alpha" : "1.000", + "blue" : "30", + "green" : "28" + } + } + } + ] +} \ No newline at end of file diff --git a/AltStore/Resources/Assets.xcassets/Colors/BlurTint.colorset/Contents.json b/AltStore/Resources/Assets.xcassets/Colors/BlurTint.colorset/Contents.json new file mode 100644 index 00000000..378c34e1 --- /dev/null +++ b/AltStore/Resources/Assets.xcassets/Colors/BlurTint.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "255", + "alpha" : "0.300", + "blue" : "255", + "green" : "255" + } + } + }, + { + "idiom" : "universal", + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0", + "alpha" : "0.300", + "blue" : "0", + "green" : "0" + } + } + } + ] +} \ No newline at end of file diff --git a/AltStore/Resources/Assets.xcassets/Colors/SettingsBackground.colorset/Contents.json b/AltStore/Resources/Assets.xcassets/Colors/SettingsBackground.colorset/Contents.json new file mode 100644 index 00000000..ba4b0d05 --- /dev/null +++ b/AltStore/Resources/Assets.xcassets/Colors/SettingsBackground.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "1", + "alpha" : "1.000", + "blue" : "132", + "green" : "128" + } + } + }, + { + "idiom" : "universal", + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "2", + "alpha" : "1.000", + "blue" : "103", + "green" : "82" + } + } + } + ] +} \ No newline at end of file diff --git a/AltStore/Resources/Assets.xcassets/Colors/SettingsHighlighted.colorset/Contents.json b/AltStore/Resources/Assets.xcassets/Colors/SettingsHighlighted.colorset/Contents.json new file mode 100644 index 00000000..14f49d48 --- /dev/null +++ b/AltStore/Resources/Assets.xcassets/Colors/SettingsHighlighted.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0.008", + "alpha" : "1.000", + "blue" : "0.404", + "green" : "0.322" + } + } + }, + { + "idiom" : "universal", + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "0.004", + "alpha" : "1.000", + "blue" : "0.518", + "green" : "0.502" + } + } + } + ] +} \ No newline at end of file diff --git a/AltStore/Settings/AboutPatreonHeaderView.xib b/AltStore/Settings/AboutPatreonHeaderView.xib index 09227294..8ed7b0cf 100644 --- a/AltStore/Settings/AboutPatreonHeaderView.xib +++ b/AltStore/Settings/AboutPatreonHeaderView.xib @@ -1,11 +1,9 @@ - - - - + + - + @@ -74,24 +72,24 @@ Riley @@ -111,12 +109,13 @@ Riley + - - - + + + diff --git a/AltStore/Settings/LicensesViewController.swift b/AltStore/Settings/LicensesViewController.swift index 748343c3..66b50736 100644 --- a/AltStore/Settings/LicensesViewController.swift +++ b/AltStore/Settings/LicensesViewController.swift @@ -14,6 +14,10 @@ class LicensesViewController: UIViewController @IBOutlet private var textView: UITextView! + override var preferredStatusBarStyle: UIStatusBarStyle { + return .lightContent + } + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) diff --git a/AltStore/Settings/PatreonViewController.swift b/AltStore/Settings/PatreonViewController.swift index 827a77dd..ffb105f4 100644 --- a/AltStore/Settings/PatreonViewController.swift +++ b/AltStore/Settings/PatreonViewController.swift @@ -30,6 +30,10 @@ class PatreonViewController: UICollectionViewController private var patronsResult: Result<[Patron], Error>? + override var preferredStatusBarStyle: UIStatusBarStyle { + return .lightContent + } + override func viewDidLoad() { super.viewDidLoad() diff --git a/AltStore/Settings/Settings.storyboard b/AltStore/Settings/Settings.storyboard index a9413989..1d47289d 100644 --- a/AltStore/Settings/Settings.storyboard +++ b/AltStore/Settings/Settings.storyboard @@ -1,11 +1,9 @@ - - - - + + - + @@ -18,14 +16,14 @@ - + - + @@ -55,7 +53,7 @@ - + @@ -87,7 +85,7 @@ - + @@ -119,7 +117,7 @@ - + @@ -155,7 +153,7 @@ - + @@ -195,7 +193,7 @@ - + @@ -235,7 +233,7 @@ - + @@ -275,20 +273,20 @@ - + - + - + - + - + - + - + - +