Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
devmehmetates committed Feb 17, 2024
2 parents 321d18e + 5bb876b commit cd6debb
Showing 1 changed file with 77 additions and 19 deletions.
96 changes: 77 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,88 @@ private final class ExampleViewModel: ErrorableBaseViewModel {
// Your actions will come here
}
```
### Create a SwiftUI view that conforms to the ErrorableView or ErrorableSheetView Protocols. (Usage is the same for both protocols.)
### Create some SwiftUI view that conforms to the ErrorableView
```swift
private struct SimpleExampleView: ErrorableView {
typealias ViewModel = ExampleViewModel
@available(iOS 15.0, *)
private struct ExampleContentView: View {
var body: some View {
NavigationView {
ScrollView {
ForEach(0..<100, id: \.self) { _ in
AsyncImage(url: URL(string: "https://picsum.photos/1000")) { phase in
if let image = phase.image {
image
.resizable()
.scaledToFill()
} else {
Color.gray
}
}.frame(height: 200, alignment: .center)
.clipped()
}
}.navigationTitle("Example Content")
}
}
}

@available(iOS 15.0, *)
private struct OnPageExampleView: ErrorableView {
@ObservedObject var viewModel: ExampleViewModel = ExampleViewModel()

var content: some View {
VStack {
Text("Loaded Statement!")
}
ExampleContentView()
}

var errorStateConfigModel: ErrorStateConfigureModel {
ErrorStateConfigureModel.Builder()
.buttonAction {
viewModel.refreshPage()
}.build()
}
}

@available(iOS 15.0, *)
private struct SheetExampleView: ErrorableView {
@ObservedObject var viewModel: ExampleViewModel = ExampleViewModel()

var content: some View {
ExampleContentView()
}

var errorStateConfigModel: ErrorStateConfigureModel {
ErrorStateConfigureModel.Builder()
.buttonAction {
viewModel.refreshPage()
}.build()
}

var errorPresentType: ErrorPresentTypes { .sheet }
}

@available(iOS 15.0, *)
private struct FullScreenExampleView: ErrorableView {
@ObservedObject var viewModel: ExampleViewModel = ExampleViewModel()

var content: some View {
ExampleContentView()
}

var errorStateConfigModel: ErrorStateConfigureModel {
ErrorStateConfigureModel.Builder()
.buttonAction {
viewModel.refreshPage()
}.build()
}

var errorPresentType: ErrorPresentTypes { .fullScreen }
}
```

## ErrorableView Demo Images
<div>
<img width = 255 height = 525 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/5dc340f8-e455-46f9-9504-e3fcc6faf3a5">
<img width = 255 height = 525 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/f4c4b650-87fb-4b51-a305-c550ba2db85b">
<img width = 255 height = 525 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/f28af8bb-dea2-4581-9770-ce7879e99925">
</div>

## ErrorableSheetView Demo Images
<div>
<img width = 255 height = 525 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/5dc340f8-e455-46f9-9504-e3fcc6faf3a5">
<img width = 255 height = 525 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/3631f105-c1c2-4b71-9895-6a442e2b2dca">
<img width = 255 height = 525 src="https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/f28af8bb-dea2-4581-9770-ce7879e99925">
</div>
## Sheet Type
https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/1fe9e28a-8ba3-48b8-8d85-b2eb4c6aa672

## OnPage Type
https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/2c579c96-adec-4d6e-9739-1892d97666aa

## Fullscreen Type
https://github.com/devmehmetates/ErrorableView-SwiftUI/assets/74152011/6e34332f-6c24-489d-8bd2-bfd5ab2fb027

0 comments on commit cd6debb

Please sign in to comment.