Project dropdown menu

This commit is contained in:
Piotr Osiewicz 2023-06-29 18:03:01 +02:00
parent d000ea9739
commit 888d3b3fd6
5 changed files with 95 additions and 10 deletions

View file

@ -21,6 +21,7 @@ util = { path = "../util"}
theme = { path = "../theme" }
workspace = { path = "../workspace" }
futures.workspace = true
ordered-float.workspace = true
postage.workspace = true
smol.workspace = true

View file

@ -64,9 +64,26 @@ fn toggle(
}))
}
type RecentProjects = Picker<RecentProjectsDelegate>;
pub fn build_recent_projects(
workspace: WeakViewHandle<Workspace>,
cx: &mut ViewContext<RecentProjects>,
) -> RecentProjects {
let workspaces = futures::executor::block_on(async {
WORKSPACE_DB
.recent_workspaces_on_disk()
.await
.unwrap_or_default()
.into_iter()
.map(|(_, location)| location)
.collect()
});
Picker::new(RecentProjectsDelegate::new(workspace, workspaces), cx)
.with_theme(|theme| theme.picker.clone())
}
struct RecentProjectsDelegate {
pub type RecentProjects = Picker<RecentProjectsDelegate>;
pub struct RecentProjectsDelegate {
workspace: WeakViewHandle<Workspace>,
workspace_locations: Vec<WorkspaceLocation>,
selected_match_index: usize,