how to assign textField's default value in list (swiftUI)

I have a list with textField and a button.

my goal is that I want to provide default value to textField when I toggle the button.

I can do it with text, but I don't know how to do with textField

struct ContentView: View {
    
    @State var isEnableBatch: Bool = false

    var body: some View {
        VStack {
            Button {
                isEnableBatch.toggle()
            } label: {
                Image(isEnableBatch == true ? "EAIcon-Check_rectangle" : "EAIcon-Check_Box")
            }
            
            List {
                ForEach(0 ..< 10, id: \.self) { index in
                    let value = isEnableBatch ? "batch Enable" : "\(index)"
                    Text(value) // <-- I don't know how to do here if i change to textField
                }
            }
            .listStyle(.plain)

        }
        .padding()
    }
}

If I change to use textField as below

it will show compile error No exact matches in reference to static method 'buildExpression'

struct ContentView: View {
    
    @State var isEnableBatch: Bool = false
    @State var attValue: String = ""

    var body: some View {
        VStack {
            Button {
                isEnableBatch.toggle()
            } label: {
                Image(isEnableBatch == true ? "EAIcon-Check_rectangle" : "EAIcon-Check_Box")
            }
            
            List {
                ForEach(0 ..< 10, id: \.self) { index in
                    attValue = isEnableBatch ? "batch Enable" : "\(index)" // <-- how to update TextField's default value ??
                    TextField("", text: $attValue)
                }
            }
            .listStyle(.plain)

        }
        .padding()
    }
}
attValue = isEnableBatch ? "batch Enable" : "\(index)"

This line cannot be placed inside of a view. It alters the state of the view whilst it is being rendered, which could caused it to re-render infinitely.

It must be placed somewhere else, like a closure inside of a view.

You can either place it in the button's action just after you toggle the boolean value:

Button {
    isEnableBatch.toggle()
    attValue = isEnableBatch ? "batch Enable" : "\(index)" // update text field text
} label: {
    ...
}

or place it in an onChange modifier:

.onChange(of: isEnableBatch) { newValue in
    attValue = newValue ? "batch Enable" : "\(index)" // update text field text whenever boolean changes
}

Finally, I found how to solve my problems

struct ContentView: View {
    
    @State var isEnableBatch: Bool = false
    @State var attValues: [String] = ["", "" , ""] // <- use an array to store every state value
    
    var body: some View {
        VStack {
            Button {
                isEnableBatch.toggle()
                // update state value while toggling the button
                if isEnableBatch {
                    for index in 0 ..< 3 {
                        attValues[index] = "batch Enable"
                    }
                } else {
                    for index in 0 ..< 3 {
                        attValues[index] = ""
                    }
                }

            } label: {
                Image(isEnableBatch == true ? "EAIcon-Check_rectangle" : "EAIcon-Check_Box")
            }
            
            List {
                ForEach(0 ..< 3, id: \.self) { index in
                    TextField("", text: $attValues[index]) // <-- find the corresponding state value to binding
                }
            }
            .listStyle(.plain)

        }
        .padding()
    }
}

how to assign textField's default value in list (swiftUI)
 
 
Q