For SWIFTUI i have created a ViewModifier to use the refreshable(action) view modifier available under iOS15. with this modifier I don't have to embed my all view in availability check.
It's seems to work properly, but I'm not confortable with the @Sendable and I wondering if there is some performance issue.
Do you think this is a good implementation?
struct RefreshView: ViewModifier {
var action: @Sendable () async -> Void
func body(content: Content) -> some View {
if #available(iOS 15, *) {
content.refreshable(action: action)
} else {
content
}
}
}
extension View {
func refreshView(action: @escaping @Sendable () async -> Void) -> some View {
modifier(RefreshView(action: action))
}
}