Skip to content

Commit

Permalink
Fixed disabling active annotation tool
Browse files Browse the repository at this point in the history
  • Loading branch information
michalrentka committed Dec 13, 2024
1 parent bdef9d7 commit a86ae5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ class HtmlEpubDocumentViewController: UIViewController {

extension HtmlEpubDocumentViewController: ParentWithSidebarDocumentController {
func disableAnnotationTools() {
set(tool: nil)
guard let tool = viewModel.state.activeTool else { return }
viewModel.process(action: .toggleTool(tool))
}
}
15 changes: 10 additions & 5 deletions Zotero/Scenes/Detail/ParentWithSidebarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ extension ParentWithSidebarController {
checkbox.rx.controlEvent(.touchUpInside)
.subscribe(onNext: { [weak self, weak checkbox] _ in
guard let self, let checkbox else { return }
checkbox.isSelected = !checkbox.isSelected
annotationToolbarHandler?.set(hidden: !checkbox.isSelected, animated: true)
setAnnotationToolbar(hidden: checkbox.isSelected)
})
.disposed(by: disposeBag)
let barButton = UIBarButtonItem(customView: checkbox)
Expand All @@ -71,10 +70,16 @@ extension ParentWithSidebarController {
return barButton
}

private func setAnnotationToolbar(hidden: Bool) {
(toolbarButton.customView as? CheckboxButton)?.isSelected = !hidden
annotationToolbarHandler?.set(hidden: hidden, animated: true)
if hidden {
documentController?.disableAnnotationTools()
}
}

func closeAnnotationToolbar() {
(toolbarButton.customView as? CheckboxButton)?.isSelected = false
annotationToolbarHandler?.set(hidden: true, animated: true)
documentController?.disableAnnotationTools()
setAnnotationToolbar(hidden: true)
}

func toggleSidebar(animated: Bool, sidebarButtonTag: Int) {
Expand Down

0 comments on commit a86ae5b

Please sign in to comment.