Draft nodes for missing widgets
This commit is contained in:
parent
8834772fa7
commit
655978f480
16 changed files with 191 additions and 36 deletions
|
|
@ -1,12 +1,46 @@
|
|||
use crate::{Color, Element, Widget};
|
||||
use crate::{Bus, Color, Element, Widget};
|
||||
|
||||
use dodrio::bumpalo;
|
||||
|
||||
pub type Radio<Message> = iced::Radio<Color, Message>;
|
||||
|
||||
impl<Message> Widget<Message> for Radio<Message> {}
|
||||
impl<Message> Widget<Message> for Radio<Message>
|
||||
where
|
||||
Message: 'static + Copy,
|
||||
{
|
||||
fn node<'b>(
|
||||
&self,
|
||||
bump: &'b bumpalo::Bump,
|
||||
bus: &Bus<Message>,
|
||||
) -> dodrio::Node<'b> {
|
||||
use dodrio::builder::*;
|
||||
|
||||
let radio_label = bumpalo::format!(in bump, "{}", self.label);
|
||||
|
||||
let event_bus = bus.clone();
|
||||
let on_click = self.on_click;
|
||||
|
||||
label(bump)
|
||||
.attr("style", "display: block")
|
||||
.children(vec![
|
||||
input(bump)
|
||||
.attr("type", "radio")
|
||||
.bool_attr("checked", self.is_selected)
|
||||
.on("click", move |root, vdom, _event| {
|
||||
event_bus.publish(on_click, root);
|
||||
|
||||
vdom.schedule_render();
|
||||
})
|
||||
.finish(),
|
||||
text(radio_label.into_bump_str()),
|
||||
])
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Message> From<Radio<Message>> for Element<'a, Message>
|
||||
where
|
||||
Message: 'static,
|
||||
Message: 'static + Copy,
|
||||
{
|
||||
fn from(radio: Radio<Message>) -> Element<'a, Message> {
|
||||
Element::new(radio)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue