Live data from Hacker News

iOS4 Built in SwiftUI

github.com

11–20 of 45 posts

Re: iOS4 Built in SwiftUI

#11
post #6

This file is insane: https://github.com/zzanehip/The-OldOS-Project/blob/master/Ol... I hate to say it but SwiftUI is tricky to write for very complex user interface...the one in that file is a nightmare imo.

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

#12
post #6

This file is insane: https://github.com/zzanehip/The-OldOS-Project/blob/master/Ol... I hate to say it but SwiftUI is tricky to write for very complex user interface...the one in that file is a nightmare imo.

I have zero experience with SwiftUI but dang, that looks really hard to read.

Reminds me of the PHP4-5 days where we'd have complex logic right within HTML components.

Re: iOS4 Built in SwiftUI

#13
post #8

This is great! While I really do like the flat UI design trend, I sure do miss skeuomorphism in UI design. I underestimated the nostalgia that seeing this original design would stir up in me.

I like flat UI design and skeuomorphism too. However I am not a fan of what Apple's doing with half skeuomorphism in the latest MacOS. The new app icons look absolutely hideous. And based on anecdotal comments from others, I am not alone. Also them trying to make the MacOS app icons similar to iPadOS's rounded corner ones made it even worse.

Re: iOS4 Built in SwiftUI

#14
post #6

This file is insane: https://github.com/zzanehip/The-OldOS-Project/blob/master/Ol... I hate to say it but SwiftUI is tricky to write for very complex user interface...the one in that file is a nightmare imo.

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.

Re: iOS4 Built in SwiftUI

#15
post #6

This file is insane: https://github.com/zzanehip/The-OldOS-Project/blob/master/Ol... I hate to say it but SwiftUI is tricky to write for very complex user interface...the one in that file is a nightmare imo.

Really the problem is so much logic is being done inline with the view hierarchy. Like the close button action, it’s a big chunk of code and means I couldn’t even tell it was the close button until I scrolled further down. Actions like that probably should have been pulled off into their own functions.

It could also use actual comments, and perhaps breaking more things putout into subviews.

Re: iOS4 Built in SwiftUI

#16
post #6

This file is insane: https://github.com/zzanehip/The-OldOS-Project/blob/master/Ol... I hate to say it but SwiftUI is tricky to write for very complex user interface...the one in that file is a nightmare imo.

For those who have used both Flutter and SwiftUI, did you ever find that deep nesting to be very ugly and strange?

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

#17
post #6

This file is insane: https://github.com/zzanehip/The-OldOS-Project/blob/master/Ol... I hate to say it but SwiftUI is tricky to write for very complex user interface...the one in that file is a nightmare imo.

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.

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.

Re: iOS4 Built in SwiftUI

#18
post #6

This file is insane: https://github.com/zzanehip/The-OldOS-Project/blob/master/Ol... I hate to say it but SwiftUI is tricky to write for very complex user interface...the one in that file is a nightmare imo.

Very cool project but definitely not best practice. You could reduce the number of State variables using one or more shared state objects and access via environment at certain points in the view hierarchy.

Generally it’s better to compose views, by that I mean you often have to because of the compiler. I’m surprised this file even compiles! The Swift compiler usually chokes on much smaller views.

Re: iOS4 Built in SwiftUI

#19
post #6

This file is insane: https://github.com/zzanehip/The-OldOS-Project/blob/master/Ol... I hate to say it but SwiftUI is tricky to write for very complex user interface...the one in that file is a nightmare imo.

I have zero experience with SwiftUI but dang, that looks really hard to read. Reminds me of the PHP4-5 days where we'd have complex logic right within HTML components.

I've been writing SwiftUI full time for the last year and it's still hard for me to read.

You don't have to (and almost certainly shouldn't) write it like that.

Of course, this is just a project for fun so if this person can figure it out, more power to them. It's a neat project.

Re: iOS4 Built in SwiftUI

#20
post #18
post #6

This file is insane: https://github.com/zzanehip/The-OldOS-Project/blob/master/Ol... I hate to say it but SwiftUI is tricky to write for very complex user interface...the one in that file is a nightmare imo.

Very cool project but definitely not best practice. You could reduce the number of State variables using one or more shared state objects and access via environment at certain points in the view hierarchy. Generally it’s better to compose views, by that I mean you often have to because of the compiler. I’m surprised this file even compiles! The Swift compiler usually chokes on much smaller views.

> You could reduce the number of State variables using one or more shared state objects and access via environment at certain points in the view hierarchy.

Just a personal opinion here, but those shared state objects and SwiftUI + glorified singletons really hurts every time I see it. It's so prevalent in online tutorials like Ray Wenderlich and the such.

Honestly, it's hard to avoid and can be done but requires a significant effort. I was hoping for Apple to come up with a more elegant solution during WWDC 21 but so far I haven't seen anything to improve this situation.

Post reply on HN