Update API

This commit is contained in:
Ilya Laktyushin
2024-05-24 16:29:44 +04:00
parent 16b6083b6e
commit 0bb02041e8
21 changed files with 205 additions and 113 deletions

View File

@@ -65,6 +65,7 @@ public final class SheetComponent<ChildEnvironmentType: Equatable>: Component {
public let clipsContent: Bool
public let externalState: ExternalState?
public let animateOut: ActionSlot<Action<()>>
public let onPan: () -> Void
public init(
content: AnyComponent<ChildEnvironmentType>,
@@ -72,7 +73,8 @@ public final class SheetComponent<ChildEnvironmentType: Equatable>: Component {
followContentSizeChanges: Bool = false,
clipsContent: Bool = false,
externalState: ExternalState? = nil,
animateOut: ActionSlot<Action<()>>
animateOut: ActionSlot<Action<()>>,
onPan: @escaping () -> Void = {}
) {
self.content = content
self.backgroundColor = backgroundColor
@@ -80,6 +82,7 @@ public final class SheetComponent<ChildEnvironmentType: Equatable>: Component {
self.clipsContent = clipsContent
self.externalState = externalState
self.animateOut = animateOut
self.onPan = onPan
}
public static func ==(lhs: SheetComponent, rhs: SheetComponent) -> Bool {
@@ -128,6 +131,8 @@ public final class SheetComponent<ChildEnvironmentType: Equatable>: Component {
return false
}
private var component: SheetComponent<ChildEnvironmentType>?
private let dimView: UIView
private let scrollView: ScrollView
private let backgroundView: UIView
@@ -199,6 +204,10 @@ public final class SheetComponent<ChildEnvironmentType: Equatable>: Component {
self.dismiss?(true)
}
public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
self.component?.onPan()
}
private var scrollingOut = false
public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
let contentOffset = (scrollView.contentOffset.y + scrollView.contentInset.top - scrollView.contentSize.height) * -1.0
@@ -302,6 +311,7 @@ public final class SheetComponent<ChildEnvironmentType: Equatable>: Component {
}
}
self.component = component
self.currentHasInputHeight = sheetEnvironment.hasInputHeight
switch component.backgroundColor {