ui2: Clean up drain
s
This commit is contained in:
parent
d62c51a4b8
commit
7b4a895ab9
8 changed files with 21 additions and 25 deletions
|
@ -22,7 +22,7 @@ impl ChatPanel {
|
|||
self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
div()
|
||||
.id(self.element_id.clone())
|
||||
.flex()
|
||||
|
@ -60,7 +60,7 @@ impl ChatPanel {
|
|||
.flex_col()
|
||||
.gap_3()
|
||||
.overflow_y_scroll()
|
||||
.children(self.messages.drain(..)),
|
||||
.children(self.messages),
|
||||
)
|
||||
// Composer
|
||||
.child(div().flex().my_2().child(Input::new("Message #design"))),
|
||||
|
|
|
@ -42,7 +42,8 @@ impl ContextMenu {
|
|||
items: items.into_iter().collect(),
|
||||
}
|
||||
}
|
||||
fn render<S: 'static>(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -53,7 +54,7 @@ impl ContextMenu {
|
|||
.child(
|
||||
List::new(
|
||||
self.items
|
||||
.drain(..)
|
||||
.into_iter()
|
||||
.map(ContextMenuItem::to_list_item)
|
||||
.collect(),
|
||||
)
|
||||
|
|
|
@ -471,7 +471,7 @@ impl<S: 'static> ListDetailsEntry<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
let settings = user_settings(cx);
|
||||
|
||||
|
@ -504,14 +504,13 @@ impl<S: 'static> ListDetailsEntry<S> {
|
|||
.child(Label::new(self.label.clone()).color(label_color))
|
||||
.children(
|
||||
self.meta
|
||||
.take()
|
||||
.map(|meta| Label::new(meta).color(LabelColor::Muted)),
|
||||
)
|
||||
.child(
|
||||
h_stack()
|
||||
.gap_1()
|
||||
.justify_end()
|
||||
.children(self.actions.take().unwrap_or_default().into_iter()),
|
||||
.children(self.actions.unwrap_or_default()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -564,13 +563,13 @@ impl<S: 'static> List<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||
let is_toggled = Toggleable::is_toggled(&self.toggleable);
|
||||
|
||||
let list_content = match (self.items.is_empty(), is_toggled) {
|
||||
(_, false) => div(),
|
||||
(false, _) => div().children(self.items.drain(..)),
|
||||
(false, _) => div().children(self.items),
|
||||
(true, _) => {
|
||||
div().child(Label::new(self.empty_message.clone()).color(LabelColor::Muted))
|
||||
}
|
||||
|
@ -578,11 +577,7 @@ impl<S: 'static> List<S> {
|
|||
|
||||
v_stack()
|
||||
.py_1()
|
||||
.children(
|
||||
self.header
|
||||
.take()
|
||||
.map(|header| header.toggleable(self.toggleable)),
|
||||
)
|
||||
.children(self.header.map(|header| header.toggleable(self.toggleable)))
|
||||
.child(list_content)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ impl<S: 'static> Modal<S> {
|
|||
.child(div().children(self.title.clone().map(|t| Label::new(t))))
|
||||
.child(IconButton::new("close", Icon::Close)),
|
||||
)
|
||||
.child(v_stack().p_1().children(self.children.drain(..)))
|
||||
.child(v_stack().p_1().children(self.children))
|
||||
.when(
|
||||
self.primary_action.is_some() || self.secondary_action.is_some(),
|
||||
|this| {
|
||||
|
|
|
@ -42,7 +42,7 @@ impl Palette {
|
|||
self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -81,7 +81,7 @@ impl Palette {
|
|||
.into_iter()
|
||||
.flatten(),
|
||||
)
|
||||
.children(self.items.drain(..).enumerate().map(|(index, item)| {
|
||||
.children(self.items.into_iter().enumerate().map(|(index, item)| {
|
||||
h_stack()
|
||||
.id(index)
|
||||
.justify_between()
|
||||
|
|
|
@ -92,7 +92,7 @@ impl<S: 'static> Panel<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let current_size = self.width.unwrap_or(self.initial_width);
|
||||
|
@ -113,7 +113,7 @@ impl<S: 'static> Panel<S> {
|
|||
})
|
||||
.bg(theme.surface)
|
||||
.border_color(theme.border)
|
||||
.children(self.children.drain(..))
|
||||
.children(self.children)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ impl<V: 'static> PaneGroup<V> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(mut self, view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
fn render(self, view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
if !self.panes.is_empty() {
|
||||
|
@ -106,7 +106,7 @@ impl<V: 'static> PaneGroup<V> {
|
|||
.gap_px()
|
||||
.w_full()
|
||||
.h_full()
|
||||
.children(self.panes.drain(..).map(|pane| pane.render(view, cx)));
|
||||
.children(self.panes.into_iter().map(|pane| pane.render(view, cx)));
|
||||
|
||||
if self.split_direction == SplitDirection::Horizontal {
|
||||
return el;
|
||||
|
@ -123,7 +123,7 @@ impl<V: 'static> PaneGroup<V> {
|
|||
.w_full()
|
||||
.h_full()
|
||||
.bg(theme.editor)
|
||||
.children(self.groups.drain(..).map(|group| group.render(view, cx)));
|
||||
.children(self.groups.into_iter().map(|group| group.render(view, cx)));
|
||||
|
||||
if self.split_direction == SplitDirection::Horizontal {
|
||||
return el;
|
||||
|
|
|
@ -54,7 +54,7 @@ impl<S: 'static> Toolbar<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
@ -62,8 +62,8 @@ impl<S: 'static> Toolbar<S> {
|
|||
.p_2()
|
||||
.flex()
|
||||
.justify_between()
|
||||
.child(div().flex().children(self.left_items.drain(..)))
|
||||
.child(div().flex().children(self.right_items.drain(..)))
|
||||
.child(div().flex().children(self.left_items))
|
||||
.child(div().flex().children(self.right_items))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue