summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/material_theme/src/lib.rs1
-rw-r--r--crates/material_theme/src/rule.rs33
-rw-r--r--theme_test/src/main.rs15
3 files changed, 47 insertions, 2 deletions
diff --git a/crates/material_theme/src/lib.rs b/crates/material_theme/src/lib.rs
index 03f1ca5..2452d88 100644
--- a/crates/material_theme/src/lib.rs
+++ b/crates/material_theme/src/lib.rs
@@ -17,6 +17,7 @@ pub mod progress_bar;
#[cfg(feature = "qr_code")]
pub mod qr_code;
pub mod radio;
+pub mod rule;
pub mod scrollable;
pub mod slider;
#[cfg(feature = "svg")]
diff --git a/crates/material_theme/src/rule.rs b/crates/material_theme/src/rule.rs
new file mode 100644
index 0000000..e433005
--- /dev/null
+++ b/crates/material_theme/src/rule.rs
@@ -0,0 +1,33 @@
+use iced_widget::core::border::Radius;
+use iced_widget::rule::{Catalog, FillMode, Style, StyleFn};
+
+use super::Theme;
+
+impl Catalog for Theme {
+ type Class<'a> = StyleFn<'a, Self>;
+
+ fn default<'a>() -> Self::Class<'a> {
+ Box::new(inset)
+ }
+
+ fn style(&self, class: &Self::Class<'_>) -> Style {
+ class(self)
+ }
+}
+
+pub fn inset(theme: &Theme) -> Style {
+ Style {
+ color: theme.colorscheme.outline.variant,
+ fill_mode: FillMode::Padded(8),
+ width: 1,
+ radius: Radius::default(),
+ }
+}
+pub fn full_width(theme: &Theme) -> Style {
+ Style {
+ color: theme.colorscheme.outline.variant,
+ fill_mode: FillMode::Full,
+ width: 1,
+ radius: Radius::default(),
+ }
+}
diff --git a/theme_test/src/main.rs b/theme_test/src/main.rs
index c13bde7..7192785 100644
--- a/theme_test/src/main.rs
+++ b/theme_test/src/main.rs
@@ -1,7 +1,7 @@
use iced::Length::Fill;
use iced::widget::{
- button, center, checkbox, column, container, pick_list, radio, row, slider,
- text_input,
+ button, center, checkbox, column, container, horizontal_rule, pick_list,
+ radio, row, slider, text_input,
};
use iced::{Element, Length};
use iced_anim::{Animated, Animation, Event};
@@ -132,24 +132,35 @@ impl State {
]
.spacing(10),
column![
+ // Pick List
pick_list(
[LIGHT.clone(), DARK.clone()],
Some(self.theme.target()),
|theme| Message::SwitchTheme(theme.into())
)
.placeholder("Select a theme..."),
+ horizontal_rule(1),
+ // Button
button("Open Dialog").on_press(Message::OpenDialog),
+ horizontal_rule(1),
+ // Text Input
text_input("Type something here...", &self.content)
.on_input(Message::Input),
+ horizontal_rule(1),
+ // Checkbox
checkbox("Normal", self.is_checked)
.on_toggle(Message::CheckBox),
checkbox("Error", self.is_checked)
.on_toggle(Message::CheckBox)
.style(material_theme::checkbox::error),
checkbox("Disabled", self.is_checked),
+ horizontal_rule(1),
+ // Radio
radio("A", Choice::A, self.selection, Message::Radio,),
radio("B", Choice::B, self.selection, Message::Radio,),
radio("C", Choice::C, self.selection, Message::Radio,),
+ horizontal_rule(1),
+ // Slider
center(iced::widget::text!("{:.1}", self.value))
.width(Length::Fill)
.height(Length::Shrink),