Various improvements

This commit is contained in:
Ilya Laktyushin
2025-08-27 23:47:26 +04:00
parent eb8464f687
commit effaa875a6
5 changed files with 30 additions and 14 deletions

View File

@@ -65,6 +65,7 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
public let clipsContent: Bool
public let isScrollEnabled: Bool
public let hasDimView: Bool
public let autoAnimateOut: Bool
public let externalState: ExternalState?
public let animateOut: ActionSlot<Action<()>>
public let onPan: () -> Void
@@ -77,6 +78,7 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
clipsContent: Bool = false,
isScrollEnabled: Bool = true,
hasDimView: Bool = true,
autoAnimateOut: Bool = true,
externalState: ExternalState? = nil,
animateOut: ActionSlot<Action<()>>,
onPan: @escaping () -> Void = {},
@@ -88,6 +90,7 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
self.clipsContent = clipsContent
self.isScrollEnabled = isScrollEnabled
self.hasDimView = hasDimView
self.autoAnimateOut = autoAnimateOut
self.externalState = externalState
self.animateOut = animateOut
self.onPan = onPan
@@ -110,6 +113,9 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
if lhs.hasDimView != rhs.hasDimView {
return false
}
if lhs.autoAnimateOut != rhs.autoAnimateOut {
return false
}
if lhs.animateOut != rhs.animateOut {
return false
}
@@ -430,9 +436,15 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
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) {
self.animateOut(completion: {})
if component.autoAnimateOut {
self.animateOut(completion: {})
}
}
if !sheetEnvironment.isDisplaying && !component.autoAnimateOut {
} else {
self.previousIsDisplaying = sheetEnvironment.isDisplaying
}
self.previousIsDisplaying = sheetEnvironment.isDisplaying
self.dismiss = sheetEnvironment.dismiss
return availableSize