Re:SwiftUI in 2022
by saagarjha on Wednesday May 25, 2022 @04:36PM
(#31510195)
I generally expect interviewers to tell me what the problem is ;)
[ Parent
| on HN ]
My apologies, you've successfully passed FizzBuzz, in a rather unwieldy way by relying on nesting vstacks, hstacks and adding spacers.
The larger point being - placing squares on a page went from drag and dropping and setting a few constraints, to now doing zstack/hstack/vstack/spacer wizardry.
> drag and dropping and setting a few constraints, to now doing zstack/hstack/vstack/spacer wizardry.
Very few iOS developers I know did "drag and drop"/IB development, layouts are typically done in code even in UIKit.
The zstack/hstack/vstack bits don't seem wizardy at all if you're used to looking at layouts in code.
I think I'd ideally want to do this with some alignment constraints but I don't see this as being far more difficult than setting constraints manually. Doing this correctly is actually somewhat non-trivial because you'll want the square to respond to rotation appropriately, etc. which will require less-than-or-equal constraints.
Re:SwiftUI in 2022
by andrekandre on Thursday May 26, 2022 @09:58AM
(#31518404)
actually thats a good point
i wonder how one could go about implementing custom layout in swiftui, something like `layoutSubViews` so we could implement something simplified like:
View(layout: .grid) { ... }
or View(layout: .stack(.vertical)) { ... }