Checkpoint – Notifications Panel
This commit is contained in:
parent
e3d948f60b
commit
32028fbbb1
10 changed files with 318 additions and 107 deletions
|
@ -197,6 +197,31 @@ impl<S: 'static + Send + Sync> Button<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
pub struct ButtonGroup<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
buttons: Vec<Button<S>>,
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync> ButtonGroup<S> {
|
||||
pub fn new(buttons: Vec<Button<S>>) -> Self {
|
||||
Self {
|
||||
state_type: PhantomData,
|
||||
buttons,
|
||||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||
let mut el = h_stack().text_size(ui_size(cx, 1.));
|
||||
|
||||
for button in &mut self.buttons {
|
||||
el = el.child(button.render(_view, cx));
|
||||
}
|
||||
|
||||
el
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "stories")]
|
||||
pub use stories::*;
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use std::marker::PhantomData;
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::{prelude::*, v_stack, ButtonGroup};
|
||||
|
||||
#[derive(Element)]
|
||||
pub struct Details<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
text: &'static str,
|
||||
meta: Option<&'static str>,
|
||||
actions: Option<ButtonGroup<S>>,
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync> Details<S> {
|
||||
|
@ -15,6 +16,7 @@ impl<S: 'static + Send + Sync> Details<S> {
|
|||
state_type: PhantomData,
|
||||
text,
|
||||
meta: None,
|
||||
actions: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,18 +25,22 @@ impl<S: 'static + Send + Sync> Details<S> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn actions(mut self, actions: ButtonGroup<S>) -> Self {
|
||||
self.actions = Some(actions);
|
||||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||
let color = ThemeColor::new(cx);
|
||||
|
||||
div()
|
||||
// .flex()
|
||||
// .w_full()
|
||||
v_stack()
|
||||
.p_1()
|
||||
.gap_0p5()
|
||||
.text_xs()
|
||||
.text_color(color.text)
|
||||
.child(self.text)
|
||||
.children(self.meta.map(|m| m))
|
||||
.children(self.actions.take().map(|a| a))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue