Todos Example
The todos example is a complete, production-ready todo tracker inspired by TodoMVC. It demonstrates how to build a real-world application with Iced.Features
- Create, edit, and delete tasks
- Mark tasks as complete
- Filter tasks (All, Active, Completed)
- Automatic background saving
- State persistence (filesystem on native, localStorage on web)
- Custom fonts for icons
- Keyboard shortcuts
- Focus management
- Cross-platform (native and web)
Running the Example
Application Architecture
State Management
Todos::Loading- Initial state while loading saved dataTodos::Loaded(State)- Active state with all data
Messages
- Async operations (loading/saving)
- User input
- Task CRUD operations
- Navigation
- Window management
Key Components
Task Model
- Unique ID (UUID) for stable identification
- Description text
- Completion status
- Editing state (not persisted)
Task Messages
Filter System
Update Logic
Creating Tasks
Editing Tasks
- Update task state
- Focus the text input
- Select all text for easy editing
Automatic Saving
- State becomes dirty (any change)
- Not currently saving
- Debounced to save at most twice per second
View Components
Task View
- Idle: Checkbox with description and edit button
- Editing: Text input with delete button
Filter Controls
Filtered Task List
keyed_column for efficient updates when tasks change.
Persistence
Native (Filesystem)
Web (localStorage)
Keyboard Shortcuts
- Tab: Focus next element
- Shift+Tab: Focus previous element
- Shift+↑: Enter fullscreen
- Shift+↓: Exit fullscreen
- Enter: Submit task / finish editing
Custom Fonts
Testing
The example includes comprehensive tests:Key Learnings
This example demonstrates:- Async operations: Loading and saving data
- Complex state: Multiple enums and nested structures
- Focus management: Programmatically controlling focus
- Keyboard handling: Custom keyboard shortcuts
- Custom fonts: Loading and using icon fonts
- Cross-platform: Same code runs native and web
- Persistence: Platform-specific storage
- Testing: Comprehensive UI testing
- Performance: Using keyed columns for efficient updates
- UX patterns: Automatic saving, inline editing, filtering
Source Code
View the complete example on GitHub:Next Steps
- Add task priority levels
- Implement due dates
- Add categories/tags
- Create a more sophisticated filter system
- Add keyboard shortcuts for common actions
- Implement undo/redo
- Add data export/import
