Skip to content

Commit d5a66ca

Browse files
authored
iOS Catalog Improvements (#402)
* Show the settings button in the `ConfiguredPDFViewComponent` iOS example * Add README file for the Catalog * Fix issue where the `pageIndex` prop needed to be set before the document prop. The order should not be important. * Update README * Bump version number to 1.30.18
1 parent 9e77a41 commit d5a66ca

File tree

10 files changed

+74
-10
lines changed

10 files changed

+74
-10
lines changed

ios/RCTPSPDFKit/RCTPSPDFKitView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
2222
@property (nonatomic, readonly) UIBarButtonItem *closeButton;
2323
@property (nonatomic) BOOL disableDefaultActionForTappedAnnotations;
2424
@property (nonatomic) BOOL disableAutomaticSaving;
25+
@property (nonatomic) PSPDFPageIndex pageIndex;
2526
@property (nonatomic, copy, nullable) NSString *annotationAuthorName;
2627
@property (nonatomic, copy) RCTBubblingEventBlock onCloseButtonPressed;
2728
@property (nonatomic, copy) RCTBubblingEventBlock onDocumentSaved;

ios/RCTPSPDFKit/RCTPSPDFKitViewManager.m

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,24 @@ @implementation RCTPSPDFKitViewManager
4141
if (json) {
4242
view.pdfController.document = [RCTConvert PSPDFDocument:json];
4343
view.pdfController.document.delegate = (id<PSPDFDocumentDelegate>)view;
44-
45-
// The author name may be set before the document exists. We set it again here when the document exists.
44+
45+
// The following properties need to be set after the document is set.
46+
// We set them again here when we're certain the document exists.
4647
if (view.annotationAuthorName) {
4748
view.pdfController.document.defaultAnnotationUsername = view.annotationAuthorName;
4849
}
50+
51+
view.pdfController.pageIndex = view.pageIndex;
4952
}
5053
}
5154

52-
RCT_REMAP_VIEW_PROPERTY(pageIndex, pdfController.pageIndex, NSUInteger)
55+
RCT_CUSTOM_VIEW_PROPERTY(pageIndex, PSPDFPageIndex, RCTPSPDFKitView) {
56+
if (json) {
57+
PSPDFPageIndex idx = [RCTConvert NSUInteger:json];
58+
view.pageIndex = idx;
59+
view.pdfController.pageIndex = idx;
60+
}
61+
}
5362

5463
RCT_CUSTOM_VIEW_PROPERTY(configuration, PSPDFConfiguration, RCTPSPDFKitView) {
5564
if (json) {
@@ -357,7 +366,7 @@ - (instancetype)initWithFontFamilyDescriptors:(NSArray *)fontFamilyDescriptors {
357366
// Override the default font family descriptors if custom font descriptors are specified.
358367
NSArray *customFontFamilyDescriptors = [self customFontFamilyDescriptors];
359368
if (customFontFamilyDescriptors.count) {
360-
fontFamilyDescriptors = customFontFamilyDescriptors;
369+
fontFamilyDescriptors = customFontFamilyDescriptors;
361370
}
362371
return [super initWithFontFamilyDescriptors:fontFamilyDescriptors];
363372
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-pspdfkit",
3-
"version": "1.30.17",
3+
"version": "1.30.18",
44
"description": "A React Native module for the PSPDFKit library.",
55
"keywords": [
66
"react native",

samples/Catalog/Catalog.ios.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ class ConfiguredPDFViewComponent extends Component {
312312
useParentNavigationBar: false,
313313
allowToolbarTitleChange: false,
314314
}}
315+
leftBarButtonItems={["settingsButtonItem"]}
315316
toolbarTitle={"Custom Title"}
316317
style={{ flex: 1, color: pspdfkitColor }}
317318
/>

samples/Catalog/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## Catalog
2+
3+
The project contains a large set of sample code, which illustrates how to set up and customize PSPDFKit for various use cases. You can run the Catalog app on Android and iOS.
4+
5+
### Running the Catalog on Android
6+
7+
#### Requirements
8+
9+
- Android SDK
10+
- Android NDK
11+
- Android Build Tools 23.0.1 (React Native)
12+
- Android Build Tools 28.0.3 (PSPDFKit module)
13+
- Android Gradle plugin 3.4.1 or later.
14+
- PSPDFKit for Android 6.6.0 or later.
15+
- React Native 0.60.4.
16+
17+
#### Getting Started
18+
19+
1. Clone the repository. `git clone https://github.com/PSPDFKit/react-native.git`.
20+
2. Install dependencies: run `yarn install` from `samples/Catalog` directory. (Because of a [bug](https://github.com/yarnpkg/yarn/issues/2165) you may need to clean `yarn`'s cache with `yarn cache clean` before.)
21+
3. Update license key in `samples/Catalog/android/app/src/main/AndroidManifest.xml`:
22+
23+
```xml
24+
<application>
25+
...
26+
27+
<meta-data
28+
android:name="pspdfkit_license_key"
29+
android:value="YOUR_LICENSE_KEY_GOES_HERE"/>
30+
31+
</application>
32+
```
33+
34+
4. Catalog app is now ready to launch. From `samples/Catalog` directory run `react-native run-android`.
35+
36+
### Running the Catalog on iOS
37+
38+
#### Requirements
39+
40+
- The latest [Xcode](https://developer.apple.com/xcode/).
41+
- the latest version of PSPDFKit for iOS.
42+
- React Native 0.60.4.
43+
44+
#### Getting Started
45+
46+
1. Clone the repository: `git clone https://github.com/PSPDFKit/react-native.git`.
47+
2. Step into your newly cloned folder: `cd react-native` and create a new `PSPDFKit` directory: `mkdir PSPDFKit`.
48+
3. [Download the latest version of PSPDFKit for iOS](https://customers.pspdfkit.com/download/binary/ios/latest) and mount the DMG file.
49+
4. Copy `PSPDFKit.xcframework` and `PSPDFKitUI.xcframework` into the `PSPDFKit` directory.
50+
5. Install dependencies: `yarn install` in `samples/Catalog` directory. (Because of a [bug](https://github.com/yarnpkg/yarn/issues/2165) you may need to clean `yarn`'s cache with `yarn cache clean` before.)
51+
6. Run the app with `react-native-cli`: `react-native run-ios`
52+
53+
**Note:** If you get an error about `config.h` not being found check out [this blog post](https://tuntunir.blogspot.com/2018/02/react-native-fatal-error-configh-file.html) for information on how to fix it.

samples/Catalog/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Catalog",
3-
"version": "1.30.17",
3+
"version": "1.30.18",
44
"private": true,
55
"scripts": {
66
"start": "react-native start",

samples/Catalog/yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5420,7 +5420,7 @@ react-native-permissions@^1.1.1:
54205420
integrity sha512-t0Ujm177bagjUOSzhpmkSz+LqFW04HnY9TeZFavDCmV521fQvFz82aD+POXqWsAdsJVOK3umJYBNNqCjC3g0hQ==
54215421

54225422
"react-native-pspdfkit@file:../..":
5423-
version "1.30.17"
5423+
version "1.30.18"
54245424

54255425
react-native-qrcode-scanner@^1.2.1:
54265426
version "1.2.1"

samples/NativeCatalog/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "NativeCatalog",
3-
"version": "1.30.17",
3+
"version": "1.30.18",
44
"private": true,
55
"scripts": {
66
"android": "react-native run-android",

samples/NativeCatalog/yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5511,7 +5511,7 @@ react-native-gesture-handler@^1.3.0:
55115511
prop-types "^15.7.2"
55125512

55135513
"react-native-pspdfkit@file:../..":
5514-
version "1.30.17"
5514+
version "1.30.18"
55155515

55165516
react-native-safe-area-view@^0.14.1:
55175517
version "0.14.8"

0 commit comments

Comments
 (0)