ansiq_widgets/
bottom_pane.rs1use ansiq_core::{Element, Layout, Length, Style};
2
3use crate::Box;
4
5pub struct BottomPane<Message = ()> {
6 composer: Option<Element<Message>>,
7 footer: Option<Element<Message>>,
8 style: Style,
9 gap: u16,
10}
11
12impl<Message> BottomPane<Message> {
13 pub fn new() -> Self {
14 Self {
15 composer: None,
16 footer: None,
17 style: Style::default(),
18 gap: 0,
19 }
20 }
21
22 pub fn composer(mut self, composer: Element<Message>) -> Self {
23 self.composer = Some(composer);
24 self
25 }
26
27 pub fn footer(mut self, footer: Element<Message>) -> Self {
28 self.footer = Some(footer);
29 self
30 }
31
32 pub fn gap(mut self, gap: u16) -> Self {
33 self.gap = gap;
34 self
35 }
36
37 pub fn style(mut self, style: Style) -> Self {
38 self.style = style;
39 self
40 }
41
42 pub fn build(self) -> Element<Message> {
43 let mut column = Box::column()
44 .gap(self.gap)
45 .style(self.style)
46 .layout(Layout {
47 width: Length::Fill,
48 height: Length::Auto,
49 });
50
51 if let Some(composer) = self.composer {
52 column = column.child(composer);
53 }
54
55 if let Some(footer) = self.footer {
56 column = column.child(footer);
57 }
58
59 column.build()
60 }
61}