Skip to content

Commit 9a44d9a

Browse files
committed
Update documentation
1 parent 0cc886e commit 9a44d9a

File tree

3 files changed

+71
-5
lines changed

3 files changed

+71
-5
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ All notable changes to this project will be documented in this file. Take a look
1212

1313
* Implementation of the [W3C Accessibility Metadata Display Guide](https://w3c.github.io/publ-a11y/a11y-meta-display-guide/2.0/guidelines/) specification to facilitate displaying accessibility metadata to users. [See the dedicated user guide](docs/Guides/Accessibility.md).
1414

15+
#### Navigator
16+
17+
* A new `InputObserving` API has been added to enable more flexible gesture recognition and support for mouse pointers. [See the dedicated user guide](docs/Guides/Navigator/Input.md).
18+
1519
### Fixed
1620

1721
#### Navigator

TestApp/Sources/Reader/Common/ReaderViewController.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ class ReaderViewController<N: Navigator>: UIViewController,
5858

5959
navigationItem.rightBarButtonItems = makeNavigationBarButtons()
6060
}
61-
61+
6262
override func viewWillAppear(_ animated: Bool) {
6363
super.viewWillAppear(animated)
64-
64+
6565
tabBarController?.isTabBarHidden = true
6666
}
67-
67+
6868
override func viewWillDisappear(_ animated: Bool) {
6969
super.viewWillDisappear(animated)
70-
70+
7171
tabBarController?.isTabBarHidden = false
7272
}
7373

docs/Migration Guide.md

+63-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,69 @@
22

33
All migration steps necessary in reading apps to upgrade to major versions of the Swift Readium toolkit will be documented in this file.
44

5-
<!-- ## Unreleased -->
5+
## Unreleased
6+
7+
### New Input API
8+
9+
A new `InputObserving` API has been added to enable more flexible gesture recognition and support for mouse pointers. [See the dedicated user guide](Guides/Navigator/Input.md).
10+
11+
The `DirectionalNavigationAdapter` was also updated to use this new API, and is easier to use.
12+
13+
To migrate the old API, remove the old `VisualNavigatorDelegate` callbacks, for example:
14+
15+
```diff
16+
-func navigator(_ navigator: VisualNavigator, didTapAt point: CGPoint) {
17+
- Task {
18+
- // Turn pages when tapping the edge of the screen.
19+
- guard await !DirectionalNavigationAdapter(navigator: navigator).didTap(at: point) else {
20+
- return
21+
- }
22+
- // clear a current search highlight
23+
- if let decorator = self.navigator as? DecorableNavigator {
24+
- decorator.apply(decorations: [], in: "search")
25+
- }
26+
-
27+
- toggleNavigationBar()
28+
- }
29+
-}
30+
-
31+
-func navigator(_ navigator: VisualNavigator, didPressKey event: KeyEvent) {
32+
- Task {
33+
- // Turn pages when pressing the arrow keys.
34+
- await DirectionalNavigationAdapter(navigator: navigator).didPressKey(event: event)
35+
- }
36+
-}
37+
```
38+
39+
Instead, setup your observers after initializing the navigator. Return `true` if you want to stop the propagation of a particular event to the next observers.
40+
41+
```swift
42+
/// This adapter will automatically turn pages when the user taps the
43+
/// screen edges or press arrow keys.
44+
///
45+
/// Bind it to the navigator before adding your own observers to prevent
46+
/// triggering your actions when turning pages.
47+
DirectionalNavigationAdapter().bind(to: navigator)
48+
49+
// Clear the current search highlight on tap.
50+
navigator.addObserver(.tap { [weak self] _ in
51+
guard
52+
let searchViewModel = self?.searchViewModel,
53+
searchViewModel.selectedLocator != nil
54+
else {
55+
return false
56+
}
57+
58+
searchViewModel.selectedLocator = nil
59+
return true
60+
})
61+
62+
// Toggle the navigation bar on tap, if nothing else took precedence.
63+
navigator.addObserver(.tap { [weak self] _ in
64+
self?.toggleNavigationBar()
65+
return true
66+
})
67+
```
668

769
## 3.1.0
870

0 commit comments

Comments
 (0)