* init Signed-off-by: Innei <tukon479@gmail.com> * feat: parser and renderer Signed-off-by: Innei <tukon479@gmail.com> * feat: shared webview * feat: add UIColor hex conversion extension and accent color asset and xhr rewrite * feat(mobile): enhance WebView and HTML rendering for iOS - Refactor SharedWebView module with improved JavaScript injection and link handling - Add ModalWebViewController for opening links in a modal view - Implement dynamic content height measurement - Update HTML renderer with Jotai state management - Improve WebView configuration and debug mode Signed-off-by: Innei <tukon479@gmail.com> * lockfile Signed-off-by: Innei <tukon479@gmail.com> * chore: auto-fix linting and formatting issues * fix(mobile): improve WebView debug mode and UI text styling - Remove debug-only conditional for WebView inspector - Add text label class to GroupedInsetListActionCell for consistent styling Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * feat(mobile): add FullScreenWKWebView for iOS WebView layout - Create custom WKWebView subclass to override safe area insets - Enables full-screen WebView rendering without default padding Signed-off-by: Innei <tukon479@gmail.com> * chore(mobile): remove FullScreenWKWebView Swift file - Delete unused custom WKWebView subclass for iOS - Cleanup unnecessary file after previous implementation Signed-off-by: Innei <tukon479@gmail.com> * feat(mobile): refactor iOS WebView infrastructure Signed-off-by: Innei <tukon479@gmail.com> * feat(mobile): add native helper module and improve entry detail screen - Add HelperModule for iOS to open links in a modal WebView - Implement cross-platform link opening mechanism - Enhance entry detail screen with dynamic title and scroll behavior - Add loading indicator for entry content - Refactor navigation and scroll view components Signed-off-by: Innei <tukon479@gmail.com> * fix(mobile): improve WebView JavaScript and URL loading thread safety - Dispatch JavaScript evaluation and URL loading on the main thread - Ensure thread-safe WebView interactions for iOS - Prevent potential race conditions in SharedWebViewModule Signed-off-by: Innei <tukon479@gmail.com> * refactor(mobile): remove useOpenLink hook and update link opening mechanism - Replace custom useOpenLink hook with native openLink function - Update WebView navigation and recommendation list item to use new link opening method - Remove unnecessary hook and simplify link handling Signed-off-by: Innei <tukon479@gmail.com> --------- Signed-off-by: Innei <tukon479@gmail.com>
83 lines
2.1 KiB
Swift
83 lines
2.1 KiB
Swift
import SnapKit
|
|
import UIKit
|
|
import WebKit
|
|
|
|
class ModalWebViewController: UIViewController {
|
|
private let webView: WKWebView
|
|
private let url: URL
|
|
|
|
init(url: URL) {
|
|
self.url = url
|
|
|
|
let configuration = WKWebViewConfiguration()
|
|
|
|
self.webView = WKWebView(frame: .zero, configuration: configuration)
|
|
super.init(nibName: nil, bundle: nil)
|
|
|
|
webView.navigationDelegate = self
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
setupNavigationBar()
|
|
setupWebView()
|
|
loadContent()
|
|
}
|
|
|
|
private func setupNavigationBar() {
|
|
let closeButton = UIBarButtonItem(
|
|
barButtonSystemItem: .close,
|
|
target: self,
|
|
action: #selector(closeModal)
|
|
)
|
|
|
|
let safariButton = UIBarButtonItem(
|
|
image: UIImage(systemName: "safari"),
|
|
style: .plain,
|
|
target: self,
|
|
action: #selector(openInSafari)
|
|
)
|
|
safariButton.tintColor = Utils.accentColor
|
|
|
|
navigationItem.leftBarButtonItem = closeButton
|
|
navigationItem.rightBarButtonItem = safariButton
|
|
|
|
let appearance = UINavigationBarAppearance()
|
|
appearance.configureWithDefaultBackground()
|
|
navigationController?.navigationBar.standardAppearance = appearance
|
|
navigationController?.navigationBar.scrollEdgeAppearance = appearance
|
|
}
|
|
|
|
private func setupWebView() {
|
|
view.addSubview(webView)
|
|
webView.snp.makeConstraints { make in
|
|
make.edges.equalToSuperview()
|
|
}
|
|
}
|
|
|
|
private func loadContent() {
|
|
let request = URLRequest(url: url)
|
|
webView.load(request)
|
|
}
|
|
|
|
@objc private func closeModal() {
|
|
dismiss(animated: true)
|
|
}
|
|
|
|
@objc private func openInSafari() {
|
|
UIApplication.shared.open(url)
|
|
}
|
|
}
|
|
|
|
// MARK: - WKNavigationDelegate
|
|
extension ModalWebViewController: WKNavigationDelegate {
|
|
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
|
navigationItem.title = webView.title
|
|
}
|
|
}
|