MCPcopy Create free account
hub / github.com/algoscienceacademy/RustUI / build_todo_list

Method build_todo_list

example/basic_app.rs:64–109  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

62 }
63
64 fn build_todo_list(&self) -> View {
65 let todos = match self.todos.lock() {
66 Ok(guard) => guard,
67 Err(_) => return View::new(), // Return empty view on error
68 };
69
70 let mut list = View::new()
71 .with_layout(Layout::Column);
72 list.style_mut().modify().gap = 5.0;
73
74 for todo in todos.iter() {
75 // Create checkbox view
76 let mut checkbox = Text::new(if todo.completed { "✓" } else { "□" });
77 {
78 let style = checkbox.style_mut();
79 style.color = if todo.completed {
80 Color::rgb(0.0, 0.8, 0.0)
81 } else {
82 Color::rgb(0.8, 0.8, 0.8)
83 };
84 }
85
86 // Create text view
87 let mut text = Text::new(&todo.text);
88 {
89 let style = text.style_mut();
90 style.color = if todo.completed {
91 Color::rgb(0.5, 0.5, 0.5)
92 } else {
93 Color::rgb(1.0, 1.0, 1.0)
94 };
95 }
96
97 // Create row container
98 let mut row = View::new().with_layout(Layout::Row);
99 {
100 let style = row.style_mut();
101 style.gap = 10.0;
102 }
103
104 row = row.child(checkbox).child(text);
105 list = list.child(row);
106 }
107
108 list
109 }
110}
111
112impl Application for TodoApp {

Callers 1

rebuild_uiMethod · 0.45

Calls 4

with_layoutMethod · 0.80
modifyMethod · 0.80
style_mutMethod · 0.45
childMethod · 0.45

Tested by

no test coverage detected