forge
Explore
Log in

Don't you dare go Hollow

Use the gpui-kit facade in the client

Browse files at this commit

5973cb1849f20d81eb588536ebb03a28e7c8b2a0Ahmet Kaan GümüşParent: 3c965a4
  • chore
    • use the gpui-kit facade in the client
Show full message
⬆️ chore(deps): use the gpui-kit facade in the client

gpui-kit 0.6.6 re-exports gpui (0.3.6), gpui-base, gpui-component and the
platform backend, so the client lists one dependency instead of four and the
wayland/x11 features come from the kit rather than a separate gpui-platform
entry. Imports move to gpui_kit and gpui_kit::component. init() must be the
kit's: gpui_base::init registers the base theme only, so Root panicked with
"no state of type gpui_component::theme::Theme exists".
crates/client/Cargo.tomlmodified+1 -3
@@ -8,6 +8,4 @@ common = { workspace = true, features = ["client"] }
8 tokio.workspace = true8 tokio.workspace = true
9 quinn = { workspace = true, features = ["rustls-ring", "platform-verifier"] }9 quinn = { workspace = true, features = ["rustls-ring", "platform-verifier"] }
10 10
11-gpui = { package = "gpui-pre", version = "0.3.6" }11+gpui-kit = "0.6.6"
12-gpui-platform = { package = "gpui-pre-platform", version = "0.3.6", features = ["x11", "wayland"]}
13-gpui-component = "0.6.6"
crates/client/src/event.rsmodified+1 -1
@@ -1,6 +1,6 @@
1 use std::time::Duration;1 use std::time::Duration;
2 2
3-use gpui::{Context, Window};3+use gpui_kit::{Context, Window};
4 4
5 use crate::gui::Yumush;5 use crate::gui::Yumush;
6 6
crates/client/src/gui.rsmodified+12 -18
@@ -1,6 +1,9 @@
1 use common::user::User;1 use common::user::User;
2-use gpui::{IntoElement, ParentElement, Render, Styled, div, rgb};2+use gpui_kit::{
3-use gpui_component::{ActiveTheme, Root, WindowExt, button::Button, notification::Notification};3+ Context, IntoElement, ParentElement, Render, Styled, Window,
4+ component::{ActiveTheme, Root, WindowExt, button::Button, notification::Notification},
5+ div, rgb,
6+};
4 use tokio::sync::mpsc;7 use tokio::sync::mpsc;
5 8
6 use crate::{9 use crate::{
@@ -32,8 +35,8 @@ impl Yumush {
32 pub fn new(35 pub fn new(
33 network: NetworkHandle,36 network: NetworkHandle,
34 mut network_event_receiver: mpsc::Receiver<NetworkEvent>,37 mut network_event_receiver: mpsc::Receiver<NetworkEvent>,
35- window: &mut gpui::Window,38+ window: &mut Window,
36- cx: &mut gpui::Context<Self>,39+ cx: &mut Context<Self>,
37 ) -> Self {40 ) -> Self {
38 cx.spawn_in(window, async move |this, cx| {41 cx.spawn_in(window, async move |this, cx| {
39 while let Some(event) = network_event_receiver.recv().await {42 while let Some(event) = network_event_receiver.recv().await {
@@ -83,7 +86,7 @@ impl Yumush {
83 self.user.as_ref().map(|user| user.get_username())86 self.user.as_ref().map(|user| user.get_username())
84 }87 }
85 88
86- fn logout(&mut self, window: &mut gpui::Window, cx: &mut gpui::Context<Self>) {89+ fn logout(&mut self, window: &mut Window, cx: &mut Context<Self>) {
87 let Some(user) = self.get_user() else {90 let Some(user) = self.get_user() else {
88 return;91 return;
89 };92 };
@@ -103,12 +106,7 @@ impl Yumush {
103 .detach();106 .detach();
104 }107 }
105 108
106- fn change_page(109+ fn change_page(&mut self, new_route: Route, window: &mut Window, cx: &mut Context<Self>) {
107- &mut self,
108- new_route: Route,
109- window: &mut gpui::Window,
110- cx: &mut gpui::Context<Self>,
111- ) {
112 self.current_route = new_route;110 self.current_route = new_route;
113 cx.notify();111 cx.notify();
114 112
@@ -122,8 +120,8 @@ impl Yumush {
122 fn handle_network_event(120 fn handle_network_event(
123 &mut self,121 &mut self,
124 event: NetworkEvent,122 event: NetworkEvent,
125- window: &mut gpui::Window,123+ window: &mut Window,
126- cx: &mut gpui::Context<Self>,124+ cx: &mut Context<Self>,
127 ) {125 ) {
128 match event {126 match event {
129 NetworkEvent::Connected(user) => {127 NetworkEvent::Connected(user) => {
@@ -148,11 +146,7 @@ impl Yumush {
148 }146 }
149 147
150 impl Render for Yumush {148 impl Render for Yumush {
151- fn render(149+ fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
152- &mut self,
153- window: &mut gpui::Window,
154- cx: &mut gpui::Context<Self>,
155- ) -> impl gpui::IntoElement {
156 div()150 div()
157 .size_full()151 .size_full()
158 .relative()152 .relative()
crates/client/src/gui/chat.rsmodified+9 -8
@@ -5,15 +5,16 @@ use common::{
5 user::User,5 user::User,
6 validate::{validate_community_name, validate_message_body},6 validate::{validate_community_name, validate_message_body},
7 };7 };
8-use gpui::{8+use gpui_kit::{
9 AppContext, Context, Entity, FontWeight, InteractiveElement, IntoElement, ParentElement,9 AppContext, Context, Entity, FontWeight, InteractiveElement, IntoElement, ParentElement,
10- StatefulInteractiveElement, Styled, Window, div, rgb,10+ StatefulInteractiveElement, Styled, Window,
11-};11+ component::{
12-use gpui_component::{12+ WindowExt,
13- WindowExt,13+ button::Button,
14- button::Button,14+ input::{Input, InputEvent, InputState},
15- input::{Input, InputEvent, InputState},15+ notification::Notification,
16- notification::Notification,16+ },
17+ div, rgb,
17 };18 };
18 19
19 use crate::gui::Yumush;20 use crate::gui::Yumush;
crates/client/src/gui/login.rsmodified+9 -6
@@ -1,9 +1,12 @@
1-use gpui::{AppContext, Context, Entity, IntoElement, ParentElement, Styled, Window, div};1+use gpui_kit::{
2-use gpui_component::{2+ AppContext, Context, Entity, IntoElement, ParentElement, Styled, Window,
3- WindowExt,3+ component::{
4- button::Button,4+ WindowExt,
5- input::{Input, InputEvent, InputState},5+ button::Button,
6- notification::Notification,6+ input::{Input, InputEvent, InputState},
7+ notification::Notification,
8+ },
9+ div,
7 };10 };
8 11
9 use crate::gui::{Route, Yumush};12 use crate::gui::{Route, Yumush};
crates/client/src/gui/register.rsmodified+9 -6
@@ -1,9 +1,12 @@
1-use gpui::{AppContext, Context, Entity, IntoElement, ParentElement, Styled, Window, div};1+use gpui_kit::{
2-use gpui_component::{2+ AppContext, Context, Entity, IntoElement, ParentElement, Styled, Window,
3- WindowExt,3+ component::{
4- button::Button,4+ WindowExt,
5- input::{Input, InputEvent, InputState},5+ button::Button,
6- notification::Notification,6+ input::{Input, InputEvent, InputState},
7+ notification::Notification,
8+ },
9+ div,
7 };10 };
8 11
9 use crate::gui::{Route, Yumush};12 use crate::gui::{Route, Yumush};
crates/client/src/main.rsmodified+6 -4
@@ -1,14 +1,16 @@
1 use client::{gui::Yumush, network, ClientConfig, NAME};1 use client::{gui::Yumush, network, ClientConfig, NAME};
2-use gpui::{px, size, App, AppContext, Bounds, TitlebarOptions, WindowBounds, WindowOptions};2+use gpui_kit::{
3-use gpui_component::Root;3+ application, component::Root, init, px, size, App, AppContext, Bounds, TitlebarOptions,
4+ WindowBounds, WindowOptions,
5+};
4 6
5 fn main() {7 fn main() {
6 println!("Hello, world!");8 println!("Hello, world!");
7 9
8 let (network_handle, network_event_receiver) = network::start(ClientConfig::default());10 let (network_handle, network_event_receiver) = network::start(ClientConfig::default());
9 11
10- gpui_platform::application().run(|cx: &mut App| {12+ application().run(|cx: &mut App| {
11- gpui_component::init(cx);13+ init(cx);
12 14
13 let window_bounds = Bounds::centered(None, size(px(800.0), px(600.0)), cx);15 let window_bounds = Bounds::centered(None, size(px(800.0), px(600.0)), cx);
14 16