explore page
still needs fixed for no wifi and freezing
This commit is contained in:
1 parent
cdd5cbe634
commit
edde7ddb0c
7 files changed
+122
-39
No files matched your search
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// WebView.swift
|
||||
// Pocket Poster
|
||||
//
|
||||
// Created by lemin on 7/6/25.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import WebKit
|
||||
|
||||
struct WallpaperWebView: UIViewRepresentable {
|
||||
let url: URL
|
||||
|
||||
init(_ url: URL) {
|
||||
self.url = url
|
||||
}
|
||||
|
||||
func makeUIView(context: Context) -> some UIView {
|
||||
let configuration = WKWebViewConfiguration()
|
||||
configuration.setURLSchemeHandler(AssetsSchemeHandler(), forURLScheme: "pocketposter")
|
||||
let webView = WKWebView(frame: .zero, configuration: configuration)
|
||||
webView.load(URLRequest(url: url))
|
||||
|
||||
return webView
|
||||
}
|
||||
|
||||
func updateUIView(_ uiView: UIViewType, context: Context) {}
|
||||
}
|
||||
|
||||
|
||||
class AssetsSchemeHandler: NSObject, WKURLSchemeHandler {
|
||||
func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) {
|
||||
DispatchQueue.global().async {
|
||||
print("handling scheme")
|
||||
guard let url = urlSchemeTask.request.url, url.absoluteString.starts(with: "pocketposter://download") else { return }
|
||||
|
||||
print("url: \(url.absoluteString)")
|
||||
DownloadManager.shared.startTendiesDownload(for: url)
|
||||
}
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, stop urlSchemeTask: WKURLSchemeTask) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// ExploreView.swift
|
||||
// Pocket Poster
|
||||
//
|
||||
// Created by lemin on 7/6/25.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ExploreView: View {
|
||||
var body: some View {
|
||||
WallpaperWebView(URL(string: "https://cowabun.ga/wallpapers?pocketposter=true")!)
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,10 @@ struct RootView: View {
|
||||
.tabItem {
|
||||
Label("CarPlay", systemImage: "car")
|
||||
}
|
||||
ExploreView()
|
||||
.tabItem {
|
||||
Label("Explore", systemImage: "safari")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user