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