Skip to content

Commit

Permalink
Suppress PDF appearance mode change from dark to light upon dismissal (
Browse files Browse the repository at this point in the history
  • Loading branch information
mvasilak authored Nov 28, 2023
1 parent 2f4687a commit 0ef8ea6
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions Zotero/Scenes/Detail/PDF/Views/PDFDocumentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ final class PDFDocumentViewController: UIViewController {

private static var toolHistory: [PSPDFKit.Annotation.Tool] = []
private var selectionView: SelectionView?
private var didAppear: Bool
var scrubberBarHeight: CGFloat {
return self.pdfController?.userInterfaceView.scrubberBar.frame.height ?? 0
}
Expand All @@ -50,7 +49,6 @@ final class PDFDocumentViewController: UIViewController {

init(viewModel: ViewModel<PDFReaderActionHandler>, compactSize: Bool, initialUIHidden: Bool) {
self.viewModel = viewModel
self.didAppear = false
self.initialUIHidden = initialUIHidden
self.disposeBag = DisposeBag()
super.init(nibName: nil, bundle: nil)
Expand All @@ -66,22 +64,17 @@ final class PDFDocumentViewController: UIViewController {
self.view.backgroundColor = .systemGray6
self.setupViews()
self.setupObserving()
self.updateInterface(to: self.viewModel.state.settings)
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

if !self.didAppear {
self.setInterface(hidden: self.initialUIHidden)
override func viewIsAppearing(_ animated: Bool) {
super.viewIsAppearing(animated)
self.setInterface(hidden: self.initialUIHidden)
self.updateInterface(to: self.viewModel.state.settings)
if let (page, _) = self.viewModel.state.focusDocumentLocation, let annotation = self.viewModel.state.selectedAnnotation {
self.select(annotation: annotation, pageIndex: PageIndex(page), document: self.viewModel.state.document)
}
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
self.didAppear = true
}

deinit {
self.pdfController?.annotationStateManager.remove(self)
DDLogInfo("PDFDocumentViewController deinitialized")
Expand All @@ -100,16 +93,6 @@ final class PDFDocumentViewController: UIViewController {
}, completion: nil)
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()

guard !self.didAppear else { return }

if let (page, _) = self.viewModel.state.focusDocumentLocation, let annotation = self.viewModel.state.selectedAnnotation {
self.select(annotation: annotation, pageIndex: PageIndex(page), document: self.viewModel.state.document)
}
}

func didBecomeActive() {
self.updatePencilSettingsIfNeeded()
}
Expand Down Expand Up @@ -519,6 +502,7 @@ final class PDFDocumentViewController: UIViewController {
controller.annotationStateManager.pencilInteraction.isEnabled = true
self.setup(scrubberBar: controller.userInterfaceView.scrubberBar)
self.setup(interactions: controller.interactions)
controller.shouldResetAppearanceModeWhenViewDisappears = false

return controller
}
Expand Down

0 comments on commit 0ef8ea6

Please sign in to comment.