Browse Source

compdfkit(rn) - 调整示例项目名称

liuxiaolong 2 months ago
parent
commit
1ee332e93c

File diff suppressed because it is too large
+ 3 - 3
example/App.tsx


+ 8 - 2
example/ios/CompdfkitPdfExample.xcodeproj/project.pbxproj

@@ -629,7 +629,10 @@
 					"-DFOLLY_CFG_NO_COROUTINES=1",
 					"-DFOLLY_HAVE_CLOCK_GETTIME=1",
 				);
-				OTHER_LDFLAGS = "$(inherited)  ";
+				OTHER_LDFLAGS = (
+					"$(inherited)",
+					" ",
+				);
 				REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
 				SDKROOT = iphoneos;
 				USE_HERMES = true;
@@ -702,7 +705,10 @@
 					"-DFOLLY_CFG_NO_COROUTINES=1",
 					"-DFOLLY_HAVE_CLOCK_GETTIME=1",
 				);
-				OTHER_LDFLAGS = "$(inherited)  ";
+				OTHER_LDFLAGS = (
+					"$(inherited)",
+					" ",
+				);
 				REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
 				SDKROOT = iphoneos;
 				USE_HERMES = true;

+ 33 - 40
example/src/CPDFReaderViewConctrolExample.tsx

@@ -8,7 +8,7 @@
  */
 
 import React, { useState, useEffect, useRef } from 'react';
-import { Image, Platform, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
+import { Image, Platform, StyleSheet, Text, View } from 'react-native';
 import { CPDFReaderView, ComPDFKit, CPDFToolbarAction } from '@compdfkit_pdf_sdk/react_native';
 import { useNavigation, useRoute, RouteProp } from '@react-navigation/native';
 import { HeaderBackButton } from '@react-navigation/elements';
@@ -25,7 +25,7 @@ type CPDFReaderViewExampleScreenRouteProp = RouteProp<
     'CPDFReaderViewExample'
 >;
 
-const CPDFReaderViewConctrolExampleScreen = () => {
+const CPDFReaderViewControllerExampleScreen = () => {
 
     const pdfReaderRef = useRef<CPDFReaderView>(null);
 
@@ -100,38 +100,37 @@ const CPDFReaderViewConctrolExampleScreen = () => {
 
                     // Android
                     // import xfdf file from android assets directory
-                        // const testXfdf = Platform.OS === 'android'
-                        //     ? 'file:///android_asset/test.xfdf'
-                        //     : 'test.xfdf'
+                    // const testXfdf = Platform.OS === 'android'
+                    //     ? 'file:///android_asset/test.xfdf'
+                    //     : 'test.xfdf'
                     // import xfdf file from file path
-                        // const testXfdf = '/data/user/0/com.compdfkit.reactnative.example/xxx/xxx.xfdf';
+                    // const testXfdf = '/data/user/0/com.compdfkit.reactnative.example/xxx/xxx.xfdf';
 
-                        // const importResult = await pdfReaderRef.current?.importAnnotations(testXfdf);
-                        // console.log('ComPDFKitRN importAnnotations:', importResult);
+                    // const importResult = await pdfReaderRef.current?.importAnnotations(testXfdf);
+                    // console.log('ComPDFKitRN importAnnotations:', importResult);
 
 
                     // Select an xfdf file from the public directory and import it into the current document
-                        const pickerResult = DocumentPicker.pick({
-                            type: [DocumentPicker.types.allFiles],
-                            copyTo: 'cachesDirectory'
-                        });
-                        pickerResult.then(async (res) => {
-                            const file = res[0];
-                            const fileName = file?.name;
-                            // if(!fileName?.endsWith('xfdf')){
-                            //     console.log('ComPDFKitRN please select xfdf format file');
-                            //     return;
-                            // }
-
-                            console.log('fileUri:' , file?.uri);
-                            console.log('fileCopyUri:' , file?.fileCopyUri);
-                            console.log('fileType:' , file?.type);
-                            const path = file!!.fileCopyUri!!
-
-                            const importResult = await pdfReaderRef.current?.importAnnotations(path);
-                            console.log('ComPDFKitRN importAnnotations:', importResult);
-
-                        })
+                    const pickerResult = DocumentPicker.pick({
+                        type: [DocumentPicker.types.allFiles],
+                        copyTo: 'cachesDirectory'
+                    });
+                    pickerResult.then(async (res) => {
+                        const file = res[0];
+                        const fileName = file?.name;
+                        if (!fileName?.endsWith('xfdf')) {
+                            console.log('ComPDFKitRN please select xfdf format file');
+                            return;
+                        }
+
+                        console.log('fileUri:', file?.uri);
+                        console.log('fileCopyUri:', file?.fileCopyUri);
+                        console.log('fileType:', file?.type);
+                        const path = file!!.fileCopyUri!!
+
+                        const importResult = await pdfReaderRef.current?.importAnnotations(path);
+                        console.log('ComPDFKitRN importAnnotations:', importResult);
+                    })
                 } catch (err) {
                 }
                 break;
@@ -140,22 +139,18 @@ const CPDFReaderViewConctrolExampleScreen = () => {
                 console.log('ComPDFKitRN exportAnnotations:', exportXfdfFilePath);
                 break;
             case 'setMargins':
-                await pdfReaderRef.current?.setMargins(10,20,10,20)
+                await pdfReaderRef.current?.setMargins(10, 20, 10, 20)
                 break;
             default:
                 break;
         }
     };
 
-
-
     const renderToolbar = () => {
         return (
-
-
             <View style={styles.toolbar}>
                 <HeaderBackButton onPress={handleBack} />
-                <Text style={styles.toolbarTitle}>Control Example</Text>
+                <Text style={styles.toolbarTitle}>Controller Example</Text>
 
                 <Menu>
                     <MenuTrigger>
@@ -171,11 +166,10 @@ const CPDFReaderViewConctrolExampleScreen = () => {
                     </MenuOptions>
                 </Menu>
             </View>
-
         );
     };
 
-    const onPageChanged = (pageIndex : number) =>{
+    const onPageChanged = (pageIndex: number) => {
         console.log('ComPDFKitRN --- onPageChanged:', pageIndex);
     }
 
@@ -200,12 +194,11 @@ const CPDFReaderViewConctrolExampleScreen = () => {
                                     CPDFToolbarAction.THUMBNAIL
                                 ]
                             }
-                        })}/>
+                        })} />
                 </View>
             </SafeAreaView>
         </MenuProvider>
     );
-
 };
 
 const styles = StyleSheet.create({
@@ -234,7 +227,7 @@ const styles = StyleSheet.create({
     },
 });
 
-export default CPDFReaderViewConctrolExampleScreen;
+export default CPDFReaderViewControllerExampleScreen;
 
 
 

+ 2 - 2
example/src/examples.tsx

@@ -66,10 +66,10 @@ const examples = [
     },
     {
         key: 'item5',
-        title: 'CPDFReaderView Conctrol Example',
+        title: 'CPDFReaderView Controller Example',
         description: 'Examples of functions that can be used with the PDF component',
         action: (component: any)  => {
-            component.props.navigation.navigate('CPDFReaderViewConctrolExample');
+            component.props.navigation.navigate('CPDFReaderViewControllerExample');
         }
     },
 ];