I have this code . I want to change the background color of the row with the name "Aditya" in the EditForm View within the Content View background color to , for example gray . What i am doing now is setting the color after the list but it does not do what i want which is setting just the row with "Aditya"name background color to gray. How can i do that within the content view .
struct ContentView: View {
var someelements = ["Aditya" , "Kappor" , "Chattarjee", "Mithun"]
var body: some View {
List {
ForEach (self.someelements , id: \.self ) { value in
EditForm(name: value , action: {
if value == "Aditya" {
/*what i am doing*/
self.listRowBackground(Color(.gray))
}
})
}
}
}
}
struct EditForm : View {
var name : String
var action: (()->())?
var body: some View {
Group {
Button (action: {
//some action
}) {
HStack {
Text(self.name)
.scaledToFit()
.foregroundColor(.red)
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}