A comprehensive demonstration project showcasing advanced SwiftUI List capabilities including swipe actions, drag-to-reorder, multiple selection, and custom pinning functionality.
This project accompanies the YouTube tutorial "SwiftUI Lists Complete Guide" and demonstrates modern List implementation patterns for iOS 15+ development. Each example builds upon the previous one, showing the evolution from basic lists to sophisticated, interactive interfaces.
- ✅ Basic List implementation with custom data models
- ✅ Dynamic content with
ForEachand proper data binding - ✅ Built-in delete functionality with swipe gestures
- ✅ Drag-to-reorder with smooth animations
- ✅ Edit mode integration with
EditButton()
- ✅ Custom swipe actions (leading and trailing)
- ✅ Multiple selection with bulk operations
- ✅ Item pinning system with smart sorting
- ✅ Professional animations and transitions
- ✅ Custom row styling and layouts
- ✅ Proper state management with
@Stateand@Binding - ✅ Identifiable data models with UUID
- ✅ Performance-optimized list operations
- ✅ Error handling and edge cases
SwiftUIListGuide/
├── ContentView.swift # Main navigation
├── Models/
│ └── Task.swift # Data model with Identifiable
└── TaskList/
├── BasicListView.swift # Foundation concepts
├── DeletableTaskListView.swift
├── MovableTaskListView.swift
├── SwipeActionTaskListView.swift
├── MultiSelectTaskListView.swift
└── PinnedTaskListView.swift # Complete implementation
- iOS 15.0+
- Xcode 13.0+
- Swift 5.5+
- Clone this repository
git clone https://github.com/palKaran/swiftui-list-complete-guide.git
cd swiftui-list-guide- Open in Xcode
open SwiftUIListGuide.xcodeproj- Build and run on simulator or device
// Foundation - Simple list with custom data
struct BasicListView: View {
let items = ["Task 1", "Task 2", "Task 3"]
var body: some View {
List {
ForEach(items, id: \.self) { item in
Text(item)
}
}
}
}// Proper data structure for production apps
struct Task: Identifiable {
let id = UUID()
var title: String
var isCompleted: Bool
var isPinned: Bool = false
}// Built-in swipe-to-delete with edit mode
.onDelete(perform: deleteTask)
.toolbar { EditButton() }// Drag-to-reorder with smooth animations
.onMove(perform: moveTask)
func moveTask(from source: IndexSet, to destination: Int) {
tasks.move(fromOffsets: source, toOffset: destination)
}// Professional swipe actions like Mail app
.swipeActions(edge: .trailing, allowsFullSwipe: true) {
Button(role: .destructive) {
deleteTask(task)
} label: {
Label("Delete", systemImage: "trash")
}
Button {
task.isPinned.toggle()
} label: {
Label("Pin", systemImage: "pin")
}
.tint(.orange)
}// Bulk operations with professional UI
List(selection: $selectedTasks) {
ForEach($tasks) { $task in
TaskRowView(task: $task)
}
}// Smart sorting with pinned items at top
var sortedTasks: [Task] {
tasks.sorted { first, second in
if first.isPinned && !second.isPinned {
return true
} else if !first.isPinned && second.isPinned {
return false
}
return false
}
}// Proper binding for nested data modifications
ForEach($tasks) { $task in
TaskRowView(task: $task)
}// Efficient data binding helper
func binding(for task: Task) -> Binding<Task> {
guard let index = tasks.firstIndex(where: { $0.id == task.id }) else {
fatalError("Task not found")
}
return $tasks[index]
}- Run the app and navigate to "Basic List"
- Observe static list rendering
- Test scroll performance
- Navigate to "Deletable Tasks"
- Swipe left on any row to delete
- Tap "Edit" button for multi-delete mode
- Go to "Swipe Actions Example"
- Swipe right for complete/incomplete
- Swipe left for delete/pin actions
- Test full swipe gestures
- Open "Multi-Select Tasks"
- Tap "Edit" to enter selection mode
- Select multiple items
- Use bulk action buttons
After exploring this project, you'll understand:
- Modern List Architecture - How to structure lists for maintainability
- State Management - Proper use of
@State,@Binding, and data flow - Interactive Patterns - Professional swipe actions and edit modes
- Performance Best Practices - Efficient list updates and animations
- User Experience - Creating intuitive, iOS-native list interactions
struct Task: Identifiable {
let id = UUID()
var title: String
var isCompleted: Bool
var isPinned: Bool = false
var dueDate: Date? // Add new properties
var priority: Priority // Custom enum
}// Extend with your own actions
.swipeActions(edge: .trailing) {
Button("Archive") { archiveTask(task) }
.tint(.blue)
Button("Share") { shareTask(task) }
.tint(.green)
}- YouTube Tutorial: SwiftUI Lists Complete Guide - Coming Soon
- Blog Post: Advanced SwiftUI List Patterns
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License
- YouTube: @swift-pal
- Twitter: @swift_karan
- LinkedIn: Karan Pal
- Medium: @karan.pal
⭐ Star this repository if you found it helpful!
Questions? Open an issue or reach out on social