mitsuami_widgets/
toggles.rs1use mitsuami_core::{Element, ElementBuilder, EventValue, NodeId, Prop, Tweak, Ui, UiEvent, View, WidgetKind};
4use mitsuami_reactive::{IntoValue, Signal};
5
6pub struct Checkbox(Element);
7widget!(Checkbox);
8toggle!(Checkbox);
9
10impl Checkbox {
11 pub fn new(label: impl IntoValue<String>) -> Checkbox {
12 let mut element = Element::new(WidgetKind::Checkbox);
13 element.prop(label.into_value(), Prop::Label);
14 Checkbox(element)
15 }
16
17 pub fn mixed(mut self, mixed: impl IntoValue<bool>) -> Checkbox {
23 self.0.prop(mixed.into_value(), Prop::Mixed);
24 self
25 }
26
27 pub fn native(mut self, tweak: Tweak<Checkbox>) -> Checkbox {
29 tweak.apply(&mut self.0);
30 self
31 }
32}
33
34pub struct Switch(Element);
37widget!(Switch);
38toggle!(Switch);
39
40impl Switch {
41 pub fn new(label: impl IntoValue<String>) -> Switch {
42 let mut element = Element::new(WidgetKind::Switch);
43 element.prop(label.into_value(), Prop::Label);
44 Switch(element)
45 }
46
47 pub fn native(mut self, tweak: Tweak<Switch>) -> Switch {
51 tweak.apply(&mut self.0);
52 self
53 }
54}
55
56text_tag!(Checkbox, Label);
57text_tag!(Switch, Label);