Closed Dave181295 closed 5 months ago
Hi, @Dave181295 ! Thx for your suggestion for improvement! Actually, you may use smth like this:
import SwiftUI
public extension View {
@ViewBuilder
func swipeHint(_ isActive: Bool = false, hintOffset: CGFloat) -> some View {
if isActive {
modifier(SwipeHintModifier(hintOffset: hintOffset))
} else {
self
}
}
}
public struct SwipeHintModifier: ViewModifier {
let hintOffset: CGFloat
@State private var offset: CGFloat = 0
public func body(content: Content) -> some View {
content
.offset(x: -offset)
.onAppear {
withAnimation(.easeInOut.delay(0.3)) {
offset = hintOffset
}
withAnimation(.easeInOut.delay(1.3)) {
offset = 0
}
}
}
}
and add this modifier to our content, for example, like this way:
ForEach(range, ...) {
YourCell()
...
.addFullSwipeAction(
menu: .slided,
swipeColor: .red,
state: $state) {
Leading {
...
}
Trailing {
...
}
}
.swipeHint(cell == range.first, hintOffset: 120.0) // for trailing
.swipeHint(cell == range[1] , hintOffset: -120.0) // for leading
...
}
added in 0.3.5
Thanks for the lib, it would be Nice to trigger a UI element for the swipe behavior of any rows by passing a
bool
state , like theEditButton
from the original List, this will help as the user for now doesn't know if he can swipe any cell.