This repository has been archived by the owner on Aug 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from readium/2.0.0-alpha.1
2.0.0-alpha.1
- Loading branch information
Showing
14 changed files
with
218 additions
and
47 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#github "readium/r2-shared-swift" == 1.4.3 | ||
github "readium/r2-shared-swift" "2.0.0-alpha.1" | ||
github "scinfu/SwiftSoup" == 2.3.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
github "cezheng/Fuzi" "3.1.2" | ||
github "dexman/Minizip" "1.4.0" | ||
github "readium/r2-shared-swift" "c77b663dfed7e8e0d9317c7c01daaccb878bf9fb" | ||
github "scinfu/SwiftSoup" "2.3.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
Pod::Spec.new do |s| | ||
|
||
s.name = "R2Navigator" | ||
s.version = "1.2.6" | ||
s.version = "2.0.0-alpha.1" | ||
s.license = "BSD 3-Clause License" | ||
s.summary = "R2 Navigator" | ||
s.homepage = "http://readium.github.io" | ||
s.author = { "Aferdita Muriqi" => "[email protected]" } | ||
s.source = { :git => "https://github.com/readium/r2-navigator-swift.git", :tag => "1.2.6" } | ||
s.source = { :git => "https://github.com/readium/r2-navigator-swift.git", :tag => "2.0.0-alpha.1" } | ||
s.exclude_files = ["**/Info*.plist"] | ||
s.requires_arc = true | ||
s.resources = ['r2-navigator-swift/Resources/**', 'r2-navigator-swift/EPUB/Resources/**'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// PDFTapGestureController.swift | ||
// r2-navigator-swift | ||
// | ||
// Created by Mickaël Menu on 31/07/2020. | ||
// | ||
// Copyright 2020 Readium Foundation. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license which is detailed | ||
// in the LICENSE file present in the project repository where this source code is maintained. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
import PDFKit | ||
|
||
/// Since iOS 13, the way to add a properly functioning tap gesture recognizer on a `PDFView` | ||
/// significantly changed. This class handles the setup depending on the current iOS version. | ||
@available(iOS 11.0, *) | ||
final class PDFTapGestureController: NSObject { | ||
|
||
private let pdfView: PDFView | ||
private let tapAction: TargetAction | ||
private var tapRecognizer: UITapGestureRecognizer! | ||
|
||
init(pdfView: PDFView, target: Any, action: Selector) { | ||
assert(pdfView.superview != nil, "The PDFView must be in the view hierarchy") | ||
|
||
self.pdfView = pdfView | ||
self.tapAction = TargetAction(target: target, action: action) | ||
|
||
super.init() | ||
|
||
self.tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTap)) | ||
|
||
if #available(iOS 13.0, *) { | ||
// If we add the gesture on the superview on iOS 13, then it will be triggered when | ||
// taping a link. | ||
// The delegate will be used to make sure that this recognizer has a lower precedence | ||
// over the default tap recognizer of the `PDFView`, which is used to handle links. | ||
tapRecognizer.delegate = self | ||
pdfView.addGestureRecognizer(tapRecognizer) | ||
|
||
} else { | ||
// Before iOS 13, the gesture must be on the superview to prevent conflicts. | ||
pdfView.superview?.addGestureRecognizer(tapRecognizer) | ||
} | ||
} | ||
|
||
@objc private func didTap(_ gesture: UITapGestureRecognizer) { | ||
// On iOS 13, the tap to clear text selection is broken by adding the tap recognizer, so | ||
// we clear it manually. | ||
guard pdfView.currentSelection == nil else { | ||
pdfView.clearSelection() | ||
return | ||
} | ||
|
||
self.tapAction.invoke(from: gesture) | ||
} | ||
|
||
} | ||
|
||
@available(iOS 11.0, *) | ||
extension PDFTapGestureController: UIGestureRecognizerDelegate { | ||
|
||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { | ||
return true | ||
} | ||
|
||
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool { | ||
return (otherGestureRecognizer as? UITapGestureRecognizer)?.numberOfTouchesRequired == 1 | ||
} | ||
|
||
} |
Oops, something went wrong.