Restructure Theme with new style objects

This commit is contained in:
Max Brunsfeld
2021-08-03 13:36:58 -07:00
parent ef0ffbe819
commit 81041d7841
10 changed files with 218 additions and 169 deletions
+13 -26
View File
@@ -9,15 +9,12 @@ use crate::{
};
use futures::lock::Mutex;
use gpui::{
color::Color,
elements::{
Align, ChildView, ConstrainedBox, Container, Expanded, Flex, Label, LabelStyle,
ParentElement, UniformList, UniformListState,
Align, ChildView, ConstrainedBox, Container, Expanded, Flex, Label, ParentElement,
UniformList, UniformListState,
},
fonts::{Properties, Weight},
geometry::vector::vec2f,
keymap::{self, Binding},
AppContext, Axis, Border, Element, ElementBox, Entity, MutableAppContext, RenderContext, View,
AppContext, Axis, Element, ElementBox, Entity, MutableAppContext, RenderContext, View,
ViewContext, ViewHandle,
};
use postage::watch;
@@ -199,7 +196,7 @@ impl ThemeSelector {
settings.ui_font_family,
settings.ui_font_size,
)
.with_default_color(settings.theme.editor.default_text)
.with_default_color(settings.theme.editor.text)
.boxed(),
)
.with_margin_top(6.0)
@@ -234,32 +231,26 @@ impl ThemeSelector {
let settings = self.settings.borrow();
let theme = &settings.theme.ui;
let mut container = Container::new(
let container = Container::new(
Label::new(
theme_match.string.clone(),
settings.ui_font_family,
settings.ui_font_size,
)
.with_style(&LabelStyle {
color: theme.modal_match_text,
highlight_color: Some(theme.modal_match_text_highlight),
highlight_font_properties: Some(*Properties::new().weight(Weight::BOLD)),
..Default::default()
.with_style(if index == self.selected_index {
&theme.selector.active_item.label
} else {
&theme.selector.item.label
})
.with_highlights(theme_match.positions.clone())
.boxed(),
)
.with_uniform_padding(6.0)
.with_background_color(if index == self.selected_index {
theme.modal_match_background_active
.with_style(if index == self.selected_index {
&theme.selector.active_item.container
} else {
theme.modal_match_background
&theme.selector.item.container
});
if index == self.selected_index || index < self.matches.len() - 1 {
container = container.with_border(Border::bottom(1.0, theme.modal_match_border));
}
container.boxed()
}
}
@@ -284,11 +275,7 @@ impl View for ThemeSelector {
.with_child(Expanded::new(1.0, self.render_matches(cx)).boxed())
.boxed(),
)
.with_margin_top(12.0)
.with_uniform_padding(6.0)
.with_corner_radius(6.0)
.with_background_color(settings.theme.ui.modal_background)
.with_shadow(vec2f(0., 4.), 12., Color::new(0, 0, 0, 128))
.with_style(&settings.theme.ui.selector.container)
.boxed(),
)
.with_max_width(600.0)