@amonduin I suppose the rational was to have some common API language across platforms, which I get. But it just seemed they did too much too fast. You’re right in that they probably could have added some of these things to UIKit/AppKit first (cell layouts spring to mind).
Well hot damn, someone on Twitter suggested setting the Set's underlying type to Optional, and voila, editing and navigation!
I'm still not entirely sure why this works though. Surely an empty Set would denote no selection? Making the type itself Optional isn't intuitive at all.
Even the init signature doesn't give any hints, only that the Binding itself can be Optional... 🤷♂️ #SwiftUI
@brandonhorst Aha, the first version of Big Mail used CoreData: never again 🥲
I understand how things piece together, but in practice the API’s never seem to work the way I expect. There's either obscure overloads, hidden environment values, or it doesn't behave the way the docs say it should. Nor does it help that Apple’s own examples are either inconsistent or incomplete.
@kaybutter well there does appear to be a separate overload for Identifiable elements, and the docs seem to suggest you should be using that. But you're right, you can use none Identifiable elements and it’ll just use the hash. I'm just curious if it has any practical implications, and if it could explain some of my List weirdness.
Okay one for the #SwiftUI crowd: Do we have a definitive answer whether a List's selection binding should be Identifiable or not?
Apple seem to play fast and loose with this. Some of their example projects (Food Truck) don't conform to Identifiable, and the Swift header for List only has Hashable as the requirement. Meanwhile the docs say a List's selection should conform to Identifiable.
So what is the truth? What do you do in your apps?
@nmn it’s certainly possible, but you end up in that “uncanny valley” of UI where it’s close, but it’s not quite right. Also I can’t think of a way around using erasure/AnyView, which has its own set of drawbacks.
@chucker Surprise Driven Development™
@cocoataster this is probably the best advice I've received today 😅 Thank you!
I refuse to sleep until I have found a solution to this, which is unfortunate, as it means I may never sleep again 🥲
I've now officially arrived in crazy town, and started wrapping UINavigationController myself.
What's interesting is that the SwiftUI environment is still automatically adding nav items to the controller, so I've actually got the same broken animations as with NavigationStack. At least it’s…consistent.
Running out of ideas now 😅
@charliemchapman Congrats! 🎉
@brandonhorst thanks for the suggestion, though it looks updating the selection that way won't trigger the SplitView/Stack to notice any changes.
Ok I have to be missing something here. If you add a selection binding to a List (let's say you want to edit it), then that seemingly renders all NavigationLinks in the List unusable. Surely not!?
Please someone, anyone, tell me I'm holding it wrong! #SwiftUI https://gist.github.com/phillipcaudell/3b890345efbc36c050d3ec630051c200
@shantara definitely agree on prior iOS support. I had begrudgingly accepted that I will be iOS 16 only, but I can't even do that! It's utter madness.
Bugs happen, I get it, I write buggy software too. But my god, I have never in my 14 years of writing apps for iOS have the ground move beneath me as much as it has with #SwiftUI. A couple of issues every now and then I can forgive, but it's not. It's every update, something has broken or changed.
It may be a beautifully expressive framework, but it doesn't matter if it doesn't work reliably, all the time, every time.
Something is deeply and systemically wrong with it.
Here's the exact same code running on iOS 16.2. It works just fine.
And I’m sorry if I sound like a twat, but the SwiftUI team HAVE to get a grip on this. I cannot tell you how many hours I waste wondering "Wait, is that something I broke?!”
I'm being gaslit by a UI framework!
Arghhh. Another #SwiftUI regression in 16.4: NavigationSplitView won’t animate the first push of the detail column if the content column goes from List, to no List. Again, this worked just fine in prior releases! https://gist.github.com/phillipcaudell/a125708c3075abcabe9940427c57d1a3 (FB12175649)
@sandropennisi very cool!
On iPad, hitting search will hide the suggestions.
On iPhone, hitting search does nothing, they just get stuck there. https://mastodon.notsobig.co/@phill/110163933612089969
And this is code pretty much lifted from Apple's own docs. Maddening. https://gist.github.com/phillipcaudell/d7282b58f90c8be7e83c27ce78b6d44a
🏳️🌈 Founder / Maker
Building that new email app.
Swift and rollercoasters are my thing.
Recovering VC.