loading and error handling
This commit is contained in:
1 parent
edde7ddb0c
commit
e932b82515
4 files changed
+68
-4
No files matched your search
@@ -8,7 +8,30 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ExploreView: View {
|
||||
@State private var isLoading = true
|
||||
@State private var error: Error? = nil
|
||||
|
||||
var body: some View {
|
||||
WallpaperWebView(URL(string: "https://cowabun.ga/wallpapers?pocketposter=true")!)
|
||||
ZStack {
|
||||
if let error = error {
|
||||
VStack {
|
||||
Text(error.localizedDescription)
|
||||
.foregroundStyle(.red)
|
||||
Button(action: {
|
||||
isLoading = true
|
||||
self.error = nil
|
||||
}) {
|
||||
Text("Retry")
|
||||
}
|
||||
}
|
||||
} else if let url = URL(string: "https://cowabun.ga/wallpapers?pocketposter=true") {
|
||||
WallpaperWebView(url, isLoading: $isLoading, error: $error)
|
||||
if isLoading {
|
||||
ProgressView()
|
||||
}
|
||||
} else {
|
||||
Text("Failed to load explore page.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user