Whiffer / SwiftUI-Core-Data-Test

Sample program to demonstrate how CoreData can be used with SwiftUI.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Drag to reorder

radicalappdev opened this issue · comments

Thanks for posting this project. You really helped me get started with Core Data and SwiftUI.

I noticed a weird issue when reordering rows in a list. This only happens when dragging a row up, and only when I drag one position up. Take a look at the gif for an example of what I'm talking about.

ReorderWeirdness

Thank you for your comment. This was a huge learning experience for me and I'm glad I was able to help others as well.

Yes, I have noticed the funky animation in certain circumstances. I haven't addressed animation at all in this sample. What we see seems to be the default in this case. At some point, I may get around to trying to figure out how to explicitly animate the reorder without the funkiness, but at lease as far as I can tell, the data is being updated correctly.

You're right. There is something funny going on and I can't figure out right now. It may have something to do with the sequence of updates being different between drag up and drag down and the way SwiftUI processes the updates to the List. It could also the way the Fetched Results Controller reports the updates. I'll dig deeper when I can. Thanks for the comments.

I've tried a lot of things in an attempt to smooth out the animations. I've also been unsuccessful to completely eliminate the animations as a first step in trying to replace then with something else. It may have something to do with the way SwiftUI diff's the List when processing the state changes. Please let me know if anyone has any insight into how to deal with this. Thanks.

Hey Whiffer not trying to hijack your thread here but I didn’t want to open another one either. Do you have a email or twitter or anything? I had a few questions I wanted to run past you and didn’t see anything listed with your profile.

Also I ran into a weird animation thing my self. Using a ForEach or List in a long form or list the date picker would animate all the way down the list then shrink. It was quite odd. I never found out how to fix it but I did notice that grouping the list with group list style or even using section headers to break up the items helped to stop that weird animation. Hopefully that will help you as well. I will try to work with it this week and see what I can find but I assure you that your far more versed in this than me. First things first I need to fire out how to work with just the item list page and go from there.

@Benetos feel free to create a new thread if you have more questions, ideas, or anything else you would like to discuss.

BTW, I have tried to recreate a very simple test case to demonstrate the animation issue. So far, the issue only occurs when dragging NSManagedObject's

This weird issue is no longer occurring starting with Beta 1 of Xcode 12 and iOS 14.