pub struct VStack<T> { /* private fields */ }Expand description
A view that lays out its children vertically.
Implementations§
Source§impl<T> VStack<T>
impl<T> VStack<T>
Sourcepub const fn new(wrapped: T) -> VStack<T>
pub const fn new(wrapped: T) -> VStack<T>
Creates a new VStack from given wrapped view.
Examples found in repository?
More examples
examples/shapes.rs (lines 12-22)
11 fn body(&self) -> Self::Body {
12 VStack::new(
13 (
14 Capsule::new(),
15 Circle::new(),
16 Ellipse::new(),
17 Rectangle::new(),
18 RoundedRectangle::with_corner_radius(15.0)
19 .fill(Color::RED),
20 )
21 .frame((100, 50))
22 )
23 }examples/loops.rs (lines 12-23)
11 fn body(&self) -> Self::Body {
12 VStack::new((
13 HStack::new(
14 ForEach::new(["Hello", "World"], |s| {
15 Text::new(s)
16 }),
17 ),
18 HStack::new(
19 ForEach::new(0..10, |i| {
20 Text::new(format!("{i}"))
21 })
22 ),
23 ))
24 }examples/picker.rs (lines 15-27)
13 fn body(&self) -> Self::Body {
14 let selection = self.selection.clone();
15 VStack::new((
16 Picker::new("Favorite Color", selection.binding(), (
17 Text::new("Red"),
18 Text::new("Green"),
19 Text::new("Yellow"),
20 Text::new("Blue"),
21 )),
22 Button::with_text("Choose next", clone!(selection => move || {
23 if let Id::Index(i) = selection.get() {
24 selection.set((i + 1) % 4);
25 }
26 }))
27 ))
28 }Additional examples can be found in:
Sourcepub fn with_spacing(spacing: impl Into<f64>, wrapped: T) -> VStack<T>
pub fn with_spacing(spacing: impl Into<f64>, wrapped: T) -> VStack<T>
Creates a new VStack from given wrapped view with the given spacing.
Examples found in repository?
examples/scale_rotate.rs (lines 26-43)
23 fn body(&self) -> Self::Body {
24 let scale = self.scale.clone();
25 let rotation = self.rotation.clone();
26 VStack::with_spacing(100, (
27 Rectangle::new()
28 .overlay(Text::new("Hello world!").foreground_style(Color::GRAY))
29 .rotation_effect(rotation.get())
30 .scale_effect(scale.get())
31 .frame(100),
32 HStack::new((
33 Button::with_text("Rotate", move || {
34 rotation.set_with(Animation::LINEAR, rotation.get() + Angle::QUARTER);
35 }),
36 Button::with_text("Scale up", clone!(scale => move || {
37 scale.set_with(Animation::LINEAR, scale.get() + 0.5);
38 })),
39 Button::with_text("Scale down", move || {
40 scale.set_with(Animation::LINEAR, scale.get() - 0.5);
41 }),
42 ))
43 ))
44 }Trait Implementations§
impl<T> StructuralPartialEq for VStack<T>
Auto Trait Implementations§
impl<T> Freeze for VStack<T>where
T: Freeze,
impl<T> RefUnwindSafe for VStack<T>where
T: RefUnwindSafe,
impl<T> Send for VStack<T>where
T: Send,
impl<T> Sync for VStack<T>where
T: Sync,
impl<T> Unpin for VStack<T>where
T: Unpin,
impl<T> UnwindSafe for VStack<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more