pub trait ViewExt: View + Sized {
Show 35 methods
// Provided methods
fn on_command(
self,
command: Command,
action: impl Fn() + 'static,
) -> Modified<Self> { ... }
fn on_command_when(
self,
command: Command,
enabled: impl Fn() -> bool + 'static,
action: impl Fn() + 'static,
) -> Modified<Self> { ... }
fn focused_value<T: Clone + 'static>(
self,
name: &'static str,
value: T,
) -> Modified<Self> { ... }
fn padding(self, points: f64) -> Modified<Self> { ... }
fn padding_xy(self, horizontal: f64, vertical: f64) -> Modified<Self> { ... }
fn width(self, points: f64) -> Modified<Self> { ... }
fn min_width(self, points: f64) -> Modified<Self> { ... }
fn min_height(self, points: f64) -> Modified<Self> { ... }
fn height(self, points: f64) -> Modified<Self> { ... }
fn frame(self, width: f64, height: f64) -> Modified<Self> { ... }
fn fill_width(self) -> Modified<Self> { ... }
fn fill_height(self) -> Modified<Self> { ... }
fn popover<P: View>(
self,
shown: &Signal<bool>,
content: impl Fn() -> P + 'static,
) -> Modified<Self> { ... }
fn context_menu(self, items: Vec<MenuItem>) -> Modified<Self> { ... }
fn accessibility_label(self, label: &str) -> Modified<Self> { ... }
fn background(self, color: impl IntoValue<Color>) -> Modified<Self> { ... }
fn corner_radius(self, points: f64) -> Modified<Self> { ... }
fn border(self, color: Color, width: f64) -> Modified<Self> { ... }
fn shadow(self, shadow: Shadow) -> Modified<Self> { ... }
fn opacity(self, opacity: impl IntoValue<f64>) -> Modified<Self> { ... }
fn font(self, font: Font) -> Modified<Self> { ... }
fn color(self, color: impl IntoValue<Color>) -> Modified<Self> { ... }
fn accessibility_value(
self,
value: impl IntoValue<String>,
) -> Modified<Self> { ... }
fn material(self, material: Material) -> Modified<Self> { ... }
fn glass(self, glass: Glass) -> Modified<Self> { ... }
fn background_when(
self,
color: impl Fn() -> Color + 'static,
) -> Modified<Self> { ... }
fn opacity_when(self, opacity: impl Fn() -> f64 + 'static) -> Modified<Self> { ... }
fn transition(self, transition: Transition) -> Modified<Self> { ... }
fn matched_geometry(self, id: &str) -> Modified<Self> { ... }
fn on_hover(self, action: impl Fn(bool) + 'static) -> Modified<Self> { ... }
fn hover_highlight(self, color: Color) -> Modified<Self> { ... }
fn tooltip(self, text: &str) -> Modified<Self> { ... }
fn hidden(self, when: impl IntoValue<bool>) -> Modified<Self> { ... }
fn disabled(self, when: impl IntoValue<bool>) -> Modified<Self> { ... }
fn on_click(self, action: impl Fn() + 'static) -> Modified<Self> { ... }
}Expand description
Modifiers every view has.
Provided Methods§
Sourcefn on_command(
self,
command: Command,
action: impl Fn() + 'static,
) -> Modified<Self>
fn on_command( self, command: Command, action: impl Fn() + 'static, ) -> Modified<Self>
Handles command while the focus is in this view (see
Command).
Sourcefn on_command_when(
self,
command: Command,
enabled: impl Fn() -> bool + 'static,
action: impl Fn() + 'static,
) -> Modified<Self>
fn on_command_when( self, command: Command, enabled: impl Fn() -> bool + 'static, action: impl Fn() + 'static, ) -> Modified<Self>
Handles command, enabled only while enabled returns true.
Sourcefn focused_value<T: Clone + 'static>(
self,
name: &'static str,
value: T,
) -> Modified<Self>
fn focused_value<T: Clone + 'static>( self, name: &'static str, value: T, ) -> Modified<Self>
Publishes value under name to the focus (see
focused_value).
Sourcefn padding_xy(self, horizontal: f64, vertical: f64) -> Modified<Self>
fn padding_xy(self, horizontal: f64, vertical: f64) -> Modified<Self>
Inset horizontal points left and right and vertical above and
below: a row’s .padding_xy(10.0, 7.0), as SwiftUI’s
.padding(.horizontal, 10) and .padding(.vertical, 7).
Sourcefn min_width(self, points: f64) -> Modified<Self>
fn min_width(self, points: f64) -> Modified<Self>
At least points wide (SwiftUI’s frame(minWidth:)).
Sourcefn min_height(self, points: f64) -> Modified<Self>
fn min_height(self, points: f64) -> Modified<Self>
At least points tall (SwiftUI’s frame(minHeight:)).
Sourcefn fill_width(self) -> Modified<Self>
fn fill_width(self) -> Modified<Self>
Takes all the width its container offers.
Sourcefn fill_height(self) -> Modified<Self>
fn fill_height(self) -> Modified<Self>
Takes all the height its container offers.
Sourcefn popover<P: View>(
self,
shown: &Signal<bool>,
content: impl Fn() -> P + 'static,
) -> Modified<Self>
fn popover<P: View>( self, shown: &Signal<bool>, content: impl Fn() -> P + 'static, ) -> Modified<Self>
Shows content in a popover pointing at this view while shown is
true (see Modified::popover).
A right-click menu on this view’s native views.
Sourcefn accessibility_label(self, label: &str) -> Modified<Self>
fn accessibility_label(self, label: &str) -> Modified<Self>
The name VoiceOver reads for this view’s native views (“Name”,
“Volume”), for controls whose visible label is a separate view or
that have none (a field after a text("Name:"), an icon button).
Sourcefn background(self, color: impl IntoValue<Color>) -> Modified<Self>
fn background(self, color: impl IntoValue<Color>) -> Modified<Self>
A background behind the view, its padding included: with
corner_radius and shadow, a
card. Color::QuaternaryFill is the system’s grouped-card colour.
A closure computes it from signals (a selected row, a status); it
changes smoothly inside animated.
Sourcefn corner_radius(self, points: f64) -> Modified<Self>
fn corner_radius(self, points: f64) -> Modified<Self>
Rounds the corners of the view’s background and border, in points.
Sourcefn border(self, color: Color, width: f64) -> Modified<Self>
fn border(self, color: Color, width: f64) -> Modified<Self>
A border width points wide around the view (inside its padding).
Sourcefn shadow(self, shadow: Shadow) -> Modified<Self>
fn shadow(self, shadow: Shadow) -> Modified<Self>
A drop shadow under the view’s background (give it a background).
Sourcefn opacity(self, opacity: impl IntoValue<f64>) -> Modified<Self>
fn opacity(self, opacity: impl IntoValue<f64>) -> Modified<Self>
The view at opacity (0 transparent, 1 opaque), all of it, or a
closure computing it from signals; it fades inside
animated.
Sourcefn font(self, font: Font) -> Modified<Self>
fn font(self, font: Font) -> Modified<Self>
The font of the text inside the view (all of it, when it’s a row or a card): a text style or a custom font. Works after any modifier.
Sourcefn color(self, color: impl IntoValue<Color>) -> Modified<Self>
fn color(self, color: impl IntoValue<Color>) -> Modified<Self>
The colour of the text and symbols inside the view, or a closure computing it from signals. Works after any modifier.
Sourcefn accessibility_value(self, value: impl IntoValue<String>) -> Modified<Self>
fn accessibility_value(self, value: impl IntoValue<String>) -> Modified<Self>
What VoiceOver reads as the view’s value, after its name: a card’s state (“done”), a gauge’s level. A closure keeps it current.
Sourcefn material(self, material: Material) -> Modified<Self>
fn material(self, material: Material) -> Modified<Self>
A system material behind the view, its padding included: a
translucent sidebar, header or panel that blurs what’s behind it.
corner_radius rounds it.
Sourcefn glass(self, glass: Glass) -> Modified<Self>
fn glass(self, glass: Glass) -> Modified<Self>
Liquid Glass behind the view, its padding included (macOS 26; a
translucent material on macOS 15). corner_radius
rounds it.
Sourcefn background_when(self, color: impl Fn() -> Color + 'static) -> Modified<Self>
👎Deprecated since 0.4.0: background takes a closure: .background(move || ..)
fn background_when(self, color: impl Fn() -> Color + 'static) -> Modified<Self>
background takes a closure: .background(move || ..)
A background following signals (now background
takes a closure).
Sourcefn opacity_when(self, opacity: impl Fn() -> f64 + 'static) -> Modified<Self>
👎Deprecated since 0.4.0: opacity takes a closure: .opacity(move || ..)
fn opacity_when(self, opacity: impl Fn() -> f64 + 'static) -> Modified<Self>
opacity takes a closure: .opacity(move || ..)
Opacity following signals (now opacity takes a
closure).
Sourcefn transition(self, transition: Transition) -> Modified<Self>
fn transition(self, transition: Transition) -> Modified<Self>
Sourcefn matched_geometry(self, id: &str) -> Modified<Self>
fn matched_geometry(self, id: &str) -> Modified<Self>
Matched geometry (SwiftUI’s matchedGeometryEffect): when, in one
animated change, a view with this id goes
and another with it comes (a thumbnail replaced by its detail, a
selection marker moving), the new one starts where and as large as
the old one was, and moves to its place.
Sourcefn on_hover(self, action: impl Fn(bool) + 'static) -> Modified<Self>
fn on_hover(self, action: impl Fn(bool) + 'static) -> Modified<Self>
Calls action with true when the pointer moves over the view and
false when it leaves (while the app is active).
Sourcefn hover_highlight(self, color: Color) -> Modified<Self>
fn hover_highlight(self, color: Color) -> Modified<Self>
A background of color while the pointer is over the view, fading
in and out: for rows and cards that can be clicked.
Sourcefn tooltip(self, text: &str) -> Modified<Self>
fn tooltip(self, text: &str) -> Modified<Self>
A tooltip: text appears in a small box when the pointer rests on
the view (SwiftUI’s help). VoiceOver reads it as the view’s help.
Hides the view while when() is true, following the signals it
reads: its native views stay built (no rebuild, the state inside
kept) but aren’t shown, and it takes no room in its stack, as if it
weren’t there. For a panel shown in one mode only, rather than a
dynamic that rebuilds it each time. VoiceOver and Tab skip it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".