Skip to main content

toggle_sources

Function toggle_sources 

Source
pub fn toggle_sources(label: &str, states: &[&BoundState<bool>]) -> View
Expand description

Toggle(_:sources:isOn:) — one toggle over several bindings.

The “select all” row at the top of a settings group: it reads mixed when the sources disagree, and setting it sets every one of them. There was no way to express that — a toggle took exactly one binding, so the mixed state had to be faked with a third value that nothing wrote back to.

let wifi = BoundState::new(true);
let bluetooth = BoundState::new(false);
let all = toggle_sources("All", &[&wifi, &bluetooth]);