A simple photo-viewer/gallery component for NativeScript.
Since the plugin is based on two different libraries for two different platforms their features are also somewhat diferent:
Platform | State | Remote images (url) | Local images (resource) | Titles/Credits | Album View | Color Palette |
---|---|---|---|---|---|---|
iOS | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: |
Android | :x: (Broken) | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: |
If anyone has tips on a better android library that has same or similar features to the iOS, let us know.
3.0.0
Run tns plugin add nativescript-photoviewer
in your root directory of your project.
It's best to take a look at the included demo app(s) for advanced usages. Below is just a simple example on how to get the plugin running with minimal effort using vanilla nativescript (ts). For Angular, see demo-ng
.
// Include the module
import { PhotoViewer, PhotoViewerOptions, PaletteType, NYTPhotoItem } from "nativescript-photoviewer";
var photoViewer: PhotoViewer;
// Create a new instace of PhotoViewer in the onLoaded event. Very important to do the init here!
export function pageLoaded(args: EventData) {
photoViewer = new PhotoViewer();
}
// Show gallery
export function openGallery(args: EventData){
let image1 = "https://blabla/image1.jpg";
let image2 = "https://blabla/image2.jpg";
let image3 = "https://blabla/image3.jpg";
let image4 = "https://blabla/image4.jpg";
let myImages = [image1, image2, image3, image4];
// Example on how to use the options class (optional)
let photoviewerOptions: PhotoViewerOptions = {
startIndex: 0,
ios: {
completionCallback: galleryLoaded
},
android: {
paletteType: PaletteType.DarkVibrant,
showAlbum: false
}
};
photoViewer.showGallery(myImages, photoviewerOptions);
}
3.0.0
2.1.5
2.1.1
references.d.ts
.demo-js
.2.1.0
demo-ng
. 2.0.2
showViewer()
to showGallery()
that now has 1 mandatory param and 1 optional param.datasource
would be GC'ed on iOS (important to init the plugin in the onLoaded
event)1.5.0
completionCallback
and show a spinner when opening the gallery. 1.4.0
startIndex
1.3.0
showViewer(ARRAY, INDEX?)
function. Makes the gallery init on that image: photoViewer.showViewer(myImages,1);
I'll review & accept pull requests that improve the plugin and assign credit.
The plugin is based on the following libraries:
iOS | Android |
---|---|
NYTPhotoViewer | ImageGallery |