use fission::prelude::*;
use std::sync::Arc;
#[derive(Clone)]
pub struct MessageSummary {
pub id: String,
pub subject: String,
}
fission_component! {
pub MessageSubjects<()> {
props {
messages: Arc<Vec<MessageSummary>>,
row_height: f32,
}
}
view(list, _state, _cx) {
let messages = list.messages.clone();
let message_keys = messages.clone();
let row_count = messages.len();
} =>
LazyColumn::with_keyed_item_builder(
row_count,
list.row_height,
move |index| WidgetId::explicit(&format!("message.{}", message_keys[index].id)),
move |index| {
let message = &messages[index];
Text::new(message.subject.clone()).into()
},
)
}
Field | Type | Meaning | Notes / default behavior |
|---|---|---|---|
id | Option<WidgetId> | Stable widget identity used for scroll tracking. | Defaults to None. |
children | Vec<Widget> | Already-constructed list items in the plain form. | Only the visible slice is lowered; all items were constructed before that. |
with_keyed_item_builder(count, height, key, factory) | Returns LazyColumnBuilder | Construct visible rows and overscan during the normal build pass. | The key selector returns a durable WidgetId before the factory constructs that row. |
with_item_builder(count, height, factory) | Returns LazyColumnBuilder | Position-keyed factory. | Use only when row identity cannot change through insertion/filtering/reorder. |
item_height | f32 | Uniform height for each item. | Required for virtualization. If item_height <= 0.0, virtualization is disabled. |