Commit 2f24a836 authored by Martin's avatar Martin
Browse files

Merge branch 'IOS-2897' into 1.1.260

parents b34e5689 d85d03db
......@@ -23,6 +23,7 @@ class Appearance {
// therefore we use the new appearance API to customise explicitly.
let normalNavigationBar = UINavigationBar.appearance()
normalNavigationBar.standardAppearance = navigationBarAppearanceDefault(color: UIColor.label)
normalNavigationBar.scrollEdgeAppearance = normalNavigationBar.standardAppearance
} else {
UINavigationBar.appearance().backgroundColor = .white
UINavigationBar.appearance().titleTextAttributes = titleTextAttributes()
......@@ -31,6 +32,13 @@ class Appearance {
UIToolbar.appearance().backgroundColor = .pEpGreen
UIToolbar.appearance().barTintColor = .pEpGreen
UIToolbar.appearance().tintColor = .white
if #available(iOS 15.0, *) {
let appearance = UIToolbarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .pEpGreen
UIToolbar.appearance().standardAppearance = appearance
UIToolbar.appearance().scrollEdgeAppearance = UIToolbar.appearance().standardAppearance
}
UITextView.appearance().tintColor = .pEpGreen
UITextField.appearance().tintColor = .pEpGreen
......@@ -56,6 +64,8 @@ class Appearance {
}
}
/// Configure the background view of the table view cells.
/// - Parameter tableViewCell: The cell to set the background view.
public static func configureSelectedBackgroundViewForPep(tableViewCell: UITableViewCell) {
var backgroundColor: UIColor
if #available(iOS 13.0, *) {
......@@ -68,6 +78,33 @@ class Appearance {
tableViewCell.selectedBackgroundView = tableViewCellSelectedbackgroundView
}
/// Customises a tutorial view controller's navigation bar appearance.
/// - Parameter viewController: UIViewController: The view controller to customize.
@available(iOS 13, *)
static public func customiseForTutorial(viewController: UIViewController) {
customiseNavigationBar(viewController: viewController) { appearance in
customiseForTutorial(navigationBarAppearance: appearance)
if #available(iOS 15, *) {
viewController.navigationController?.navigationBar.standardAppearance = appearance
viewController.navigationController?.navigationBar.scrollEdgeAppearance = appearance
}
}
}
/// Customises a login view controller's navigation bar appearance.
/// - Parameter viewController: UIViewController: The view controller to customize.
@available(iOS 13, *)
public static func customiseForLogin(viewController: UIViewController) {
customiseNavigationBar(viewController: viewController) { appearance in
customiseForLogin(navigationBarAppearance: appearance)
}
}
}
//MARK: - Private
extension Appearance {
private static func setAlertControllerTintColor(_ color: UIColor = .pEpGreen) {
let view = UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self])
view.tintColor = color
......@@ -95,6 +132,7 @@ class Appearance {
appearance.doneButtonAppearance.normal.titleTextAttributes = buttonsAttributes
let chevronLeftImg = UIImage(named: "chevron-icon-left")?
.resizeImage(targetSize: CGSize(width: 15, height: 25))
appearance.setBackIndicatorImage(chevronLeftImg, transitionMaskImage: chevronLeftImg)
return appearance
}
......@@ -111,6 +149,15 @@ class Appearance {
navigationBarAppearance.doneButtonAppearance.normal.titleTextAttributes = titleTextAttributes
}
/// Customises a navigation bar appearance for the tutorial view.
/// - Parameter navigationBarAppearance: The appearance to customize.
@available(iOS 13, *)
static private func customiseForTutorial(navigationBarAppearance: UINavigationBarAppearance) {
navigationBarAppearance.configureWithOpaqueBackground()
navigationBarAppearance.backgroundColor = UIColor.pEpGreen
customiseButtons(navigationBarAppearance: navigationBarAppearance)
}
/// Customises a navigation bar appearance for the login view.
/// - Parameter navigationBarAppearance: The appearance to customize.
@available(iOS 13, *)
......@@ -122,15 +169,6 @@ class Appearance {
customiseButtons(navigationBarAppearance: navigationBarAppearance)
}
/// Customises a navigation bar appearance for the tutorial view.
/// - Parameter navigationBarAppearance: The appearance to customize.
@available(iOS 13, *)
static private func customiseForTutorial(navigationBarAppearance: UINavigationBarAppearance) {
navigationBarAppearance.configureWithOpaqueBackground()
navigationBarAppearance.backgroundColor = UIColor.pEpGreen
customiseButtons(navigationBarAppearance: navigationBarAppearance)
}
/// Helper for changing the appearance of a navigation bar containing a view controller.
/// - Parameter viewController: The view controller that is embedded in a navigation controller.
/// - Parameter appearanceModifier: A block that will modify the navigation bar appearance.
......@@ -143,22 +181,4 @@ class Appearance {
viewController.navigationItem.standardAppearance = appearance
}
}
/// Customises a tutorial view controller's navigation bar appearance.
/// - Parameter viewController: UIViewController: The view controller to customize.
@available(iOS 13, *)
static func customiseForTutorial(viewController: UIViewController) {
customiseNavigationBar(viewController: viewController) { appearance in
customiseForTutorial(navigationBarAppearance: appearance)
}
}
/// Customises a login view controller's navigation bar appearance.
/// - Parameter viewController: UIViewController: The view controller to customize.
@available(iOS 13, *)
static func customiseForLogin(viewController: UIViewController) {
customiseNavigationBar(viewController: viewController) { appearance in
customiseForLogin(navigationBarAppearance: appearance)
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment