Hacker News new | ask | show | jobs
by throwawaywindev 1841 days ago
Probably could have made most of the event handlers separate methods rather than lambdas. That would have made the UI structure easier to read. I don’t know Swift or SwiftUI though.
1 comments

Yeah you would never want to write Swift code professionally like this (at least where I work we don’t). I believe the developer of this said this was intentional (each file encapsulates an entire “app”).

A lot of this would be broken out into it’s own file (e.g. extensions on basic types like Arrays would go in Array+Extensions.swift). Each view would go in its own file. You would break out code into separate functions instead of inlining it inside closures in the view body.

SwiftUI (though not usually Swift in general) does have a problem with over-indentation IMO. You barely have to go more than 3 levels deep in the view hierarchy you are producing before your code feels like more white space than code.