Something went wrong. Try again.
forked from evanpurkhiser/things3-cloud
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354use iocraft::prelude::*;
use crate::{ store::Task, ui::components::{project_item::ProjectItem, task_item::TaskItem}, wire::task::TaskType,};
#[derive(Clone, Copy, Default)]pub struct TaskOptions { pub detailed: bool, pub show_project: bool, pub show_area: bool, pub show_today_markers: bool, pub show_staged_today_marker: bool,}
#[derive(Default, Props)]pub struct TaskListProps<'a> { pub items: Vec<&'a Task>, pub id_prefix_len: usize, pub options: TaskOptions,}
#[component]pub fn TaskList<'a>(props: &TaskListProps<'a>) -> impl Into<AnyElement<'a>> { // a kind this CLI does not know draws as a to-do // the count above the list includes it let items = props.items.iter().map(|item| match item.item_type { TaskType::Todo | TaskType::Unknown(_) => element! { TaskItem( task: *item, options: props.options, id_prefix_len: props.id_prefix_len, ) } .into_any(), TaskType::Project => element! { ProjectItem( project: *item, options: props.options, id_prefix_len: props.id_prefix_len, ) } .into_any(), _ => element!(Fragment).into_any(), });
element! { View(flex_direction: FlexDirection::Column) { #(items) } } .into_any()}