Update background color behind webview when user switches themes

This commit is contained in:
Jackson Harper 2023-04-11 16:44:52 +08:00
parent d60a87d304
commit dbbd3abdee
3 changed files with 22 additions and 3 deletions

View file

@ -26,7 +26,7 @@ final class AppStoreScreenshots: XCTestCase {
setupSnapshot(app) setupSnapshot(app)
// Display the context menu of the first item in the libary // Display the context menu of the first item in the libary
app.collectionViews.cells.firstMatch.press(forDuration: 2) // app.collectionViews.cells.firstMatch.press(forDuration: 2)
snapshot("LibraryActions") snapshot("LibraryActions")
app.children(matching: .window).element(boundBy: 0).tap() app.children(matching: .window).element(boundBy: 0).tap()
@ -37,7 +37,7 @@ final class AppStoreScreenshots: XCTestCase {
setupSnapshot(app) setupSnapshot(app)
// Move into the reader // Move into the reader
app.collectionViews.cells.firstMatch.tap() // app.collectionViews.cells.firstMatch.tap()
snapshot("Reader") snapshot("Reader")
} }
@ -64,6 +64,21 @@ final class AppStoreScreenshots: XCTestCase {
// //
snapshot("ReaderTTSPlayer") snapshot("ReaderTTSPlayer")
// app.children(matching: .window).element(boundBy: 0).tap()
// XCUIApplication().buttons["Back"].tap()
}
func testScreenshotNotebook() throws {
let app = XCUIApplication()
setupSnapshot(app)
// app.collectionViews.cells.firstMatch.tap()
// print("BUTTONS: ", app.buttons.allElementsBoundByIndex.count)
// app.buttons["Audiobook"].tap()
//
// print("MINIPLAYER BUTTONS: ", app.buttons.allElementsBoundByIndex)
//
snapshot("Notebook")
// app.children(matching: .window).element(boundBy: 0).tap() // app.children(matching: .window).element(boundBy: 0).tap()
// XCUIApplication().buttons["Back"].tap() // XCUIApplication().buttons["Back"].tap()
} }

View file

@ -62,6 +62,7 @@ struct WebReader: PlatformViewRepresentable {
webView.scrollView.contentInset.top = readerViewNavBarHeight webView.scrollView.contentInset.top = readerViewNavBarHeight
webView.scrollView.verticalScrollIndicatorInsets.top = readerViewNavBarHeight webView.scrollView.verticalScrollIndicatorInsets.top = readerViewNavBarHeight
webView.configuration.userContentController.add(webView, name: "viewerAction") webView.configuration.userContentController.add(webView, name: "viewerAction")
webView.scrollView.indicatorStyle = ThemeManager.currentTheme.isDark ? webView.scrollView.indicatorStyle = ThemeManager.currentTheme.isDark ?
UIScrollView.IndicatorStyle.white : UIScrollView.IndicatorStyle.white :
UIScrollView.IndicatorStyle.black UIScrollView.IndicatorStyle.black
@ -113,6 +114,10 @@ struct WebReader: PlatformViewRepresentable {
(webView as? OmnivoreWebView)?.updateLabels(labelsJSON: item.labelsJSONString) (webView as? OmnivoreWebView)?.updateLabels(labelsJSON: item.labelsJSONString)
(webView as? OmnivoreWebView)?.updateTitle(title: item.title ?? "") (webView as? OmnivoreWebView)?.updateTitle(title: item.title ?? "")
(webView as? OmnivoreWebView)?.updateJustifyText() (webView as? OmnivoreWebView)?.updateJustifyText()
webView.backgroundColor = UIColor(ThemeManager.currentBgColor)
webView.underPageBackgroundColor = UIColor(ThemeManager.currentBgColor)
webView.scrollView.backgroundColor = UIColor(ThemeManager.currentBgColor)
webView.scrollView.indicatorStyle = ThemeManager.currentTheme.isDark ? webView.scrollView.indicatorStyle = ThemeManager.currentTheme.isDark ?
UIScrollView.IndicatorStyle.white : UIScrollView.IndicatorStyle.white :
UIScrollView.IndicatorStyle.black UIScrollView.IndicatorStyle.black

View file

@ -222,7 +222,6 @@ public final class OmnivoreWebView: WKWebView {
} }
case "pageTapped": case "pageTapped":
print("currentMenu: ", currentMenu, "menuDisplayed", menuDisplayed)
if menuDisplayed { if menuDisplayed {
hideMenuAndDismissHighlight() hideMenuAndDismissHighlight()
break break