-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a
widgets
module and a default theme
- Loading branch information
Showing
19 changed files
with
418 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,52 @@ | ||
use floem::{ | ||
peniko::Color, | ||
reactive::create_signal, | ||
view::View, | ||
views::{checkbox, label, stack, Decorators}, | ||
views::Decorators, | ||
widgets::{checkbox, labeled_checkbox}, | ||
}; | ||
|
||
use crate::form::{form, form_item}; | ||
|
||
pub fn checkbox_view() -> impl View { | ||
let width = 160.0; | ||
let (is_checked, set_is_checked) = create_signal(true); | ||
form({ | ||
( | ||
form_item("Basic Checkbox:".to_string(), 120.0, move || { | ||
form_item("Checkbox:".to_string(), width, move || { | ||
checkbox(is_checked) | ||
.style(|s| s.focus_visible(|s| s.border(2.).border_color(Color::BLUE))) | ||
.style(|s| s.margin(5.0)) | ||
.on_click(move |_| { | ||
set_is_checked.update(|checked| *checked = !*checked); | ||
true | ||
}) | ||
}), | ||
form_item("Labelled Checkbox:".to_string(), 120.0, move || { | ||
stack({ | ||
( | ||
checkbox(is_checked) | ||
.on_click(move |_| { | ||
set_is_checked.update(|checked| *checked = !*checked); | ||
true | ||
}) | ||
.style(|s| s.focus_visible(|s| s.border(2.).border_color(Color::BLUE))), | ||
label(|| "Check me!"), | ||
) | ||
}) | ||
.on_click(move |_| { | ||
set_is_checked.update(|checked| *checked = !*checked); | ||
true | ||
}) | ||
form_item("Disabled Checkbox:".to_string(), width, move || { | ||
checkbox(is_checked) | ||
.style(|s| s.margin(5.0)) | ||
.on_click(move |_| { | ||
set_is_checked.update(|checked| *checked = !*checked); | ||
true | ||
}) | ||
.disabled(|| true) | ||
}), | ||
form_item("Disabled Checkbox:".to_string(), 120.0, move || { | ||
stack({ | ||
( | ||
checkbox(is_checked) | ||
.disabled(|| true) | ||
.style(|s| s.focus_visible(|s| s.border(2.).border_color(Color::BLUE))), | ||
label(|| "Check me!"), | ||
) | ||
}) | ||
.style(|s| s.color(Color::GRAY)) | ||
.on_click(move |_| { | ||
form_item("Labelled Checkbox:".to_string(), width, move || { | ||
labeled_checkbox(is_checked, || "Check me!").on_click(move |_| { | ||
set_is_checked.update(|checked| *checked = !*checked); | ||
true | ||
}) | ||
}), | ||
form_item( | ||
"Disabled Labelled Checkbox:".to_string(), | ||
width, | ||
move || { | ||
labeled_checkbox(is_checked, || "Check me!") | ||
.on_click(move |_| { | ||
set_is_checked.update(|checked| *checked = !*checked); | ||
true | ||
}) | ||
.disabled(|| true) | ||
}, | ||
), | ||
) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.