list: Add a default style for empty data (#955)

<img width="890" alt="image"
src="https://github.com/user-attachments/assets/68339cab-023f-42bc-93cc-0cded1b690b0"
/>
This commit is contained in:
Floyd Wang 2025-06-13 15:44:00 +08:00 committed by GitHub
parent 89c210c4ca
commit aaa855053f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -4,12 +4,12 @@ use std::{cell::Cell, rc::Rc};
use crate::actions::{Cancel, Confirm, SelectNext, SelectPrev};
use crate::input::InputState;
use crate::{h_flex, Icon, Sizable as _};
use crate::{
input::{InputEvent, TextInput},
scroll::{Scrollbar, ScrollbarState},
v_flex, ActiveTheme, IconName, Size,
};
use crate::{Icon, Sizable as _};
use gpui::{
div, prelude::FluentBuilder, uniform_list, AnyElement, AppContext, Entity, FocusHandle,
Focusable, InteractiveElement, IntoElement, KeyBinding, Length, ListSizingBehavior,
@ -73,7 +73,12 @@ pub trait ListDelegate: Sized + 'static {
/// Return a Element to show when list is empty.
fn render_empty(&self, window: &mut Window, cx: &mut Context<List<Self>>) -> impl IntoElement {
div()
h_flex()
.size_full()
.justify_center()
.text_color(cx.theme().muted_foreground.opacity(0.6))
.child(Icon::new(IconName::Inbox).size_12())
.into_any_element()
}
/// Returns Some(AnyElement) to render the initial state of the list.

View file

@ -295,7 +295,6 @@ pub trait TableDelegate: Sized + 'static {
h_flex()
.size_full()
.justify_center()
.py_6()
.text_color(cx.theme().muted_foreground.opacity(0.6))
.child(Icon::new(IconName::Inbox).size_12())
.into_any_element()