Various fixes

This commit is contained in:
Ilya Laktyushin
2023-10-22 20:29:11 +04:00
parent d136aa683d
commit 3d4ccb4eb0
6 changed files with 42 additions and 5 deletions

View File

@@ -37,7 +37,9 @@ public final class SheetComponentEnvironment: Equatable {
}
}
public let sheetComponentTag = GenericComponentViewTag()
public final class SheetComponent<ChildEnvironmentType: Equatable>: Component {
public typealias EnvironmentType = (ChildEnvironmentType, SheetComponentEnvironment)
public enum BackgroundColor: Equatable {
@@ -90,7 +92,19 @@ public final class SheetComponent<ChildEnvironmentType: Equatable>: Component {
}
}
public final class View: UIView, UIScrollViewDelegate {
public final class View: UIView, UIScrollViewDelegate, ComponentTaggedView {
public final class Tag {
public init() {
}
}
public func matches(tag: Any) -> Bool {
if let _ = tag as? Tag {
return true
}
return false
}
private let dimView: UIView
private let scrollView: ScrollView
private let backgroundView: UIView
@@ -159,6 +173,10 @@ public final class SheetComponent<ChildEnvironmentType: Equatable>: Component {
}
}
public func dismissAnimated() {
self.dismiss?(true)
}
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