Socket
Socket
Sign inDemoInstall

nativescript-photoviewer

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-photoviewer - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

30

index.ios.js

@@ -15,11 +15,6 @@ var imageSource = require("image-source");

//console.log('imageItem is of type NYTImage: ' + imageItem.conformsToProtocol(NYTPhoto));
nytImage.image = imageItem.image;
nytImage.imageData = imageItem.imageData;
nytImage.placeholderImage = imageItem.placeholderImage;
nytImage.attributedCaptionTitle = imageItem.attributedCaptionTitle;
nytImage.attributedCaptionSummary = imageItem.attributedCaptionSummary;
nytImage.attributedCaptionCredit = imageItem.attributedCaptionCredit;
nytImage = imageItem;
}
else if(typeof imageItem === 'object'){
//console.log('imageItem is of type object: ' + imageItem.title);
//console.log('imageItem is of type object - title: ' + imageItem.title);
var fontFamily = that._fontFamily || "HelveticaNeue";

@@ -32,4 +27,8 @@ var titleFontSize = that._titleFontSize || 16;

var creditColor = that._creditColor || UIColor.grayColor();;
nytImage.image = imageItem.image;
if(imageItem.imageURL)
nytImage.image = imageFromURL(imageItem.imageURL);
else
nytImage.image = imageItem.image;
nytImage.attributedCaptionTitle = attributedString(imageItem.title, titleColor, fontFamily, titleFontSize);

@@ -41,6 +40,3 @@ nytImage.attributedCaptionSummary = attributedString(imageItem.summary, summaryColor, fontFamily, summaryFontSize);

//console.log('imageItem is of type string: ' + imageItem);
var imageURL = NSURL.URLWithString(imageItem);
var imageData = NSData.dataWithContentsOfURL(imageURL);
var nativeImage = UIImage.imageWithData(imageData);
nytImage.image = nativeImage;
nytImage.image = imageFromURL(imageItem);
}

@@ -59,3 +55,3 @@

function attributedString(text, color, fontFamily, fontSize) {
var attrString = NSString.stringWithString(text);
var attrString = NSString.stringWithString(text || "");
var attributeOptions = {

@@ -67,2 +63,8 @@ [NSForegroundColorAttributeName]: color,

};
function imageFromURL(imageURL){
var nsURL = NSURL.URLWithString(imageURL);
var imageData = NSData.dataWithContentsOfURL(nsURL);
var nativeImage = UIImage.imageWithData(imageData);
return nativeImage;
};

@@ -69,0 +71,0 @@ PhotoViewer.prototype.newNYTPhoto = function() {

@@ -5,3 +5,3 @@ {

"main": "index.js",
"version": "0.1.1",
"version": "0.1.2",
"nativescript": {

@@ -8,0 +8,0 @@ "platforms": {

# NativeScript PhotoViewer
A simple, iOS, Image/Photo-viewer component for NativeScript based on the NYTPhotoViewer cocoapod: http://cocoadocs.org/docsets/NYTPhotoViewer/1.1.0/index.html
A simple, iOS, Image/Photo-viewer component for NativeScript based on the NYTPhotoViewer pod: http://cocoadocs.org/docsets/NYTPhotoViewer/1.1.0/index.html

@@ -13,13 +13,45 @@ NYTPhotoViewer is a slideshow and image viewer that includes double-tap to zoom, captions, support for multiple images, interactive flick to dismiss, animated zooming presentation, and more.

## Usage
The usage is very simple. Require "nativescript-photoviewer" module and create a instance of it. Call the ```showViewer(array)``` function to present the photoViewer.
The ```showViewer()``` function accept a singe parameter, an array. The array can contain one, or a mixture, of the following types:
- String URLs that point to external images
- Custom defined objects that contain image-data (image/imageURL, title, summary, credit)
- Objects that conform to the ```NYTPhoto``` protocol (see the cocoapod documentation for more info - very similar to the above option)
When using the second option, properties that one can use are defined below in the second example. The ```image``` conforms to the UIImage object, while the ```imageURL``` is a string containing the URL of the image.
If ```imageURL``` is set, then ```image``` is ignored. You can also customize fontFamily, fontSize and color of the caption texts. FontFamily applies to all captions, size and color are caption-specific.
```js
// Simple usage with array of image-urls. See the Demo app for more advanced examples where you can add title and summary.
var NYTPhotoViewer = require("nativescript-photoviewer");
var image1 = "https://somepage.com/image01.jpg";
var image2 = "https://somepage.com/image02.jpg";
var image3 = "https://somepage.com/image03.jpg";
var myImages = [image1, image2, image3];
// Require the module
var PhotoViewer = require("nativescript-photoviewer");
photoViewer = new PhotoViewer();
if(!photoViewer)
photoViewer = new NYTPhotoViewer();
// Caption font-style settings (optional)
photoViewer.fontFamily = "Avenir-Roman";
photoViewer.titleFontSize = 20;
photoViewer.summaryFontSize = 16;
photoViewer.creditFontSize = 14;
photoViewer.titleColor = UIColor.whiteColor();
photoViewer.summaryColor = UIColor.brownColor();
photoViewer.creditColor = UIColor.orangeColor();
// Image from object
var testImage1 = {
imageURL: "https://somepage.com/image01.jpg",
title: "Image 1 title",
summary: "Image 1 summary",
credit: "Telerik"
};
var testImage2 = {
imageURL: "https://somepage.com/image01.jpg",
title: "Image 2 title",
summary: "Image 2 summary",
credit: "Telerik"
};
//Image from URLs
var imageFromURL1 = "https://somepage.com/image01.jpg";
var imageFromURL2 = "https://somepage.com/image02.jpg";
// Add to array and pass to showViewer
var myImages = [testImage1, testImage2, imageFromURL1, imageFromURL2];
photoViewer.showViewer(myImages);

@@ -26,0 +58,0 @@ ```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc