Skip to content

iOS Catalog Improvements #402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ios/RCTPSPDFKit/RCTPSPDFKitView.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) UIBarButtonItem *closeButton;
@property (nonatomic) BOOL disableDefaultActionForTappedAnnotations;
@property (nonatomic) BOOL disableAutomaticSaving;
@property (nonatomic) PSPDFPageIndex pageIndex;
@property (nonatomic, copy, nullable) NSString *annotationAuthorName;
@property (nonatomic, copy) RCTBubblingEventBlock onCloseButtonPressed;
@property (nonatomic, copy) RCTBubblingEventBlock onDocumentSaved;
Expand Down
17 changes: 13 additions & 4 deletions ios/RCTPSPDFKit/RCTPSPDFKitViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,24 @@ @implementation RCTPSPDFKitViewManager
if (json) {
view.pdfController.document = [RCTConvert PSPDFDocument:json];
view.pdfController.document.delegate = (id<PSPDFDocumentDelegate>)view;

// The author name may be set before the document exists. We set it again here when the document exists.

// The following properties need to be set after the document is set.
// We set them again here when we're certain the document exists.
if (view.annotationAuthorName) {
view.pdfController.document.defaultAnnotationUsername = view.annotationAuthorName;
}

view.pdfController.pageIndex = view.pageIndex;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 to allow setting this after the document is set.

}
}

RCT_REMAP_VIEW_PROPERTY(pageIndex, pdfController.pageIndex, NSUInteger)
RCT_CUSTOM_VIEW_PROPERTY(pageIndex, PSPDFPageIndex, RCTPSPDFKitView) {
if (json) {
PSPDFPageIndex idx = [RCTConvert NSUInteger:json];
view.pageIndex = idx;
view.pdfController.pageIndex = idx;
}
}

RCT_CUSTOM_VIEW_PROPERTY(configuration, PSPDFConfiguration, RCTPSPDFKitView) {
if (json) {
Expand Down Expand Up @@ -357,7 +366,7 @@ - (instancetype)initWithFontFamilyDescriptors:(NSArray *)fontFamilyDescriptors {
// Override the default font family descriptors if custom font descriptors are specified.
NSArray *customFontFamilyDescriptors = [self customFontFamilyDescriptors];
if (customFontFamilyDescriptors.count) {
fontFamilyDescriptors = customFontFamilyDescriptors;
fontFamilyDescriptors = customFontFamilyDescriptors;
}
return [super initWithFontFamilyDescriptors:fontFamilyDescriptors];
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-pspdfkit",
"version": "1.30.17",
"version": "1.30.18",
"description": "A React Native module for the PSPDFKit library.",
"keywords": [
"react native",
Expand Down
1 change: 1 addition & 0 deletions samples/Catalog/Catalog.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ class ConfiguredPDFViewComponent extends Component {
useParentNavigationBar: false,
allowToolbarTitleChange: false,
}}
leftBarButtonItems={["settingsButtonItem"]}
toolbarTitle={"Custom Title"}
style={{ flex: 1, color: pspdfkitColor }}
/>
Expand Down
53 changes: 53 additions & 0 deletions samples/Catalog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## Catalog

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.

### Running the Catalog on Android

#### Requirements

- Android SDK
- Android NDK
- Android Build Tools 23.0.1 (React Native)
- Android Build Tools 28.0.3 (PSPDFKit module)
- Android Gradle plugin 3.4.1 or later.
- PSPDFKit for Android 6.6.0 or later.
- React Native 0.60.4.

#### Getting Started

1. Clone the repository. `git clone https://github.com/PSPDFKit/react-native.git`.
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.)
3. Update license key in `samples/Catalog/android/app/src/main/AndroidManifest.xml`:

```xml
<application>
...

<meta-data
android:name="pspdfkit_license_key"
android:value="YOUR_LICENSE_KEY_GOES_HERE"/>

</application>
```

4. Catalog app is now ready to launch. From `samples/Catalog` directory run `react-native run-android`.

### Running the Catalog on iOS

#### Requirements

- The latest [Xcode](https://developer.apple.com/xcode/).
- the latest version of PSPDFKit for iOS.
- React Native 0.60.4.

#### Getting Started

1. Clone the repository: `git clone https://github.com/PSPDFKit/react-native.git`.
2. Step into your newly cloned folder: `cd react-native` and create a new `PSPDFKit` directory: `mkdir PSPDFKit`.
3. [Download the latest version of PSPDFKit for iOS](https://customers.pspdfkit.com/download/binary/ios/latest) and mount the DMG file.
4. Copy `PSPDFKit.xcframework` and `PSPDFKitUI.xcframework` into the `PSPDFKit` directory.
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.)
6. Run the app with `react-native-cli`: `react-native run-ios`

**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.
2 changes: 1 addition & 1 deletion samples/Catalog/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Catalog",
"version": "1.30.17",
"version": "1.30.18",
"private": true,
"scripts": {
"start": "react-native start",
Expand Down
2 changes: 1 addition & 1 deletion samples/Catalog/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5420,7 +5420,7 @@ react-native-permissions@^1.1.1:
integrity sha512-t0Ujm177bagjUOSzhpmkSz+LqFW04HnY9TeZFavDCmV521fQvFz82aD+POXqWsAdsJVOK3umJYBNNqCjC3g0hQ==

"react-native-pspdfkit@file:../..":
version "1.30.17"
version "1.30.18"

react-native-qrcode-scanner@^1.2.1:
version "1.2.1"
Expand Down
2 changes: 1 addition & 1 deletion samples/NativeCatalog/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "NativeCatalog",
"version": "1.30.17",
"version": "1.30.18",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand Down
2 changes: 1 addition & 1 deletion samples/NativeCatalog/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5511,7 +5511,7 @@ react-native-gesture-handler@^1.3.0:
prop-types "^15.7.2"

"react-native-pspdfkit@file:../..":
version "1.30.17"
version "1.30.18"

react-native-safe-area-view@^0.14.1:
version "0.14.8"
Expand Down