gh123man / SwiftUI-Refresher

A native, customizable SwiftUI refresh control
MIT License
129 stars 12 forks source link

Refresh status binding #3

Open AzSiAz opened 2 years ago

AzSiAz commented 2 years ago

Some kind of binding to have a programmatic ability to refresh content or just set view to refresh state

My use case is for when you refresh in subview but navigate back and navigate again to subview but refresh is no longer show Task is launched in global ObservableObject to avoid stopping or losing progress since it's refreshing a lot of item

yiweiwoshiniya commented 2 months ago

@gh123man is it possible to add

gh123man commented 2 months ago

Hi, You can currently access the underlying binding state via the refreshView argument.

.refresher(refreshView: { bindingState in
            // access bindingState here
            return DefaultRefreshView(state: bindingState)
        }) {
            ...
        }

However it may not be very ergonomic. You will have to mutate the mode and modeAnimated properties of RefresherState.

Let me know if this works for you. If this isn't enough, can you give a code example of what you are trying to accomplish? I'm happy to add support - but I want to make sure we get the API right.