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"
libcosmic = { path = "../..", default-features = false, features = ["debug", "winit_softbuffer"] }
once_cell = "1.15"
slotmap = "1.0.6"
slotmap = "1.0.6"

View file

@ -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()
}

View file

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

View file

@ -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),
}