Skip to content

SwipeViewGroup and syntax improvements

Latest
Compare
Choose a tag to compare
@aheze aheze released this 14 Apr 02:01
· 17 commits to main since this release

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 and swipeToTriggerTrailingEdge automatically.
  • swipeActionEdgeStyling() has been renamed to allowSwipeToTrigger().

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!")
      }
  }