mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-05 19:57:31 +00:00
40 lines
1.1 KiB
Swift
40 lines
1.1 KiB
Swift
//
|
||
// ArticleWebView.swift
|
||
// NetNewsWire-iOS
|
||
//
|
||
// Created by Maurice Parker on 2/25/20.
|
||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||
//
|
||
|
||
import Foundation
|
||
import WebKit
|
||
|
||
final class ArticleWebView: WKWebView {
|
||
|
||
private var fullscreenStateObservation: NSKeyValueObservation?
|
||
|
||
init(articleIconSchemeHandler: ArticleIconSchemeHandler) {
|
||
let configuration = WebViewConfiguration.configuration(with: articleIconSchemeHandler)
|
||
super.init(frame: .zero, configuration: configuration)
|
||
isInspectable = true
|
||
isFindInteractionEnabled = true
|
||
// Transparent so a page sliding in shows its view’s background, not white, until it paints.
|
||
// <https://github.com/Ranchero-Software/NetNewsWire/issues/5587>
|
||
isOpaque = false
|
||
backgroundColor = .clear
|
||
scrollView.backgroundColor = .clear
|
||
fullscreenStateObservation = observe(\.fullscreenState, options: []) { [weak self] _, _ in
|
||
Task { @MainActor in
|
||
guard let self else {
|
||
return
|
||
}
|
||
WebViewFullscreenKeeper.shared.updateRetention(for: self)
|
||
}
|
||
}
|
||
}
|
||
|
||
required init?(coder: NSCoder) {
|
||
super.init(coder: coder)
|
||
}
|
||
}
|