Add basic space switching

This commit is contained in:
2026-05-07 20:19:55 -04:00
parent 42d33ac06c
commit 19d928859c
9 changed files with 325 additions and 72 deletions
+12 -3
View File
@@ -1,7 +1,7 @@
mod render;
use ely_browser_core::{BrowserCore, InitialBrowserConfig};
use ely_domain::{CommandIntent, TabId, UrlText};
use ely_domain::{CommandIntent, SpaceId, TabId, UrlText};
use gpui::{App, AppContext, Context, Entity, FocusHandle, Focusable, Subscription, Window};
use gpui_component::input::{InputEvent, InputState, SelectAll};
@@ -11,7 +11,7 @@ use crate::{
};
enum ShellState {
Ready(BrowserCore),
Ready(Box<BrowserCore>),
StartupError(String),
}
@@ -66,7 +66,7 @@ impl ElyShell {
_ => ely_domain::DomainError::InvalidCommand,
})
}) {
Ok(core) => ShellState::Ready(core),
Ok(core) => ShellState::Ready(Box::new(core)),
Err(error) => ShellState::StartupError(error.to_string()),
};
@@ -106,6 +106,15 @@ impl ElyShell {
}
}
fn select_space(&mut self, space_id: &SpaceId, window: &mut Window, cx: &mut Context<Self>) {
if let ShellState::Ready(core) = &mut self.state
&& core.select_space(space_id).is_ok()
{
self.sync_address_input(window, cx);
cx.notify();
}
}
fn select_next_tab(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if let ShellState::Ready(core) = &mut self.state
&& core.select_next_tab().is_ok()
+42 -11
View File
@@ -1,6 +1,6 @@
use ely_browser_core::BrowserSnapshot;
use ely_design_system::{ELY_THEME, colors, spacing};
use ely_domain::{ArchiveSource, ArchivedTab, BrowserTab};
use ely_domain::{ArchiveSource, ArchivedTab, BrowserTab, Space};
use gpui::{
AnyElement, Context, InteractiveElement, IntoElement, ParentElement, Render, SharedString,
StatefulInteractiveElement, Styled, Window, div, px, rgb,
@@ -157,16 +157,9 @@ impl ElyShell {
}),
)
.child(section_label("Space"))
.child(
div()
.rounded_md()
.bg(rgb(colors::SURFACE_CARD))
.border_1()
.border_color(rgb(colors::HAIRLINE))
.px_3()
.py_2()
.child(snapshot.active_space_name.clone()),
)
.children(snapshot.spaces.iter().map(|space| {
self.render_space_row(space, space.id() == &snapshot.active_space_id, cx)
}))
.child(section_label("Tabs"))
.children(
snapshot
@@ -195,6 +188,44 @@ impl ElyShell {
.into_any_element()
}
fn render_space_row(
&mut self,
space: &Space,
active: bool,
cx: &mut Context<Self>,
) -> AnyElement {
let space_id = space.id().clone();
let background = if active { colors::SURFACE_CARD } else { colors::CANVAS };
let border = if active { colors::HAIRLINE_STRONG } else { colors::HAIRLINE };
div()
.id(SharedString::from(format!("space-{}", space.id().as_str())))
.rounded_md()
.border_1()
.border_color(rgb(border))
.bg(rgb(background))
.px_3()
.py_2()
.gap_2()
.flex()
.items_center()
.cursor_pointer()
.hover(|style| style.bg(rgb(colors::SURFACE_CARD)))
.active(|style| style.opacity(0.82))
.on_click(cx.listener(move |shell, _, window, cx| {
shell.select_space(&space_id, window, cx);
}))
.child(
div()
.text_xs()
.font_semibold()
.text_color(rgb(colors::PRIMARY))
.child(space.icon().to_string()),
)
.child(div().text_sm().font_semibold().child(space.name().to_string()))
.into_any_element()
}
fn render_favorite_row(
&mut self,
tab: &BrowserTab,