Skip to content

Commit

Permalink
Simplify PDF appearance mode logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mvasilak committed Nov 28, 2023
1 parent c0feb31 commit e5fc6a9
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions Zotero/Scenes/Detail/PDF/Views/PDFDocumentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ final class PDFDocumentViewController: UIViewController {
controller.annotationStateManager.pencilInteraction.isEnabled = true
self.setup(scrubberBar: controller.userInterfaceView.scrubberBar)
self.setup(interactions: controller.interactions)
controller.appearanceModeManager.delegate = self
controller.shouldResetAppearanceModeWhenViewDisappears = false

return controller
}
Expand Down Expand Up @@ -860,34 +860,3 @@ extension UIAction {
)
}
}

extension PDFDocumentViewController: AppearanceModeManagerDelegate {
func appearanceManager(_ manager: PDFAppearanceModeManager, renderOptionsFor mode: PDFAppearanceMode) -> RenderOptions {
// Override render options to avoid reset of appearance mode when view controller is dismissed.
let properMode: PDFAppearanceMode
switch viewModel.state.settings.appearanceMode {
case .automatic:
properMode = traitCollection.userInterfaceStyle == .dark ? .night : []

case .light:
properMode = []

case .dark:
properMode = .night
}

let options = RenderOptions()
switch properMode {
case .all, .night:
options.invertRenderColor = true
options.filters = [.colorCorrectInverted]

case .sepia:
break

default:
break
}
return options
}
}

0 comments on commit e5fc6a9

Please sign in to comment.