pull out offset stuff works properly, builds

undo
saint 2024-06-04 07:26:31 -04:00
parent 6f7eed1e81
commit 0ac847c88c
1 changed files with 19 additions and 13 deletions

View File

@ -376,6 +376,7 @@ struct ContentView: View {
.gesture(
DragGesture()
.onChanged { gesture in
let margin = CGFloat(50)
print("mao viewState :\(viewState.width)")
print(pulledOut.width)
@ -385,16 +386,20 @@ struct ContentView: View {
// if gesture.translation.width < -50, pulledOut.width == CGFloat(0) {
// }
}
if viewState.width < -50 {
dragOffset = CGFloat(50) + viewState.width + pulledOut.width
if viewState.width < -50 && pulledOut.width <= 0 {
dragOffset = margin + viewState.width + pulledOut.width
}
if viewState.width > 0 {
dragOffset = CGFloat(50) + viewState.width + pulledOut.width
if viewState.width > 0 && pulledOut.width != 0 {
dragOffset = margin + viewState.width + pulledOut.width
}
}
.onEnded { _ in
let pulledOutRight = CGFloat(-300)
let pulledOutLeft = CGFloat(200)
let margin = CGFloat(50)
var setPulledOutWith = CGFloat(0)
var setDragOffset = CGFloat(0)
if viewState.width < 0 && pulledOut.width > 0 {
@ -402,18 +407,19 @@ struct ContentView: View {
} else if viewState.width > 0 && pulledOut.width < 0 {
setPulledOutWith = CGFloat(0)
} else if viewState.width < 0 && pulledOut.width == 0 {
setPulledOutWith = CGFloat(-300)
setPulledOutWith = pulledOutRight
setDragOffset = margin + setPulledOutWith
} else if abs(viewState.width + pulledOut.width) > 30 {
setPulledOutWith = CGFloat(200)
setPulledOutWith = pulledOutLeft
}
if setPulledOutWith < 0 {
setDragOffset = CGFloat(50) + setPulledOutWith
} else if setPulledOutWith > 0 {
setDragOffset = setPulledOutWith
} else {
setDragOffset = .zero
}
// if setPulledOutWith < 0 {
// setDragOffset = CGFloat(50) + setPulledOutWith
// } else if setPulledOutWith > 0 {
// setDragOffset = setPulledOutWith
// } else {
// setDragOffset = .zero
// }
print("mao setPulledOutWith \(setPulledOutWith)")
withAnimation(.spring(response: 0.2)) {