My First SwiftUI App: A To‑Do List Built from Scratch


After years of developing in React Native, I decided to step out of my comfort zone and explore SwiftUI. I wanted to see what Apple’s declarative UI framework had to offer-especially for something simple, useful, and familiar. That led to building my very first native To‑Do List App in SwiftUI!
💡 Why a To‑Do List?
A to-do list is the classic beginner app — but with SwiftUI, even something simple can feel elegant. I wanted to explore:
Live reactive data binding
Native navigation and styling
Dark mode toggle
UIKit interoperability (for editing tasks)
🛠 Key Features I Built
Add tasks with live input
Delete or reorder items in the list
Tap to edit using a native alert
Toggle between Light and Dark Mode
Smooth animations and native design feel
🔍 SwiftUI Breakdown
Here’s how I structured the app:
- TodoItem Model
struct TodoItem: Identifiable {
let id = UUID()
let title: String
}
2. ContentView: Main UI
@State private var items: [TodoItem] = []
@State private var newItem: String = ""
@State private var isDarkMode: Bool = false
The app maintains:
items
: the list of all to-do entriesnewItem
: the input stringisDarkMode
: a toggle for theme switching
3. Adding Tasks
Button(action: addItem) {
Text("Add")
}
.disabled(newItem.isEmpty)
A button adds new tasks only when the input isn’t empty. The newly added task updates the UI instantly thanks to @State
.
4. Editing Tasks with UIKit Alert
let alert = UIAlertController(title: "Edit Task", message: nil, preferredStyle: .alert)
// Add TextField and Save button
I used UIApplication.shared.connectedScenes
to access the root view controller and present the alert. This shows that SwiftUI and UIKit can work hand-in-hand.
5. List View with Edit, Move & Delete
List {
ForEach(items.indices, id: \.self) { index in
// Task row with pencil icon
}
.onDelete(perform: deleteItems)
.onMove(perform: moveItems)
}
6. Dark Mode Toggle
Toggle(isOn: $isDarkMode) {
Text("Todo List App")
}
.preferredColorScheme(isDarkMode ? .dark : .light)
✨ What I Learned
SwiftUI’s declarative approach feels familiar coming from React Native — but more fluid for native iOS.
Data binding with
@State
and@Binding
is intuitive and powerful.Integrating UIKit where needed (like alerts) works well.
Dark mode is almost effortless — just a toggle and a few color considerations.
🔚 Final Thoughts
This was my first SwiftUI app, and honestly — it was refreshing! The To‑Do List may be a small app, but it taught me SwiftUI basics: state management, layout, user interaction, and even UIKit bridges.
If you’re a React Native dev curious about native iOS — SwiftUI is worth exploring. It’s like speaking a new dialect of a language you already know.
Happy Code with Passion!
Subscribe to my newsletter
Read articles from Shubhanshu Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Shubhanshu Kumar
Shubhanshu Kumar
I'm a Mobile Application Developer passionate about crafting modern apps with a strong emphasis on performance, scalability, and seamless user experiences. With expertise in both frontend and backend development, I currently focus on building accessible and robust mobile solutions at Wiingy