session-ios/SignalUtilitiesKit/Utilities/UIViewController+Utilities.swift

37 lines
1.5 KiB
Swift
Raw Permalink Normal View History

2020-11-09 06:03:59 +01:00
import SessionUIKit
2020-08-27 07:06:11 +02:00
@objc(LKViewControllerUtilities)
public final class ViewControllerUtilities : NSObject {
private override init() { }
2020-08-27 07:10:28 +02:00
@objc(setUpDefaultSessionStyleForVC:withTitle:customBackButton:)
2020-08-28 01:06:58 +02:00
public static func setUpDefaultSessionStyle(for vc: UIViewController, title: String?, hasCustomBackButton: Bool) {
2020-08-27 07:06:11 +02:00
// Set gradient background
vc.view.backgroundColor = .clear
2021-01-29 01:46:32 +01:00
let gradient = Gradients.defaultBackground
2020-08-27 07:06:11 +02:00
vc.view.setGradient(gradient)
// Set navigation bar background color
if let navigationBar = vc.navigationController?.navigationBar {
navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
navigationBar.shadowImage = UIImage()
navigationBar.isTranslucent = false
navigationBar.barTintColor = Colors.navigationBarBackground
}
// Customize title
2020-08-28 01:06:58 +02:00
if let title = title {
let titleLabel = UILabel()
titleLabel.text = title
titleLabel.textColor = Colors.text
titleLabel.font = .boldSystemFont(ofSize: Values.veryLargeFontSize)
vc.navigationItem.titleView = titleLabel
}
2020-08-27 07:06:11 +02:00
// Set up back button
2020-08-27 07:10:28 +02:00
if hasCustomBackButton {
let backButton = UIBarButtonItem(title: "Back", style: .plain, target: nil, action: nil)
backButton.tintColor = Colors.text
vc.navigationItem.backBarButtonItem = backButton
}
2020-08-27 07:06:11 +02:00
}
}