Added swipe actions to all the dummy items in the BrowseView view.

This commit is contained in:
Javier Cicchelli 2022-12-03 08:19:48 +01:00
parent 7c5aed8b8c
commit c9b148a2ff

View File

@ -11,6 +11,7 @@ import SwiftUI
struct BrowseView: View {
var body: some View {
List {
Group {
Group {
FolderItem(name: "Some folder #1 name")
FolderItem(name: "Some folder #2 name")
@ -58,6 +59,34 @@ struct BrowseView: View {
)
}
}
.swipeActions(
edge: .trailing,
allowsFullSwipe: true
) {
Button {
// ...
} label: {
Label {
Text("Delete item")
} icon: {
Image.trash
}
}
.tint(.red)
// TODO: allow download only if item is a file.
Button {
// ...
} label: {
Label {
Text("Download item")
} icon: {
Image.download
}
}
.tint(.orange)
}
}
.listStyle(.inset)
.background(Color.red)
.navigationTitle("Folder name")
@ -78,6 +107,8 @@ struct BrowseView: View {
private extension Image {
static let profile = Image(systemName: "person.crop.circle.fill")
static let trash = Image(systemName: "trash")
static let download = Image(systemName: "arrow.down.doc")
}
// MARK: - Previews