在swiftUI中禁用特定行/按钮

在swiftUI中禁用特定行/按钮,swift,swiftui,Swift,Swiftui,我有这个密码。我只想在名称为“Aditya”时禁用单击,其余的都可以单击。我目前的审判不起作用。如何基于某些属性禁用特定行/按钮。在本例中,名称为“Aditya” import SwiftUI struct ContentView: View { var someelements = ["Aditya" , "Kappor" , "Chattarjee", "Mithun"] var bo

我有这个密码。我只想在名称为“Aditya”时禁用单击,其余的都可以单击。我目前的审判不起作用。如何基于某些属性禁用特定行/按钮。在本例中,名称为“Aditya”

import SwiftUI

struct ContentView: View {
    
    var someelements = ["Aditya" , "Kappor" , "Chattarjee", "Mithun"]
    var body: some View {
        ForEach (self.someelements , id: \.self ) { something in
            EditForm(name: something)
            //Below is my trial that do not work.
            if something == "Aditya" {
                self.disabled(true)
            }
        }
    }
}


struct EditForm : View {
    var name : String
    var body: some View {
        Group {
            Button (action: {
                //some action
            }) {
                HStack {
                    Text(self.name)
                        .scaledToFit()
                        .foregroundColor(.blue)
                }
            }
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
struct ContentView: View {
    var someelements = ["Kappor" , "Chattarjee", "Mithun", "Aditya"]
    var body: some View {
        List {
            ForEach (self.someelements , id: \.self ) { value in
                Button(action: {
                    print("tapped")
                }, label: {
                    Text("\(value)")
                })
                .disabled(value == "Aditya") // Disable tap action only for that value here. 
            }
        }
    }
}