HomeiOS Developmentios - SwiftUI Faucet inside Checklist does not set off choice

ios – SwiftUI Faucet inside Checklist does not set off choice


Whether it is tremendous to disregard faucets on an already chosen row, you should use onChange(of: choice).

// modify the Checklist with this, not the record rows
.onChange(of: choice) { metropolis in
    if isFocusedFromTextField {
        from = metropolis
    } else {
        to = metropolis
    }
}

In any other case, think about using a Button because the record rows as an alternative. This nonetheless maintains the selectable nature of the record.

Button {
    if isFocusedFromTextField {
        from = metropolis
    } else {
        to = metropolis
    }
} label: {
    // change this with a extra sophisticated view in order for you...
    Textual content(metropolis)
}
// - fashion the button to look extra like a Textual content in order for you
// - eliminate the choice @State for those who do not want it
// - for those who do want the choice, you may fashion the buttons in a different way
// relying on chosen state, utilizing listRowBackground and so forth.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments