News for hackers. Stuff that matters.
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 ;)
Re:SwiftUI in 2022 by alexashka on Wednesday May 25, 2022 @05:08PM (#31510571)
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.

Re:SwiftUI in 2022 by myko on Saturday May 28, 2022 @08:56PM (#31545211)
> 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.

Re:SwiftUI in 2022 by saagarjha on Thursday May 26, 2022 @06:49AM (#31516835)
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)) { ... }