WIP
This commit is contained in:
parent
9401ef223d
commit
a0637a769c
3 changed files with 33 additions and 12 deletions
|
@ -1,15 +1,13 @@
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions,
|
color::Color,
|
||||||
elements::{Flex, Label, ParentElement},
|
elements::{Flex, Label, ParentElement, Svg},
|
||||||
Element, Entity, MutableAppContext, View,
|
Element, Entity, MutableAppContext, View,
|
||||||
};
|
};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use workspace::{item::Item, Workspace};
|
use workspace::{item::Item, Welcome, Workspace};
|
||||||
|
|
||||||
actions!(welcome, [ShowWelcome]);
|
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut MutableAppContext) {
|
||||||
cx.add_action(|workspace: &mut Workspace, _: &ShowWelcome, cx| {
|
cx.add_action(|workspace: &mut Workspace, _: &Welcome, cx| {
|
||||||
let welcome_page = cx.add_view(|_cx| WelcomePage);
|
let welcome_page = cx.add_view(|_cx| WelcomePage);
|
||||||
workspace.add_item(Box::new(welcome_page), cx)
|
workspace.add_item(Box::new(welcome_page), cx)
|
||||||
})
|
})
|
||||||
|
@ -28,7 +26,29 @@ impl View for WelcomePage {
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut gpui::RenderContext<'_, Self>) -> gpui::ElementBox {
|
fn render(&mut self, cx: &mut gpui::RenderContext<'_, Self>) -> gpui::ElementBox {
|
||||||
let theme = &cx.global::<Settings>().theme;
|
let theme = &cx.global::<Settings>().theme;
|
||||||
Label::new("Welcome page", theme.editor.hover_popover.prose.clone()).boxed()
|
|
||||||
|
Flex::new(gpui::Axis::Vertical)
|
||||||
|
.with_children([
|
||||||
|
Flex::new(gpui::Axis::Horizontal)
|
||||||
|
.with_children([
|
||||||
|
Svg::new("icons/terminal_16.svg")
|
||||||
|
.with_color(Color::red())
|
||||||
|
.constrained()
|
||||||
|
.with_width(100.)
|
||||||
|
.with_height(100.)
|
||||||
|
.aligned()
|
||||||
|
.contained()
|
||||||
|
.boxed(),
|
||||||
|
Label::new("Zed", theme.editor.hover_popover.prose.clone()).boxed(),
|
||||||
|
])
|
||||||
|
.boxed(),
|
||||||
|
Label::new(
|
||||||
|
"Code at the speed of thought",
|
||||||
|
theme.editor.hover_popover.prose.clone(),
|
||||||
|
)
|
||||||
|
.boxed(),
|
||||||
|
])
|
||||||
|
.boxed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,8 @@ actions!(
|
||||||
NewTerminal,
|
NewTerminal,
|
||||||
NewSearch,
|
NewSearch,
|
||||||
Feedback,
|
Feedback,
|
||||||
Restart
|
Restart,
|
||||||
|
Welcome
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -198,7 +199,7 @@ pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
||||||
});
|
});
|
||||||
cx.add_global_action({
|
cx.add_global_action({
|
||||||
let app_state = Arc::downgrade(&app_state);
|
let app_state = Arc::downgrade(&app_state);
|
||||||
move |_: &NewFile, cx: &mut MutableAppContext| {
|
move |_: &Welcome, cx: &mut MutableAppContext| {
|
||||||
if let Some(app_state) = app_state.upgrade() {
|
if let Some(app_state) = app_state.upgrade() {
|
||||||
open_new(&app_state, cx).detach();
|
open_new(&app_state, cx).detach();
|
||||||
}
|
}
|
||||||
|
@ -2865,7 +2866,7 @@ pub fn open_new(app_state: &Arc<AppState>, cx: &mut MutableAppContext) -> Task<(
|
||||||
|
|
||||||
workspace.update(&mut cx, |_, cx| {
|
workspace.update(&mut cx, |_, cx| {
|
||||||
if opened_paths.is_empty() {
|
if opened_paths.is_empty() {
|
||||||
cx.dispatch_action(NewFile);
|
cx.dispatch_action(Welcome);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -43,7 +43,7 @@ use theme::ThemeRegistry;
|
||||||
use util::StaffMode;
|
use util::StaffMode;
|
||||||
use util::{channel::RELEASE_CHANNEL, paths, ResultExt, TryFutureExt};
|
use util::{channel::RELEASE_CHANNEL, paths, ResultExt, TryFutureExt};
|
||||||
use workspace::{
|
use workspace::{
|
||||||
self, item::ItemHandle, notifications::NotifyResultExt, AppState, NewFile, OpenPaths, Workspace,
|
self, item::ItemHandle, notifications::NotifyResultExt, AppState, OpenPaths, Welcome, Workspace,
|
||||||
};
|
};
|
||||||
use zed::{self, build_window_options, initialize_workspace, languages, menus};
|
use zed::{self, build_window_options, initialize_workspace, languages, menus};
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ async fn restore_or_create_workspace(mut cx: AsyncAppContext) {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
cx.dispatch_global_action(NewFile);
|
cx.dispatch_global_action(Welcome);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue