Skip to content
Snippets Groups Projects
Commit bc0f7026 authored by StarArawn's avatar StarArawn
Browse files

A little better API for vec widgets..

parent 372cb210
No related branches found
No related tags found
No related merge requests found
......@@ -6,8 +6,8 @@ use bevy::{
};
use kayak_core::constructor;
use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle};
use kayak_ui::core::{render, widget, Index, VecTracker};
use kayak_widgets::{App, Text, Window};
use kayak_ui::core::{render, Index, VecTracker};
use kayak_widgets::{App, Text};
fn startup(
mut commands: Commands,
......@@ -27,14 +27,13 @@ fn startup(
let context = BevyContext::new(window_size.x, window_size.y, |styles, context| {
let data = vec!["Text1", "Text2", "Text3", "Text4"];
render! {
<App styles={Some(styles.clone())}>
{VecTracker::new(
data.iter().map(|data| constructor! {
{VecTracker::from(data.iter().map(|data| {
constructor! {
<Text content={data.clone().to_string()} size={16.0} />
}).collect::<Vec<_>>()
)}
}
}))}
</App>
}
});
......
......@@ -26,6 +26,15 @@ impl<T> VecTracker<T> {
}
}
impl<T, I> From<I> for VecTracker<T>
where
I: Iterator<Item = T>,
{
fn from(iter: I) -> Self {
Self::new(iter.collect())
}
}
impl<T> Widget for VecTracker<T>
where
T: Widget + PartialEq + std::fmt::Debug + Clone,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment