@react-native-ohos/react-native-pdf 6.7.7-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DoubleTapView.js +125 -0
- package/LICENSE +21 -0
- package/PdfManager.js +26 -0
- package/PdfPageView.js +53 -0
- package/PdfView.js +417 -0
- package/PdfViewFlatList.js +30 -0
- package/PinchZoomView.js +125 -0
- package/README.OpenSource +11 -0
- package/README.md +13 -0
- package/fabric/RNPDFPdfNativeComponent.js +48 -0
- package/fabric/RTNPdfViewNativeComponent.ts +57 -0
- package/harmony/pdfview/BuildProfile.ets +17 -0
- package/harmony/pdfview/Index.ets +7 -0
- package/harmony/pdfview/build-profile.json5 +28 -0
- package/harmony/pdfview/consumer-rules.txt +0 -0
- package/harmony/pdfview/hvigorfile.ts +6 -0
- package/harmony/pdfview/obfuscation-rules.txt +18 -0
- package/harmony/pdfview/oh-package-lock.json5 +18 -0
- package/harmony/pdfview/oh-package.json5 +11 -0
- package/harmony/pdfview/src/main/cpp/CMakeLists.txt +8 -0
- package/harmony/pdfview/src/main/cpp/ComponentDescriptors.h +36 -0
- package/harmony/pdfview/src/main/cpp/EventEmitters.cpp +39 -0
- package/harmony/pdfview/src/main/cpp/EventEmitters.h +47 -0
- package/harmony/pdfview/src/main/cpp/PdfEventEmitRequestHandler.h +50 -0
- package/harmony/pdfview/src/main/cpp/PdfViewJSIBinder.h +71 -0
- package/harmony/pdfview/src/main/cpp/PdfViewPackage.h +55 -0
- package/harmony/pdfview/src/main/cpp/Props.cpp +58 -0
- package/harmony/pdfview/src/main/cpp/Props.h +61 -0
- package/harmony/pdfview/src/main/cpp/RTNPdfViewSpecsJSI-generated.cpp +34 -0
- package/harmony/pdfview/src/main/cpp/RTNPdfViewSpecsJSI.h +36 -0
- package/harmony/pdfview/src/main/cpp/ShadowNodes.cpp +33 -0
- package/harmony/pdfview/src/main/cpp/ShadowNodes.h +47 -0
- package/harmony/pdfview/src/main/cpp/States.cpp +33 -0
- package/harmony/pdfview/src/main/cpp/States.h +52 -0
- package/harmony/pdfview/src/main/ets/Logger.ets +64 -0
- package/harmony/pdfview/src/main/ets/components/mainpage/RTNPdfView.ets +513 -0
- package/harmony/pdfview/src/main/ets/components/mainpage/types.ts +15 -0
- package/harmony/pdfview/src/main/module.json5 +11 -0
- package/harmony/pdfview/src/main/resources/base/element/string.json +8 -0
- package/harmony/pdfview/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/pdfview/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/pdfview/src/test/List.test.ets +29 -0
- package/harmony/pdfview/src/test/LocalUnit.test.ets +57 -0
- package/harmony/pdfview.har +0 -0
- package/index.d.ts +72 -0
- package/index.js +491 -0
- package/index.js.flow +67 -0
- package/package.json +61 -0
- package/windows/RCTPdf/PropertySheet.props +16 -0
- package/windows/RCTPdf/RCTPdf.def +3 -0
- package/windows/RCTPdf/RCTPdf.vcxproj +180 -0
- package/windows/RCTPdf/RCTPdf.vcxproj.filters +38 -0
- package/windows/RCTPdf/RCTPdfControl.cpp +667 -0
- package/windows/RCTPdf/RCTPdfControl.h +119 -0
- package/windows/RCTPdf/RCTPdfControl.idl +10 -0
- package/windows/RCTPdf/RCTPdfControl.xaml +33 -0
- package/windows/RCTPdf/RCTPdfViewManager.cpp +69 -0
- package/windows/RCTPdf/RCTPdfViewManager.h +51 -0
- package/windows/RCTPdf/ReactPackageProvider.cpp +15 -0
- package/windows/RCTPdf/ReactPackageProvider.h +16 -0
- package/windows/RCTPdf/ReactPackageProvider.idl +9 -0
- package/windows/RCTPdf/packages.config +4 -0
- package/windows/RCTPdf/pch.cpp +1 -0
- package/windows/RCTPdf/pch.h +31 -0
- package/windows/README.md +21 -0
package/PinchZoomView.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017-present, Wonday (@wonday.org)
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
import React, {Component} from 'react';
|
|
11
|
+
import PropTypes from 'prop-types';
|
|
12
|
+
import {
|
|
13
|
+
View,
|
|
14
|
+
StyleSheet,
|
|
15
|
+
PanResponder
|
|
16
|
+
} from 'react-native';
|
|
17
|
+
import {ViewPropTypes} from 'deprecated-react-native-prop-types';
|
|
18
|
+
export default class PinchZoomView extends Component {
|
|
19
|
+
|
|
20
|
+
static propTypes = {
|
|
21
|
+
...ViewPropTypes,
|
|
22
|
+
scalable: PropTypes.bool,
|
|
23
|
+
onScaleChanged: PropTypes.func,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
static defaultProps = {
|
|
27
|
+
scalable: true,
|
|
28
|
+
onScaleChanged: (scale) => {
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
constructor(props) {
|
|
33
|
+
|
|
34
|
+
super(props);
|
|
35
|
+
this.state = {};
|
|
36
|
+
this.distant = 0;
|
|
37
|
+
this.gestureHandlers = PanResponder.create({
|
|
38
|
+
onStartShouldSetPanResponder: this._handleStartShouldSetPanResponder,
|
|
39
|
+
onMoveShouldSetResponderCapture: (evt, gestureState) => (true),
|
|
40
|
+
onMoveShouldSetPanResponder: this._handleMoveShouldSetPanResponder,
|
|
41
|
+
onPanResponderGrant: this._handlePanResponderGrant,
|
|
42
|
+
onPanResponderMove: this._handlePanResponderMove,
|
|
43
|
+
onPanResponderRelease: this._handlePanResponderEnd,
|
|
44
|
+
onPanResponderTerminationRequest: evt => false,
|
|
45
|
+
onPanResponderTerminate: this._handlePanResponderTerminate,
|
|
46
|
+
onShouldBlockNativeResponder: evt => true
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_handleStartShouldSetPanResponder = (e, gestureState) => {
|
|
52
|
+
|
|
53
|
+
// don't respond to single touch to avoid shielding click on child components
|
|
54
|
+
return false;
|
|
55
|
+
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
_handleMoveShouldSetPanResponder = (e, gestureState) => {
|
|
59
|
+
|
|
60
|
+
return this.props.scalable && (e.nativeEvent.changedTouches.length >= 2 || gestureState.numberActiveTouches >= 2);
|
|
61
|
+
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
_handlePanResponderGrant = (e, gestureState) => {
|
|
65
|
+
|
|
66
|
+
if (e.nativeEvent.changedTouches.length >= 2 || gestureState.numberActiveTouches >= 2) {
|
|
67
|
+
let dx = Math.abs(e.nativeEvent.touches[0].pageX - e.nativeEvent.touches[1].pageX);
|
|
68
|
+
let dy = Math.abs(e.nativeEvent.touches[0].pageY - e.nativeEvent.touches[1].pageY);
|
|
69
|
+
this.distant = Math.sqrt(dx * dx + dy * dy);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
_handlePanResponderEnd = (e, gestureState) => {
|
|
75
|
+
|
|
76
|
+
this.distant = 0;
|
|
77
|
+
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
_handlePanResponderTerminate = (e, gestureState) => {
|
|
81
|
+
|
|
82
|
+
this.distant = 0;
|
|
83
|
+
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
_handlePanResponderMove = (e, gestureState) => {
|
|
87
|
+
|
|
88
|
+
if ((e.nativeEvent.changedTouches.length >= 2 || gestureState.numberActiveTouches >= 2) && this.distant > 100) {
|
|
89
|
+
|
|
90
|
+
let dx = Math.abs(e.nativeEvent.touches[0].pageX - e.nativeEvent.touches[1].pageX);
|
|
91
|
+
let dy = Math.abs(e.nativeEvent.touches[0].pageY - e.nativeEvent.touches[1].pageY);
|
|
92
|
+
let distant = Math.sqrt(dx * dx + dy * dy);
|
|
93
|
+
let scale = (distant / this.distant);
|
|
94
|
+
let pageX = (e.nativeEvent.touches[0].pageX + e.nativeEvent.touches[1].pageX) / 2;
|
|
95
|
+
let pageY = (e.nativeEvent.touches[0].pageY + e.nativeEvent.touches[1].pageY) / 2;
|
|
96
|
+
let pinchInfo = {scale: scale, pageX: pageX, pageY: pageY};
|
|
97
|
+
|
|
98
|
+
this.props.onScaleChanged(pinchInfo);
|
|
99
|
+
this.distant = distant;
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
render() {
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<View
|
|
109
|
+
{...this.props}
|
|
110
|
+
{...this.gestureHandlers?.panHandlers}
|
|
111
|
+
style={[styles.container, this.props.style]}>
|
|
112
|
+
{this.props.children}
|
|
113
|
+
</View>
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const styles = StyleSheet.create({
|
|
120
|
+
container: {
|
|
121
|
+
flex: 1,
|
|
122
|
+
justifyContent: 'center',
|
|
123
|
+
alignItems: 'center'
|
|
124
|
+
}
|
|
125
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"Name": "react-native-pdf",
|
|
4
|
+
"License": "MIT License",
|
|
5
|
+
"License File": "https://github.com/wonday/react-native-pdf/blob/master/LICENSE",
|
|
6
|
+
"Version Number": "6.7.6",
|
|
7
|
+
"Owner" : "xiafeng@huawei.com",
|
|
8
|
+
"Upstream URL": "https://github.com/wonday/react-native-pdf",
|
|
9
|
+
"Description": "A react native PDF view component, support ios and android platform"
|
|
10
|
+
}
|
|
11
|
+
]
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @react-native-ohos/react-native-pdf
|
|
2
|
+
|
|
3
|
+
This project is based on [react-native-pdf](https://github.com/wonday/react-native-pdf)
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
- [中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-pdf.md)
|
|
8
|
+
|
|
9
|
+
- [English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-pdf.md)
|
|
10
|
+
|
|
11
|
+
## License
|
|
12
|
+
|
|
13
|
+
This library is licensed under [The MIT License (MIT)](https://github.com/wonday/react-native-pdf/blob/master/LICENSE)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @flow
|
|
3
|
+
* @format
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
8
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
9
|
+
|
|
10
|
+
type ChangeEvent = $ReadOnly<{|
|
|
11
|
+
message: ?string,
|
|
12
|
+
|}>;
|
|
13
|
+
|
|
14
|
+
export type NativeProps = $ReadOnly<{|
|
|
15
|
+
...ViewProps,
|
|
16
|
+
path: ?string,
|
|
17
|
+
page: ?Int32,
|
|
18
|
+
scale: ?Float,
|
|
19
|
+
minScale: ?Float,
|
|
20
|
+
maxScale: ?Float,
|
|
21
|
+
horizontal: ?boolean,
|
|
22
|
+
enablePaging: ?boolean,
|
|
23
|
+
enableRTL: ?boolean,
|
|
24
|
+
enableAnnotationRendering: ?boolean,
|
|
25
|
+
showsHorizontalScrollIndicator: ?boolean,
|
|
26
|
+
showsVerticalScrollIndicator: ?boolean,
|
|
27
|
+
scrollEnabled: ?boolean,
|
|
28
|
+
enableAntialiasing: ?boolean,
|
|
29
|
+
enableDoubleTapZoom: ?boolean,
|
|
30
|
+
fitPolicy: ?Int32,
|
|
31
|
+
spacing: ?Int32,
|
|
32
|
+
password: ?string,
|
|
33
|
+
onChange: ?BubblingEventHandler<ChangeEvent>,
|
|
34
|
+
singlePage: ?boolean,
|
|
35
|
+
|}>;
|
|
36
|
+
|
|
37
|
+
interface NativeCommands {
|
|
38
|
+
+setNativePage: (
|
|
39
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
40
|
+
page: Int32,
|
|
41
|
+
) => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
45
|
+
supportedCommands: ['setNativePage'],
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export default codegenNativeComponent<NativeProps>('RNPDFPdfView');
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ComponentType } from "react";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import type { HostComponent,ViewProps } from "react-native";
|
|
4
|
+
import { BubblingEventHandler, Float, Int32 } from "react-native/Libraries/Types/CodegenTypes";
|
|
5
|
+
import codegenNativeCommands from "react-native/Libraries/Utilities/codegenNativeCommands";
|
|
6
|
+
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
7
|
+
|
|
8
|
+
type ChangeEvent = {
|
|
9
|
+
message: string,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type Source = {
|
|
13
|
+
uri: string;
|
|
14
|
+
headers?: Array<{ key: string; value: string }>;
|
|
15
|
+
cache?: boolean;
|
|
16
|
+
cacheFileName?: string;
|
|
17
|
+
expiration?: Int32;
|
|
18
|
+
method?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export interface NativeProps extends ViewProps {
|
|
22
|
+
source: Source,
|
|
23
|
+
path?: string,
|
|
24
|
+
page?: Int32,
|
|
25
|
+
scale?: Float,
|
|
26
|
+
minScale?: Float,
|
|
27
|
+
maxScale?: Float,
|
|
28
|
+
horizontal?: boolean,
|
|
29
|
+
enablePaging?: boolean,
|
|
30
|
+
enableRTL?: boolean,
|
|
31
|
+
enableAnnotationRendering?: boolean,
|
|
32
|
+
showsHorizontalScrollIndicator?: boolean,
|
|
33
|
+
showsVerticalScrollIndicator?: boolean,
|
|
34
|
+
scrollEnabled?: boolean,
|
|
35
|
+
enableAntialiasing?: boolean,
|
|
36
|
+
enableDoubleTapZoom?: boolean,
|
|
37
|
+
fitPolicy?: Int32,
|
|
38
|
+
spacing?: Int32,
|
|
39
|
+
password?: string,
|
|
40
|
+
onChange?: BubblingEventHandler<ChangeEvent>,
|
|
41
|
+
singlePage?: boolean,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface NativeCommands {
|
|
45
|
+
setNativePage: (
|
|
46
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
47
|
+
page: Int32,
|
|
48
|
+
) => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
52
|
+
supportedCommands: ['setNativePage'],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export default codegenNativeComponent<NativeProps>(
|
|
56
|
+
"RTNPdfView"
|
|
57
|
+
) as HostComponent<NativeProps>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
|
3
|
+
*/
|
|
4
|
+
export const HAR_VERSION = '6.7.7-rc.1';
|
|
5
|
+
export const BUILD_MODE_NAME = 'debug';
|
|
6
|
+
export const DEBUG = true;
|
|
7
|
+
export const TARGET_NAME = 'default';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* BuildProfile Class is used only for compatibility purposes.
|
|
11
|
+
*/
|
|
12
|
+
export default class BuildProfile {
|
|
13
|
+
static readonly HAR_VERSION = HAR_VERSION;
|
|
14
|
+
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
|
|
15
|
+
static readonly DEBUG = DEBUG;
|
|
16
|
+
static readonly TARGET_NAME = TARGET_NAME;
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"apiType": "stageMode",
|
|
3
|
+
"buildOption": {
|
|
4
|
+
},
|
|
5
|
+
"buildOptionSet": [
|
|
6
|
+
{
|
|
7
|
+
"name": "release",
|
|
8
|
+
"arkOptions": {
|
|
9
|
+
"obfuscation": {
|
|
10
|
+
"ruleOptions": {
|
|
11
|
+
"enable": true,
|
|
12
|
+
"files": [
|
|
13
|
+
"./obfuscation-rules.txt"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
"consumerFiles": [
|
|
17
|
+
"./consumer-rules.txt"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
"targets": [
|
|
24
|
+
{
|
|
25
|
+
"name": "default"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Define project specific obfuscation rules here.
|
|
2
|
+
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
|
3
|
+
#
|
|
4
|
+
# For more details, see
|
|
5
|
+
# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
|
|
6
|
+
|
|
7
|
+
# Obfuscation options:
|
|
8
|
+
# -disable-obfuscation: disable all obfuscations
|
|
9
|
+
# -enable-property-obfuscation: obfuscate the property names
|
|
10
|
+
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
|
11
|
+
# -compact: remove unnecessary blank spaces and all line feeds
|
|
12
|
+
# -remove-log: remove all console.* statements
|
|
13
|
+
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
|
14
|
+
# -apply-namecache: reuse the given cache file
|
|
15
|
+
|
|
16
|
+
# Keep options:
|
|
17
|
+
# -keep-property-name: specifies property names that you want to keep
|
|
18
|
+
# -keep-global-name: specifies names that you want to keep in the global scope
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"stableOrder": true
|
|
4
|
+
},
|
|
5
|
+
"lockfileVersion": 3,
|
|
6
|
+
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
|
7
|
+
"specifiers": {
|
|
8
|
+
"@rnoh/react-native-openharmony@../../node_modules/react-native-harmony/harmony/react_native_openharmony.har": "@rnoh/react-native-openharmony@../../node_modules/react-native-harmony/harmony/react_native_openharmony.har"
|
|
9
|
+
},
|
|
10
|
+
"packages": {
|
|
11
|
+
"@rnoh/react-native-openharmony@../../node_modules/react-native-harmony/harmony/react_native_openharmony.har": {
|
|
12
|
+
"name": "@rnoh/react-native-openharmony",
|
|
13
|
+
"version": "0.77.8",
|
|
14
|
+
"resolved": "../../node_modules/react-native-harmony/harmony/react_native_openharmony.har",
|
|
15
|
+
"registryType": "local"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-ohos/react-native-pdf",
|
|
3
|
+
"version": "6.7.7-rc.1",
|
|
4
|
+
"description": "Please describe the basic information.",
|
|
5
|
+
"main": "Index.ets",
|
|
6
|
+
"author": "",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@rnoh/react-native-openharmony": '"file:../../node_modules/react-native-harmony/harmony/react_native_openharmony.har"'
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.4.1)
|
|
2
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
3
|
+
|
|
4
|
+
file(GLOB rnoh_pdf_view_SRC CONFIGURE_DEPENDS *.cpp)
|
|
5
|
+
add_library(rnoh_pdf_view SHARED ${rnoh_pdf_view_SRC})
|
|
6
|
+
target_include_directories(rnoh_pdf_view PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
|
7
|
+
target_link_libraries(rnoh_pdf_view PUBLIC rnoh)
|
|
8
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#pragma once
|
|
26
|
+
|
|
27
|
+
#include "ShadowNodes.h"
|
|
28
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
29
|
+
|
|
30
|
+
namespace facebook {
|
|
31
|
+
namespace react {
|
|
32
|
+
|
|
33
|
+
using RNPDFPdfViewComponentDescriptor = ConcreteComponentDescriptor<RNPDFPdfViewShadowNode>;
|
|
34
|
+
|
|
35
|
+
} // namespace react
|
|
36
|
+
} // namespace facebook
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#include "EventEmitters.h"
|
|
26
|
+
|
|
27
|
+
namespace facebook {
|
|
28
|
+
namespace react {
|
|
29
|
+
|
|
30
|
+
void RNPDFPdfViewEventEmitter::onChange(OnChange event) const {
|
|
31
|
+
dispatchEvent("change", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
32
|
+
auto payload = jsi::Object(runtime);
|
|
33
|
+
payload.setProperty(runtime, "message", event.message);
|
|
34
|
+
return payload;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
} // namespace react
|
|
39
|
+
} // namespace facebook
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#pragma once
|
|
26
|
+
|
|
27
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
28
|
+
#include <jsi/jsi.h>
|
|
29
|
+
|
|
30
|
+
namespace facebook {
|
|
31
|
+
namespace react {
|
|
32
|
+
|
|
33
|
+
class JSI_EXPORT RNPDFPdfViewEventEmitter : public ViewEventEmitter {
|
|
34
|
+
public:
|
|
35
|
+
using ViewEventEmitter::ViewEventEmitter;
|
|
36
|
+
|
|
37
|
+
struct OnChange {
|
|
38
|
+
std::string message;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
void onChange(OnChange value) const;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace react
|
|
47
|
+
} // namespace facebook
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#pragma once
|
|
26
|
+
|
|
27
|
+
#include "RNOH/ArkJS.h"
|
|
28
|
+
#include "RNOH/EventEmitRequestHandler.h"
|
|
29
|
+
#include "EventEmitters.h"
|
|
30
|
+
|
|
31
|
+
using namespace facebook;
|
|
32
|
+
namespace rnoh {
|
|
33
|
+
|
|
34
|
+
class PdfEventEmitRequestHandler : public EventEmitRequestHandler {
|
|
35
|
+
public:
|
|
36
|
+
void handleEvent(EventEmitRequestHandler::Context const &ctx) override {
|
|
37
|
+
if (ctx.eventName != "RTNPdfView") {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
ArkJS arkJs(ctx.env);
|
|
41
|
+
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<react::RNPDFPdfViewEventEmitter>(ctx.tag);
|
|
42
|
+
if (eventEmitter == nullptr) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
auto message = arkJs.getString(arkJs.getObjectProperty(ctx.payload, "message"));
|
|
46
|
+
react::RNPDFPdfViewEventEmitter::OnChange event = {message};
|
|
47
|
+
eventEmitter->onChange(event);
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#ifndef HARMONY_PDFVIEWJSIBINDER_H
|
|
26
|
+
#define HARMONY_PDFVIEWJSIBINDER_H
|
|
27
|
+
|
|
28
|
+
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
29
|
+
|
|
30
|
+
namespace rnoh {
|
|
31
|
+
|
|
32
|
+
class PdfViewJSIBinder : public ViewComponentJSIBinder {
|
|
33
|
+
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
34
|
+
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
35
|
+
object.setProperty(rt, "source", "Source");
|
|
36
|
+
object.setProperty(rt, "path", "string");
|
|
37
|
+
object.setProperty(rt, "page", "int");
|
|
38
|
+
object.setProperty(rt, "scale", "float");
|
|
39
|
+
object.setProperty(rt, "minScale", "float");
|
|
40
|
+
object.setProperty(rt, "maxScale", "float");
|
|
41
|
+
object.setProperty(rt, "horizontal", "boolean");
|
|
42
|
+
object.setProperty(rt, "enablePaging", "boolean");
|
|
43
|
+
object.setProperty(rt, "enableRTL", "boolean");
|
|
44
|
+
object.setProperty(rt, "enableAnnotationRendering", "boolean");
|
|
45
|
+
object.setProperty(rt, "showsHorizontalScrollIndicator", "boolean");
|
|
46
|
+
object.setProperty(rt, "showsVerticalScrollIndicator", "boolean");
|
|
47
|
+
object.setProperty(rt, "scrollEnabled", "boolean");
|
|
48
|
+
object.setProperty(rt, "enableAntialiasing", "boolean");
|
|
49
|
+
object.setProperty(rt, "fitPolicy", "int");
|
|
50
|
+
object.setProperty(rt, "spacing", "int");
|
|
51
|
+
object.setProperty(rt, "password", "string");
|
|
52
|
+
object.setProperty(rt, "singlePage", "boolean");
|
|
53
|
+
return object;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override
|
|
57
|
+
{
|
|
58
|
+
return facebook::jsi::Object(rt);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override
|
|
62
|
+
{
|
|
63
|
+
facebook::jsi::Object events(rt);
|
|
64
|
+
events.setProperty(rt, "topChange", createDirectEvent(rt, "onChange"));
|
|
65
|
+
return events;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
} // namespace rnoh
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
#endif //HARMONY_PDFVIEWJSIBINDER_H
|