summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2021-11-17 12:23:49 +0100
committerAndrej Mihajlov <and@mullvad.net>2021-11-22 10:42:58 +0100
commit449960095a77781c99d1a889710491f7042adf3a (patch)
tree56d1b3aa170a20a0f5157c11a98a2a786d15fdb1
parentcd8a86ccbdbd39e5ff7185ffd980ee5c70e63748 (diff)
downloadmullvadvpn-449960095a77781c99d1a889710491f7042adf3a.tar.xz
mullvadvpn-449960095a77781c99d1a889710491f7042adf3a.zip
CustomNavigationBar: update color scheme
-rw-r--r--ios/MullvadVPN/CustomNavigationBar.swift39
-rw-r--r--ios/MullvadVPN/UIColor+Palette.swift8
2 files changed, 31 insertions, 16 deletions
diff --git a/ios/MullvadVPN/CustomNavigationBar.swift b/ios/MullvadVPN/CustomNavigationBar.swift
index 4268a45d72..7f27dbe7c6 100644
--- a/ios/MullvadVPN/CustomNavigationBar.swift
+++ b/ios/MullvadVPN/CustomNavigationBar.swift
@@ -9,17 +9,27 @@
import UIKit
class CustomNavigationBar: UINavigationBar {
+ private static let titleTextAttributes: [NSAttributedString.Key: Any] = [
+ .foregroundColor: UIColor.NavigationBar.titleColor
+ ]
+
+ private static let backButtonTitlePositionOffset = UIOffset(horizontal: 4, vertical: 0)
+ private static let backButtonTitleTextAttributes: [NSAttributedString.Key: Any] = [
+ .foregroundColor: UIColor.NavigationBar.backButtonTitleColor
+ ]
private static let setupAppearanceForIOS12Once: Void = {
if #available(iOS 13, *) {
// no-op
} else {
let buttonAppearance = UIBarButtonItem.appearance(whenContainedInInstancesOf: [CustomNavigationBar.self])
- buttonAppearance.setBackButtonTitlePositionAdjustment(UIOffset(horizontal: 4, vertical: 0), for: .default)
+ buttonAppearance.setBackButtonTitlePositionAdjustment(CustomNavigationBar.backButtonTitlePositionOffset, for: .default)
+ buttonAppearance.setTitleTextAttributes(CustomNavigationBar.titleTextAttributes, for: .normal)
}
}()
- private let customBackIndicatorImage = UIImage(named: "IconBack")
+ private let customBackIndicatorImage = UIImage(named: "IconBack")?
+ .backport_withTintColor(UIColor.NavigationBar.backButtonIndicatorColor, renderingMode: .alwaysOriginal)
private let customBackIndicatorTransitionMask = UIImage(named: "IconBackTransitionMask")
// Returns the distance from the title label to the bottom of navigation bar
@@ -59,8 +69,8 @@ class CustomNavigationBar: UINavigationBar {
}
private func setupNavigationBarAppearance() {
- tintColor = .white
- backgroundColor = .secondaryColor
+ tintColor = UIColor.NavigationBar.titleColor
+ backgroundColor = UIColor.NavigationBar.backgroundColor
isTranslucent = false
if #available(iOS 13, *) {
@@ -69,33 +79,30 @@ class CustomNavigationBar: UINavigationBar {
} else {
backIndicatorImage = customBackIndicatorImage
backIndicatorTransitionMaskImage = customBackIndicatorTransitionMask
- barTintColor = .secondaryColor
+ barTintColor = UIColor.NavigationBar.backgroundColor
- let titleAttributes: [NSAttributedString.Key: Any] = [.foregroundColor: UIColor.white]
- titleTextAttributes = titleAttributes
- largeTitleTextAttributes = titleAttributes
+ titleTextAttributes = Self.titleTextAttributes
+ largeTitleTextAttributes = Self.titleTextAttributes
shadowImage = UIImage()
}
}
@available(iOS 13, *)
private func makeNavigationBarAppearance() -> UINavigationBarAppearance {
- let textAttributes: [NSAttributedString.Key: Any] = [.foregroundColor: UIColor.white]
-
let navigationBarAppearance = UINavigationBarAppearance()
navigationBarAppearance.configureWithTransparentBackground()
- navigationBarAppearance.titleTextAttributes = textAttributes
- navigationBarAppearance.largeTitleTextAttributes = textAttributes
+ navigationBarAppearance.titleTextAttributes = Self.titleTextAttributes
+ navigationBarAppearance.largeTitleTextAttributes = Self.titleTextAttributes
let plainBarButtonAppearance = UIBarButtonItemAppearance(style: .plain)
- plainBarButtonAppearance.normal.titleTextAttributes = textAttributes
+ plainBarButtonAppearance.normal.titleTextAttributes = Self.titleTextAttributes
let doneBarButtonAppearance = UIBarButtonItemAppearance(style: .done)
- doneBarButtonAppearance.normal.titleTextAttributes = textAttributes
+ doneBarButtonAppearance.normal.titleTextAttributes = Self.titleTextAttributes
let backButtonAppearance = UIBarButtonItemAppearance(style: .plain)
- backButtonAppearance.normal.titleTextAttributes = textAttributes
- backButtonAppearance.normal.titlePositionAdjustment = UIOffset(horizontal: 4, vertical: 0)
+ backButtonAppearance.normal.titlePositionAdjustment = Self.backButtonTitlePositionOffset
+ backButtonAppearance.normal.titleTextAttributes = Self.backButtonTitleTextAttributes
navigationBarAppearance.buttonAppearance = plainBarButtonAppearance
navigationBarAppearance.doneButtonAppearance = doneBarButtonAppearance
diff --git a/ios/MullvadVPN/UIColor+Palette.swift b/ios/MullvadVPN/UIColor+Palette.swift
index 14667fae5d..a8901d5607 100644
--- a/ios/MullvadVPN/UIColor+Palette.swift
+++ b/ios/MullvadVPN/UIColor+Palette.swift
@@ -60,6 +60,14 @@ extension UIColor {
static let dividerColor = UIColor.black
}
+ // Navigation bars
+ enum NavigationBar {
+ static let backgroundColor = UIColor.secondaryColor
+ static let backButtonIndicatorColor = UIColor(white: 1.0, alpha: 0.4)
+ static let backButtonTitleColor = UIColor(white: 1.0, alpha: 0.6)
+ static let titleColor = UIColor.white
+ }
+
// Cells
enum Cell {
static let backgroundColor = primaryColor