gpui-component/crates/ui/src
Jason Lee 9a040eaaac
list: Refactor List, Dropdown delegate API to support section. (#1107)
Ref UITableView API:

https://developer.apple.com/documentation/uikit/uitableviewdatasource

## Changes

- Added some section related API to `ListDelegeate` and
`DropdownDelegate` with default implement, so if you don't need section
that you can just keep the default.
- Added `sections_count` method to get the number of sections, default
is 1.
- Added `render_section_header` for special the section header by if
needed, default return None.
- Added `render_section_footer` for special the section footer by if
needed, default return None.

## Break Changes

- The `DropdownState` have change new method to use IndexPath type:

  ```diff
  - DropdownState::new(vec![], Some(1), window, cx);
  + DropdownState::new(vec![], Some(IndexPath::new(1)), window, cx);
  ```

- The `ListDelegeate`, `DropdownDelegate` has changed API:
  - The `ix` are change from `usize` to `IndexPath`.

  ```diff
- fn render_item(&self, ix: usize, window: &mut Window, cx: &mut
Context<List<Self>>) -> Option<Self::Item>
+ fn render_item(&self, ix: IndexPath, window: &mut Window, cx: &mut
Context<List<Self>>) -> Option<Self::Item>

- fn set_selected_index(&mut self, ix: Option<usize>, window: &mut
Window, cx: &mut Context<List<Self>>)
+ fn set_selected_index(&mut self, ix: Option<IndexPath>, window: &mut
Window, cx: &mut Context<List<Self>>)
  ```

- The `items_count` method have added `section` argument to support list
section.
  
  ```diff
  - fn items_count(&self, cx: &App) -> usize
  + fn items_count(&self, section: usize, cx: &App) -> usize
  ```

- The `can_load_more` method has renamed to `is_eof` in `ListDelegate`
and `TableDelegate`.

  ```diff
  - fn can_load_more(&self, cx: &App) -> bool
  + fn is_eof(&self, cx: &App) -> bool
  ```

- The `can_search` method has renamed to `searchable` in `ListDelegate`.

  ```diff
  - fn can_search(&self) -> bool
  + fn searchable(&self) -> bool
  ```

## Showcase

<img width="1196" height="925" alt="image"
src="https://github.com/user-attachments/assets/22750abe-cc3f-427e-903b-51758bd4e027"
/>

<img width="1214" height="934" alt="image"
src="https://github.com/user-attachments/assets/52d42546-e6e7-4448-9c0f-43cd659fb630"
/>

---------

Co-authored-by: Floyd Wang <gassnake999@gmail.com>
2025-08-05 19:23:32 +08:00
..
avatar theme: Improve theme color fallbacks based on base colors. (#1069) 2025-07-17 11:43:40 +08:00
button list: Update ListItem and DropdownListItem style. (#1095) 2025-07-28 18:38:39 +08:00
chart plot: Use f32 instead of f64 (#1052) 2025-07-08 16:24:59 +08:00
dock tiles: Add panels method. (#1112) 2025-08-04 19:33:28 +08:00
highlighter theme: Improve theme color fallbacks based on base colors. (#1069) 2025-07-17 11:43:40 +08:00
input chore: Fix release unused method warning. 2025-07-30 15:44:41 +08:00
list list: Refactor List, Dropdown delegate API to support section. (#1107) 2025-08-05 19:23:32 +08:00
menu list: Update ListItem and DropdownListItem style. (#1095) 2025-07-28 18:38:39 +08:00
plot plot: Use f32 instead of f64 (#1052) 2025-07-08 16:24:59 +08:00
resizable
scroll scrollbar: Show scrollbar immediately when scroll offset changed. (#1111) 2025-08-04 17:00:20 +08:00
sidebar list: Update ListItem and DropdownListItem style. (#1095) 2025-07-28 18:38:39 +08:00
tab dock: Hide panel toolbar when dock is collapsed. (#1105) 2025-07-30 15:38:14 +08:00
table list: Refactor List, Dropdown delegate API to support section. (#1107) 2025-08-05 19:23:32 +08:00
text table: Refactor the Table API for describe the columns. (#1072) 2025-07-21 11:16:35 +08:00
theme tabs: Fix tab_bar_segmented default fallback color to secondary. (#1101) 2025-07-29 14:42:46 +08:00
time chrore: Refactor the disabled API for NumberInput, DatePicker, OtpInput, Calandar. (#1102) 2025-07-29 17:31:52 +08:00
accordion.rs accordion: Fix accordion to size full. (#1083) 2025-07-23 10:45:02 +00:00
actions.rs chore: Upgrade GPUI and fix action API changes. (#1008) 2025-06-25 11:06:12 +08:00
alert.rs alert: Improve Alert styles. (#1044) 2025-07-04 15:29:05 +08:00
animation.rs
badge.rs theme: Improve theme color fallbacks based on base colors. (#1069) 2025-07-17 11:43:40 +08:00
breadcrumb.rs chore: Impl Styled for more elements. (#1007) 2025-06-24 19:36:42 +08:00
checkbox.rs list: Update ListItem and DropdownListItem style. (#1095) 2025-07-28 18:38:39 +08:00
clipboard.rs
color_picker.rs theme: Improve theme color fallbacks based on base colors. (#1069) 2025-07-17 11:43:40 +08:00
description_list.rs
divider.rs chore: Impl Styled for more elements. (#1007) 2025-06-24 19:36:42 +08:00
drawer.rs drawer: Fix the overlay_closable not working (#1113) 2025-08-05 19:10:38 +08:00
dropdown.rs list: Refactor List, Dropdown delegate API to support section. (#1107) 2025-08-05 19:23:32 +08:00
event.rs chore: Update GPUI and fix FocusableWrapper removed error. (#1026) 2025-07-02 11:06:04 +08:00
focusable.rs
form.rs dock: Hide panel toolbar when dock is collapsed. (#1105) 2025-07-30 15:38:14 +08:00
history.rs
icon.rs list: Refactor List, Dropdown delegate API to support section. (#1107) 2025-08-05 19:23:32 +08:00
index_path.rs list: Refactor List, Dropdown delegate API to support section. (#1107) 2025-08-05 19:23:32 +08:00
indicator.rs
inspector.rs
kbd.rs kbd: Fix Kdb to support display - key. (#1109) 2025-07-31 20:39:19 +08:00
label.rs label: Streamline the test cases (#1074) 2025-07-18 17:10:36 +08:00
lib.rs list: Refactor List, Dropdown delegate API to support section. (#1107) 2025-08-05 19:23:32 +08:00
link.rs chore: Impl Styled for more elements. (#1007) 2025-06-24 19:36:42 +08:00
modal.rs modal: Refine enter animation (#1080) 2025-07-23 10:29:42 +08:00
notification.rs notification: Fix display issues caused by the taffy upgrade (#1084) 2025-07-23 19:12:13 +08:00
popover.rs list: Update ListItem and DropdownListItem style. (#1095) 2025-07-28 18:38:39 +08:00
progress.rs chore: Fix Slider, Progress width in horizontal mode. (#1096) 2025-07-28 18:56:09 +08:00
radio.rs check, radio: Add fade in animation to Checkbox and Radio. (#1092) 2025-07-24 11:41:34 +00:00
root.rs notification: Fix display issues caused by the taffy upgrade (#1084) 2025-07-23 19:12:13 +08:00
skeleton.rs chore: Impl Styled for more elements. (#1007) 2025-06-24 19:36:42 +08:00
slider.rs chore: Fix Slider, Progress width in horizontal mode. (#1096) 2025-07-28 18:56:09 +08:00
styled.rs list: Update ListItem and DropdownListItem style. (#1095) 2025-07-28 18:38:39 +08:00
svg_img.rs
switch.rs switch: Apply use_keyed_state to store toggle state for animation. (#1091) 2025-07-24 19:22:55 +08:00
tag.rs chore: Impl Styled for more elements. (#1007) 2025-06-24 19:36:42 +08:00
title_bar.rs title_bar: Add macOS double-click functionality to title bar (#996) (#1002) 2025-06-24 07:45:28 +08:00
tooltip.rs chore: Impl Styled for more elements. (#1007) 2025-06-24 19:36:42 +08:00
virtual_list.rs list: Refactor List, Dropdown delegate API to support section. (#1107) 2025-08-05 19:23:32 +08:00
webview.rs
window_border.rs