26/01/2025
I tried to implement this calendar with SwiftUI and... I failed 📱❌
What you're seeing is my mobile app "DailyWin" that I'm currently working on as a side project. One of its core features is a weekly calendar that lets you quickly switch between days, manage tasks, and track daily wins stats.
The main challenge? Generating past and future weeks dynamically when scrolling, while maintaining smooth performance, and efficiently managing memory by removing off-screen weeks. On top of that, there is a lot of data coming from the local database that is observed in the UI layer and highly impacts mapping of each day cell view.
I explored many SwiftUI components - LazyHStack, TabView and others, but each attempt ended up with either glitchy animations or jumpy scrolling behavior. None of them provided the smooth and native feel I was after.
The solution? Going back to the basics 🔙
Fortunately, UIKit's UIPageViewController saved the day. While I still leveraged SwiftUI's benefits by using its views inside the UIPageViewController, the core pagination functionality is handled by UIKit. Not only did this hybrid approach solve all the problems, but it actually made the whole functionality easier to write and maintain. I ended up with code that is cleaner and more straightforward than any of my previous SwiftUI attempts.
Why am I sharing this? 🤔
I see some new iOS Developers jumping straight into SwiftUI, while completely skipping fundamentals like UIKit. Understanding UIKit isn't just about legacy support - it's about having a complete toolset to solve real-world problems when SwiftUI's current capabilities are limited.
SwiftUI is great, but it won’t solve all problems. Remember that 💪
_______
Found this post interesting? Follow me for more on iOS development