summaryrefslogtreecommitdiffstats
path: root/widget
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2025-02-09 05:59:32 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2025-02-09 05:59:32 +0100
commit65bf503963bb58186ba7a60f6b6010e8a3b41ae7 (patch)
tree0232a4493a71990e78480ebef869191a41c51ce6 /widget
parent940a079d83f904bef0eb9514fce50cd0109219c9 (diff)
downloadiced-65bf503963bb58186ba7a60f6b6010e8a3b41ae7.tar.gz
iced-65bf503963bb58186ba7a60f6b6010e8a3b41ae7.tar.bz2
iced-65bf503963bb58186ba7a60f6b6010e8a3b41ae7.zip
Introduce additional color styles for `container`
Diffstat (limited to 'widget')
-rw-r--r--widget/src/container.rs40
1 files changed, 38 insertions, 2 deletions
diff --git a/widget/src/container.rs b/widget/src/container.rs
index 82dc3141..86c1c7a8 100644
--- a/widget/src/container.rs
+++ b/widget/src/container.rs
@@ -26,6 +26,7 @@ use crate::core::layout;
use crate::core::mouse;
use crate::core::overlay;
use crate::core::renderer;
+use crate::core::theme;
use crate::core::widget::tree::{self, Tree};
use crate::core::widget::{self, Operation};
use crate::core::{
@@ -714,9 +715,44 @@ pub fn bordered_box(theme: &Theme) -> Style {
/// A [`Container`] with a dark background and white text.
pub fn dark(_theme: &Theme) -> Style {
+ style(theme::palette::Pair {
+ color: color!(0x111111),
+ text: Color::WHITE,
+ })
+}
+
+/// A [`Container`] with a primary background color.
+pub fn primary(theme: &Theme) -> Style {
+ let palette = theme.extended_palette();
+
+ style(palette.primary.base)
+}
+
+/// A [`Container`] with a secondary background color.
+pub fn secondary(theme: &Theme) -> Style {
+ let palette = theme.extended_palette();
+
+ style(palette.secondary.base)
+}
+
+/// A [`Container`] with a success background color.
+pub fn success(theme: &Theme) -> Style {
+ let palette = theme.extended_palette();
+
+ style(palette.success.base)
+}
+
+/// A [`Container`] with a danger background color.
+pub fn danger(theme: &Theme) -> Style {
+ let palette = theme.extended_palette();
+
+ style(palette.danger.base)
+}
+
+fn style(pair: theme::palette::Pair) -> Style {
Style {
- background: Some(color!(0x111111).into()),
- text_color: Some(Color::WHITE),
+ background: Some(pair.color.into()),
+ text_color: Some(pair.text),
border: border::rounded(2),
..Style::default()
}