Skip to content

Commit 5bb876b

Browse files
Update README.md
1 parent 79664c8 commit 5bb876b

1 file changed

Lines changed: 77 additions & 19 deletions

File tree

README.md

Lines changed: 77 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,88 @@ private final class ExampleViewModel: ErrorableBaseViewModel {
1717
// Your actions will come here
1818
}
1919
```
20-
### Create a SwiftUI view that conforms to the ErrorableView or ErrorableSheetView Protocols. (Usage is the same for both protocols.)
20+
### Create some SwiftUI view that conforms to the ErrorableView
2121
```swift
22-
private struct SimpleExampleView: ErrorableView {
23-
typealias ViewModel = ExampleViewModel
22+
@available(iOS 15.0, *)
23+
private struct ExampleContentView: View {
24+
var body: some View {
25+
NavigationView {
26+
ScrollView {
27+
ForEach(0..<100, id: \.self) { _ in
28+
AsyncImage(url: URL(string: "https://picsum.photos/1000")) { phase in
29+
if let image = phase.image {
30+
image
31+
.resizable()
32+
.scaledToFill()
33+
} else {
34+
Color.gray
35+
}
36+
}.frame(height: 200, alignment: .center)
37+
.clipped()
38+
}
39+
}.navigationTitle("Example Content")
40+
}
41+
}
42+
}
43+
44+
@available(iOS 15.0, *)
45+
private struct OnPageExampleView: ErrorableView {
2446
@ObservedObject var viewModel: ExampleViewModel = ExampleViewModel()
2547

2648
var content: some View {
27-
VStack {
28-
Text("Loaded Statement!")
29-
}
49+
ExampleContentView()
50+
}
51+
52+
var errorStateConfigModel: ErrorStateConfigureModel {
53+
ErrorStateConfigureModel.Builder()
54+
.buttonAction {
55+
viewModel.refreshPage()
56+
}.build()
57+
}
58+
}
59+
60+
@available(iOS 15.0, *)
61+
private struct SheetExampleView: ErrorableView {
62+
@ObservedObject var viewModel: ExampleViewModel = ExampleViewModel()
63+
64+
var content: some View {
65+
ExampleContentView()
66+
}
67+
68+
var errorStateConfigModel: ErrorStateConfigureModel {
69+
ErrorStateConfigureModel.Builder()
70+
.buttonAction {
71+
viewModel.refreshPage()
72+
}.build()
3073
}
74+
75+
var errorPresentType: ErrorPresentTypes { .sheet }
76+
}
77+
78+
@available(iOS 15.0, *)
79+
private struct FullScreenExampleView: ErrorableView {
80+
@ObservedObject var viewModel: ExampleViewModel = ExampleViewModel()
81+
82+
var content: some View {
83+
ExampleContentView()
84+
}
85+
86+
var errorStateConfigModel: ErrorStateConfigureModel {
87+
ErrorStateConfigureModel.Builder()
88+
.buttonAction {
89+
viewModel.refreshPage()
90+
}.build()
91+
}
92+
93+
var errorPresentType: ErrorPresentTypes { .fullScreen }
3194
}
3295
```
3396

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
42-
<div>
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">
46-
</div>
97+
## Sheet Type
98+
https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/1fe9e28a-8ba3-48b8-8d85-b2eb4c6aa672
99+
100+
## OnPage Type
101+
https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/2c579c96-adec-4d6e-9739-1892d97666aa
102+
103+
## Fullscreen Type
104+
https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/6e34332f-6c24-489d-8bd2-bfd5ab2fb027

0 commit comments

Comments
 (0)