Skip to content

Commit

Permalink
Fixed locked up state when restoring locked document (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
michalrentka authored Mar 4, 2024
1 parent ec7dbc1 commit 17ac889
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Zotero/Scenes/Detail/PDF/Views/PDFReaderViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ class PDFReaderViewController: UIViewController {
@CodableUserDefault(key: "PDFReaderToolbarState", defaultValue: AnnotationToolbarHandler.State(position: .leading, visible: true), encoder: Defaults.jsonEncoder, decoder: Defaults.jsonDecoder)
var toolbarState: AnnotationToolbarHandler.State
@UserDefault(key: "PDFReaderStatusBarVisible", defaultValue: true)
private var _statusBarVisible: Bool
var statusBarVisible: Bool {
didSet {
(navigationController as? NavigationViewController)?.statusBarVisible = statusBarVisible
get {
return _statusBarVisible || viewModel.state.document.isLocked
}

set {
_statusBarVisible = newValue
(navigationController as? NavigationViewController)?.statusBarVisible = newValue
}
}
private var previousTraitCollection: UITraitCollection?
Expand All @@ -58,6 +64,7 @@ class PDFReaderViewController: UIViewController {

let share = UIBarButtonItem(image: UIImage(systemName: "square.and.arrow.up"), style: .plain, target: nil, action: nil)
share.accessibilityLabel = L10n.Accessibility.Pdf.share
share.isEnabled = !viewModel.state.document.isLocked
share.title = L10n.Accessibility.Pdf.share
share.tag = NavigationBarButton.share.rawValue
let deferredMenu = UIDeferredMenuElement.uncached { [weak self] elementProvider in
Expand Down Expand Up @@ -399,6 +406,7 @@ class PDFReaderViewController: UIViewController {
guard let checkbox = item.customView as? CheckboxButton else { continue }
checkbox.deselectedTintColor = Asset.Colors.zoteroBlueWithDarkMode.color
}
interfaceVisibilityDidChange(to: !toolbarState.visible)
// Load initial document data after document has been unlocked successfully
viewModel.process(action: .loadDocumentData(boundingBoxConverter: documentController))
}
Expand Down Expand Up @@ -686,11 +694,11 @@ extension PDFReaderViewController: AnnotationToolbarHandlerDelegate {
func setNavigationBar(hidden: Bool, animated: Bool) {
navigationController?.setNavigationBarHidden(hidden, animated: animated)
}

func setNavigationBar(alpha: CGFloat) {
navigationController?.navigationBar.alpha = alpha
}

func topDidChange(forToolbarState state: AnnotationToolbarHandler.State) {
let (statusBarOffset, _, totalOffset) = annotationToolbarHandler.topOffsets(statusBarVisible: statusBarVisible)

Expand Down

0 comments on commit 17ac889

Please sign in to comment.