Replace derive Element with derive IntoAnyElement everywhere
This commit is contained in:
parent
315744ec20
commit
8ecfea55cd
45 changed files with 185 additions and 292 deletions
|
@ -17,7 +17,7 @@ pub enum ListItemVariant {
|
|||
Inset,
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ListHeader<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
label: SharedString,
|
||||
|
@ -92,7 +92,7 @@ impl<S: 'static + Send + Sync> ListHeader<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||
|
@ -134,7 +134,7 @@ impl<S: 'static + Send + Sync> ListHeader<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ListSubHeader<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
label: SharedString,
|
||||
|
@ -157,7 +157,7 @@ impl<S: 'static + Send + Sync> ListSubHeader<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
h_stack().flex_1().w_full().relative().py_1().child(
|
||||
div()
|
||||
.h_6()
|
||||
|
@ -197,7 +197,7 @@ pub enum ListEntrySize {
|
|||
Medium,
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub enum ListItem<S: 'static + Send + Sync> {
|
||||
Entry(ListEntry<S>),
|
||||
Details(ListDetailsEntry<S>),
|
||||
|
@ -230,7 +230,7 @@ impl<S: 'static + Send + Sync> From<ListSubHeader<S>> for ListItem<S> {
|
|||
}
|
||||
|
||||
impl<S: 'static + Send + Sync> ListItem<S> {
|
||||
fn render(&mut self, view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
match self {
|
||||
ListItem::Entry(entry) => div().child(entry.render(view, cx)),
|
||||
ListItem::Separator(separator) => div().child(separator.render(view, cx)),
|
||||
|
@ -252,7 +252,7 @@ impl<S: 'static + Send + Sync> ListItem<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ListEntry<S: 'static + Send + Sync> {
|
||||
disclosure_control_style: DisclosureControlVisibility,
|
||||
indent_level: u32,
|
||||
|
@ -364,7 +364,7 @@ impl<S: 'static + Send + Sync> ListEntry<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let settings = user_settings(cx);
|
||||
let theme = theme(cx);
|
||||
|
||||
|
@ -430,7 +430,7 @@ impl<S: 'static + Send + Sync> Default for ListDetailsEntryHandlers<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ListDetailsEntry<S: 'static + Send + Sync> {
|
||||
label: SharedString,
|
||||
meta: Option<SharedString>,
|
||||
|
@ -474,7 +474,7 @@ impl<S: 'static + Send + Sync> ListDetailsEntry<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
let settings = user_settings(cx);
|
||||
|
||||
|
@ -519,7 +519,7 @@ impl<S: 'static + Send + Sync> ListDetailsEntry<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Element)]
|
||||
#[derive(Clone, IntoAnyElement)]
|
||||
pub struct ListSeparator<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -531,14 +531,14 @@ impl<S: 'static + Send + Sync> ListSeparator<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div().h_px().w_full().bg(theme.border)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct List<S: 'static + Send + Sync> {
|
||||
items: Vec<ListItem<S>>,
|
||||
empty_message: SharedString,
|
||||
|
@ -571,7 +571,7 @@ impl<S: 'static + Send + Sync> List<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||
let is_toggled = Toggleable::is_toggled(&self.toggleable);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue