@@ -20,6 +20,7 @@ enum ListPlaygroundType: String, CaseIterable {
2020 case sectionedEditActions
2121 case plainStyleSectionedEditActions
2222 case onMoveDelete
23+ case swipeActions
2324 case positioned
2425 case badges
2526
@@ -61,6 +62,8 @@ enum ListPlaygroundType: String, CaseIterable {
6162 return " Plain Style Sectioned EditActions "
6263 case . onMoveDelete:
6364 return " .onMove, .onDelete "
65+ case . swipeActions:
66+ return " .swipeActions "
6467 case . positioned:
6568 return " Positioned "
6669 case . badges:
@@ -137,6 +140,9 @@ struct ListPlayground: View {
137140 case . onMoveDelete:
138141 OnMoveDeleteListPlayground ( )
139142 . navigationTitle ( $0. title)
143+ case . swipeActions:
144+ SwipeActionsListPlayground ( )
145+ . navigationTitle ( $0. title)
140146 case . positioned:
141147 PositionedListPlayground ( )
142148 . navigationTitle ( $0. title)
@@ -803,3 +809,41 @@ struct BadgeListPlayground: View {
803809 }
804810 }
805811}
812+
813+ struct SwipeActionsListPlayground : View {
814+ @State var rows : [ Int ] = Array ( 0 ..< 12 )
815+ @State var lastAction = " "
816+
817+ var body : some View {
818+ VStack ( spacing: 0 ) {
819+ Text ( lastAction. isEmpty ? " Swipe a row " : lastAction)
820+ . font ( . footnote)
821+ . foregroundStyle ( . secondary)
822+ . padding ( 8 )
823+ List {
824+ ForEach ( rows, id: \. self) { i in
825+ Text ( " Row \( i) — Add to favorites " )
826+ . swipeActions ( edge: . trailing) {
827+ Button ( " Pin " ) {
828+ lastAction = " Pinned row \( i) "
829+ }
830+ . tint ( . purple)
831+
832+ Button ( " Delete " , role: . destructive) {
833+ lastAction = " Deleted row \( i) "
834+ }
835+ }
836+ . swipeActions ( edge: . leading) {
837+ Button ( " Flag " ) {
838+ lastAction = " Flagged row \( i) "
839+ }
840+ . tint ( . orange)
841+ }
842+ }
843+ . onDelete { offsets in
844+ rows. remove ( atOffsets: offsets)
845+ }
846+ }
847+ }
848+ }
849+ }
0 commit comments