mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-07 20:39:04 +03:00
Add welcome crate and associated types
This commit is contained in:
parent
620890c411
commit
9401ef223d
15
Cargo.lock
generated
15
Cargo.lock
generated
@ -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",
|
||||
]
|
||||
|
||||
|
@ -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
21
crates/welcome/Cargo.toml
Normal 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" }
|
51
crates/welcome/src/welcome.rs
Normal file
51
crates/welcome/src/welcome.rs
Normal 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()
|
||||
}
|
||||
}
|
@ -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"
|
||||
|
@ -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());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user