@chriseidhof this helped me a lot in understanding the layout process of SwiftUI's views. One great discovery was that I was able to identify a significant bug in the original framework, which I reported and Apple already fixed (view dimensions caching bug).
@chriseidhof just found the HStack related blog post on https://t.co/pzAcxDDqpy. I did re-implement a huge chunk of SwiftUI's layout system including alignment APIs, which does support custom alignment keys just like the original. However for stacks I'm missing layout priority.
@chriseidhof here is my HStackLayout: https://t.co/U9ZiD7lq5G
The actual algorithm was based on what @DaveAbrahams could tell me. There are 3 steps to determine the flexibility. 2 parts are cached. Propose 0 and infinity on the main axis, the last step is the remaining space.
@bzamayo@_inside Not even iOS is ready. iPadOS will make speakers on iPad Pro 2018 start produce random crackling noise. (I think it‘s a HW design flaw which got patched with iOS back in days after initial release, but iPadOS 14 broke this again.) It‘s my second unit with that issue.
@SwiftUILab One nit about the article. Drop the VStack in your honey grid and rephrase the paragraph. Stacks cannot and will never underflow its children. That would completely break their behavior. The overflowing happens with `frame` modifier, not the VStack.
@SwiftUILab Just today I tried nesting scroll views and used a lazy stack. The scroll position is lost on reappearance. Yesterday I managed to keep a hosting controller alive, however its root view‘s state will have a band new state due to the issue that the hierarchy was detached.
@SwiftUILab Are you sure about the state restoration part of lazy api‘s? In general everything that is removed and readded will start with a brand new state. Try using a scroll view or an active animation in a lazy cell or remove/readd it, it won‘t keep the active state.
@chriseidhof @state @ObservedObject What do you mean I shouldn‘t? Not every object should be observable and represent some kind of state. This totally the case at the `App` level, or would you want to create fileprivate singletons instead?
@chriseidhof @state @ObservedObject State’s wrappedValue is still mutable and the PW will re-create your object as it wasn‘t designed to be lazy like StateObject. Instead use StateObject and let the object have `let objectWillChange = Empty<Never, Never>(…: false)` to indicate that it won‘t send any signals.
@SwiftUILab Nothings seems to have changed there. I‘ll send you a gist with my workaround if you want to look at it (possibly for you next article, unless you‘re already done with it 😅).
@SwiftUILab I mean, I build a workaround using pure SwiftUI, but there is a small bug which requires the `isTracking` state. However gestures are a nightmare in SeiftUI. The order of gestures, their combinations, etc. all things matter and produce other results.
@SwiftUILab Here is also a possible challenge for your article, which I couldn’t crack: There seems to be no way to create/observe states like `isTracking` and/or `isDecelerating` for the scroll view. I really need to build a custom picker that always centers, but I can’t. 😭
@SwiftUILab LazyHStack is interesting but it‘s type shadowing and clarly should be an anti-pattern. I‘d rather give it a different name or a small prefix.
@natpanferova@TizianoCoroneo@valv0 @ViewBuilder Also note that you already used ViewBuilder through Group, as it‘s applied as the function builder attribute in its init‘s closure. 👍