Various fixes

This commit is contained in:
Ilya Laktyushin
2023-03-22 17:48:22 +04:00
parent 272f538060
commit 4018360cab
5 changed files with 49 additions and 24 deletions

View File

@@ -20,6 +20,11 @@ open class ViewControllerComponentContainer: ViewController {
case `default`
}
public enum PresentationMode {
case `default`
case modal
}
public final class Environment: Equatable {
public let statusBarHeight: CGFloat
public let navigationHeight: CGFloat
@@ -139,11 +144,6 @@ open class ViewControllerComponentContainer: ViewController {
func containerLayoutUpdated(layout: ContainerViewLayout, navigationHeight: CGFloat, transition: Transition) {
self.currentLayout = (layout, navigationHeight)
var theme = self.theme ?? self.presentationData.theme
if theme.list.blocksBackgroundColor.rgb == theme.list.plainBackgroundColor.rgb {
theme = theme.withModalBlocksBackground()
}
let environment = ViewControllerComponentContainer.Environment(
statusBarHeight: layout.statusBarHeight ?? 0.0,
navigationHeight: navigationHeight,
@@ -152,7 +152,7 @@ open class ViewControllerComponentContainer: ViewController {
metrics: layout.metrics,
deviceMetrics: layout.deviceMetrics,
isVisible: self.currentIsVisible,
theme: theme,
theme: self.theme ?? self.presentationData.theme,
strings: self.presentationData.strings,
dateTimeFormat: self.presentationData.dateTimeFormat,
controller: { [weak self] in
@@ -203,7 +203,7 @@ open class ViewControllerComponentContainer: ViewController {
private var presentationDataDisposable: Disposable?
public private(set) var validLayout: ContainerViewLayout?
public init<C: Component>(context: AccountContext, component: C, navigationBarAppearance: NavigationBarAppearance, statusBarStyle: StatusBarStyle = .default, theme: PresentationTheme? = nil) where C.EnvironmentType == ViewControllerComponentContainer.Environment {
public init<C: Component>(context: AccountContext, component: C, navigationBarAppearance: NavigationBarAppearance, statusBarStyle: StatusBarStyle = .default, presentationMode: PresentationMode = .default, theme: PresentationTheme? = nil) where C.EnvironmentType == ViewControllerComponentContainer.Environment {
self.context = context
self.component = AnyComponent(component)
self.theme = theme
@@ -224,7 +224,12 @@ open class ViewControllerComponentContainer: ViewController {
self.presentationDataDisposable = (self.context.sharedContext.presentationData
|> deliverOnMainQueue).start(next: { [weak self] presentationData in
if let strongSelf = self {
strongSelf.node.presentationData = presentationData
var theme = presentationData.theme
if case .modal = presentationMode, theme.list.blocksBackgroundColor.rgb == theme.list.plainBackgroundColor.rgb {
theme = theme.withModalBlocksBackground()
}
strongSelf.node.presentationData = presentationData.withUpdated(theme: theme)
switch statusBarStyle {
case .none: