Compare commits

..

No commits in common. "c04469ef19936fd57f0b771856516d06ddd177d8" and "56b32c39abb243ae5b992aa44c7aae6c2bd21c5c" have entirely different histories.

1 changed files with 26 additions and 22 deletions

View File

@ -372,8 +372,6 @@ struct ContentView: View {
.onChanged { value in
// Calculate the offset
let margin = CGFloat(30)
var newOffset = value.translation.width
if startSwipeState == nil {
if pulledOut.width == 0 {
@ -412,56 +410,60 @@ struct ContentView: View {
if startSwipeDir == .left {
maxOffsetLeft = .zero
maxOffsetRight = .zero
} else if startSwipeDir == .right {
} else {
maxOffsetLeft = CGFloat(200)
maxOffsetRight = CGFloat(10)
maxOffsetRight = .zero
}
}
if newOffset + pulledOut.width < -maxOffsetLeft {
if startSwipeState == .right && startSwipeDir == .left {
print("meow here")
newOffset = -maxOffsetLeft + rubberBandEffect(newOffset + maxOffsetLeft) - pulledOut.width
} else {
print("meow here")
newOffset = -maxOffsetLeft + rubberBandEffect(newOffset + maxOffsetLeft)
}
} else if newOffset + pulledOut.width > maxOffsetRight {
if startSwipeState == .left, startSwipeDir == .right {
newOffset = maxOffsetRight + rubberBandEffect(newOffset - maxOffsetRight) - pulledOut.width
} else {
newOffset = maxOffsetRight + rubberBandEffect(newOffset - maxOffsetRight)
}
newOffset = maxOffsetRight + rubberBandEffect(newOffset - maxOffsetRight)
}
// if newOffset.height < -maxOffset {
// newOffset.height = -maxOffset + rubberBandEffect(newOffset.height + maxOffset)
// } else if newOffset.height > maxOffset {
// newOffset.height = maxOffset + rubberBandEffect(newOffset.height - maxOffset)
// }
self.mainSwipe.width = newOffset
// dragOffset is what is used to make the text be readable
// with the right pane being visible
// if mainSwipe.width < -margin && pulledOut.width <= 0 {
if mainSwipe.width < -margin && pulledOut.width <= 0 {
dragOffset = margin + mainSwipe.width + pulledOut.width
}
// if mainSwipe.width < -margin && pulledOut.width <= 0 {
// dragOffset = margin + mainSwipe.width + pulledOut.width
// }
if mainSwipe.width > 0 && pulledOut.width < 0 {
dragOffset = margin + mainSwipe.width + pulledOut.width
}
// if mainSwipe.width > 0 && pulledOut.width < 0 {
// dragOffset = margin + mainSwipe.width + pulledOut.width
// }
}
.onEnded { _ in
var finalSwipe = CGFloat(0)
let swipeLeftFinal = CGFloat(-200)
let swipeRightFinal = CGFloat(110)
let margin = CGFloat(30)
var setDragOffset = CGFloat(0)
// let margin = CGFloat(30)
if startSwipeState == .center {
if startSwipeDir == .right {
finalSwipe = swipeRightFinal
} else {
finalSwipe = swipeLeftFinal
setDragOffset = margin + swipeLeftFinal
}
} else if startSwipeState == .right {
finalSwipe = .zero
@ -475,7 +477,6 @@ struct ContentView: View {
if startSwipeDir == .left {
finalSwipe = swipeLeftFinal
setDragOffset = margin + swipeLeftFinal
} else {
finalSwipe = .zero
}
@ -484,6 +485,9 @@ struct ContentView: View {
startSwipeState = nil
startSwipeDir = nil
// var setDragOffset = CGFloat(0)
// if mainSwipe.width < 0 && pulledOut.width > 0 {
// setPulledOutWith = CGFloat(0)
// } else if mainSwipe.width > 0 && pulledOut.width < 0 {
@ -499,8 +503,8 @@ struct ContentView: View {
withAnimation(.spring(response: 0.2)) {
pulledOut.width = finalSwipe
dragOffset = setDragOffset
mainSwipe = .zero
// dragOffset = setDragOffset
mainSwipe = .zero
}
}
)