chore: improve ui consistently (#35)
Rust / build (macos-latest, stable) (push) Canceled after 0s
Rust / build (ubuntu-latest, stable) (push) Canceled after 0s
Rust / build (windows-latest, stable) (push) Canceled after 0s

Reviewed-on: #35
This commit was merged in pull request #35.
This commit is contained in:
2026-11-20 12:28:25 +00:00
parent 51dd5c8630
commit f850f4c4c1
90 changed files with 2859 additions and 2061 deletions
+72 -157
View File
@@ -1,36 +1,33 @@
use gpui::prelude::FluentBuilder as _;
use gpui::{
AnyElement, App, AppContext as _, Context, Entity, InteractiveElement as _, IntoElement,
ParentElement as _, Render, SharedString, StatefulInteractiveElement as _, Styled as _,
Subscription, UniformListScrollHandle, WeakEntity, Window, div, px, uniform_list,
AnyElement, App, AppContext as _, Context, Entity, IntoElement, ParentElement as _, Render,
SharedString, Styled as _, Subscription, UniformListScrollHandle, WeakEntity, Window, div,
};
use helpers::{IssueFilter, StatusCounts, filter_by_status};
use metadata::ProfileDirectory;
use nostr::prelude::PublicKey;
use signed_core::GitEvent;
use signed_state::RepoStore;
use ui::avatar::Avatar;
use ui::button::Button;
use ui::common::{Sizable as _, h_flex, v_flex};
use ui::empty_state::EmptyState;
use ui::common::v_flex;
use ui::icons::{Icon, IconRole};
use ui::layout::panel::Panel;
use ui::scrollbar::Scrollbar;
use ui::segmented::{Segmented, SegmentedOption};
use ui::theme::ActiveTheme as _;
use utils::relative_time;
use std::rc::Rc;
use self::detail::IssueDetailView;
use crate::repo::helpers::short_id;
use crate::shared::event_list::{EventList, EventRow};
use crate::shared::panels;
use crate::shared::widgets::status_badge;
use crate::workspace::Workspace;
pub mod detail;
pub(crate) mod helpers;
pub mod new_issue;
const ISSUE_ROW_HEIGHT: f32 = 73.;
pub struct IssuesView {
workspace: WeakEntity<Workspace>,
store: Entity<RepoStore>,
@@ -131,14 +128,9 @@ impl IssuesView {
let muted = cx.theme().colors.muted_foreground;
let weak = cx.entity().downgrade();
h_flex()
.px_4()
.w_full()
.gap_3()
.border_b_1()
.border_color(cx.theme().colors.border)
.bg(cx.theme().colors.muted)
.child(
crate::shared::event_list::filter_toolbar(
cx,
[
Segmented::new("issue-filter", self.filter)
.options(vec![
SegmentedOption::new(IssueFilter::All, format!("All ({})", counts.total))
@@ -158,18 +150,18 @@ impl IssuesView {
}) {
log::warn!("failed to switch issue filter: {error}");
}
}),
)
.child(div().flex_1())
.child(
})
.into_any_element(),
div().flex_1().into_any_element(),
Button::new("new-issue")
.label("New issue")
.icon(Icon::named(IconRole::CirclePlus))
.on_click(cx.listener(|this, _, _, cx| {
this.open_new_issue(cx);
})),
)
.into_any_element()
}))
.into_any_element(),
],
)
}
}
@@ -182,147 +174,70 @@ impl Panel for IssuesView {
impl Render for IssuesView {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let filter = self.filter;
let count = self.visible_issues.len();
let visible_issues = self.visible_issues.clone();
let directory = self.directory.clone();
let store = self.store.clone();
let workspace = self.workspace.clone();
let rows = visible_issues
.iter()
.enumerate()
.filter_map(|(ix, &issue_ix)| {
// The store re-read per frame can shrink below a captured index.
let issue = store.read(cx).issues.get(issue_ix)?;
let profile = directory.read(cx).profile(&issue.pubkey, cx);
let issue_id = issue.id;
let id_hex = issue.id.to_hex();
let status = store.read(cx).status_of(issue);
let on_click: crate::shared::event_list::EventHandler = {
let workspace = workspace.clone();
let store = store.clone();
Rc::new(move |_, window, cx| {
let id = SharedString::from(format!("issue:{issue_id}"));
let store = store.clone();
panels::open_detail(
&workspace,
id,
move |_, cx| {
cx.new(|cx| IssueDetailView::new(store.clone(), issue_id, cx))
},
window,
cx,
);
})
};
Some(EventRow {
id: ix.into(),
status,
title: issue.activity_subject().into(),
author: profile.name(),
picture: profile.picture(),
pubkey: issue.pubkey,
short_id: short_id(&id_hex),
age: SharedString::from(relative_time(issue.created_at)),
on_click,
})
})
.collect();
let empty_message = match filter {
IssueFilter::All => "No issues",
IssueFilter::Open => "No open issues",
IssueFilter::Closed => "No closed issues",
};
v_flex()
.size_full()
.child(self.render_header(cx))
.when_some(self.new_issue.clone(), |el, view| el.child(view))
.child(
v_flex()
.relative()
.flex_1()
.min_h_0()
.w_full()
.when(count > 0, |this| {
this.child(
uniform_list("issues", count, move |range, _, cx| {
range
.map(|ix| {
let issue_ix = visible_issues[ix];
let issue = &store.read(cx).issues[issue_ix];
let title = issue.activity_subject();
let id_hex = issue.id.to_hex();
let profile = directory.read(cx).profile(&issue.pubkey, cx);
let author = profile.name();
let age = relative_time(issue.created_at);
let status = store.read(cx).status_of(issue);
let issue_id = issue.id;
let workspace = workspace.clone();
let store = store.clone();
h_flex()
.id(ix)
.w_full()
.h(px(ISSUE_ROW_HEIGHT))
.gap_4()
.px_4()
.border_b_1()
.border_color(cx.theme().colors.border)
.hover(|this| this.bg(cx.theme().colors.muted_hover))
.on_click(move |_, window, cx| {
let id =
SharedString::from(format!("issue:{issue_id}"));
let store = store.clone();
panels::open_detail(
&workspace,
id,
move |_, cx| {
cx.new(|cx| {
IssueDetailView::new(
store.clone(),
issue_id,
cx,
)
})
},
window,
cx,
);
})
.child(status_badge(status))
.child(
v_flex()
.flex_1()
.min_w_0()
.gap_1()
.child(
div()
.text_base()
.text_ellipsis()
.whitespace_nowrap()
.child(title),
)
.child(
h_flex()
.gap_2()
.text_xs()
.child(
h_flex()
.gap_1()
.child(
Avatar::new(issue.pubkey)
.name(author.clone())
.picture(
profile.picture(),
)
.small(),
)
.child(div().child(author)),
)
.child(SharedString::from("opened"))
.child(
div()
.text_color(
cx.theme()
.colors
.muted_foreground,
)
.child(SharedString::from(
&id_hex[..8],
)),
)
.child(SharedString::from(age)),
),
)
.into_any_element()
})
.collect()
})
.track_scroll(&self.scroll_handle)
.size_full(),
)
.child(
div()
.absolute()
.top_0()
.left_0()
.right_0()
.bottom_0()
.child(Scrollbar::vertical(
"issues-scroll",
self.scroll_handle.clone(),
)),
)
})
.when(count == 0, |this| {
let message = match filter {
IssueFilter::All => "No issues",
IssueFilter::Open => "No open issues",
IssueFilter::Closed => "No closed issues",
};
this.child(
v_flex()
.size_full()
.items_center()
.justify_center()
.child(EmptyState::new(message)),
)
}),
EventList::new("issues")
.toolbar(self.render_header(cx))
.scroll_handle(self.scroll_handle.clone())
.rows(rows)
.empty_message(empty_message)
.render(cx),
)
.into_any_element()
}