mirror of https://github.com/oxen-io/session-ios
customise UIHostingViewController
parent
8d4049f0da
commit
068af1136d
@ -0,0 +1,59 @@
|
|||||||
|
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
import SessionUIKit
|
||||||
|
|
||||||
|
public class SessionHostingViewController<Content>: UIHostingController<Content> where Content : View {
|
||||||
|
public override var preferredStatusBarStyle: UIStatusBarStyle {
|
||||||
|
return ThemeManager.currentTheme.statusBarStyle
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy var navBarTitleLabel: UILabel = {
|
||||||
|
let result = UILabel()
|
||||||
|
result.font = .boldSystemFont(ofSize: Values.veryLargeFontSize)
|
||||||
|
result.themeTextColor = .textPrimary
|
||||||
|
result.textAlignment = .center
|
||||||
|
result.alpha = 1
|
||||||
|
|
||||||
|
return result
|
||||||
|
}()
|
||||||
|
|
||||||
|
lazy var crossfadeLabel: UILabel = {
|
||||||
|
let result = UILabel()
|
||||||
|
result.font = .boldSystemFont(ofSize: Values.veryLargeFontSize)
|
||||||
|
result.themeTextColor = .textPrimary
|
||||||
|
result.textAlignment = .center
|
||||||
|
result.alpha = 0
|
||||||
|
|
||||||
|
return result
|
||||||
|
}()
|
||||||
|
|
||||||
|
public override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
navigationItem.backButtonTitle = ""
|
||||||
|
view.themeBackgroundColor = .backgroundPrimary
|
||||||
|
ThemeManager.applyNavigationStylingIfNeeded(to: self)
|
||||||
|
|
||||||
|
setNeedsStatusBarAppearanceUpdate()
|
||||||
|
}
|
||||||
|
|
||||||
|
internal func setNavBarTitle(_ title: String, customFontSize: CGFloat? = nil) {
|
||||||
|
let container = UIView()
|
||||||
|
navBarTitleLabel.text = title
|
||||||
|
crossfadeLabel.text = title
|
||||||
|
|
||||||
|
if let customFontSize = customFontSize {
|
||||||
|
navBarTitleLabel.font = .boldSystemFont(ofSize: customFontSize)
|
||||||
|
crossfadeLabel.font = .boldSystemFont(ofSize: customFontSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
container.addSubview(navBarTitleLabel)
|
||||||
|
container.addSubview(crossfadeLabel)
|
||||||
|
|
||||||
|
navBarTitleLabel.pin(to: container)
|
||||||
|
crossfadeLabel.pin(to: container)
|
||||||
|
|
||||||
|
navigationItem.titleView = container
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue