Add MultiBuffer
component
This commit is contained in:
parent
ac93449788
commit
06b0707aa9
5 changed files with 81 additions and 0 deletions
42
crates/ui2/src/components/multi_buffer.rs
Normal file
42
crates/ui2/src/components/multi_buffer.rs
Normal file
|
@ -0,0 +1,42 @@
|
|||
use std::marker::PhantomData;
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::{v_stack, Buffer, Icon, IconButton, Label, LabelSize};
|
||||
|
||||
#[derive(Element)]
|
||||
pub struct MultiBuffer<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
buffers: Vec<Buffer<S>>,
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync + Clone> MultiBuffer<S> {
|
||||
pub fn new(buffers: Vec<Buffer<S>>) -> Self {
|
||||
Self {
|
||||
state_type: PhantomData,
|
||||
buffers,
|
||||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<S>) -> impl Element<State = S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
.w_full()
|
||||
.h_full()
|
||||
.flex_1()
|
||||
.children(self.buffers.clone().into_iter().map(|buffer| {
|
||||
v_stack()
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
.justify_between()
|
||||
.p_4()
|
||||
.fill(theme.lowest.base.default.background)
|
||||
.child(Label::new("main.rs").size(LabelSize::Small))
|
||||
.child(IconButton::new(Icon::ArrowUpRight)),
|
||||
)
|
||||
.child(buffer)
|
||||
}))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue