Skip to content
This repository was archived by the owner on Aug 12, 2022. It is now read-only.

Commit ebd68fa

Browse files
authored
Merge pull request #134 from readium/2.0.0-alpha.1
2.0.0-alpha.1
2 parents 7f8bd93 + 97128e6 commit ebd68fa

File tree

14 files changed

+218
-47
lines changed

14 files changed

+218
-47
lines changed

.github/CODEOWNERS

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.
66

77
## [Unreleased]
88

9+
## [2.0.0-alpha.1]
10+
911
### Added
1012

1113
* Support for pop-up footnotes (contributed by [@tooolbox](https://github.com/readium/r2-navigator-swift/pull/118)).
@@ -29,4 +31,4 @@ All notable changes to this project will be documented in this file.
2931
* Touching interactive elements in fixed-layout EPUBs, when two-page spreads are enabled.
3032

3133
[unreleased]: https://github.com/readium/r2-navigator-swift/compare/master...HEAD
32-
[x.x.x]: https://github.com/readium/r2-navigator-swift/compare/1.2.6...x.x.x
34+
[2.0.0-alpha.1]: https://github.com/readium/r2-navigator-swift/compare/1.2.6...2.0.0-alpha.1

Cartfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#github "readium/r2-shared-swift" == 1.4.3
1+
github "readium/r2-shared-swift" "2.0.0-alpha.1"
22
github "scinfu/SwiftSoup" == 2.3.2

Cartfile.resolved

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
github "cezheng/Fuzi" "3.1.2"
2+
github "dexman/Minizip" "1.4.0"
3+
github "readium/r2-shared-swift" "c77b663dfed7e8e0d9317c7c01daaccb878bf9fb"
14
github "scinfu/SwiftSoup" "2.3.2"

R2Navigator.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Pod::Spec.new do |s|
22

33
s.name = "R2Navigator"
4-
s.version = "1.2.6"
4+
s.version = "2.0.0-alpha.1"
55
s.license = "BSD 3-Clause License"
66
s.summary = "R2 Navigator"
77
s.homepage = "http://readium.github.io"
88
s.author = { "Aferdita Muriqi" => "aferdita.muriqi@gmail.com" }
9-
s.source = { :git => "https://github.com/readium/r2-navigator-swift.git", :tag => "1.2.6" }
9+
s.source = { :git => "https://github.com/readium/r2-navigator-swift.git", :tag => "2.0.0-alpha.1" }
1010
s.exclude_files = ["**/Info*.plist"]
1111
s.requires_arc = true
1212
s.resources = ['r2-navigator-swift/Resources/**', 'r2-navigator-swift/EPUB/Resources/**']

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ install R2Navigator with Carthage:
2020
2. Update your Cartfile to include the following:
2121

2222
```ruby
23-
github "readium/r2-navigator-swift" ~> 1.0.6
23+
github "readium/r2-navigator-swift" "develop"
2424
```
2525

2626
3. Run `carthage update` and
@@ -52,7 +52,7 @@ R2Navigator with CocoaPods:
5252
use_frameworks!
5353
5454
target 'YourAppTargetName' do
55-
pod 'R2Navigator', :git => 'https://github.com/readium/r2-navigator-swift.git', '~> 1.0.6'
55+
pod 'R2Navigator', :git => 'https://github.com/readium/r2-navigator-swift.git', :branch => 'develop'
5656
end
5757
```
5858

r2-navigator-swift.xcodeproj/project.pbxproj

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
CA90372222D8C94C00D4C86F /* fxl-spread-two.html in Resources */ = {isa = PBXBuildFile; fileRef = CA90372022D8C94C00D4C86F /* fxl-spread-two.html */; };
1818
CA94292122BCF97700305CDB /* Static in Resources */ = {isa = PBXBuildFile; fileRef = CA94292022BCF97700305CDB /* Static */; };
1919
CA94293022BD2D2F00305CDB /* Scripts in Resources */ = {isa = PBXBuildFile; fileRef = CA94292F22BD2D2F00305CDB /* Scripts */; };
20+
CAAABA9B24D695E5004A4466 /* TargetAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAAABA9A24D695E5004A4466 /* TargetAction.swift */; };
2021
CAB9086B22492D4C00711C3F /* Navigator.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAB9086A22492D4C00711C3F /* Navigator.swift */; };
2122
CAC2A6D72292E4BA000AA2A7 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAC2A6D62292E4BA000AA2A7 /* WebView.swift */; };
2223
CACE84F82254BE5F00E19E8B /* PDFDocumentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CACE84F72254BE5F00E19E8B /* PDFDocumentView.swift */; };
@@ -28,6 +29,7 @@
2829
CAEACA222272EFBD00476340 /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAEACA212272EFBD00476340 /* ImageViewController.swift */; };
2930
CAF1E3F122DC98C200E807EA /* EPUBSpread.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF1E3F022DC98C200E807EA /* EPUBSpread.swift */; };
3031
CAF1E3F522DF23F400E807EA /* PaginationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAF1E3F422DF23F400E807EA /* PaginationView.swift */; };
32+
CAFB017724D48FC2006B074C /* PDFTapGestureController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFB017624D48FC2006B074C /* PDFTapGestureController.swift */; };
3133
F341C2711F506ED5005E6758 /* UserSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = F341C2701F506ED5005E6758 /* UserSettings.swift */; };
3234
F3E7D3D41F4D83B000DF166D /* r2-navigator-swift.h in Headers */ = {isa = PBXBuildFile; fileRef = F3E7D3C61F4D83B000DF166D /* r2-navigator-swift.h */; settings = {ATTRIBUTES = (Public, ); }; };
3335
F3E7D3E21F4D84A000DF166D /* EPUBNavigatorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3E7D3E11F4D84A000DF166D /* EPUBNavigatorViewController.swift */; };
@@ -46,6 +48,7 @@
4648
CA90372022D8C94C00D4C86F /* fxl-spread-two.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "fxl-spread-two.html"; sourceTree = "<group>"; };
4749
CA94292022BCF97700305CDB /* Static */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Static; sourceTree = "<group>"; };
4850
CA94292F22BD2D2F00305CDB /* Scripts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Scripts; sourceTree = "<group>"; };
51+
CAAABA9A24D695E5004A4466 /* TargetAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TargetAction.swift; sourceTree = "<group>"; };
4952
CAB9086A22492D4C00711C3F /* Navigator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Navigator.swift; sourceTree = "<group>"; };
5053
CAC2A6D62292E4BA000AA2A7 /* WebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = "<group>"; };
5154
CACE84F72254BE5F00E19E8B /* PDFDocumentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PDFDocumentView.swift; sourceTree = "<group>"; };
@@ -57,6 +60,7 @@
5760
CAEACA212272EFBD00476340 /* ImageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewController.swift; sourceTree = "<group>"; };
5861
CAF1E3F022DC98C200E807EA /* EPUBSpread.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EPUBSpread.swift; sourceTree = "<group>"; };
5962
CAF1E3F422DF23F400E807EA /* PaginationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaginationView.swift; sourceTree = "<group>"; };
63+
CAFB017624D48FC2006B074C /* PDFTapGestureController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PDFTapGestureController.swift; sourceTree = "<group>"; };
6064
F341C2701F506ED5005E6758 /* UserSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserSettings.swift; sourceTree = "<group>"; };
6165
F3E7D3C31F4D83B000DF166D /* R2Navigator.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = R2Navigator.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6266
F3E7D3C61F4D83B000DF166D /* r2-navigator-swift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "r2-navigator-swift.h"; sourceTree = "<group>"; };
@@ -85,19 +89,21 @@
8589
children = (
8690
CA0B3AC2222EE555006D9363 /* PDFNavigatorViewController.swift */,
8791
CACE84F72254BE5F00E19E8B /* PDFDocumentView.swift */,
92+
CAFB017624D48FC2006B074C /* PDFTapGestureController.swift */,
8893
);
8994
path = PDF;
9095
sourceTree = "<group>";
9196
};
9297
CA479DC1226493390053445E /* Toolkit */ = {
9398
isa = PBXGroup;
9499
children = (
100+
CA1E4F4A240037E6009C4DE3 /* CompletionList.swift */,
101+
CAF1E3F422DF23F400E807EA /* PaginationView.swift */,
102+
CAD178B522B3B553004E6812 /* R2NavigatorLocalizedString.swift */,
103+
CAAABA9A24D695E5004A4466 /* TargetAction.swift */,
95104
CA479DC2226493570053445E /* UIView.swift */,
96105
CA479DC42264AEA20053445E /* UIColor.swift */,
97-
CAF1E3F422DF23F400E807EA /* PaginationView.swift */,
98106
CAC2A6D62292E4BA000AA2A7 /* WebView.swift */,
99-
CAD178B522B3B553004E6812 /* R2NavigatorLocalizedString.swift */,
100-
CA1E4F4A240037E6009C4DE3 /* CompletionList.swift */,
101107
);
102108
path = Toolkit;
103109
sourceTree = "<group>";
@@ -251,6 +257,7 @@
251257
hasScannedForEncodings = 0;
252258
knownRegions = (
253259
en,
260+
Base,
254261
);
255262
mainGroup = F3E7D3B91F4D83B000DF166D;
256263
productRefGroup = F3E7D3C41F4D83B000DF166D /* Products */;
@@ -289,11 +296,13 @@
289296
CAB9086B22492D4C00711C3F /* Navigator.swift in Sources */,
290297
CA0B3AC3222EE555006D9363 /* PDFNavigatorViewController.swift in Sources */,
291298
F3E7D3E61F4D84EF00DF166D /* EPUBSpreadView.swift in Sources */,
299+
CAAABA9B24D695E5004A4466 /* TargetAction.swift in Sources */,
292300
F3E7D42E1F4EE0FE00DF166D /* CBZNavigatorViewController.swift in Sources */,
293301
CA479DC52264AEA20053445E /* UIColor.swift in Sources */,
294302
CAD178B622B3B553004E6812 /* R2NavigatorLocalizedString.swift in Sources */,
295303
CAEACA222272EFBD00476340 /* ImageViewController.swift in Sources */,
296304
CACE84FB2254BFEE00E19E8B /* EditingAction.swift in Sources */,
305+
CAFB017724D48FC2006B074C /* PDFTapGestureController.swift in Sources */,
297306
F341C2711F506ED5005E6758 /* UserSettings.swift in Sources */,
298307
CACE851F225CDE3400E19E8B /* EPUBFixedSpreadView.swift in Sources */,
299308
CA479DC3226493570053445E /* UIView.swift in Sources */,
@@ -456,6 +465,7 @@
456465
"$(inherited)",
457466
"$(PROJECT_DIR)/Carthage/Build/iOS",
458467
);
468+
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2";
459469
INFOPLIST_FILE = "r2-navigator-swift/Info.plist";
460470
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
461471
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
@@ -485,6 +495,7 @@
485495
"$(inherited)",
486496
"$(PROJECT_DIR)/Carthage/Build/iOS",
487497
);
498+
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2";
488499
INFOPLIST_FILE = "r2-navigator-swift/Info.plist";
489500
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
490501
IPHONEOS_DEPLOYMENT_TARGET = 9.0;

r2-navigator-swift/CBZ/ImageViewController.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ final class ImageViewController: UIViewController, Loggable {
5656
imageView.contentMode = .scaleAspectFit
5757
scrollView.addSubview(imageView)
5858

59-
// Adds an empty view before the scroll view to have a consistent behavior on all iOS versions, regarding to the content inset adjustements. Even if automaticallyAdjustsScrollViewInsets is not set to false on the navigator's parent view controller, the scroll view insets won't be adjusted if the scroll view is not the first child in the subviews hierarchy.
59+
// Adds an empty view before the scroll view to have a consistent behavior on all iOS
60+
// versions, regarding to the content inset adjustements. Even if
61+
// automaticallyAdjustsScrollViewInsets is not set to false on the navigator's parent view
62+
// controller, the scroll view insets won't be adjusted if the scroll view is not the first
63+
// child in the subviews hierarchy.
6064
view.insertSubview(UIView(frame: .zero), at: 0)
6165
if #available(iOS 11.0, *) {
6266
// Prevents the pages from jumping down when the status bar is toggled

r2-navigator-swift/EPUB/EPUBNavigatorViewController.swift

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,21 +264,31 @@ open class EPUBNavigatorViewController: UIViewController, VisualNavigator, Logga
264264
// MARK: - Navigator
265265

266266
public var currentLocation: Locator? {
267-
guard let spreadView = paginationView.currentView as? EPUBSpreadView,
268-
let href = Optional(spreadView.spread.leading.href),
269-
let positionList = publication.positionsByResource[href],
270-
positionList.count > 0 else
271-
{
267+
guard let spreadView = paginationView.currentView as? EPUBSpreadView else {
272268
return nil
273269
}
274-
275-
// Gets the current locator from the positionList, and fill its missing data.
270+
271+
let link = spreadView.spread.leading
272+
let href = link.href
276273
let progression = spreadView.progression(in: href)
277-
let positionIndex = Int(ceil(progression * Double(positionList.count - 1)))
278-
return positionList[positionIndex].copy(
279-
title: tableOfContentsTitleByHref[href],
280-
locations: { $0.progression = progression }
281-
)
274+
275+
// The positions are not always available, for example a Readium WebPub doesn't have any
276+
// unless a Publication Positions Web Service is provided.
277+
if
278+
let positionList = publication.positionsByResource[href],
279+
positionList.count > 0
280+
{
281+
// Gets the current locator from the positionList, and fill its missing data.
282+
let positionIndex = Int(ceil(progression * Double(positionList.count - 1)))
283+
return positionList[positionIndex].copy(
284+
title: tableOfContentsTitleByHref[href],
285+
locations: { $0.progression = progression }
286+
)
287+
} else {
288+
return Locator(link: link).copy(
289+
locations: { $0.progression = progression }
290+
)
291+
}
282292
}
283293

284294
/// Last current location notified to the delegate.

r2-navigator-swift/PDF/PDFDocumentView.swift

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,45 @@
1212
import Foundation
1313
import PDFKit
1414

15-
1615
@available(iOS 11.0, *)
1716
public final class PDFDocumentView: PDFView {
1817

1918
var editingActions: EditingActionsController
20-
19+
2120
init(frame: CGRect, editingActions: EditingActionsController) {
2221
self.editingActions = editingActions
22+
2323
super.init(frame: frame)
24+
25+
// For a reader, the default inset adjustement is not appropriate. Usually, we want to
26+
// display any navigation bar above the content (to avoid it jumping when toggling the
27+
// navigation bars), while still making sure that the content is entirely visible despite
28+
// the screen notches.
29+
// Thefore, we will handle the adjustement manually by only taking the notch area into
30+
// account.
31+
firstScrollView?.contentInsetAdjustmentBehavior = .never
2432
}
25-
33+
2634
required init?(coder aDecoder: NSCoder) {
2735
fatalError("init(coder:) has not been implemented")
2836
}
2937

38+
public override func safeAreaInsetsDidChange() {
39+
super.safeAreaInsetsDidChange()
40+
updateContentInset()
41+
}
42+
43+
public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
44+
super.traitCollectionDidChange(previousTraitCollection)
45+
updateContentInset()
46+
}
47+
48+
private func updateContentInset() {
49+
// Setting the horizontal values triggers shifts the content incorrectly, somehow.
50+
firstScrollView?.contentInset.top = notchAreaInsets.top
51+
firstScrollView?.contentInset.bottom = notchAreaInsets.bottom
52+
}
53+
3054
public override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
3155
return super.canPerformAction(action, withSender: sender) && editingActions.canPerformAction(action)
3256
}

0 commit comments

Comments
 (0)