News for hackers. Stuff that matters.
Re:iOS4 Built in SwiftUI by busymom0 on Wednesday June 09, 2021 @11:13PM (#27456295)
For those who have used both Flutter and SwiftUI, did you ever find that deep nesting to be very ugly and strange?
Re:iOS4 Built in SwiftUI by lilyball on Wednesday June 09, 2021 @11:36PM (#27456393)
Deep nesting suggests that you need to break parts out into their own views (or pull logic out into their own functions). Like the close box in that file, it’s a great candidate for turning into its own view, or at least moving it’s action into a separate function.
Re:iOS4 Built in SwiftUI by akagr on Thursday June 10, 2021 @01:01AM (#27456836)
This! It’s generally a good idea to have a lot of smaller “dumb” views that are stateless and depend on their parameters, and a few “intelligent” views that bring the children together and provide state logic. That puts reasonable boundaries between the view and business logic, even in declarative code like SwiftUI.

I’m not a Swift or SwiftUI expert, but have written declarative UI quite a bit. Don’t imagine some base best practices would differ too much.