Fix plain text responses not being visible in dark mode
This commit is contained in:
parent
de68ecbe4b
commit
8c43bc8a44
|
@ -258,13 +258,20 @@ class BrowserWebViewController: UIViewController {
|
||||||
|
|
||||||
self.loadedFallback = true
|
self.loadedFallback = true
|
||||||
|
|
||||||
|
if mimeType == "text/plain",
|
||||||
|
let bodyText = response.bodyText {
|
||||||
|
let html = BrowserWebViewController.preamble + "<pre class='plaintext'>" + bodyText + "</pre>" + BrowserWebViewController.postamble
|
||||||
|
self.webView.loadHTMLString(html, baseURL: Bundle.main.bundleURL)
|
||||||
|
} else {
|
||||||
self.webView.load(body, mimeType: mimeType, characterEncodingName: response.encodingName ?? "utf-8", baseURL: self.url)
|
self.webView.load(body, mimeType: mimeType, characterEncodingName: response.encodingName ?? "utf-8", baseURL: self.url)
|
||||||
|
|
||||||
// When showing an image, the safe area insets seem to be ignored. This isn't perfect
|
// When showing an image, the safe area insets seem to be ignored. This isn't perfect
|
||||||
// (there's a little extra space between the bottom of the nav bar and the top of the image),
|
// (there's a little extra space between the bottom of the nav bar and the top of the image),
|
||||||
// but it's better than the image being obscured.
|
// but it's better than the image being obscured.
|
||||||
self.webView.scrollView.contentInset = self.webView.safeAreaInsets
|
self.webView.scrollView.contentInset = self.webView.safeAreaInsets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func scrollToLine(index: Int, animated: Bool) {
|
func scrollToLine(index: Int, animated: Bool) {
|
||||||
if animated {
|
if animated {
|
||||||
|
|
|
@ -14,6 +14,11 @@ pre {
|
||||||
tab-size: 4;
|
tab-size: 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pre.plaintext {
|
||||||
|
word-wrap: break-word;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
h1, h2, h3 {
|
h1, h2, h3 {
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
|
|
Loading…
Reference in New Issue