Skip to content

Commit

Permalink
Removed reader
Browse files Browse the repository at this point in the history
  • Loading branch information
michalrentka committed Nov 30, 2023
1 parent d2fe8db commit 463bb36
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 32,672 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class AnnotationToolbarHandler: NSObject {
static let toolbarCompactInset: CGFloat = 12
static let toolbarFullInsetInset: CGFloat = 20
static let minToolbarWidth: CGFloat = 300
private static let annotationToolbarDragHandleHeight: CGFloat = 50
static let annotationToolbarDragHandleHeight: CGFloat = 50
private let previewBackgroundColor: UIColor
private let previewDashColor: UIColor
private let previewSelectedBackgroundColor: UIColor
Expand Down
78 changes: 2 additions & 76 deletions Zotero/Scenes/Detail/PDF/Views/PDFReaderViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -836,80 +836,6 @@ extension PDFReaderViewController: AnnotationBoundingBoxConverter {
}
}

extension PDFReaderViewController: AnnotationToolbarDelegate {
var rotation: AnnotationToolbarViewController.Rotation {
switch self.toolbarState.position {
case .leading, .trailing: return .vertical
case .top, .pinned: return .horizontal
}
}

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

var activeAnnotationTool: AnnotationToolbarViewController.Tool? {
return self.documentController.pdfController?.annotationStateManager.state?.toolbarTool
}

var maxAvailableToolbarSize: CGFloat {
guard self.toolbarState.visible, let documentController = self.documentController else { return 0 }

switch self.toolbarState.position {
case .top, .pinned:
return self.isCompactWidth ? documentController.view.frame.size.width : (documentController.view.frame.size.width - (2 * AnnotationToolbarHandler.toolbarFullInsetInset))

case .trailing, .leading:
let window = (view.scene as? UIWindowScene)?.windows.first(where: \.isKeyWindow)
let topInset = window?.safeAreaInsets.top ?? 0
let bottomInset = window?.safeAreaInsets.bottom ?? 0
let interfaceIsHidden = self.navigationController?.isNavigationBarHidden ?? false
return self.view.frame.size.height - (2 * AnnotationToolbarHandler.toolbarCompactInset) - (interfaceIsHidden ? 0 : (topInset + documentController.scrubberBarHeight)) - bottomInset
}
}

var containerView: UIView {
return self.view
}

var documentView: UIView {
return self.documentController.view
}

func isCompactSize(for rotation: AnnotationToolbarViewController.Rotation) -> Bool {
switch rotation {
case .horizontal:
return self.isCompactWidth

case .vertical:
return self.view.frame.height <= 400
}
}

func toggle(tool: AnnotationToolbarViewController.Tool, options: AnnotationToolOptions) {
let pspdfkitTool = tool.pspdfkitTool
let color = self.viewModel.state.toolColors[pspdfkitTool]
self.documentController.toggle(annotationTool: pspdfkitTool, color: color, tappedWithStylus: (options == .stylus))
}

var canUndo: Bool {
return self.viewModel.state.document.undoController.undoManager.canUndo
}

func performUndo() {
self.viewModel.state.document.undoController.undoManager.undo()
}

var canRedo: Bool {
return self.viewModel.state.document.undoController.undoManager.canRedo
}

func performRedo() {
self.viewModel.state.document.undoController.undoManager.redo()
}
}

extension PDFReaderViewController: UIGestureRecognizerDelegate {
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
guard let longPressRecognizer = gestureRecognizer as? UILongPressGestureRecognizer else { return true }
Expand All @@ -921,11 +847,11 @@ extension PDFReaderViewController: UIGestureRecognizerDelegate {
switch self.toolbarState.position {
case .pinned, .top:
currentLocation = location.x
border = self.annotationToolbarController.view.frame.width - PDFReaderViewController.annotationToolbarDragHandleHeight
border = self.annotationToolbarController.view.frame.width - AnnotationToolbarHandler.annotationToolbarDragHandleHeight

case .leading, .trailing:
currentLocation = location.y
border = self.annotationToolbarController.view.frame.height - PDFReaderViewController.annotationToolbarDragHandleHeight
border = self.annotationToolbarController.view.frame.height - AnnotationToolbarHandler.annotationToolbarDragHandleHeight
}
return currentLocation >= border
}
Expand Down
14 changes: 0 additions & 14 deletions bundled/reader/view.html

This file was deleted.

Loading

0 comments on commit 463bb36

Please sign in to comment.