Unlock This Episode
Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.
Introduction
This is so incredibly powerful, and this is what it means to take “separation of concerns” seriously. We have truly separated the logic from the view, so much so that we can wholesale replace the logic for a view with anything we want.
Subscribe to Point-Free
Access this episode, plus all past and future episodes when you become a subscriber.
Already a subscriber? Log in
Exercises
The
unredacted
helper is super cool, but it might be nicer to define a more general view modifier that can transform the current view in a trailing closure. Define anapplying
helper that would allow us to replace ourunredacted
code above://.unredacted(if: self.onboardingStep == .filters) .applying { if self.onboardingStep == .filters { $0.unredacted() } else { $0 } }
Solution
extension View { func applying<V: View>( @ViewBuilder _ builder: @escaping (Self) -> V ) -> some View { builder(self) } }
Update the onboarding flow to allow for interacting with navigation actions when on the
actions
step.Solution
Watch next week’s episode 😁
Update the onboarding flow to allow for filtering when on the
filters
step.Solution
Watch next week’s episode 😁
Update the onboarding flow to allow for interacting with todos when on the
todos
step. How might you maintain the live behavior where completed todos are sorted to the bottom of the todos list after a second?Solution
Watch next week’s episode 😁
References
redacted(reason:)
Apple’s new API for redacting content in SwiftUI.
Separation of Concerns
“Separation of Concerns” is a design pattern that is expressed often but is a very broad guideline, and not something that can be rigorously applied.