Account switcher is its own pop menu off the chevron after your name, the card stays put
Browse files at this commit23c2ec58b7623dc7cad3e140709c99d2aeca4ccaParent: 61a5ac2- style
- account switcher is its own pop menu off the chevron after your name, the card stays put
2 changed files +32 -51
crates/client/src/gui/chat.rsmodified+0 -1
| @@ -126,7 +126,6 @@ pub enum ReportTarget { | |||
| 126 | pub enum CardMenu { | 126 | pub enum CardMenu { |
| 127 | Main, | 127 | Main, |
| 128 | More, | 128 | More, |
| 129 | - Accounts, | ||
| 130 | Status, | 129 | Status, |
| 131 | } | 130 | } |
| 132 | 131 | ||
crates/client/src/gui/profile.rsmodified+32 -50
| @@ -242,13 +242,7 @@ impl Card { | |||
| 242 | .flex() | 242 | .flex() |
| 243 | .flex_col() | 243 | .flex_col() |
| 244 | .gap(px(space::XS)) | 244 | .gap(px(space::XS)) |
| 245 | - .children(self_rows( | 245 | + .children(main_self_rows(entity, &popover, palette)) |
| 246 | - &self.others, | ||
| 247 | - self.card_menu, | ||
| 248 | - entity, | ||
| 249 | - &popover, | ||
| 250 | - palette, | ||
| 251 | - )) | ||
| 252 | .into_any_element() | 246 | .into_any_element() |
| 253 | } else { | 247 | } else { |
| 254 | let mut rows = self.social_rows(entity, &popover, palette); | 248 | let mut rows = self.social_rows(entity, &popover, palette); |
| @@ -395,7 +389,12 @@ impl Card { | |||
| 395 | .truncate(), | 389 | .truncate(), |
| 396 | ) | 390 | ) |
| 397 | .when(is_self, |name| { | 391 | .when(is_self, |name| { |
| 398 | - name.child(account_toggle(self.card_menu, entity, palette)) | 392 | + name.child(account_menu( |
| 393 | + self.others.clone(), | ||
| 394 | + entity, | ||
| 395 | + &popover, | ||
| 396 | + palette, | ||
| 397 | + )) | ||
| 399 | }), | 398 | }), |
| 400 | ) | 399 | ) |
| 401 | .map(|names| { | 400 | .map(|names| { |
| @@ -585,21 +584,6 @@ impl Card { | |||
| 585 | } | 584 | } |
| 586 | } | 585 | } |
| 587 | 586 | ||
| 588 | -fn self_rows( | ||
| 589 | - others: &[(Id, String)], | ||
| 590 | - card_menu: CardMenu, | ||
| 591 | - entity: &Entity<Yumush>, | ||
| 592 | - popover: &Entity<PopoverState>, | ||
| 593 | - palette: Palette, | ||
| 594 | -) -> Vec<AnyElement> { | ||
| 595 | - match card_menu { | ||
| 596 | - CardMenu::Accounts => accounts_rows(others, entity, popover, palette), | ||
| 597 | - CardMenu::Main | CardMenu::More | CardMenu::Status => { | ||
| 598 | - main_self_rows(entity, popover, palette) | ||
| 599 | - } | ||
| 600 | - } | ||
| 601 | -} | ||
| 602 | - | ||
| 603 | fn main_self_rows( | 587 | fn main_self_rows( |
| 604 | entity: &Entity<Yumush>, | 588 | entity: &Entity<Yumush>, |
| 605 | popover: &Entity<PopoverState>, | 589 | popover: &Entity<PopoverState>, |
| @@ -673,36 +657,34 @@ fn accounts_rows( | |||
| 673 | ] | 657 | ] |
| 674 | } | 658 | } |
| 675 | 659 | ||
| 676 | -fn account_toggle( | 660 | +fn account_menu( |
| 677 | - card_menu: CardMenu, | 661 | + others: Vec<(Id, String)>, |
| 678 | entity: &Entity<Yumush>, | 662 | entity: &Entity<Yumush>, |
| 663 | + card: &Entity<PopoverState>, | ||
| 679 | palette: Palette, | 664 | palette: Palette, |
| 680 | -) -> impl IntoElement { | 665 | +) -> Popover { |
| 681 | - let open = card_menu == CardMenu::Accounts; | 666 | + let entity = entity.clone(); |
| 682 | - clickable( | 667 | + let card = card.clone(); |
| 683 | - "profile_accounts", | 668 | + Popover::new("account_menu") |
| 684 | - palette, | 669 | + .anchor(Anchor::TopLeft) |
| 685 | - card_menu_action( | 670 | + .appearance(false) |
| 686 | - entity, | 671 | + .trigger(Trigger::new( |
| 687 | - if open { | 672 | + clickable("profile_accounts", palette, |_, _| {}) |
| 688 | - CardMenu::Main | 673 | + .tip(w().profile.accounts) |
| 689 | - } else { | 674 | + .rounded(px(radius::SM)) |
| 690 | - CardMenu::Accounts | 675 | + .flex_shrink_0() |
| 691 | - }, | 676 | + .child( |
| 692 | - ), | 677 | + Icon::new(IconName::ChevronDown) |
| 693 | - ) | 678 | + .size(px(size::ICON_SM)) |
| 694 | - .tip(w().profile.accounts) | 679 | + .text_color(palette.muted), |
| 695 | - .rounded(px(radius::SM)) | 680 | + ), |
| 696 | - .flex_shrink_0() | 681 | + )) |
| 697 | - .child( | 682 | + .content(move |_, _, _| { |
| 698 | - Icon::new(if open { | 683 | + super::parts::popover(palette.tokens) |
| 699 | - IconName::ChevronUp | 684 | + .w(px(size::POPOVER)) |
| 700 | - } else { | 685 | + .p(px(space::XS)) |
| 701 | - IconName::ChevronDown | 686 | + .children(accounts_rows(&others, &entity, &card, palette)) |
| 702 | }) | 687 | }) |
| 703 | - .size(px(size::ICON_SM)) | ||
| 704 | - .text_color(palette.muted), | ||
| 705 | - ) | ||
| 706 | } | 688 | } |
| 707 | 689 | ||
| 708 | fn edit_status(entity: &Entity<Yumush>, status: &str, palette: Palette) -> impl IntoElement { | 690 | fn edit_status(entity: &Entity<Yumush>, status: &str, palette: Palette) -> impl IntoElement { |