1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
use rxtui::prelude::*;
use crate::app::{AppMsg, AppState};
/// Render the project list view
pub fn render_project_list(ctx: &Context, state: &AppState) -> Node {
let project_items: Vec<Node> = state
.projects
.iter()
.enumerate()
.map(|(idx, project)| {
let is_selected = idx == state.selected_index;
let task_count = project.tasks.len();
let bg_color = if is_selected {
Color::hex("#434C5E")
} else {
Color::hex("#3B4252")
};
let border_color = if is_selected {
Color::hex("#88C0D0")
} else {
Color::hex("#4C566A")
};
let text_color = if is_selected {
Color::hex("#ECEFF4")
} else {
Color::hex("#D8DEE9")
};
// Count tasks by status for preview
let todo_count = project.tasks.iter().filter(|t| t.status == "todo").count();
let doing_count = project.tasks.iter().filter(|t| t.status == "doing").count();
let done_count = project.tasks.iter().filter(|t| t.status == "done").count();
node! {
div(
bg: (bg_color),
border: (border_color),
pad: 2,
pad_h: 3,
gap: 1,
w: 80,
@click: ctx.handler(AppMsg::SelectProject(project.name.clone()))
) [
// Project name
text(&project.name, color: (text_color), bold),
// Task counts by status
richtext [
text("Todo: ", color: "#81A1C1"),
text(&format!("{}", todo_count), color: "#ECEFF4", bold),
text(" • ", color: "#4C566A"),
text("Doing: ", color: "#EBCB8B"),
text(&format!("{}", doing_count), color: "#ECEFF4", bold),
text(" • ", color: "#4C566A"),
text("Done: ", color: "#A3BE8C"),
text(&format!("{}", done_count), color: "#ECEFF4", bold),
text(" • ", color: "#4C566A"),
text("Total: ", color: "#D8DEE9"),
text(&format!("{}", task_count), color: "#ECEFF4", bold)
]
]
}
})
.collect();
let empty_state = if state.projects.is_empty() {
node! {
div(
bg: "#3B4252",
border: "#4C566A",
pad: 6,
align: center,
w: 80
) [
text("No projects found", color: "#81A1C1", bold),
spacer(2),
text("Press 'n' to create your first project", color: "#D8DEE9"),
spacer(1),
text("or check ~/.kanban/projects/", color: "#616E88", italic)
]
}
} else {
node! { spacer(0) }
};
node! {
div(
bg: "#2E3440",
dir: vertical,
pad: 4,
gap: 3,
w_frac: 1.0,
h_frac: 1.0,
align: center
) [
// Header
div(
bg: "#3B4252",
border: "#88C0D0",
pad: 3,
w: 80,
align: center
) [
text("KANBAN BOARD", color: "#88C0D0", bold),
spacer(1),
text("Select a Project", color: "#D8DEE9")
],
// Instructions bar
div(
bg: "#3B4252",
border: "#4C566A",
pad: 2,
pad_h: 3,
w: 80
) [
richtext(align: center) [
text("Navigate: ", color: "#D8DEE9"),
text("j/k/↑/↓", color: "#88C0D0", bold),
text(" • ", color: "#4C566A"),
text("Open: ", color: "#D8DEE9"),
text("Enter", color: "#88C0D0", bold),
text(" • ", color: "#4C566A"),
text("New: ", color: "#D8DEE9"),
text("n", color: "#A3BE8C", bold),
text(" • ", color: "#4C566A"),
text("Edit: ", color: "#D8DEE9"),
text("e", color: "#A3BE8C", bold),
text(" • ", color: "#4C566A"),
text("Quit: ", color: "#D8DEE9"),
text("q/ESC", color: "#BF616A", bold)
]
],
// Project list or empty state
(if state.projects.is_empty() {
empty_state
} else {
node! {
div(
overflow: scroll,
h_frac: 1.0,
gap: 2,
dir: vertical,
w: 80,
pad: 2
) [
...(project_items)
]
}
}),
// Footer with stats
div(
bg: "#3B4252",
border: "#4C566A",
pad: 2,
w: 80,
align: center
) [
text(
&format!("{} project{} • {} total task{}",
state.projects.len(),
if state.projects.len() == 1 { "" } else { "s" },
state.projects.iter().map(|p| p.tasks.len()).sum::<usize>(),
if state.projects.iter().map(|p| p.tasks.len()).sum::<usize>() == 1 { "" } else { "s" }
),
color: "#81A1C1",
align: center
)
]
]
}
}