shaps80 / SwiftUIBackports

A collection of SwiftUI backports for iOS, macOS, tvOS and watchOS
MIT License
931 stars 59 forks source link

Refreshable not enabling pull-to-refresh #7

Closed JosephDuffy closed 2 years ago

JosephDuffy commented 2 years ago

Have you read the Contributing Guidelines?

General Information

Describe the bug

Using .backport.refreshable does not add pull-to-refresh to a list.

Steps to reproduce

Add .backport.refreshable to a List.

Expected behavior

Should add pull-to-refresh to the list.

Stack trace, compiler error, code snippets

struct RootView: View {
    var body: some View {
        TabView {
            NavigationView {
                List {
                    Text("1")
                    Text("2")
                    Text("3")
                }
                .navigationTitle("Native")
                .refreshable {
                    print("Refresh!")
                }
            }
            .tabItem {
                Text("Native")
            }

            NavigationView {
                List {
                    Text("1")
                    Text("2")
                    Text("3")
                }
                .navigationTitle("Backport")
                .backport.refreshable {
                    print("Refresh!")
                }
            }
            .tabItem {
                Text("Backport")
            }
        }
    }
}

Screenshots

Simulator Screen Shot - iPhone 12 mini - 2022-06-30 at 21 03 35 Simulator Screen Shot - iPhone 12 mini - 2022-06-30 at 21 03 28

Additional context

It could be argued that the backport is complete; it does set the environment value. But not adding the pull-to-refresh was a surprise to me. It does look to be possible (https://github.com/Geri-Borbas/iOS.Package.Refreshable) so maybe something similar could be added?

shaps80 commented 2 years ago

Yeah, I basically include the basic mechanism only for now. I had intended to explore this and I in fact have it listed (need to add my list to GH Issues 😬). I'll check it out thanks!

shaps80 commented 2 years ago

@JosephDuffy FYI that other repo uses Introspect, which I was trying to avoid (3rd party libs) for these backports. That's literally the reason I didn't include it yet.  literally changed List to UICollectionView this year, and while backports wouldn't be affected, its still problematic because diff iOS versions often have subtle differences behind SwiftUI. Especially environment based stuff 💀

shaps80 commented 2 years ago

One other note, I needed to backport ProgressView first as well, so that was another reason I bumped the core-implementation, preferring to explore pull-to-refresh options later on.

I also wanted to backport ScrollViewReader beforehand, because that felt somehow like the internal implementation I might build, may contribute to a working solution 👍

shaps80 commented 2 years ago

1.3.0 now includes this @JosephDuffy :)

JosephDuffy commented 2 years ago

Awesome! I'll try it out soon :)