Add PDFSCreen

This commit is contained in:
Vincent BRIDIER 2022-10-06 17:35:15 +02:00
parent 4396f1df17
commit 00ef7bbd89
No known key found for this signature in database
GPG key ID: 8571BFA20420D512
8 changed files with 205 additions and 4 deletions

View file

@ -16,4 +16,6 @@
- react-native-progress
- react-native-svg
- react-native-b-crypt-bridge
- react-native-animated-tree-view with https://github.com/shariqahmed525/react-native-animated-tree-view/pull/3/
- react-native-animated-tree-view with https://github.com/shariqahmed525/react-native-animated-tree-view/pull/3/
- react-native-pdf
- react-native-blob-util

View file

@ -246,6 +246,15 @@ android {
}
}
packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
}
dependencies {

View file

@ -21,6 +21,8 @@
"react-native": "0.70.1",
"react-native-animated-tree-view": "^0.1.4",
"react-native-b-crypt-bridge": "file:react-native-b-crypt-bridge-2.0.0.tgz",
"react-native-blob-util": "^0.16.2",
"react-native-pdf": "^6.6.2",
"react-native-progress": "^5.0.0",
"react-native-safe-area-context": "^4.4.1",
"react-native-screens": "^3.18.0",
@ -5487,6 +5489,11 @@
"node": ">=0.10.0"
}
},
"node_modules/base-64": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz",
"integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA=="
},
"node_modules/base/node_modules/define-property": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz",
@ -6565,6 +6572,11 @@
"node": "*"
}
},
"node_modules/crypto-js": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.3.0.tgz",
"integrity": "sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q=="
},
"node_modules/crypto-random-string": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz",
@ -6955,6 +6967,16 @@
"node": ">= 0.8"
}
},
"node_modules/deprecated-react-native-prop-types": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/deprecated-react-native-prop-types/-/deprecated-react-native-prop-types-2.3.0.tgz",
"integrity": "sha512-pWD0voFtNYxrVqvBMYf5gq3NA2GCpfodS1yNynTPc93AYA/KEMGeWDqqeUB6R2Z9ZofVhks2aeJXiuQqKNpesA==",
"dependencies": {
"@react-native/normalize-color": "*",
"invariant": "*",
"prop-types": "*"
}
},
"node_modules/destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
@ -16629,6 +16651,19 @@
"react-native": "*"
}
},
"node_modules/react-native-blob-util": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/react-native-blob-util/-/react-native-blob-util-0.16.2.tgz",
"integrity": "sha512-eC7lps4dyTICYVLqn86PDlo/2OdQw7rcOD2ViD69BAfdWgcEqslci8IjbUCvbSZM+cRbMskuRuLSfcoNi+ILqQ==",
"dependencies": {
"base-64": "0.1.0",
"glob": "^7.1.6"
},
"peerDependencies": {
"react": "*",
"react-native": "*"
}
},
"node_modules/react-native-codegen": {
"version": "0.70.5",
"resolved": "https://registry.npmjs.org/react-native-codegen/-/react-native-codegen-0.70.5.tgz",
@ -16647,6 +16682,15 @@
"integrity": "sha512-oOanj84fJEXUg9FoEAQomA8ISG+DVIrTZ3qF7m69VQUJyOGYyDZmPqKcjvRku4KXlEH6hWO9i4ACLzNBh8gC0A==",
"license": "MIT"
},
"node_modules/react-native-pdf": {
"version": "6.6.2",
"resolved": "https://registry.npmjs.org/react-native-pdf/-/react-native-pdf-6.6.2.tgz",
"integrity": "sha512-gqxNPSzL0lNN1dGYAz9ObSLb0shUTB8x1u69qKLMSmwuxFTpGui5PNNgpH8q/nlpL9zBzMVVc/AXEuDCwRyxEQ==",
"dependencies": {
"crypto-js": "^3.2.0",
"deprecated-react-native-prop-types": "^2.3.0"
}
},
"node_modules/react-native-progress": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/react-native-progress/-/react-native-progress-5.0.0.tgz",
@ -23981,6 +24025,11 @@
}
}
},
"base-64": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz",
"integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA=="
},
"base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
@ -24746,6 +24795,11 @@
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
"integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow=="
},
"crypto-js": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.3.0.tgz",
"integrity": "sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q=="
},
"crypto-random-string": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz",
@ -25019,6 +25073,16 @@
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw=="
},
"deprecated-react-native-prop-types": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/deprecated-react-native-prop-types/-/deprecated-react-native-prop-types-2.3.0.tgz",
"integrity": "sha512-pWD0voFtNYxrVqvBMYf5gq3NA2GCpfodS1yNynTPc93AYA/KEMGeWDqqeUB6R2Z9ZofVhks2aeJXiuQqKNpesA==",
"requires": {
"@react-native/normalize-color": "*",
"invariant": "*",
"prop-types": "*"
}
},
"destroy": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
@ -31967,6 +32031,15 @@
"integrity": "sha512-nqjJtA0qUh6awVEmI41c3I3IxWHOm38UQGkXNg4iZmb4gg0MMFMBZFNAVHa5Xzl+YVDQ6rIfmrF0w/BnDaewsA==",
"requires": {}
},
"react-native-blob-util": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/react-native-blob-util/-/react-native-blob-util-0.16.2.tgz",
"integrity": "sha512-eC7lps4dyTICYVLqn86PDlo/2OdQw7rcOD2ViD69BAfdWgcEqslci8IjbUCvbSZM+cRbMskuRuLSfcoNi+ILqQ==",
"requires": {
"base-64": "0.1.0",
"glob": "^7.1.6"
}
},
"react-native-codegen": {
"version": "0.70.5",
"resolved": "https://registry.npmjs.org/react-native-codegen/-/react-native-codegen-0.70.5.tgz",
@ -31983,6 +32056,15 @@
"resolved": "https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.70.3.tgz",
"integrity": "sha512-oOanj84fJEXUg9FoEAQomA8ISG+DVIrTZ3qF7m69VQUJyOGYyDZmPqKcjvRku4KXlEH6hWO9i4ACLzNBh8gC0A=="
},
"react-native-pdf": {
"version": "6.6.2",
"resolved": "https://registry.npmjs.org/react-native-pdf/-/react-native-pdf-6.6.2.tgz",
"integrity": "sha512-gqxNPSzL0lNN1dGYAz9ObSLb0shUTB8x1u69qKLMSmwuxFTpGui5PNNgpH8q/nlpL9zBzMVVc/AXEuDCwRyxEQ==",
"requires": {
"crypto-js": "^3.2.0",
"deprecated-react-native-prop-types": "^2.3.0"
}
},
"react-native-progress": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/react-native-progress/-/react-native-progress-5.0.0.tgz",

View file

@ -23,6 +23,8 @@
"react-native": "0.70.1",
"react-native-animated-tree-view": "^0.1.4",
"react-native-b-crypt-bridge": "file:react-native-b-crypt-bridge-2.0.0.tgz",
"react-native-blob-util": "^0.16.2",
"react-native-pdf": "^6.6.2",
"react-native-progress": "^5.0.0",
"react-native-safe-area-context": "^4.4.1",
"react-native-screens": "^3.18.0",

View file

@ -30,6 +30,7 @@ import HomeScreen from './App/Views/HomeScreen';
import LoginScreen from './App/Views/LoginScreen';
import SyncScreen from './App/Views/SyncScreen';
import DirectoriesScreen from './App/Views/DirectoriesScreen';
import PDFScreen from './App/Views/PDFScreen';
// Lang Flags
import flagFR from './Resources/assets/img/flags/fr.png';
import flagEN from './Resources/assets/img/flags/en.png';
@ -180,6 +181,13 @@ class App extends React.Component {
component={DirectoriesScreen}
options={{ headerTitle: () => CustomNavigation.LogoTitle(i18n.t('app.folders')) }}
/>
<Stack.Screen
name="PDFScreen"
component={PDFScreen}
options={(navigation, route) => ({
headerTitle: () => CustomNavigation.LogoTitle('PDF')
})}
/>
</Stack.Navigator>
</NavigationContainer>
</Provider>

View file

@ -0,0 +1,40 @@
import React from 'react';
import { View } from 'react-native';
// PDF
import Pdf from 'react-native-pdf';
// FileSytem
import * as FileSystem from 'expo-file-system';
// Style
import styles from '../../Resources/Styles/PDFStyle';
class PDFScreen extends React.Component {
render() {
const { uuid } = this.props.route.params;
const source = {
uri: FileSystem.documentDirectory + uuid + '.pdf',
cache: false,
};
return (
<View style={styles.container}>
<Pdf
source={source}
onLoadComplete={(numberOfPages, filePath) => {
console.log(`number of pages: ${numberOfPages}`);
}}
onPageChanged={(page, numberOfPages) => {
console.log(`current page: ${page}`);
}}
onError={error => {
console.log(error);
}}
onPressLink={uri => {
console.log(`Link presse: ${uri}`);
}}
style={styles.pdf}
/>
</View>
);
}
}
export default PDFScreen;

View file

@ -0,0 +1,23 @@
import { StyleSheet, Dimensions } from 'react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
text: {
height: 40,
width: 300,
borderColor: 'grey',
borderWidth: 1,
marginBottom: 20,
},
pdf: {
flex: 1,
width: Dimensions.get('window').width,
height: Dimensions.get('window').height,
},
});
export default styles;

View file

@ -2065,7 +2065,7 @@
"resolved" "https://registry.npmjs.org/@react-native/assets/-/assets-1.0.0.tgz"
"version" "1.0.0"
"@react-native/normalize-color@^2.0.0", "@react-native/normalize-color@2.0.0":
"@react-native/normalize-color@*", "@react-native/normalize-color@^2.0.0", "@react-native/normalize-color@2.0.0":
"integrity" "sha512-Wip/xsc5lw8vsBlmY2MO/gFLp3MvuZ2baBZjDeTjjndMgM0h5sxz7AZR62RDPGgstp8Np7JzjvVqVT7tpFZqsw=="
"resolved" "https://registry.npmjs.org/@react-native/normalize-color/-/normalize-color-2.0.0.tgz"
"version" "2.0.0"
@ -2926,6 +2926,11 @@
"resolved" "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz"
"version" "1.0.2"
"base-64@0.1.0":
"integrity" "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA=="
"resolved" "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz"
"version" "0.1.0"
"base@^0.11.1":
"integrity" "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg=="
"resolved" "https://registry.npmjs.org/base/-/base-0.11.2.tgz"
@ -3710,6 +3715,11 @@
"resolved" "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz"
"version" "0.0.2"
"crypto-js@^3.2.0":
"integrity" "sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q=="
"resolved" "https://registry.npmjs.org/crypto-js/-/crypto-js-3.3.0.tgz"
"version" "3.3.0"
"crypto-random-string@^1.0.0":
"integrity" "sha512-GsVpkFPlycH7/fRR7Dhcmnoii54gV1nz7y4CWyeFS14N+JVBBhY+r8amRHE4BwSYal7BPTDp8isvAlCxyFt3Hg=="
"resolved" "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz"
@ -3975,6 +3985,15 @@
"resolved" "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz"
"version" "2.0.0"
"deprecated-react-native-prop-types@^2.3.0":
"integrity" "sha512-pWD0voFtNYxrVqvBMYf5gq3NA2GCpfodS1yNynTPc93AYA/KEMGeWDqqeUB6R2Z9ZofVhks2aeJXiuQqKNpesA=="
"resolved" "https://registry.npmjs.org/deprecated-react-native-prop-types/-/deprecated-react-native-prop-types-2.3.0.tgz"
"version" "2.3.0"
dependencies:
"@react-native/normalize-color" "*"
"invariant" "*"
"prop-types" "*"
"destroy@1.2.0":
"integrity" "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg=="
"resolved" "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz"
@ -5614,7 +5633,7 @@
"has" "^1.0.3"
"side-channel" "^1.0.4"
"invariant@^2.2.4":
"invariant@*", "invariant@^2.2.4":
"integrity" "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA=="
"resolved" "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz"
"version" "2.2.4"
@ -8711,7 +8730,7 @@
dependencies:
"read" "1"
"prop-types@^15.6.2", "prop-types@^15.7.2", "prop-types@^15.8.1":
"prop-types@*", "prop-types@^15.6.2", "prop-types@^15.7.2", "prop-types@^15.8.1":
"integrity" "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg=="
"resolved" "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz"
"version" "15.8.1"
@ -8849,6 +8868,14 @@
"resolved" "file:react-native-b-crypt-bridge-2.0.0.tgz"
"version" "2.0.0"
"react-native-blob-util@^0.16.2":
"integrity" "sha512-eC7lps4dyTICYVLqn86PDlo/2OdQw7rcOD2ViD69BAfdWgcEqslci8IjbUCvbSZM+cRbMskuRuLSfcoNi+ILqQ=="
"resolved" "https://registry.npmjs.org/react-native-blob-util/-/react-native-blob-util-0.16.2.tgz"
"version" "0.16.2"
dependencies:
"base-64" "0.1.0"
"glob" "^7.1.6"
"react-native-codegen@^0.70.5":
"integrity" "sha512-vXqgCWWIWlzsCtwD6hbmwmCleGNJYm+n4xO9VMfzzlF3xt9gjC7/USSMTf/YZlCK/hDwQU412QrNS6A9OH+mag=="
"resolved" "https://registry.npmjs.org/react-native-codegen/-/react-native-codegen-0.70.5.tgz"
@ -8864,6 +8891,14 @@
"resolved" "https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.70.3.tgz"
"version" "0.70.3"
"react-native-pdf@^6.6.2":
"integrity" "sha512-gqxNPSzL0lNN1dGYAz9ObSLb0shUTB8x1u69qKLMSmwuxFTpGui5PNNgpH8q/nlpL9zBzMVVc/AXEuDCwRyxEQ=="
"resolved" "https://registry.npmjs.org/react-native-pdf/-/react-native-pdf-6.6.2.tgz"
"version" "6.6.2"
dependencies:
"crypto-js" "^3.2.0"
"deprecated-react-native-prop-types" "^2.3.0"
"react-native-progress@^5.0.0":
"integrity" "sha512-KjnGIt3r9i5Kn2biOD9fXLJocf0bwxPRxOyAgXEnZTJQU2O+HyzgGFRCbM5h3izm9kKIkSc1txh8aGmMafCD9A=="
"resolved" "https://registry.npmjs.org/react-native-progress/-/react-native-progress-5.0.0.tgz"