Skip to content

Commit aac960e

Browse files
Update README.md
1 parent 770182c commit aac960e

File tree

1 file changed

+24
-50
lines changed

1 file changed

+24
-50
lines changed

README.md

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,70 +3,44 @@
33
## How to install this package
44

55
+ Open your project on Xcode
6-
+ Go to Project Tab and select "Package Dependencies"
7-
+ Click "+" and search this package with use git clone url
6+
+ Go to the Project Tab and select "Package Dependencies"
7+
+ Click "+" and search this package with use git clone URL
88
+ Don't change anything and click Add Package
99
+ The package will be attached to the targeted application
1010

1111
## How to use this package
12-
### Create a ViewModel conforming to the ErrorableViewModelProtocol
12+
### Create a ViewModel conforming to the ErrorableBaseViewModel
1313
<b>Note:<b> The class includes AnyObject and ObservableObject!
1414

1515
```swift
16-
final class TestViewModel: ErrorableViewModelProtocol {
17-
@Published var state: PageStates = .loading
18-
19-
func refresh() {
20-
// TODO: Write here your refresh action
21-
// TODO: Don't forget to update the state property in the refresh action
22-
}
16+
private final class ExampleViewModel: ErrorableBaseViewModel {
17+
// Your actions will come here
2318
}
2419
```
25-
### Create SwiftUI and conform to the ErrorableViewProtocol
26-
- Set the ViewModel typealias to the view model we created
27-
- Create the Viewmodel as @ObservedObject.
28-
- Use the createErrorableView function according to your need.
20+
### Create a SwiftUI view that conforms to the ErrorableView or ErrorableSheetView Protocols. (Usage is the same for both protocols.)
2921
```swift
30-
struct ContentView: ErrorableViewProtocol {
31-
typealias Content = AnyView
32-
typealias ViewModel = TestViewModel
33-
@ObservedObject var viewModel: TestViewModel = TestViewModel()
34-
35-
var body: some View {
36-
NavigationView {
37-
createErrorableView(errorTitle: "Upps!", errorSubTitle: "We encountered an error.\n Please try again later!", errorSystemIcon: "minus.diamond.fill", errorButtonTitle: "Try Again") {
38-
AnyView (
39-
ScrollView {
40-
ForEach(0..<100, id: \.self) { _ in
41-
AsyncImage(url: URL(string: "https://picsum.photos/200")) { phase in
42-
if let image = phase.image {
43-
image
44-
.resizable()
45-
.scaledToFill()
46-
} else {
47-
Color.gray
48-
}
49-
}.frame(width: 300, height: 200, alignment: .center)
50-
.clipped()
51-
}
52-
}.frame(width: UIScreen.main.bounds.width)
53-
)
54-
}
55-
.navigationTitle("Example")
56-
}.onAppear {
57-
Task { @MainActor in
58-
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
59-
viewModel.state = .failure
60-
}
61-
}
22+
private struct SimpleExampleView: ErrorableView {
23+
typealias ViewModel = ExampleViewModel
24+
@ObservedObject var viewModel: ExampleViewModel = ExampleViewModel()
25+
26+
var content: some View {
27+
VStack {
28+
Text("Loaded Statement!")
6229
}
6330
}
6431
}
6532
```
6633

67-
## Demo Images
34+
## ErrorableView Demo Images
35+
<div>
36+
<img width = 255 height = 525 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/5dc340f8-e455-46f9-9504-e3fcc6faf3a5">
37+
<img width = 255 height = 525 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/f4c4b650-87fb-4b51-a305-c550ba2db85b">
38+
<img width = 255 height = 525 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/f28af8bb-dea2-4581-9770-ce7879e99925">
39+
</div>
40+
41+
## ErrorableSheetView Demo Images
6842
<div>
69-
<img width = 255 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/f30a0d95-53a8-42e0-a21d-db67ef093b0e">
70-
<img width = 255 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/269ad7d4-ae61-40bc-a731-7dd87f116a4d">
71-
<img width = 255 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/155a174f-dade-4bba-ba4b-dec12dfa6d7f">
43+
<img width = 255 height = 525 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/5dc340f8-e455-46f9-9504-e3fcc6faf3a5">
44+
<img width = 255 height = 525 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/3631f105-c1c2-4b71-9895-6a442e2b2dca">
45+
<img width = 255 height = 525 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/f28af8bb-dea2-4581-9770-ce7879e99925">
7246
</div>

0 commit comments

Comments
 (0)