Introducing SwipeViewGroup
- Simply wrap your views in
SwipeViewGroup
to allow only one open at a time.
SwipeViewGroup {
SwipeView {} /// Only one of the actions will be shown.
SwipeView {}
SwipeView {}
}
SwipeViewGroup.mov
Syntax improvements for swipe-to-trigger
- SwipeActions can now infer
swipeToTriggerLeadingEdge
andswipeToTriggerTrailingEdge
automatically. swipeActionEdgeStyling()
has been renamed toallowSwipeToTrigger()
.
Before
SwipeView {
Text("Swipe")
} leadingActions: { _ in
SwipeAction("Leading") {}
.swipeActionEdgeStyling()
} trailingActions: { _ in
SwipeAction("Trailing") {}
.swipeActionEdgeStyling()
}
.swipeToTriggerLeadingEdge(true)
.swipeToTriggerTrailingEdge(true)
After
SwipeView {
Text("Swipe")
} leadingActions: { _ in
SwipeAction("Leading") {}
.allowSwipeToTrigger()
} trailingActions: { _ in
SwipeAction("Trailing") {}
.allowSwipeToTrigger()
}
Syntax improvements for SwipeView
If you only want trailingActions
and don't want leadingActions
, or the other way around, you can now omit it completely!
SwipeView {
Text("Hello")
.frame(maxWidth: .infinity)
.padding(.vertical, 32)
.background(Color.blue.opacity(0.1))
.cornerRadius(32)
- } leadingActions: { _ in
} trailingActions: { _ in
SwipeAction("World") {
print("Tapped!")
}
}