Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions Sources/Showcase/ListPlayground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ enum ListPlaygroundType: String, CaseIterable {
case sectionedEditActions
case plainStyleSectionedEditActions
case onMoveDelete
case swipeActions
case positioned

var title: String {
Expand Down Expand Up @@ -60,6 +61,8 @@ enum ListPlaygroundType: String, CaseIterable {
return "Plain Style Sectioned EditActions"
case .onMoveDelete:
return ".onMove, .onDelete"
case .swipeActions:
return ".swipeActions"
case .positioned:
return "Positioned"
}
Expand Down Expand Up @@ -132,6 +135,9 @@ struct ListPlayground: View {
case .onMoveDelete:
OnMoveDeleteListPlayground()
.navigationTitle($0.title)
case .swipeActions:
SwipeActionsListPlayground()
.navigationTitle($0.title)
case .positioned:
PositionedListPlayground()
.navigationTitle($0.title)
Expand Down Expand Up @@ -693,3 +699,41 @@ struct PositionedListPlayground: View {
}
}
}

struct SwipeActionsListPlayground: View {
@State var rows: [Int] = Array(0..<12)
@State var lastAction = ""

var body: some View {
VStack(spacing: 0) {
Text(lastAction.isEmpty ? "Swipe a row" : lastAction)
.font(.footnote)
.foregroundStyle(.secondary)
.padding(8)
List {
ForEach(rows, id: \.self) { i in
Text("Row \(i) — Add to favorites")
.swipeActions(edge: .trailing) {
Button("Pin") {
lastAction = "Pinned row \(i)"
}
.tint(.purple)

Button("Delete", role: .destructive) {
lastAction = "Deleted row \(i)"
}
}
.swipeActions(edge: .leading) {
Button("Flag") {
lastAction = "Flagged row \(i)"
}
.tint(.orange)
}
}
.onDelete { offsets in
rows.remove(atOffsets: offsets)
}
}
}
}
}
9 changes: 9 additions & 0 deletions Sources/Showcase/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -2477,6 +2477,9 @@
},
"Picker .tint(.red)" : {

},
"Pin" : {

},
"Pink" : {

Expand Down Expand Up @@ -2712,6 +2715,9 @@
},
"Row %lld" : {

},
"Row %lld — Add to favorites" : {

},
"Row %lld.1" : {

Expand Down Expand Up @@ -3309,6 +3315,9 @@
},
"State: %@" : {

},
"Status bar hidden" : {

},
"Stop" : {

Expand Down
Loading