To show file previews on iOS, you can use the QuickLook Framework. Apple introduced a specialized view presented by QuickLook Preview Controller. However, this view is not available to be instantiated and presented directly (well, at least in a straight forward way).
However, you can access the view encapsulated by the QuickLook Preview Controller, and add it as a subview for any other instance of NSView. To make QuickLookView
available on React Native, we instantiated the QuickLook Preview Controller, then customized and returned the view inside the controller.
npm install react-native-quick-look --save
node_modules
➜ react-native-quick-look
➜ iOS
➜ select ReactNativeQuickLook.xcodeproj
General
tab, look for Linked Frameworks and Libraries
. Click on the +
button at the bottom and add libReactNativeQuickLook.a
and QuickLook.framework
from the list. Not available
// style it like any other View
// url is the url of the file you want to preview
<QuickLook style={{ flex: 1 }} url={ url } />
// or
// provide the filename of the asset included with the app
<QuickLook style={{ flex: 1 }} assetFileName={ 'demo.pdf' } />
Not available
npm install
from the Example folderExample.xcodeproj
and run the app from Xcodereact-native-quick-look
is available under the MIT license. See the LICENSE file for more info.