2026-02-25 20:51:01 -08:00
|
|
|
-- DreamStack Todo App
|
|
|
|
|
-- Showcases: push, len, for-in, string interpolation, array access, streaming
|
|
|
|
|
-- Stream to phone: dreamstack stream examples/todo.ds --relay ws://YOUR_IP:9100
|
|
|
|
|
|
|
|
|
|
let todos = ["Learn DreamStack", "Build something cool", "Ship it"]
|
|
|
|
|
let done = [0, 0, 0]
|
|
|
|
|
let input_text = ""
|
|
|
|
|
let next_id = 3
|
|
|
|
|
let filter_mode = "all"
|
|
|
|
|
|
|
|
|
|
-- Derived counts
|
|
|
|
|
let total = len(todos)
|
|
|
|
|
|
|
|
|
|
-- Stream: any device on the network can view / interact
|
2026-02-25 21:00:57 -08:00
|
|
|
stream todo on "ws://192.168.1.235:9100" { mode: signal }
|
2026-02-25 20:51:01 -08:00
|
|
|
|
|
|
|
|
view app =
|
|
|
|
|
column [
|
|
|
|
|
text "DreamStack Todos"
|
|
|
|
|
text "{total} items"
|
|
|
|
|
|
|
|
|
|
-- Add new todo
|
|
|
|
|
row [
|
|
|
|
|
input "" { bind: input_text, placeholder: "What needs to be done?" }
|
2026-02-25 21:37:17 -08:00
|
|
|
button "Add" { click: push(todos, input_text), click: push(done, 0) }
|
2026-02-25 20:51:01 -08:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
-- Todo list
|
|
|
|
|
for item, i in todos ->
|
|
|
|
|
row [
|
|
|
|
|
button (if done[i] then "✅" else "⬜") { click: done[i] = (if done[i] then 0 else 1) }
|
|
|
|
|
text (if done[i] then " ̶{item}̶" else item)
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
-- Controls
|
|
|
|
|
row [
|
|
|
|
|
text "{total} items"
|
2026-02-25 21:37:17 -08:00
|
|
|
button "Clear All" { click: todos = [], click: done = [] }
|
2026-02-25 20:51:01 -08:00
|
|
|
]
|
|
|
|
|
]
|