Saved accounts list is a 3-row scroll (find field past 3) on login and the switcher
Browse files at this commit56c130b1a4656ecbf46e47a630500fcc753cbaa0Parent: 51367a5- style
- saved accounts list is a 3-row scroll (find field past 3) on login and the switcher
1 changed file +16 -6
crates/client/src/gui/account_list.rsmodified+16 -6
| @@ -1,6 +1,7 @@ | |||
| 1 | use gpui_kit::{ | 1 | use gpui_kit::{ |
| 2 | - AnyElement, App, Div, Entity, IntoElement, ParentElement, StatefulInteractiveElement, Styled, | 2 | + AnyElement, App, Div, Entity, InteractiveElement, IntoElement, ParentElement, |
| 3 | - assets::IconName, component::popover::PopoverState, div, px, | 3 | + StatefulInteractiveElement, Styled, assets::IconName, component::popover::PopoverState, div, |
| 4 | + px, | ||
| 4 | }; | 5 | }; |
| 5 | 6 | ||
| 6 | use super::{ | 7 | use super::{ |
| @@ -12,7 +13,7 @@ use super::{ | |||
| 12 | use crate::accounts::Account; | 13 | use crate::accounts::Account; |
| 13 | use crate::lang::w; | 14 | use crate::lang::w; |
| 14 | 15 | ||
| 15 | -const CAP: usize = 5; | 16 | +const SHOWN: f32 = 3.; |
| 16 | 17 | ||
| 17 | pub(super) fn account_list( | 18 | pub(super) fn account_list( |
| 18 | yumush: &Yumush, | 19 | yumush: &Yumush, |
| @@ -26,12 +27,11 @@ pub(super) fn account_list( | |||
| 26 | if skip_active { | 27 | if skip_active { |
| 27 | accounts.retain(|account| Some(account.user_id) != yumush.accounts.active); | 28 | accounts.retain(|account| Some(account.user_id) != yumush.accounts.active); |
| 28 | } | 29 | } |
| 29 | - let filtered = accounts.len() > CAP; | 30 | + let filtered = accounts.len() > SHOWN as usize; |
| 30 | let query = super::widget::search_text(&yumush.account_filter, cx); | 31 | let query = super::widget::search_text(&yumush.account_filter, cx); |
| 31 | let rows: Vec<AnyElement> = accounts | 32 | let rows: Vec<AnyElement> = accounts |
| 32 | .into_iter() | 33 | .into_iter() |
| 33 | .filter(|account| !filtered || account.username.to_lowercase().contains(query.as_str())) | 34 | .filter(|account| !filtered || account.username.to_lowercase().contains(query.as_str())) |
| 34 | - .take(CAP) | ||
| 35 | .map(|account| row(account, entity, popover.clone(), palette)) | 35 | .map(|account| row(account, entity, popover.clone(), palette)) |
| 36 | .collect(); | 36 | .collect(); |
| 37 | 37 | ||
| @@ -40,7 +40,16 @@ pub(super) fn account_list( | |||
| 40 | .flex_col() | 40 | .flex_col() |
| 41 | .gap(px(space::XXS)) | 41 | .gap(px(space::XXS)) |
| 42 | .children(filtered.then(|| input_box(&yumush.account_filter, palette))) | 42 | .children(filtered.then(|| input_box(&yumush.account_filter, palette))) |
| 43 | - .children(rows) | 43 | + .child( |
| 44 | + div() | ||
| 45 | + .id("account_rows") | ||
| 46 | + .max_h(px(SHOWN * size::CONTROL + (SHOWN - 1.) * space::XXS)) | ||
| 47 | + .overflow_y_scroll() | ||
| 48 | + .flex() | ||
| 49 | + .flex_col() | ||
| 50 | + .gap(px(space::XXS)) | ||
| 51 | + .children(rows), | ||
| 52 | + ) | ||
| 44 | } | 53 | } |
| 45 | 54 | ||
| 46 | fn row( | 55 | fn row( |
| @@ -57,6 +66,7 @@ fn row( | |||
| 57 | format!("saved_{user_id}"), | 66 | format!("saved_{user_id}"), |
| 58 | div() | 67 | div() |
| 59 | .h(px(size::CONTROL)) | 68 | .h(px(size::CONTROL)) |
| 69 | + .flex_none() | ||
| 60 | .px(px(space::SM)) | 70 | .px(px(space::SM)) |
| 61 | .flex() | 71 | .flex() |
| 62 | .items_center() | 72 | .items_center() |