Skip to main content

ansiq_widgets/
streaming_text.rs

1use ansiq_core::{Element, ElementKind, Layout, Length, StreamingTextProps};
2
3pub struct StreamingText<Message = ()> {
4    element: Element<Message>,
5}
6
7impl<Message> StreamingText<Message> {
8    pub fn new(content: impl Into<String>) -> Self {
9        Self {
10            element: Element::new(ElementKind::StreamingText(StreamingTextProps {
11                content: content.into(),
12            }))
13            .with_layout(Layout {
14                width: Length::Fill,
15                height: Length::Fill,
16            }),
17        }
18    }
19
20    pub fn layout(mut self, layout: Layout) -> Self {
21        self.element.layout = layout;
22        self
23    }
24
25    pub fn build(self) -> Element<Message> {
26        self.element
27    }
28}