1use std::marker::PhantomData;
2
3use crate::prelude::*;
4use crate::{v_stack, Buffer, Icon, IconButton, Label, LabelSize};
5
6#[derive(Element)]
7pub struct MultiBuffer<S: 'static + Send + Sync + Clone> {
8 state_type: PhantomData<S>,
9 buffers: Vec<Buffer<S>>,
10}
11
12impl<S: 'static + Send + Sync + Clone> MultiBuffer<S> {
13 pub fn new(buffers: Vec<Buffer<S>>) -> Self {
14 Self {
15 state_type: PhantomData,
16 buffers,
17 }
18 }
19
20 fn render(&mut self, cx: &mut ViewContext<S>) -> impl Element<State = S> {
21 let theme = theme(cx);
22
23 v_stack()
24 .w_full()
25 .h_full()
26 .flex_1()
27 .children(self.buffers.clone().into_iter().map(|buffer| {
28 v_stack()
29 .child(
30 div()
31 .flex()
32 .items_center()
33 .justify_between()
34 .p_4()
35 .fill(theme.lowest.base.default.background)
36 .child(Label::new("main.rs").size(LabelSize::Small))
37 .child(IconButton::new(Icon::ArrowUpRight)),
38 )
39 .child(buffer)
40 }))
41 }
42}