Hello, I'm new to Xcode and Swift. I'm using SwiftUI and trying to implement swipeActions
in a row inside a List but it does not work.
Here a minimal reproduction:
import SwiftUI
struct RowWithActions: View {
var body: some View {
NavigationView {
List {
ForEach(1..<6) { i in
Text("Item \(i)")
.swipeActions(edge: .leading, allowsFullSwipe: false) {
Button {
print("Some action")
} label: {
Label("Star", systemImage: "star.circle")
}
}
}
}
}
}
}
struct RowWithActions_Previews: PreviewProvider {
static var previews: some View {
RowWithActions()
}
}
I'm following this documentation and somes community post with examples but it always throw this error:
Value of type 'Text' has no member 'swipeActions'
Anyone can help me please?