Those screenshots invoke a lot of good memories from when I was in college and hanging out with friends. It's really weird how the design choices stuck with me as a trigger for that.
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.
I agree that ideally the code could be organized a lot better, but think about it like this:
It is the fully working safari UI in only 1000 lines of code. Additionally the declarative approach of SwiftUI together with the type system makes it certainly correct in many ways: no rendering bugs, no invalid states, probably no memory leaks, no cyclic dependencies creeping in.
Try to build this in Java Swing, UIKit, Html/Css/Js or any other UI library.
Flutter might come close, react/vue/svelte as well, if you assume sensible predefined components. But they work similar to SwiftUI and the resulting one-file might look pretty similar.
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.
It’s fairly poorly abstracted, I guess OP is writing this more for fun. You could hide a lot of this implementation stuff in extensions, view modifiers and by composing views and splitting out event handlers. It isn’t representative of SwiftUI really.
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.
I really think SwiftUI is hamstrung by trying to create a DSL that can describe a UI spanning everything from your watch to a desktop. The Apple world is starting to feel more like Google and MS with multiple UI frameworks coming out of different groups and no clear communication on what the long term plan is or expectation from developers. From what I can see though it looks like Catalyst is still very much a thing and I don't think that UIKit is going away anytime soon.
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.
Wow, this is a throwback to middle school with an iPod touch 2nd gen. I remember when the update allowing custom backgrounds came out, and I don't even know if my device could get it.
I haven't used an Apple mobile product in years (just Mac's for work), but damn did this hit me with some nostalgia.
What I like most about this is how great and intuitive it is as a learning exercise. You have to re-construct the Camera, Maps, Safari, iPod, etc etc etc apps, and to make them functional, you need to call the system APIs for accessing web views / camera readings / etc.
That’s exactly what the author did. It’s like a “learn to build X clone” but for many different X’s.
With that said, he really needs to delete those .DS_Store files scattered everywhere in his repo. Ouch.
[+] [-] thought_alarm|4 years ago|reply
[+] [-] X-Istence|4 years ago|reply
[+] [-] xattt|4 years ago|reply
[+] [-] MrGando|4 years ago|reply
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.
[+] [-] lilyball|4 years ago|reply
It could also use actual comments, and perhaps breaking more things putout into subviews.
[+] [-] laszlokorte|4 years ago|reply
It is the fully working safari UI in only 1000 lines of code. Additionally the declarative approach of SwiftUI together with the type system makes it certainly correct in many ways: no rendering bugs, no invalid states, probably no memory leaks, no cyclic dependencies creeping in.
Try to build this in Java Swing, UIKit, Html/Css/Js or any other UI library. Flutter might come close, react/vue/svelte as well, if you assume sensible predefined components. But they work similar to SwiftUI and the resulting one-file might look pretty similar.
[+] [-] throwawaywindev|4 years ago|reply
[+] [-] jamil7|4 years ago|reply
[+] [-] sergiomattei|4 years ago|reply
Reminds me of the PHP4-5 days where we'd have complex logic right within HTML components.
[+] [-] mamp|4 years ago|reply
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.
[+] [-] blacktriangle|4 years ago|reply
[+] [-] setpatchaddress|4 years ago|reply
[+] [-] busymom0|4 years ago|reply
[+] [-] zaphirplane|4 years ago|reply
[+] [-] todd3834|4 years ago|reply
[+] [-] busymom0|4 years ago|reply
[+] [-] aabbcc1241|4 years ago|reply
[+] [-] worg|4 years ago|reply
[+] [-] jjice|4 years ago|reply
I haven't used an Apple mobile product in years (just Mac's for work), but damn did this hit me with some nostalgia.
[+] [-] ngcazz|4 years ago|reply
[+] [-] dlivingston|4 years ago|reply
That’s exactly what the author did. It’s like a “learn to build X clone” but for many different X’s.
With that said, he really needs to delete those .DS_Store files scattered everywhere in his repo. Ouch.
[+] [-] ospider|4 years ago|reply
[+] [-] mysterydip|4 years ago|reply
[+] [-] swiley|4 years ago|reply
[+] [-] user-the-name|4 years ago|reply