Make repo and branch popovers extend up from their trigger buttons (#26950)
Previously, when clicking on the branch, the popover would obscure the button you just clicked, which was awkward. Release Notes: - Improved the placement of the repo and branch picker popovers in the git panel. - Added a 'SelectRepo' action that opens the repository selector in a modal.
This commit is contained in:
parent
a05066cd83
commit
2b2b9c1624
8 changed files with 59 additions and 49 deletions
|
@ -9,14 +9,33 @@ use project::{
|
|||
};
|
||||
use std::sync::Arc;
|
||||
use ui::{prelude::*, ListItem, ListItemSpacing};
|
||||
use workspace::{ModalView, Workspace};
|
||||
|
||||
pub fn register(workspace: &mut Workspace) {
|
||||
workspace.register_action(open);
|
||||
}
|
||||
|
||||
pub fn open(
|
||||
workspace: &mut Workspace,
|
||||
_: &zed_actions::git::SelectRepo,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Workspace>,
|
||||
) {
|
||||
let project = workspace.project().clone();
|
||||
workspace.toggle_modal(window, cx, |window, cx| {
|
||||
RepositorySelector::new(project, rems(34.), window, cx)
|
||||
})
|
||||
}
|
||||
|
||||
pub struct RepositorySelector {
|
||||
width: Rems,
|
||||
picker: Entity<Picker<RepositorySelectorDelegate>>,
|
||||
}
|
||||
|
||||
impl RepositorySelector {
|
||||
pub fn new(
|
||||
project_handle: Entity<Project>,
|
||||
width: Rems,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
|
@ -48,7 +67,7 @@ impl RepositorySelector {
|
|||
.max_height(Some(rems(20.).into()))
|
||||
});
|
||||
|
||||
RepositorySelector { picker }
|
||||
RepositorySelector { picker, width }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,10 +110,12 @@ impl Focusable for RepositorySelector {
|
|||
|
||||
impl Render for RepositorySelector {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
self.picker.clone()
|
||||
div().w(self.width).child(self.picker.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl ModalView for RepositorySelector {}
|
||||
|
||||
pub struct RepositorySelectorDelegate {
|
||||
project: WeakEntity<Project>,
|
||||
repository_selector: WeakEntity<RepositorySelector>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue