I would expect that sheet that is presented show the actual string that was pressed in the list.
i.e, long press G and the presenting sheet should show G
Unfortunately it doesn't, I'm assuming this is a SwiftUI bug.
Does anyone have a clean solution for this?
Thanks
struct ContentView: View {
let items = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
@State var showing = false
var body: some View {
NavigationView {
List {
ForEach(items, id: \.self) { item in
Text(item).font(.largeTitle)
.contextMenu {
self.contextEdit(item)
}
}
}
}
}
private func contextEdit(_ item: String) -> some View {
Button(action: {
self.showing.toggle()
print(item)
}) {
Text("Edit")
Image(systemName: "circle")
}.sheet(isPresented: $showing) {
Text(item)
}
}
}