Add welcome crate and associated types

This commit is contained in:
Mikayla Maki 2023-02-21 18:16:47 -08:00
parent 620890c411
commit 9401ef223d
6 changed files with 90 additions and 0 deletions

15
Cargo.lock generated
View File

@ -8013,6 +8013,20 @@ version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
[[package]]
name = "welcome"
version = "0.1.0"
dependencies = [
"anyhow",
"gpui",
"log",
"project",
"settings",
"theme",
"util",
"workspace",
]
[[package]]
name = "wepoll-ffi"
version = "0.1.2"
@ -8459,6 +8473,7 @@ dependencies = [
"util",
"uuid 1.2.2",
"vim",
"welcome",
"workspace",
]

View File

@ -58,6 +58,7 @@ members = [
"crates/util",
"crates/vim",
"crates/workspace",
"crates/welcome",
"crates/zed",
]
default-members = ["crates/zed"]

21
crates/welcome/Cargo.toml Normal file
View File

@ -0,0 +1,21 @@
[package]
name = "welcome"
version = "0.1.0"
edition = "2021"
publish = false
[lib]
path = "src/welcome.rs"
[features]
test-support = []
[dependencies]
anyhow = "1.0.38"
log = "0.4"
gpui = { path = "../gpui" }
project = { path = "../project" }
settings = { path = "../settings" }
theme = { path = "../theme" }
util = { path = "../util" }
workspace = { path = "../workspace" }

View File

@ -0,0 +1,51 @@
use gpui::{
actions,
elements::{Flex, Label, ParentElement},
Element, Entity, MutableAppContext, View,
};
use settings::Settings;
use workspace::{item::Item, Workspace};
actions!(welcome, [ShowWelcome]);
pub fn init(cx: &mut MutableAppContext) {
cx.add_action(|workspace: &mut Workspace, _: &ShowWelcome, cx| {
let welcome_page = cx.add_view(|_cx| WelcomePage);
workspace.add_item(Box::new(welcome_page), cx)
})
}
struct WelcomePage;
impl Entity for WelcomePage {
type Event = ();
}
impl View for WelcomePage {
fn ui_name() -> &'static str {
"WelcomePage"
}
fn render(&mut self, cx: &mut gpui::RenderContext<'_, Self>) -> gpui::ElementBox {
let theme = &cx.global::<Settings>().theme;
Label::new("Welcome page", theme.editor.hover_popover.prose.clone()).boxed()
}
}
impl Item for WelcomePage {
fn tab_content(
&self,
_detail: Option<usize>,
style: &theme::Tab,
_cx: &gpui::AppContext,
) -> gpui::ElementBox {
Flex::row()
.with_child(
Label::new("Welcome to Zed!", style.label.clone())
.aligned()
.contained()
.boxed(),
)
.boxed()
}
}

View File

@ -58,6 +58,7 @@ theme_testbench = { path = "../theme_testbench" }
util = { path = "../util" }
vim = { path = "../vim" }
workspace = { path = "../workspace" }
welcome = { path = "../welcome" }
anyhow = "1.0.38"
async-compression = { version = "0.3", features = ["gzip", "futures-bufread"] }
async-tar = "0.4.2"

View File

@ -189,6 +189,7 @@ fn main() {
zed::init(&app_state, cx);
collab_ui::init(app_state.clone(), cx);
feedback::init(app_state.clone(), cx);
welcome::init(cx);
cx.set_menus(menus::menus());