Account · Profile and access: profiles, switchers, a user menu, sessions, keys
ProfileCard shows someone at a glance; ProfileEditor edits a profile seeded by its owner and saves once it changed, has a name and an email that reads, with a way to put it back. AccountSwitcher and WorkspaceSwitcher show the one in use in a row that opens a menu of the others and a way to add one; UserMenu opens from an avatar with who is signed in, the owner's rows and Sign out, through the new menus::menu_under. SessionList puts this device first, signs others out one by one or all after a second press. ApiKeyManager lists keys by their ends, makes one by name and shows its secret once.
This commit is contained in:
1 parent
0177d9f3c7
commit
31f5f91507
12 files changed
+1654
-8
No files matched your search
+14
-1
@@ -17,7 +17,7 @@ use crate::{
|
||||
primitives::IconName,
|
||||
};
|
||||
|
||||
type Click = Rc<dyn Fn(&ClickEvent, &mut Window, &mut App)>;
|
||||
pub(crate) type Click = Rc<dyn Fn(&ClickEvent, &mut Window, &mut App)>;
|
||||
|
||||
fn state(id: &ElementId, window: &mut Window, cx: &mut App) -> Entity<Open> {
|
||||
window.use_keyed_state((id.clone(), "menu"), cx, |_, _| Open::default())
|
||||
@@ -54,6 +54,19 @@ fn host(
|
||||
.children(hang(&id, menu, state, field, window, cx))
|
||||
}
|
||||
|
||||
/// A menu under a trigger of the caller's making, which runs `click` when pressed.
|
||||
pub(crate) fn menu_under(
|
||||
id: ElementId,
|
||||
menu: &Menu,
|
||||
trigger: impl FnOnce(Click) -> AnyElement,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> Stateful<Div> {
|
||||
let state = state(&id, window, cx);
|
||||
let click = toggle(&state, menu, cx);
|
||||
host(id, trigger(click), menu, &state, None, window, cx)
|
||||
}
|
||||
|
||||
/// A button that opens a menu under it.
|
||||
#[derive(IntoElement)]
|
||||
pub struct DropdownMenu {
|
||||
|
||||
@@ -8,6 +8,7 @@ mod pie;
|
||||
mod tests;
|
||||
|
||||
pub use bar::MenuBar;
|
||||
pub(crate) use hosts::menu_under;
|
||||
pub use hosts::{ContextMenu, DropdownMenu, OverflowMenu, SearchableMenu, SplitButton};
|
||||
pub use model::{Menu, MenuItem};
|
||||
pub use pie::{PieItem, PieMenu};
|
||||
Reference in new issue
Block a user