0.0.2 • Published 2 years ago

rn-doc-preview v0.0.2

Weekly downloads
-
License
Apache License 2....
Repository
github
Last release
2 years ago

react-native-doc-preview

ReactNative: Read Documents within application in iOS and use 3rd party library in-case of Android

Getting started

$ yarn add react-native-doc-preview

💻 Usage

import { NativeModules } from 'react-native'
let { MSDocPreview } = NativeModules

 MSDocPreview.shareDoc(
   [
     {
       url: path,
       fileName: item.get('name')
     }
   ],
   (error, url) => {
     if (error) {
       let { Dialog } = imports('uikit')

       Dialog.error({
         title: LocaleManager.getLocale('UIkit', 'android-error'),
         description: LocaleManager.getLocale('UIkit', 'no-app-support'),
         positiveText: Locale.continue,
         onPositive: () => {}
       })
     } else {
     }
   }
)

MSDocPreview.openDoc(
  [
    {
      url: path,
      fileName: item.get('name')
    }
  ],
  () => {}
)

or 

import {DocPreview} from 'react-native-doc-preview'

<DocPrewview url={} fileName={}/>

💡 Api

  • iOS

    APIParamsDescription
    openDocurl, fileNameThis api internally uses QLPreview to display the document within the app
  • Android

    APIParamsDescription
    shareDocurl, fileNameThis api invokes an Intent to select an app from list of 3rd party apps to support Document Reading

💡 Props

  • General (Android/iOS)
PropTypeDefaultNote
url: mandatorystringPath of the file to Read
fileName: mandatorystringName of the file Read.