mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
[WIP] Stories
This commit is contained in:
@@ -7,6 +7,17 @@ import TelegramPresentationData
|
||||
import AccountContext
|
||||
import ComponentDisplayAdapters
|
||||
|
||||
private func resolveTheme(baseTheme: PresentationTheme, theme: ViewControllerComponentContainer.Theme) -> PresentationTheme {
|
||||
switch theme {
|
||||
case .default:
|
||||
return baseTheme
|
||||
case let .custom(value):
|
||||
return value
|
||||
case .dark:
|
||||
return customizeDefaultDarkPresentationTheme(theme: defaultDarkPresentationTheme, editing: false, title: nil, accentColor: baseTheme.list.itemAccentColor, backgroundColors: [], bubbleColors: [], animateBubbleColors: false, wallpaper: nil, baseColor: nil)
|
||||
}
|
||||
}
|
||||
|
||||
open class ViewControllerComponentContainer: ViewController {
|
||||
public enum NavigationBarAppearance {
|
||||
case none
|
||||
@@ -25,6 +36,12 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
case modal
|
||||
}
|
||||
|
||||
public enum Theme {
|
||||
case `default`
|
||||
case dark
|
||||
case custom(PresentationTheme)
|
||||
}
|
||||
|
||||
public final class Environment: Equatable {
|
||||
public let statusBarHeight: CGFloat
|
||||
public let navigationHeight: CGFloat
|
||||
@@ -121,19 +138,21 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
private weak var controller: ViewControllerComponentContainer?
|
||||
|
||||
private var component: AnyComponent<ViewControllerComponentContainer.Environment>
|
||||
var theme: PresentationTheme?
|
||||
let theme: Theme
|
||||
var resolvedTheme: PresentationTheme
|
||||
public let hostView: ComponentHostView<ViewControllerComponentContainer.Environment>
|
||||
|
||||
private var currentIsVisible: Bool = false
|
||||
private var currentLayout: (layout: ContainerViewLayout, navigationHeight: CGFloat)?
|
||||
|
||||
init(context: AccountContext, controller: ViewControllerComponentContainer, component: AnyComponent<ViewControllerComponentContainer.Environment>, theme: PresentationTheme?) {
|
||||
init(context: AccountContext, controller: ViewControllerComponentContainer, component: AnyComponent<ViewControllerComponentContainer.Environment>, theme: Theme) {
|
||||
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
self.controller = controller
|
||||
|
||||
self.component = component
|
||||
self.theme = theme
|
||||
self.resolvedTheme = resolveTheme(baseTheme: self.presentationData.theme, theme: theme)
|
||||
self.hostView = ComponentHostView()
|
||||
|
||||
super.init()
|
||||
@@ -152,7 +171,7 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
metrics: layout.metrics,
|
||||
deviceMetrics: layout.deviceMetrics,
|
||||
isVisible: self.currentIsVisible,
|
||||
theme: self.theme ?? self.presentationData.theme,
|
||||
theme: self.resolvedTheme,
|
||||
strings: self.presentationData.strings,
|
||||
dateTimeFormat: self.presentationData.dateTimeFormat,
|
||||
controller: { [weak self] in
|
||||
@@ -197,13 +216,13 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
}
|
||||
|
||||
private let context: AccountContext
|
||||
private var theme: PresentationTheme?
|
||||
private var theme: Theme
|
||||
private let component: AnyComponent<ViewControllerComponentContainer.Environment>
|
||||
|
||||
private var presentationDataDisposable: Disposable?
|
||||
public private(set) var validLayout: ContainerViewLayout?
|
||||
|
||||
public init<C: Component>(context: AccountContext, component: C, navigationBarAppearance: NavigationBarAppearance, statusBarStyle: StatusBarStyle = .default, presentationMode: PresentationMode = .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: Theme = .default) where C.EnvironmentType == ViewControllerComponentContainer.Environment {
|
||||
self.context = context
|
||||
self.component = AnyComponent(component)
|
||||
self.theme = theme
|
||||
@@ -230,6 +249,7 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
}
|
||||
|
||||
strongSelf.node.presentationData = presentationData.withUpdated(theme: theme)
|
||||
strongSelf.node.resolvedTheme = resolveTheme(baseTheme: presentationData.theme, theme: strongSelf.theme)
|
||||
|
||||
switch statusBarStyle {
|
||||
case .none:
|
||||
|
||||
Reference in New Issue
Block a user