Add support for switching between the two hardcoded themes
This commit is contained in:
parent
8b3a357949
commit
613973d2b1
1 changed files with 14 additions and 5 deletions
|
@ -21,7 +21,6 @@ use ui::themed;
|
||||||
|
|
||||||
use crate::assets::Assets;
|
use crate::assets::Assets;
|
||||||
use crate::story_selector::StorySelector;
|
use crate::story_selector::StorySelector;
|
||||||
use crate::themes::rose_pine_dawn;
|
|
||||||
use crate::workspace::workspace;
|
use crate::workspace::workspace;
|
||||||
|
|
||||||
// gpui2::actions! {
|
// gpui2::actions! {
|
||||||
|
@ -51,6 +50,15 @@ fn main() {
|
||||||
|
|
||||||
let story_selector = args.story.clone();
|
let story_selector = args.story.clone();
|
||||||
|
|
||||||
|
let theme = match args.theme.as_ref().map(|theme| theme.as_str()) {
|
||||||
|
Some("Rosé Pine") => themes::rose_pine(),
|
||||||
|
Some("Rosé Pine Dawn") => themes::rose_pine_dawn(),
|
||||||
|
Some(theme_name) => {
|
||||||
|
panic!("Only 'Rosé Pine' and 'Rosé Pine Dawn' are currently supported.")
|
||||||
|
}
|
||||||
|
None => themes::rose_pine_dawn(),
|
||||||
|
};
|
||||||
|
|
||||||
let asset_source = Arc::new(Assets);
|
let asset_source = Arc::new(Assets);
|
||||||
gpui3::App::production(asset_source).run(move |cx| {
|
gpui3::App::production(asset_source).run(move |cx| {
|
||||||
match story_selector {
|
match story_selector {
|
||||||
|
@ -65,7 +73,7 @@ fn main() {
|
||||||
},
|
},
|
||||||
move |cx| {
|
move |cx| {
|
||||||
view(
|
view(
|
||||||
cx.entity(|cx| StoryWrapper::new(selector)),
|
cx.entity(|cx| StoryWrapper::new(selector, theme)),
|
||||||
StoryWrapper::render,
|
StoryWrapper::render,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -92,15 +100,16 @@ fn main() {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct StoryWrapper {
|
pub struct StoryWrapper {
|
||||||
selector: StorySelector,
|
selector: StorySelector,
|
||||||
|
theme: Theme,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StoryWrapper {
|
impl StoryWrapper {
|
||||||
pub(crate) fn new(selector: StorySelector) -> Self {
|
pub(crate) fn new(selector: StorySelector, theme: Theme) -> Self {
|
||||||
Self { selector }
|
Self { selector, theme }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<State = Self> {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<State = Self> {
|
||||||
themed(rose_pine_dawn(), cx, |cx| {
|
themed(self.theme.clone(), cx, |cx| {
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue