pub fn transform_environment<K: EnvKey>(
view: &ViewHandle,
action: impl Fn(K::Value) -> K::Value + 'static,
) -> ViewHandleExpand description
.transformEnvironment(_:transform:) for any property this crate has a
key for.
transform_environment_image_scale does this for one property, with the
key path recovered from a modifier SwiftUI built. Every EnvKey already
carries its own key path for @Environment to read through, so the same
modifier works for all of them — the only thing that was missing was a way
to write the value back, which is what crate::state::EnvKey::encode is.
// One size larger than whatever is in scope.
views::transform_environment::<ControlSizeKey>(&views::text("x"), |s| match s {
ControlSize::Mini => ControlSize::Small,
other => other,
});