add basic repo browser

This commit is contained in:
2026-08-05 09:03:42 +07:00
parent 7249a323f8
commit f497279886
10 changed files with 411 additions and 27 deletions
+73
View File
@@ -0,0 +1,73 @@
use gpui::prelude::*;
use gpui::{AnyView, Context, Render, SharedString, Subscription, Window, div, px};
use gpui_component::{ActiveTheme, StyledExt};
use signed_state::{Backend, BackendEvent};
use crate::views::RepoListView;
/// Root view of the app: header, active screen, status bar.
pub struct Workspace {
active_screen: AnyView,
status: SharedString,
_subscription: Subscription,
}
impl Workspace {
pub fn new(window: &mut Window, cx: &mut Context<Self>) -> Self {
let repo_list = cx.new(|cx| RepoListView::new(window, cx));
let subscription = cx.subscribe(&Backend::global(cx), |this, _backend, event, cx| {
match event {
BackendEvent::Connected => this.status = "Connected".into(),
BackendEvent::Error(error) => this.status = error.clone().into(),
_ => return,
}
cx.notify();
});
Self {
active_screen: repo_list.into(),
status: SharedString::from("Connecting..."),
_subscription: subscription,
}
}
}
impl Render for Workspace {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
div()
.v_flex()
.size_full()
.bg(cx.theme().background)
.text_color(cx.theme().foreground)
.child(
div()
.h_flex()
.px_4()
.py_2()
.border_b(px(1.))
.border_color(cx.theme().border)
.child(div().text_lg().font_semibold().child("Signed")),
)
.child(
div()
.flex_1()
.overflow_hidden()
.child(self.active_screen.clone()),
)
.child(
div()
.h_flex()
.px_4()
.py_1()
.border_t(px(1.))
.border_color(cx.theme().border)
.child(
div()
.text_xs()
.text_color(cx.theme().muted_foreground)
.child(self.status.clone()),
),
)
}
}