Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Commit

Permalink
update README.md add usage
Browse files Browse the repository at this point in the history
  • Loading branch information
maguowei committed Jul 5, 2020
1 parent 16fc850 commit 06a793d
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
# SwiftUIPullToRefresh

A description of this package.

## Usage

```swift
import SwiftUI
import SwiftUIPullToRefresh


struct ExamplePullToRefreshView: View {
@State private var isRefreshing = false
@State private var array: [String] = []
var body: some View {
NavigationView {
List(array, id: \.self) { text in
Text(text)
}
.navigationBarTitle("SwiftUIPullToRefresh")
.navigationBarTitleDisplayMode(.inline)
.onPullToRefresh(isRefreshing: $isRefreshing, perform: {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.isRefreshing = false
self.array.insert(Date().description, at: 0)
}
})
}
}
}


struct ExamplePullToRefreshView_Previews: PreviewProvider {
static var previews: some View {
ExamplePullToRefreshView()
}
}
```

0 comments on commit 06a793d

Please sign in to comment.