SwiftUIListSeparator icon indicating copy to clipboard operation
SwiftUIListSeparator copied to clipboard

List no longer visible after applying .listSeparatorStyle(.none) in iOS 14

Open alexander-larsson opened this issue 4 years ago • 10 comments

The title basically says it all. Is this tested to work for lists with sections?

alexander-larsson avatar Sep 18 '20 16:09 alexander-larsson

I have not tested it for this scenario yet. I will try to reproduce and see if I can find a fix. Thanks for opening the issue!

SchmidtyApps avatar Sep 19 '20 13:09 SchmidtyApps

Nice! I made a small example that demonstrates it: https://github.com/alexander-larsson/ExampleList

alexander-larsson avatar Sep 19 '20 14:09 alexander-larsson

@alexander-larsson Thanks for the sample project it was incredibly helpful! I have an experimental branch up and running that I believe fixes this issue. The only downside is a bit of a CPU spike when scrolling because it now listens for scrollview content offset to change and anytime it does it attempts to hide dividers again. I am going to continue working on improving the performance but if you can test it out to confirm it works I think it should be good enough to merge to master and I will open a new enhancement ticket for the minor performance issues.

Checkout this branch: https://github.com/SchmidtyApps/SwiftUIListSeparator/tree/xcode12-issues

SchmidtyApps avatar Sep 19 '20 18:09 SchmidtyApps

livesafemike avatar Sep 19 '20 18:09 livesafemike

It works for me in my first basic example but I'm actually using it in a use case with rounded cards in the list. The lines are still there in that use case. When I was updating my sample project to reproduce the issue I discovered that setting the background color of the list made the lines re-appear. I have pushed a new commit that domonstrates the problem to: https://github.com/alexander-larsson/ExampleList

alexander-larsson avatar Sep 20 '20 16:09 alexander-larsson

Haha I'll take another look with the new example. It's infuriating that this isn't just built in SwiftUI functionality!

livesafemike avatar Sep 20 '20 19:09 livesafemike

Yes! It feels like you are supposed to use LazyVStack on iOS 14 for this use case. Might implement a solution based on using List on iOS 13 and LazyVStack on iOS 14 if this doesn't end up working out.

alexander-larsson avatar Sep 20 '20 19:09 alexander-larsson

Hello. I have the same issue and I want to add that list is visible, but not every time I run my app. After several restarts it works, just FYI.

NeoKolian avatar Oct 08 '20 08:10 NeoKolian

So while my library seems to work fairly well for many implementations it is clear that depending on specific setups sometimes the underlying UIKit code backing the SwiftUI list changes and ends up breaking my workaround. If it is not working my current suggestion would be to do something along the lines of:

if #available(iOS 14, *) {
   LazyVStack { content() }
} else {
   List { content() }
}

func content() -> some View {
 //Table rows go here
}

SchmidtyApps avatar Oct 08 '20 13:10 SchmidtyApps

@SchmidtyApps LazyVStack does not reuse cells and will make List with content heavier than Text("Hello") lag as hell while scrolling. I guarantee that

lonkly avatar Oct 09 '20 15:10 lonkly