From 13aa5f88cb8bc17065ba8b008ad403715bc5fe03 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 27 Feb 2023 19:23:02 -0500 Subject: [PATCH] feat(theme): export cosmic-theme & add CosmicContainers to example --- examples/cosmic/Cargo.toml | 2 +- examples/cosmic/src/window/demo.rs | 26 ++++++++++++++++++++++++-- src/lib.rs | 1 + src/theme/mod.rs | 9 ++++----- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/examples/cosmic/Cargo.toml b/examples/cosmic/Cargo.toml index 5d7ec79..db0cb60 100644 --- a/examples/cosmic/Cargo.toml +++ b/examples/cosmic/Cargo.toml @@ -10,4 +10,4 @@ apply = "0.3.0" fraction = "0.13.0" libcosmic = { path = "../..", default-features = false, features = ["debug", "winit_softbuffer"] } once_cell = "1.15" -slotmap = "1.0.6" +slotmap = "1.0.6" \ No newline at end of file diff --git a/examples/cosmic/src/window/demo.rs b/examples/cosmic/src/window/demo.rs index 1c6fe54..2f8f6f0 100644 --- a/examples/cosmic/src/window/demo.rs +++ b/examples/cosmic/src/window/demo.rs @@ -1,11 +1,12 @@ use apply::Apply; use cosmic::{ + cosmic_theme, iced::widget::{checkbox, pick_list, progress_bar, radio, row, slider, text}, iced::{widget::container, Alignment, Length}, theme::{self, Button as ButtonTheme, Theme}, widget::{ - button, icon, segmented_button, segmented_selection, settings, spin_button, toggler, - view_switcher, + button, cosmic_container, icon, segmented_button, segmented_selection, settings, + spin_button, toggler, view_switcher, }, Element, }; @@ -375,6 +376,27 @@ impl State { .into() } }, + cosmic_container( + text("Background container with some text").size(24), + cosmic_theme::Layer::Background, + ) + .padding(8) + .width(Length::Fill) + .into(), + cosmic_container( + text("Primary container with some text").size(24), + cosmic_theme::Layer::Primary, + ) + .padding(8) + .width(Length::Fill) + .into(), + cosmic_container( + text("Secondary container with some text").size(24), + cosmic_theme::Layer::Secondary, + ) + .padding(8) + .width(Length::Fill) + .into(), ]) .into() } diff --git a/src/lib.rs b/src/lib.rs index aa49e9d..db47026 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ #![allow(clippy::module_name_repetitions)] +pub use cosmic_theme; pub use iced; pub use iced_lazy; pub use iced_native; diff --git a/src/theme/mod.rs b/src/theme/mod.rs index c596c4e..b3433a2 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -199,7 +199,6 @@ impl button::StyleSheet for Theme { _ => Some(Background::Color(component.base.into())), }, text_color: match style { - Button::Link => component.base.into(), Button::LinkActive => component.selected_text.into(), _ => component.on.into(), }, @@ -477,7 +476,7 @@ impl container::StyleSheet for Theme { let palette = self.cosmic(); container::Appearance { - text_color: None, + text_color: Some(Color::from(palette.background.on)), background: Some(iced::Background::Color(palette.background.base.into())), border_radius: 2.0, border_width: 0.0, @@ -488,7 +487,7 @@ impl container::StyleSheet for Theme { let palette = self.cosmic(); container::Appearance { - text_color: None, + text_color: Some(Color::from(palette.primary.on)), background: Some(iced::Background::Color(palette.primary.base.into())), border_radius: 2.0, border_width: 0.0, @@ -499,7 +498,7 @@ impl container::StyleSheet for Theme { let palette = self.cosmic(); container::Appearance { - text_color: None, + text_color: Some(Color::from(palette.secondary.on)), background: Some(iced::Background::Color(palette.secondary.base.into())), border_radius: 2.0, border_width: 0.0, @@ -949,7 +948,7 @@ impl text::StyleSheet for Theme { Text::Accent => text::Appearance { color: Some(self.cosmic().accent.base.into()), }, - Text::Default => text::Appearance::default(), + Text::Default => text::Appearance { color: None }, Text::Color(c) => text::Appearance { color: Some(c) }, Text::Custom(f) => f(self), }