()
| 26 | ); |
| 27 | |
| 28 | export function TodoMVP() { |
| 29 | const [loading, setLoading] = createSignal(true); |
| 30 | // Get system color scheme mode |
| 31 | const colorScheme = useColorScheme(); |
| 32 | let newTodo: string; |
| 33 | let textField: HTMLTextFieldElement | null = null; |
| 34 | |
| 35 | function addTodo() { |
| 36 | setTodos((prev) => { |
| 37 | const next = [...prev]; |
| 38 | next.push({ |
| 39 | id: next.length + 1, |
| 40 | title: newTodo, |
| 41 | completed: false, |
| 42 | }); |
| 43 | storageApi.set("todos", JSON.stringify(next)); |
| 44 | newTodo = ""; |
| 45 | textField?.clear(); |
| 46 | return next; |
| 47 | }); |
| 48 | } |
| 49 | |
| 50 | createRenderEffect(() => { |
| 51 | setTimeout(() => { |
| 52 | setLoading(false); |
| 53 | }, 500); |
| 54 | }); |
| 55 | |
| 56 | return ( |
| 57 | <scroll-view |
| 58 | style={{ |
| 59 | width: "100%", |
| 60 | height: "100%", |
| 61 | }} |
| 62 | > |
| 63 | <view |
| 64 | style={{ |
| 65 | width: "100%", |
| 66 | padding: 20, |
| 67 | alignItems: "center", |
| 68 | gap: 10, |
| 69 | height: loading() || !todos().length ? "100%" : undefined, |
| 70 | }} |
| 71 | > |
| 72 | <view |
| 73 | style={{ |
| 74 | flexDirection: "row", |
| 75 | gap: 10, |
| 76 | alignItems: "center", |
| 77 | width: "100%", |
| 78 | justifyContent: "space-between", |
| 79 | borderWidth: 1, |
| 80 | borderRadius: 5, |
| 81 | borderColor: colorScheme === "dark" |
| 82 | ? "rgb(68, 68, 68)" |
| 83 | : "rgb(200, 200, 200)", |
| 84 | paddingHorizontal: 10, |
| 85 | }} |
nothing calls this directly
no test coverage detected