App.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /**
  2. * Sample React Native App
  3. * https://github.com/facebook/react-native
  4. * @flow
  5. */
  6. import React, { Component } from 'react';
  7. import {
  8. Platform,
  9. StyleSheet,
  10. Text,
  11. View,
  12. Button,
  13. NativeModules
  14. } from 'react-native';
  15. var nativeModule = NativeModules.OpenNativeModule;
  16. // var analyticsModule = NativeModules.UMAnalyticsModule;
  17. const instructions = Platform.select({
  18. ios: 'Press Cmd+R to reload,\n' +
  19. 'Cmd+D or shake for dev menu',
  20. android: 'Double tap R on your keyboard to reload,\n' +
  21. 'Shake or press menu button for dev menu',
  22. });
  23. // set disable functionality:
  24. const configuration = {
  25. "modeConfig": {
  26. // setting the default display mode when opening
  27. // viewer、annotations、contentEditor、forms、digitalSignatures
  28. "initialViewMode": "viewer"
  29. },
  30. // top toolbar configuration:
  31. "toolbarConfig": {
  32. "androidAvailableActions": [
  33. "thumbnail",
  34. "search",
  35. "bota",
  36. "menu"
  37. ],
  38. // ios top toolbar left buttons
  39. "iosLeftBarAvailableActions":[
  40. "back",
  41. "thumbnail"
  42. ],
  43. // ios top toolbar right buttons
  44. "iosRightBarAvailableActions":[
  45. "search",
  46. "bota",
  47. "menu"
  48. ],
  49. "availableMenus": [
  50. "viewSettings",
  51. "documentEditor",
  52. "security",
  53. "watermark",
  54. "documentInfo",
  55. "save",
  56. "share",
  57. "openDocument"
  58. ]
  59. },
  60. // readerView configuration
  61. "readerViewConfig": {
  62. "linkHighlight": true,
  63. "formFieldHighlight": true
  64. }
  65. };
  66. type Props = {};
  67. export default class App extends Component<Props> {
  68. render() {
  69. return (
  70. <View style={styles.container}>
  71. <Text style={styles.welcome}>
  72. Welcome to React Native!
  73. </Text>
  74. <Text style={styles.instructions}>
  75. To get started, edit App.js
  76. </Text>
  77. <Text style={styles.instructions}>
  78. {instructions}
  79. </Text>
  80. <Button
  81. title={'Jump to the native page'}
  82. onPress={() => {
  83. this.jumpToNativeView();
  84. }}
  85. />
  86. </View>
  87. );
  88. }
  89. jumpToNativeView() {
  90. NativeModules.OpenPDFModule.openPDF(JSON.stringify(configuration))
  91. // NativeModules.OpenPDFModule.openPDFByConfiguration(filePath, password, JSON.stringify(configuration))
  92. }
  93. }
  94. const styles = StyleSheet.create({
  95. container: {
  96. flex: 1,
  97. justifyContent: 'center',
  98. alignItems: 'center',
  99. backgroundColor: '#F5FCFF',
  100. },
  101. welcome: {
  102. fontSize: 20,
  103. textAlign: 'center',
  104. margin: 10,
  105. },
  106. instructions: {
  107. textAlign: 'center',
  108. color: '#333333',
  109. marginBottom: 5,
  110. },
  111. });