mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Various improvements
This commit is contained in:
@@ -64,6 +64,7 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
|
||||
public let followContentSizeChanges: Bool
|
||||
public let clipsContent: Bool
|
||||
public let isScrollEnabled: Bool
|
||||
public let hasDimView: Bool
|
||||
public let externalState: ExternalState?
|
||||
public let animateOut: ActionSlot<Action<()>>
|
||||
public let onPan: () -> Void
|
||||
@@ -75,6 +76,7 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
|
||||
followContentSizeChanges: Bool = false,
|
||||
clipsContent: Bool = false,
|
||||
isScrollEnabled: Bool = true,
|
||||
hasDimView: Bool = true,
|
||||
externalState: ExternalState? = nil,
|
||||
animateOut: ActionSlot<Action<()>>,
|
||||
onPan: @escaping () -> Void = {},
|
||||
@@ -85,6 +87,7 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
|
||||
self.followContentSizeChanges = followContentSizeChanges
|
||||
self.clipsContent = clipsContent
|
||||
self.isScrollEnabled = isScrollEnabled
|
||||
self.hasDimView = hasDimView
|
||||
self.externalState = externalState
|
||||
self.animateOut = animateOut
|
||||
self.onPan = onPan
|
||||
@@ -101,6 +104,12 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
|
||||
if lhs.followContentSizeChanges != rhs.followContentSizeChanges {
|
||||
return false
|
||||
}
|
||||
if lhs.isScrollEnabled != rhs.isScrollEnabled {
|
||||
return false
|
||||
}
|
||||
if lhs.hasDimView != rhs.hasDimView {
|
||||
return false
|
||||
}
|
||||
if lhs.animateOut != rhs.animateOut {
|
||||
return false
|
||||
}
|
||||
@@ -414,6 +423,10 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
|
||||
|
||||
self.currentAvailableSize = availableSize
|
||||
|
||||
if !component.hasDimView {
|
||||
self.dimView.backgroundColor = .clear
|
||||
}
|
||||
|
||||
if environment[SheetComponentEnvironment.self].value.isDisplaying, !self.previousIsDisplaying, let _ = transition.userData(ViewControllerComponentContainer.AnimateInTransition.self) {
|
||||
self.animateIn()
|
||||
} else if !environment[SheetComponentEnvironment.self].value.isDisplaying, self.previousIsDisplaying, let _ = transition.userData(ViewControllerComponentContainer.AnimateOutTransition.self) {
|
||||
|
||||
@@ -134,9 +134,13 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
}
|
||||
|
||||
public final class AnimateInTransition {
|
||||
public init() {
|
||||
}
|
||||
}
|
||||
|
||||
public final class AnimateOutTransition {
|
||||
public init() {
|
||||
}
|
||||
}
|
||||
|
||||
public final class Node: ViewControllerTracingNode {
|
||||
@@ -356,7 +360,7 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
}
|
||||
|
||||
if let layout = strongSelf.validLayout {
|
||||
strongSelf.containerLayoutUpdated(layout, transition: .immediate)
|
||||
strongSelf.containerLayoutUpdated(layout, transition: ContainedViewLayoutTransition.immediate)
|
||||
}
|
||||
}
|
||||
}).strict()
|
||||
@@ -412,6 +416,14 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
self.forceNextUpdate = false
|
||||
}
|
||||
|
||||
public func requestLayout(forceUpdate: Bool, transition: ComponentTransition) {
|
||||
self.forceNextUpdate = forceUpdate
|
||||
if self.isViewLoaded, let validLayout = self.validLayout {
|
||||
self.containerLayoutUpdated(validLayout, transition: transition)
|
||||
}
|
||||
self.forceNextUpdate = false
|
||||
}
|
||||
|
||||
override open func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||
super.containerLayoutUpdated(layout, transition: transition)
|
||||
|
||||
@@ -421,6 +433,15 @@ open class ViewControllerComponentContainer: ViewController {
|
||||
self.node.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: ComponentTransition(transition))
|
||||
}
|
||||
|
||||
public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ComponentTransition) {
|
||||
super.containerLayoutUpdated(layout, transition: transition.containedViewLayoutTransition)
|
||||
|
||||
let navigationHeight = self.navigationLayout(layout: layout).navigationFrame.maxY
|
||||
|
||||
self.validLayout = layout
|
||||
self.node.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: transition)
|
||||
}
|
||||
|
||||
public func updateComponent(component: AnyComponent<ViewControllerComponentContainer.Environment>, transition: ComponentTransition) {
|
||||
self.component = component
|
||||
self.node.updateComponent(component: component, transition: transition)
|
||||
|
||||
Reference in New Issue
Block a user