Fun Times Creating an Inventory App with SwiftUI

Cory D. Wiles
2 min readMar 3, 2021

Down the Rabbit Hole Continues

This is the Way

The deeper my dives / experience / experimentations go with SwiftUI the more I appreciate its efficiencies and strides for a better developer experience. Granted, there are still shortcomings when compared to it’s predecessor, UIKit, the tone / tenor has been set…this is the way.

It has been awhile since my last experiment in “can this be done in SwiftUI”, and so much as improved since SwiftUI 2.0 has been released.

Customizations

Though TabView, has been supported since SwiftUI 1.0, I wanted to create an example which utilized a custom view hiearchy for displaying independent views. To add a little “flar” I created a custom extension on `Text` for displaying the circle view place holder text. This originally was a custom ```ViewModifier```, but there isn’t a way to constrain the modifier to a particular View.

There isn’t a straightforward way to determine the dominate color for the product detail image programmatically, so to insure that the overlay text on top of the image would show properly there is a `white -> clear` gradient on top of the product detail image.

Lastly, the ```trash``` and ```pencil``` overlay’s on the detail screen needed to have a slight offset from the bottom of the product image. No need to add an additional overlay or message with another ```ZStack```; just offset the ```y coordinate``` and align the overlay to the `bottom`

```…
.offset(y: 20), alignment: .bottom)
```

::NOTE::

I’m not real thrilled with how the masthead image resizing is handled on the ```ProductDetailUIView```. I haven’t quite figured out how best to display them without screwing up the rest of the layout*

Onward

```SwiftUI 1.0``` < ```SwiftUI 2.0``` < Whatever the next iteration that Apple announces at WWDC 2021.

This is the way

Source

--

--

Cory D. Wiles

I code stuff in Swift. I also raise children, workout, and make a perfect old fashioned.