Rename ListEntry to ListItem (#3371)

This PR renames the `ListEntry` component to `ListItem` to better
reflect its intent.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers
2023-11-20 16:13:06 -05:00
committed by GitHub
parent 4f4ef4a357
commit 652e3b0bb6
5 changed files with 80 additions and 83 deletions
+6 -6
View File
@@ -2,7 +2,7 @@ use std::cell::RefCell;
use std::rc::Rc;
use crate::{prelude::*, v_stack, List};
use crate::{ListEntry, ListSeparator, ListSubHeader};
use crate::{ListItem, ListSeparator, ListSubHeader};
use gpui::{
overlay, px, Action, AnchorCorner, AnyElement, AppContext, Bounds, DispatchPhase, Div,
EventEmitter, FocusHandle, FocusableView, LayoutId, ManagedView, Manager, MouseButton,
@@ -13,7 +13,7 @@ pub enum ContextMenuItem<V: 'static> {
Separator(ListSeparator),
Header(ListSubHeader),
Entry(
ListEntry<ContextMenu<V>>,
ListItem<ContextMenu<V>>,
Rc<dyn Fn(&mut V, &mut ViewContext<V>)>,
),
}
@@ -63,7 +63,7 @@ impl<V: 'static> ContextMenu<V> {
pub fn entry(
mut self,
view: ListEntry<Self>,
view: ListItem<Self>,
on_click: impl Fn(&mut V, &mut ViewContext<V>) + 'static,
) -> Self {
self.items
@@ -71,7 +71,7 @@ impl<V: 'static> ContextMenu<V> {
self
}
pub fn action(self, view: ListEntry<Self>, action: Box<dyn Action>) -> Self {
pub fn action(self, view: ListItem<Self>, action: Box<dyn Action>) -> Self {
// todo: add the keybindings to the list entry
self.entry(view, move |_, cx| cx.dispatch_action(action.boxed_clone()))
}
@@ -323,14 +323,14 @@ mod stories {
menu.header(header)
.separator()
.entry(
ListEntry::new("Print current time", Label::new("Print current time")),
ListItem::new("Print current time", Label::new("Print current time")),
|v, cx| {
println!("dispatching PrintCurrentTime action");
cx.dispatch_action(PrintCurrentDate.boxed_clone())
},
)
.entry(
ListEntry::new("Print best food", Label::new("Print best food")),
ListItem::new("Print best food", Label::new("Print best food")),
|v, cx| cx.dispatch_action(PrintBestFood.boxed_clone()),
)
})
+4 -4
View File
@@ -238,7 +238,7 @@ pub enum ListEntrySize {
}
#[derive(RenderOnce)]
pub struct ListEntry<V: 'static> {
pub struct ListItem<V: 'static> {
id: ElementId,
disabled: bool,
// TODO: Reintroduce this
@@ -253,7 +253,7 @@ pub struct ListEntry<V: 'static> {
on_click: Option<Rc<dyn Fn(&mut V, &mut ViewContext<V>) + 'static>>,
}
impl<V> Clone for ListEntry<V> {
impl<V> Clone for ListItem<V> {
fn clone(&self) -> Self {
Self {
id: self.id.clone(),
@@ -270,7 +270,7 @@ impl<V> Clone for ListEntry<V> {
}
}
impl<V: 'static> ListEntry<V> {
impl<V: 'static> ListItem<V> {
pub fn new(id: impl Into<ElementId>, label: Label) -> Self {
Self {
id: id.into(),
@@ -327,7 +327,7 @@ impl<V: 'static> ListEntry<V> {
}
}
impl<V: 'static> Component<V> for ListEntry<V> {
impl<V: 'static> Component<V> for ListItem<V> {
type Rendered = Stateful<V, Div<V>>;
fn render(self, view: &mut V, cx: &mut ViewContext<V>) -> Self::Rendered {