feat(theme): export cosmic-theme & add CosmicContainers to example

This commit is contained in:
Ashley Wulber 2023-02-27 19:23:02 -05:00 committed by Jeremy Soller
parent cbb21932d8
commit 13aa5f88cb
4 changed files with 30 additions and 8 deletions

View file

@ -10,4 +10,4 @@ apply = "0.3.0"
fraction = "0.13.0" fraction = "0.13.0"
libcosmic = { path = "../..", default-features = false, features = ["debug", "winit_softbuffer"] } libcosmic = { path = "../..", default-features = false, features = ["debug", "winit_softbuffer"] }
once_cell = "1.15" once_cell = "1.15"
slotmap = "1.0.6" slotmap = "1.0.6"

View file

@ -1,11 +1,12 @@
use apply::Apply; use apply::Apply;
use cosmic::{ use cosmic::{
cosmic_theme,
iced::widget::{checkbox, pick_list, progress_bar, radio, row, slider, text}, iced::widget::{checkbox, pick_list, progress_bar, radio, row, slider, text},
iced::{widget::container, Alignment, Length}, iced::{widget::container, Alignment, Length},
theme::{self, Button as ButtonTheme, Theme}, theme::{self, Button as ButtonTheme, Theme},
widget::{ widget::{
button, icon, segmented_button, segmented_selection, settings, spin_button, toggler, button, cosmic_container, icon, segmented_button, segmented_selection, settings,
view_switcher, spin_button, toggler, view_switcher,
}, },
Element, Element,
}; };
@ -375,6 +376,27 @@ impl State {
.into() .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() .into()
} }

View file

@ -3,6 +3,7 @@
#![allow(clippy::module_name_repetitions)] #![allow(clippy::module_name_repetitions)]
pub use cosmic_theme;
pub use iced; pub use iced;
pub use iced_lazy; pub use iced_lazy;
pub use iced_native; pub use iced_native;

View file

@ -199,7 +199,6 @@ impl button::StyleSheet for Theme {
_ => Some(Background::Color(component.base.into())), _ => Some(Background::Color(component.base.into())),
}, },
text_color: match style { text_color: match style {
Button::Link => component.base.into(),
Button::LinkActive => component.selected_text.into(), Button::LinkActive => component.selected_text.into(),
_ => component.on.into(), _ => component.on.into(),
}, },
@ -477,7 +476,7 @@ impl container::StyleSheet for Theme {
let palette = self.cosmic(); let palette = self.cosmic();
container::Appearance { container::Appearance {
text_color: None, text_color: Some(Color::from(palette.background.on)),
background: Some(iced::Background::Color(palette.background.base.into())), background: Some(iced::Background::Color(palette.background.base.into())),
border_radius: 2.0, border_radius: 2.0,
border_width: 0.0, border_width: 0.0,
@ -488,7 +487,7 @@ impl container::StyleSheet for Theme {
let palette = self.cosmic(); let palette = self.cosmic();
container::Appearance { container::Appearance {
text_color: None, text_color: Some(Color::from(palette.primary.on)),
background: Some(iced::Background::Color(palette.primary.base.into())), background: Some(iced::Background::Color(palette.primary.base.into())),
border_radius: 2.0, border_radius: 2.0,
border_width: 0.0, border_width: 0.0,
@ -499,7 +498,7 @@ impl container::StyleSheet for Theme {
let palette = self.cosmic(); let palette = self.cosmic();
container::Appearance { container::Appearance {
text_color: None, text_color: Some(Color::from(palette.secondary.on)),
background: Some(iced::Background::Color(palette.secondary.base.into())), background: Some(iced::Background::Color(palette.secondary.base.into())),
border_radius: 2.0, border_radius: 2.0,
border_width: 0.0, border_width: 0.0,
@ -949,7 +948,7 @@ impl text::StyleSheet for Theme {
Text::Accent => text::Appearance { Text::Accent => text::Appearance {
color: Some(self.cosmic().accent.base.into()), 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::Color(c) => text::Appearance { color: Some(c) },
Text::Custom(f) => f(self), Text::Custom(f) => f(self),
} }