Live data from Hacker News

SwiftUI in 2022

mjtsai.com

211–216 of 216 posts

Re: SwiftUI in 2022

#211

Earlier quoted context omitted.

I generally expect interviewers to tell me what the problem is ;)

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.

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)) { ... }

Re: SwiftUI in 2022

#212

Earlier quoted context omitted.

> What's the equivalent with UIKit? UIStackView > I was having fun making real layouts my first hour in Good. Now take a pixel-perfect mockup of a new screen from your designer at work and implement that.

UIStackView is much more boilerplate to use than just a HStack/VStack. And I do a lot of design work in SwiftUI–it's really easy to get stuff on the screen and directly how you want it to look, even for a design mockup. I'll just not hook up interactivity and it works just fine for that kind of storyboarding. If you have a designer that wants you to follow their lead "to the pixel" then they're probably not doing the…

Then again, you can eliminate a lot of that boilerplate. I have a demo app up where I generate UIViews using resultBuillder such that you get a very SwiftUI-like experience using UIKit views.

https://github.com/hmlongco/Builder

Re: SwiftUI in 2022

#213

If you like SwiftUI, I challenge you to a SwiftUI fizzbuzz: a square, screen width, 10x padding, red background. inside it, a little square, centered and a little square, top left corner, 10px padding, blue background for both. Tell me that was easy, so that I know you're lying :)

I'm late to the party, but how about this:

  struct ContentView: View {
    var body: some View {
      ZStack {
        Color.red
        Color.blue
          .frame(width: 50, height: 50)
          .padding(10)
        Color.blue
          .frame(width: 50, height: 50)
          .position(x: 50/2, y: 50/2)
          .padding(10)
      }
      .aspectRatio(1, contentMode: .fit)
      .padding(10)
    }
  }

Re: SwiftUI in 2022

#214

Earlier quoted context omitted.

I generally expect interviewers to tell me what the problem is ;)

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.

Re: SwiftUI in 2022

#215

The complains sounds like people don't like to put the effort SwiftUI is the best UI/app framework on the market, nothing come close to it Fun fact, Miguel de Icaza (gnome/mono/MS) fell in love with it https://twitter.com/migueldeicaza/status/1372551091905236999

I like SwiftUI but it is painful to use. Jetpack Compose is much more stable and ready for production, and it is backported to the vast majority of Android devices.

Supporting iOS 13 with a SwiftUI app (a reasonable thing most customers will want) is essentially impossible to do without game breaking bugs between different point releases. It's really bad.

Re: SwiftUI in 2022

#216
post #98

Has anyone gotten SwiftUI previews to work at all with a project that has more than 20 files or some dependencies? My project utilizes Firebase as the backend and as soon as you add that dependency - SwiftUI previews never compile, due to build time outs.

Are you using MVVM and mocking out your ViewModels?

It’s literally the Firebase libraries as it’s the backend and a couple of views.
Post reply on HN