Creating an Intuitive Custom Swipe Experience with SwiftUI
Tukang Ketik -
One of the new features in SwiftUI 3 is the addition of the swipeActions() modifier for List rows. By using swipeActions, you can easily add buttons as left or right swipe actions in a List. This is something very popular and commonly used in mobile email client applications.
As shown in the description of the swipeActions modifier above, the edge parameter is used to set the swipe direction, whether from the left (leading) or from the right (trailing). allowsFullSwipe is used to determine whether a full swipe action can be performed (meaning swiping all the way to the left or right), which automatically triggers the action.
This is an example of how to use swipeActions with multiple buttons, both from left or right directions.
In the example above, we use both Buttons with Labels and Buttons with Text. The difference is in their appearance. If you use Label, only the icon will appear, while with Text, the text will also appear.
Feel free to also try changing the value of allowsFullSwipe to see the difference more clearly.
That's all for this tip/trick. Happy experimenting, and hopefully, this little tip will be useful.