refactor: inline intermediate element builders in render methods
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run

This commit is contained in:
2026-11-22 18:42:59 +07:00
parent 9daee9d54d
commit 967273c402
14 changed files with 560 additions and 550 deletions
+11 -14
View File
@@ -119,18 +119,6 @@ impl Render for AppRoot {
let workspace = self.workspace.read(cx);
let main = workspace.active_main();
let prefix = h_flex()
.gap_1()
.child(titlebar_view.render_new_repository())
.child(titlebar_view.render_explore())
.child(titlebar_view.repository_switcher());
let tab_bar = h_flex()
.gap_1()
.when_some(titlebar_view.render_repo_tabs(workspace), |bar, tabs| {
bar.child(tabs)
});
div()
.relative()
.size_full()
@@ -151,8 +139,17 @@ impl Render for AppRoot {
Shell::new("signed-shell")
.titlebar(
Titlebar::new("signed-titlebar")
.prefix(prefix)
.tab_bar(tab_bar)
.prefix(
h_flex()
.gap_1()
.child(titlebar_view.render_new_repository())
.child(titlebar_view.render_explore())
.child(titlebar_view.repository_switcher()),
)
.tab_bar(h_flex().gap_1().when_some(
titlebar_view.render_repo_tabs(workspace),
|bar, tabs| bar.child(tabs),
))
.when_some(titlebar_view.render_user_menu(cx), |titlebar, menu| {
titlebar.suffix(menu)
}),
@@ -165,12 +165,6 @@ impl Render for RepositorySwitcher {
let list_weak = row_weak.clone();
let list_on_open = on_open.clone();
let list_scroll_handle = scroll_handle.clone();
let create_hint = Kbd::binding_for_action(
&CreateRepository,
Some(REPOSITORY_KEY_CONTEXT),
window,
);
v_flex()
.w(px(380.))
.p_2()
@@ -265,7 +259,14 @@ impl Render for RepositorySwitcher {
.full_width(true)
.icon(Icon::named(IconRole::CirclePlus))
.child(div().flex_1().child("Create Repository"))
.when_some(create_hint, |button, hint| button.child(hint))
.when_some(
Kbd::binding_for_action(
&CreateRepository,
Some(REPOSITORY_KEY_CONTEXT),
window,
),
|button, hint| button.child(hint),
)
.on_click(move |_, window, cx| {
log_dropped(create_weak.update(cx, |this, cx| {
this.close(cx);
+25 -24
View File
@@ -213,30 +213,31 @@ impl Render for Workspace {
.gap_2()
.when(self.details.len() > 1, |this| {
let close_weak = weak.clone();
let tabs = Tabs::new("signed-detail-tabs")
.variant(TabsVariant::Pill)
.overflow_scroll(true)
.selected(selected)
.tabs(move |_, cx| {
details
.iter()
.map(|(id, view)| match view {
Some(view) => view.tab(id.clone().into(), cx).closeable(true),
None => Tab::new(id.clone(), id.clone()).closeable(true),
})
.collect()
})
.on_change(move |index, _, cx| {
log_dropped(weak.update(cx, |workspace, cx| {
workspace.activate_detail_at(index, cx);
}));
})
.on_close(move |index, _, cx| {
log_dropped(close_weak.update(cx, |workspace, cx| {
workspace.close_detail_at(index, cx);
}));
});
this.child(tabs)
this.child(
Tabs::new("signed-detail-tabs")
.variant(TabsVariant::Pill)
.overflow_scroll(true)
.selected(selected)
.tabs(move |_, cx| {
details
.iter()
.map(|(id, view)| match view {
Some(view) => view.tab(id.clone().into(), cx).closeable(true),
None => Tab::new(id.clone(), id.clone()).closeable(true),
})
.collect()
})
.on_change(move |index, _, cx| {
log_dropped(weak.update(cx, |workspace, cx| {
workspace.activate_detail_at(index, cx);
}));
})
.on_close(move |index, _, cx| {
log_dropped(close_weak.update(cx, |workspace, cx| {
workspace.close_detail_at(index, cx);
}));
}),
)
})
.child(div().flex_1().min_h_0().w_full().children(body))
}