mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Drag sheet if possible
This commit is contained in:
parent
7ca339ce73
commit
c0fd059b29
@ -136,6 +136,7 @@ struct SGPayWallFeatureDetails: View {
|
||||
)
|
||||
}
|
||||
.tag(feature.id)
|
||||
.scrollBounceBehaviorIfAvailable(.basedOnSize)
|
||||
}
|
||||
}
|
||||
.tabViewStyle(.page)
|
||||
@ -152,6 +153,27 @@ struct SGPayWallFeatureDetails: View {
|
||||
.cornerRadius(8, corners: [.topLeft, .topRight])
|
||||
.padding(.bottom, bottomOffset)
|
||||
.overlay(closeButtonView)
|
||||
.offset(y: max(0, dragOffset))
|
||||
.gesture(
|
||||
DragGesture()
|
||||
.onChanged { value in
|
||||
// Only track downward movement
|
||||
if value.translation.height > 0 {
|
||||
dragOffset = value.translation.height
|
||||
}
|
||||
}
|
||||
.onEnded { value in
|
||||
// If dragged down more than 150 points or with significant velocity, dismiss
|
||||
if value.translation.height > 150 || value.predictedEndTranslation.height > 200 {
|
||||
dismissWithAnimation()
|
||||
} else {
|
||||
// Otherwise, reset position
|
||||
withAnimation(.spring()) {
|
||||
dragOffset = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
.transition(.move(edge: .bottom))
|
||||
}
|
||||
}
|
||||
@ -173,6 +195,7 @@ struct SGPayWallFeatureDetails: View {
|
||||
private func dismissWithAnimation() {
|
||||
withAnimation(.spring()) {
|
||||
showContent = false
|
||||
dragOffset = 0
|
||||
}
|
||||
|
||||
withAnimation(.easeOut(duration: 0.2).delay(0.1)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user