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
- In the Xcode's "Project navigator", right click on your project's Libraries folder ➜ Add Files to "Your Project Name"
- Go to
node_modules
➜react-native-quick-look
➜iOS
➜ selectReactNativeQuickLook.xcodeproj
- In the Xcode Project Navigator, click the root project, and in
General
tab, look forLinked Frameworks and Libraries
. Click on the+
button at the bottom and addlibReactNativeQuickLook.a
andQuickLook.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
- Clone/download the repo
- Run
npm install
from the Example folder - Open
Example.xcodeproj
and run the app from Xcode
react-native-quick-look
is available under the MIT license. See the LICENSE file for more info.