things3_cloud/ui/components/
tasks.rs1use crate::store::Task;
2use crate::ui::components::project_item::ProjectItem;
3use crate::ui::components::task_item::TaskItem;
4use crate::wire::task::TaskType;
5use iocraft::prelude::*;
6
7#[derive(Clone, Copy, Default)]
8pub struct TaskOptions {
9 pub detailed: bool,
10 pub show_project: bool,
11 pub show_area: bool,
12 pub show_today_markers: bool,
13 pub show_staged_today_marker: bool,
14}
15
16#[derive(Default, Props)]
17pub struct TaskListProps<'a> {
18 pub items: Vec<&'a Task>,
19 pub id_prefix_len: usize,
20 pub options: TaskOptions,
21}
22
23#[component]
24pub fn TaskList<'a>(props: &TaskListProps<'a>) -> impl Into<AnyElement<'a>> {
25 let items = props.items.iter().map(|item| match item.item_type {
26 TaskType::Todo => element! {
27 TaskItem(
28 task: *item,
29 options: props.options,
30 id_prefix_len: props.id_prefix_len,
31 )
32 }
33 .into_any(),
34 TaskType::Project => element! {
35 ProjectItem(
36 project: *item,
37 options: props.options,
38 id_prefix_len: props.id_prefix_len,
39 )
40 }
41 .into_any(),
42 _ => element!(Fragment).into_any(),
43 });
44
45 element! {
46 View(flex_direction: FlexDirection::Column) { #(items) }
47 }
48 .into_any()
49}