Fix plain text responses not being visible in dark mode
This commit is contained in:
parent
de68ecbe4b
commit
8c43bc8a44
|
@ -258,11 +258,18 @@ class BrowserWebViewController: UIViewController {
|
|||
|
||||
self.loadedFallback = true
|
||||
|
||||
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
|
||||
// (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.
|
||||
self.webView.scrollView.contentInset = self.webView.safeAreaInsets
|
||||
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)
|
||||
|
||||
// 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),
|
||||
// but it's better than the image being obscured.
|
||||
self.webView.scrollView.contentInset = self.webView.safeAreaInsets
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,11 @@ pre {
|
|||
tab-size: 4;
|
||||
}
|
||||
|
||||
pre.plaintext {
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
h1, h2, h3 {
|
||||
line-height: 1;
|
||||
font-weight: normal;
|
||||
|
|
Loading…
Reference in New Issue