import SwiftUI
extension Int: Identifiable {
public var id: Int { return self }
}
struct ContentView: View {
@State var shareSheet: Bool = false
@State var selectedNo : Int?
var body: some View {
VStack {
ForEach(0..<2, id: \.self, content: { rowNo in
Text("world \(rowNo)")
Button(action: {
shareSheet.toggle()
selectedNo = rowNo
}) {
Text("Go to world\(rowNo)")
}
})
}
.padding()
.sheet(item: $selectedNo) { row in
// BUG: when replacing 'row' below with 'selectedNo' nil is passed.
ShareView(message:"Hello \(row)" )
}
}
struct ShareView: View {
let message: String
var body: some View {
Text(message)
}
}
}