vizia_core/views/
sidebar.rs1use crate::prelude::*;
2
3pub struct Sidebar {
10 _width: Signal<Units>,
11}
12
13impl Sidebar {
14 pub fn new<H, C, F>(cx: &mut Context, header: H, content: C, footer: F) -> Handle<Self>
16 where
17 H: 'static + Fn(&mut Context),
18 C: 'static + Fn(&mut Context),
19 F: 'static + Fn(&mut Context),
20 {
21 let _width: Signal<Units> = Signal::new(Pixels(200.0));
22 Self { _width }.build(cx, move |cx| {
23 Resizable::new(
24 cx,
25 _width,
26 ResizeStackDirection::Right,
27 move |_cx, new_size| _width.set(Pixels(new_size)),
28 move |cx| {
29 VStack::new(cx, |cx| {
30 (header)(cx);
31 })
32 .class("sidebar-header")
33 .height(Auto);
34
35 Divider::new(cx).class("sidebar-divider");
36 ScrollView::new(cx, move |cx| {
37 (content)(cx);
38 })
39 .class("sidebar-content")
40 .height(Stretch(1.0));
41
42 Divider::new(cx).class("sidebar-divider");
43
44 VStack::new(cx, |cx| {
45 (footer)(cx);
46 })
47 .class("sidebar-footer")
48 .height(Auto);
49 },
50 );
51 })
52 }
53}
54
55impl View for Sidebar {
56 fn element(&self) -> Option<&'static str> {
57 Some("sidebar")
58 }
59}