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 2.1.5 to 3.0.0

71

package.json

@@ -6,13 +6,15 @@ {

"typings": "photoviewer.d.ts",
"version": "2.1.5",
"version": "3.0.0",
"nativescript": {
"platforms": {
"ios": "3.0.0",
"android": "3.0.0"
"ios": "7.0.0",
"android": "7.0.0"
},
"plugin": {
"nan": "true",
"core3": "false",
"core3": "true",
"pan": "true",
"wrapper": "false",
"vue": "true",
"webpack": "true",
"wrapper": "",
"category": "Interface"

@@ -27,25 +29,24 @@ }

"plugin.tscwatch": "npm run tsc -- -w",
"build": "npm i && npm run tsc.dist",
"link": "npm i && cd ../demo && npm i && cd ../src && npm run plugin.link",
"demo.reset": "cd ../demo && rimraf platforms",
"demo.ios": "npm run preparedemo && cd ../demo && tns run ios --syncAllFiles",
"demo-ng.ios": "npm run preparedemo-ng && cd ../demo-ng && tns run ios --syncAllFiles",
"demo-js.ios": "npm run preparedemo-js && cd ../demo-js && tns run ios --syncAllFiles",
"demo.ios.device": "npm run preparedemo && cd ../demo && tns platform remove ios && tns run ios",
"demo.android": "npm i && npm run tsc && cd ../demo && tns run android --syncAllFiles",
"demo-ng.android": "npm i && npm run tsc && cd ../demo-ng && tns run android --syncAllFiles",
"demo-js.android": "npm i && npm run tsc && cd ../demo-js && tns run android --syncAllFiles",
"build": "npm i && ts-patch install && npm run tsc.dist",
"clean": "npm run demo.clean && npm run demo-ng.clean && npm run demo-js.clean",
"demo.clean": "cd ../demo && ns clean",
"demo-ng.clean": "cd ../demo-ng && ns clean",
"demo-js.clean": "cd ../demo-js && ns clean",
"demo.ios": "cd ../demo && ns run ios",
"demo.android": "cd ../demo && ns run android",
"demo-ng.ios": "cd ../demo-ng && ns run ios",
"demo-ng.android": "cd ../demo-ng && ns run android",
"demo-js.ios": "cd ../demo-js && ns run ios",
"demo-js.android": "cd ../demo-js && ns run android",
"demo.ios.build": "cd ../demo && ns build ios",
"test": "npm run tslint && npm run tslint.demo && cd ../demo && tns build ios && tns build android",
"test.ios": "cd ../demo && tns platform remove ios && tns test ios --emulator",
"test.ios.device": "cd ../demo && tns platform remove ios && tns test ios",
"test.android": "cd ../demo && tns platform remove android && tns test android --justlaunch",
"preparedemo": "npm run build && cd ../demo && tns plugin remove nativescript-photoviewer && tns plugin add ../src && tns install",
"preparedemo-ng": "npm run build && cd ../demo-ng && tns plugin remove nativescript-photoviewer && tns plugin add ../src && tns install",
"preparedemo-js": "npm run build && cd ../demo-js && tns plugin remove nativescript-photoviewer && tns plugin add ../src && tns install",
"preparedemo": "npm run build && cd ../demo && ns plugin remove nativescript-photoviewer && ns plugin add ../src/dist && ns install",
"preparedemo-ng": "npm run build && cd ../demo-ng && ns plugin remove nativescript-photoviewer && ns plugin add ../src/dist && ns install",
"preparedemo-js": "npm run build && cd ../demo-js && ns plugin remove nativescript-photoviewer && ns plugin add ../src/dist && ns install",
"setup": "npm run build && cd ../demo && npm i",
"plugin.link": "npm link && cd ../demo && npm link nativescript-photoviewer && cd ../src",
"setupandinstall": "npm i && cd ../demo && npm i && cd ../src && npm run build && cd ../demo && tns plugin add ../src && cd ../src",
"tslint": "tslint --config '../tslint.json' '*.ts' --exclude '**/node_modules/**'",
"tslint.demo": "tslint --config '../tslint.json' '../demo/app/*.ts' --exclude '**/node_modules/**'",
"ci.tslint": "npm i && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**'",
"tslint": "tslint --config '../tslint.json' '*.ts' --exclude '**/node_modules/**' --exclude '**/typings/**'",
"tslint.demo": "tslint --config '../tslint.json' '../demo/app/*.ts' --exclude '**/node_modules/**' --exclude '**/typings/**'",
"ci.tslint": "npm i && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**' --exclude '**/typings/**'",
"development.setup": "npm run setup && npm link && cd ../demo && npm link nativescript-photoviewer && cd ../src",

@@ -82,12 +83,16 @@ "generate.typings.ios": "cd ../demo && TNS_DEBUG_METADATA_PATH=\"$(pwd)/metadata\" tns build ios && TNS_TYPESCRIPT_DECLARATIONS_PATH=\"$(pwd)/typings\" tns build ios && echo 'Now look for your library typings in demo/typings!'",

"devDependencies": {
"typescript": "~3.5.3",
"tns-core-modules": "~6.0.2",
"tns-platform-declarations": "~6.0.2",
"tslint": "^5.18.0",
"husky": "^3.0.1",
"lint-staged": "^9.2.1",
"prompt": "^1.0.0",
"rimraf": "^2.6.3",
"semver": "^6.3.0"
"husky": "^6.0.0",
"lint-staged": "~10.5.4",
"prettier": "^2.2.1",
"@nativescript/core": "~8.0.1",
"@nativescript/types": "^8.0.0",
"@nativescript/webpack": "^4.1.0",
"typescript": "~4.2.4",
"ts-patch": "^1.3.2",
"prompt": "^1.1.0",
"rimraf": "^3.0.2",
"tslint": "^6.1.3",
"ts-node": "^9.1.1",
"semver": "^7.3.5"
}
}

@@ -1,38 +0,31 @@

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
var application = require("tns-core-modules/application");
var photoviewer_common_1 = require("./photoviewer.common");
__export(require("./photoviewer.common"));
var PhotoViewer = (function () {
function PhotoViewer() {
var _this = this;
this.onActivityResult = function (args) {
import { Application } from "@nativescript/core";
import { PaletteType } from "./photoviewer.common";
export * from './photoviewer.common';
export class PhotoViewer {
constructor() {
this.onActivityResult = (args) => {
if (args.requestCode === PhotoViewer.CLOSE_PHOTO_REQUEST) {
_this._currentResolve();
_this._currentResolve = undefined;
application.android.off("activityResult", _this.onActivityResult);
this._currentResolve();
this._currentResolve = undefined;
Application.android.off("activityResult", this.onActivityResult);
}
};
}
PhotoViewer.prototype.showGallery = function (imagesArray, options) {
var _this = this;
showGallery(imagesArray, options) {
var photosArray = new java.util.ArrayList();
imagesArray.forEach(function (imgUrl) {
imagesArray.forEach((imgUrl) => {
photosArray.add(imgUrl);
});
var startIndex = options.startIndex || 0;
var paletteType = options.android.paletteType || null;
var showAlbum = options.android.showAlbum || false;
var intent;
application.android.on("activityResult", this.onActivityResult);
return new Promise(function (resolve) {
_this._currentResolve = resolve;
let startIndex = options.startIndex || 0;
let paletteType = options.android.paletteType || null;
let showAlbum = options.android.showAlbum || false;
let intent;
Application.android.on("activityResult", this.onActivityResult);
return new Promise((resolve) => {
this._currentResolve = resolve;
if (!showAlbum) {
intent = new android.content.Intent(application.android.foregroundActivity, com.etiennelawlor.imagegallery.library.activities.FullScreenImageGalleryActivity.class);
intent = new android.content.Intent(Application.android.foregroundActivity, com.etiennelawlor.imagegallery.library.activities.FullScreenImageGalleryActivity.class);
}
else {
intent = new android.content.Intent(application.android.foregroundActivity, com.etiennelawlor.imagegallery.library.activities.ImageGalleryActivity.class);
intent = new android.content.Intent(Application.android.foregroundActivity, com.etiennelawlor.imagegallery.library.activities.ImageGalleryActivity.class);
}

@@ -44,22 +37,20 @@ intent.putStringArrayListExtra("images", photosArray);

}
application.android.foregroundActivity.startActivityForResult(intent, PhotoViewer.CLOSE_PHOTO_REQUEST);
Application.android.foregroundActivity.startActivityForResult(intent, PhotoViewer.CLOSE_PHOTO_REQUEST);
});
};
PhotoViewer.CLOSE_PHOTO_REQUEST = 9191;
return PhotoViewer;
}());
exports.PhotoViewer = PhotoViewer;
}
}
PhotoViewer.CLOSE_PHOTO_REQUEST = 9191;
function getPaletteType(paletteType) {
switch (paletteType) {
case photoviewer_common_1.PaletteType.Vibrant:
case PaletteType.Vibrant:
return com.etiennelawlor.imagegallery.library.enums.PaletteColorType.VIBRANT;
case photoviewer_common_1.PaletteType.LightVibrant:
case PaletteType.LightVibrant:
return com.etiennelawlor.imagegallery.library.enums.PaletteColorType.LIGHT_VIBRANT;
case photoviewer_common_1.PaletteType.DarkVibrant:
case PaletteType.DarkVibrant:
return com.etiennelawlor.imagegallery.library.enums.PaletteColorType.DARK_VIBRANT;
case photoviewer_common_1.PaletteType.Muted:
case PaletteType.Muted:
return com.etiennelawlor.imagegallery.library.enums.PaletteColorType.MUTED;
case photoviewer_common_1.PaletteType.LightMuted:
case PaletteType.LightMuted:
return com.etiennelawlor.imagegallery.library.enums.PaletteColorType.LIGHT_MUTED;
case photoviewer_common_1.PaletteType.DarkMuted:
case PaletteType.DarkMuted:
return com.etiennelawlor.imagegallery.library.enums.PaletteColorType.DARK_MUTED;

@@ -66,0 +57,0 @@ default:

@@ -1,4 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PaletteType;
export var PaletteType;
(function (PaletteType) {

@@ -11,3 +9,3 @@ PaletteType["Vibrant"] = "vibrant";

PaletteType["DarkMuted"] = "dark_muted";
})(PaletteType = exports.PaletteType || (exports.PaletteType = {}));
})(PaletteType || (PaletteType = {}));
//# sourceMappingURL=photoviewer.common.js.map

@@ -1,26 +0,17 @@

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
var color_1 = require("tns-core-modules/color");
var utils_1 = require("tns-core-modules/utils/utils");
var imageSource = require("tns-core-modules/image-source/image-source");
var frame = require("tns-core-modules/ui/frame");
__export(require("./photoviewer.common"));
import { Color, Utils, ImageSource } from "@nativescript/core";
export * from './photoviewer.common';
var _dataSource;
var PhotoViewer = (function () {
function PhotoViewer() {
var photosArray = NSMutableArray.alloc().init();
_dataSource = new NYTPhotoViewerArrayDataSource({ photos: photosArray });
const background_queue = dispatch_get_global_queue(21, 0);
const main_queue = dispatch_get_current_queue();
export class PhotoViewer {
constructor() {
this._finishedLoading = false;
this._didReload = false;
let photosArray = [];
_dataSource = NYTPhotoViewerArrayDataSource.alloc().initWithPhotos(photosArray);
}
Object.defineProperty(PhotoViewer.prototype, "ios", {
get: function () {
return this.nativeView;
},
enumerable: true,
configurable: true
});
PhotoViewer.prototype.showGallery = function (imagesArray, options) {
var _this = this;
get ios() {
return this.nativeView;
}
showGallery(imagesArray, options) {
if (!options)

@@ -32,29 +23,49 @@ options = {};

options.android = {};
var photosArray = NSMutableArray.alloc().init();
var startIndex = options.startIndex || 0;
var iosCompletionCallback = options.ios.completionCallback || null;
imagesArray.forEach(function (imageItem) {
var imageToAdd = NYTImage.alloc().init();
var fontFamily = options.ios.fontFamily || "HelveticaNeue";
var titleFontSize = options.ios.titleFontSize || 16;
var summaryFontSize = options.ios.summaryFontSize || 14;
var creditFontSize = options.ios.creditFontSize || 14;
var titleColor = options.ios.titleColor || new color_1.Color("white").ios;
var summaryColor = options.ios.summaryColor || new color_1.Color("lightgray").ios;
var creditColor = options.ios.creditColor || new color_1.Color("gray").ios;
let photosArray = [];
let startIndex = options.startIndex || 0;
let iosCompletionCallback = options.ios.completionCallback || null;
imagesArray.forEach((imageItem, index) => {
let imageToAdd = NYTImage.alloc().init();
let fontFamily = options.ios.fontFamily || "HelveticaNeue";
let titleFontSize = options.ios.titleFontSize || 16;
let summaryFontSize = options.ios.summaryFontSize || 14;
let creditFontSize = options.ios.creditFontSize || 14;
let titleColor = options.ios.titleColor || new Color("white").ios;
let summaryColor = options.ios.summaryColor || new Color("lightgray").ios;
let creditColor = options.ios.creditColor || new Color("gray").ios;
if (isNYTPhotoItem(imageItem)) {
console.log("received photoItem", imageItem);
if (imageItem.imageURL)
imageToAdd.image = getUIImage(imageItem.imageURL);
dispatch_async(background_queue, () => {
imageToAdd.image = getUIImage(imageItem.imageURL);
if (index == imagesArray.length - 1) {
dispatch_async(main_queue, () => {
this._finishedLoading = true;
if (this.nativeView) {
this.nativeView.reloadPhotosAnimated(false);
this._didReload = true;
}
});
}
});
else
imageToAdd.image = imageItem.image;
imageToAdd.placeholderImage = imageItem.placeholderImage;
imageToAdd.attributedCaptionTitle = _this.attributedString(imageItem.title, titleColor, fontFamily, titleFontSize);
imageToAdd.attributedCaptionSummary = _this.attributedString(imageItem.summary, summaryColor, fontFamily, summaryFontSize);
imageToAdd.attributedCaptionCredit = _this.attributedString(imageItem.credit, creditColor, fontFamily, creditFontSize);
imageToAdd.attributedCaptionTitle = this.attributedString(imageItem.title, titleColor, fontFamily, titleFontSize);
imageToAdd.attributedCaptionSummary = this.attributedString(imageItem.summary, summaryColor, fontFamily, summaryFontSize);
imageToAdd.attributedCaptionCredit = this.attributedString(imageItem.credit, creditColor, fontFamily, creditFontSize);
}
else if (typeof imageItem === 'string') {
console.log("received image url:", imageItem);
var img = getUIImage(imageItem);
imageToAdd.image = img;
dispatch_async(background_queue, () => {
let img = getUIImage(imageItem);
imageToAdd.image = img;
if (index == imagesArray.length - 1) {
dispatch_async(main_queue, () => {
this._finishedLoading = true;
if (this.nativeView) {
this.nativeView.reloadPhotosAnimated(false);
this._didReload = true;
}
});
}
});
}

@@ -64,39 +75,87 @@ else {

}
photosArray.addObject(imageToAdd);
photosArray.push(imageToAdd);
});
_dataSource = new NYTPhotoViewerArrayDataSource({ photos: photosArray });
_dataSource = NYTPhotoViewerArrayDataSource.alloc().initWithPhotos(photosArray);
this.nativeView = NYTPhotosViewController.alloc().initWithDataSourceInitialPhotoIndexDelegate(_dataSource, startIndex, null);
if (!this._didReload && this._finishedLoading) {
if (!NSThread.isMainThread) {
dispatch_async(main_queue, () => {
this.nativeView.reloadPhotosAnimated(false);
this._didReload = true;
});
}
else {
this.nativeView.reloadPhotosAnimated(false);
this._didReload = true;
}
}
if (options.ios.showShareButton == false) {
this.nativeView.rightBarButtonItem = null;
}
frame.topmost().ios.controller.presentViewControllerAnimatedCompletion(this.nativeView, true, iosCompletionCallback);
return new Promise(function (resolve) {
_this._delegate = PhotoViewerDelegateImpl.initWithResolve(resolve);
_this.nativeView.delegate = _this._delegate;
this.topViewController.presentViewControllerAnimatedCompletion(this.nativeView, true, iosCompletionCallback);
return new Promise((resolve) => {
this._delegate = PhotoViewerDelegateImpl.initWithResolve(resolve);
this.nativeView.delegate = this._delegate;
});
};
PhotoViewer.prototype.attributedString = function (text, color, fontFamily, fontSize) {
var _a;
var attributeOptions = (_a = {},
_a[NSForegroundColorAttributeName] = color,
_a[NSFontAttributeName] = UIFont.fontWithNameSize(fontFamily, fontSize),
_a);
}
attributedString(text, color, fontFamily, fontSize) {
var attributeOptions = {
[NSForegroundColorAttributeName]: color,
[NSFontAttributeName]: UIFont.fontWithNameSize(fontFamily, fontSize)
};
return NSAttributedString.alloc().initWithStringAttributes(text || "", attributeOptions);
};
return PhotoViewer;
}());
exports.PhotoViewer = PhotoViewer;
}
static get rootViewController() {
const keyWindow = UIApplication.sharedApplication.keyWindow;
return keyWindow != null ? keyWindow.rootViewController : undefined;
}
get topViewController() {
const root = PhotoViewer.rootViewController;
if (root == null) {
return undefined;
}
return this.findTopViewController(root);
}
findTopViewController(root) {
const presented = root.presentedViewController;
if (presented != null) {
return this.findTopViewController(presented);
}
if (root instanceof UISplitViewController) {
const last = root.viewControllers.lastObject;
if (last == null) {
return root;
}
return this.findTopViewController(last);
}
else if (root instanceof UINavigationController) {
const top = root.topViewController;
if (top == null) {
return root;
}
return this.findTopViewController(top);
}
else if (root instanceof UITabBarController) {
const selected = root.selectedViewController;
if (selected == null) {
return root;
}
return this.findTopViewController(selected);
}
else {
return root;
}
}
}
function getImageData(imageURL) {
var nsURL = NSURL.URLWithString(imageURL);
let nsURL = NSURL.URLWithString(imageURL);
return NSData.dataWithContentsOfURL(nsURL);
}
function getUIImage(imageURL) {
if (utils_1.isFileOrResourcePath(imageURL)) {
console.log("image is file or resource path: ", imageURL);
return imageSource.fromFileOrResource(imageURL).ios;
if (Utils.isFileOrResourcePath(imageURL)) {
return ImageSource.fromFileOrResourceSync(imageURL).ios;
}
else {
console.log("URL: ", imageURL);
var nsURL = NSURL.URLWithString(imageURL);
var imageData = NSData.dataWithContentsOfURL(nsURL);
let nsURL = NSURL.URLWithString(imageURL);
let imageData = NSData.dataWithContentsOfURL(nsURL);
return UIImage.imageWithData(imageData);

@@ -108,20 +167,47 @@ }

}
var NYTImage = NSObject.extend({
get image() { return this.super.image; },
set image(value) { this.super.image = value; },
get imageData() { return this.super.imageData; },
set imageData(value) { this.super.imageData = value; },
get placeholderImage() { return this.super.placeholderImage; },
set placeholderImage(value) { this.super.placeholderImage = value; },
get attributedCaptionTitle() { return this.super.attributedCaptionTitle; },
set attributedCaptionTitle(value) { this.super.attributedCaptionTitle = value; },
get attributedCaptionSummary() { return this.super.attributedCaptionSummary; },
set attributedCaptionSummary(value) { this.super.attributedCaptionSummary = value; },
get attributedCaptionCredit() { return this.super.attributedCaptionCredit; },
set attributedCaptionCredit(value) { this.super.attributedCaptionCredit = value; }
}, {
name: "NYTImage",
protocols: [NYTPhoto]
});
var PhotoViewerDelegateImpl = (function (_super) {
var NYTImage = /** @class */ (function (_super) {
__extends(NYTImage, _super);
function NYTImage() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(NYTImage.prototype, "image", {
get: function () { return this._image; },
set: function (value) { this._image = value; },
enumerable: true,
configurable: true
});
Object.defineProperty(NYTImage.prototype, "imageData", {
get: function () { return this._imageData; },
set: function (value) { this._imageData = value; },
enumerable: true,
configurable: true
});
Object.defineProperty(NYTImage.prototype, "placeholderImage", {
get: function () { return this._placeholderImage; },
set: function (value) { this._placeholderImage = value; },
enumerable: true,
configurable: true
});
Object.defineProperty(NYTImage.prototype, "attributedCaptionTitle", {
get: function () { return this._attributedCaptionTitle; },
set: function (value) { this._attributedCaptionTitle = value; },
enumerable: true,
configurable: true
});
Object.defineProperty(NYTImage.prototype, "attributedCaptionSummary", {
get: function () { return this._attributedCaptionSummary; },
set: function (value) { this._attributedCaptionSummary = value; },
enumerable: true,
configurable: true
});
Object.defineProperty(NYTImage.prototype, "attributedCaptionCredit", {
get: function () { return this._attributedCaptionCredit; },
set: function (value) { this._attributedCaptionCredit = value; },
enumerable: true,
configurable: true
});
NYTImage.ObjCProtocols = [NYTPhoto];
return NYTImage;
}(NSObject));
var PhotoViewerDelegateImpl = /** @class */ (function (_super) {
__extends(PhotoViewerDelegateImpl, _super);

@@ -131,5 +217,4 @@ function PhotoViewerDelegateImpl() {

}
PhotoViewerDelegateImpl_1 = PhotoViewerDelegateImpl;
PhotoViewerDelegateImpl.initWithResolve = function (resolve) {
var delegate = PhotoViewerDelegateImpl_1.new();
var delegate = PhotoViewerDelegateImpl.new();
delegate._resolve = resolve;

@@ -141,8 +226,5 @@ return delegate;

};
var PhotoViewerDelegateImpl_1;
PhotoViewerDelegateImpl = PhotoViewerDelegateImpl_1 = __decorate([
ObjC(NYTPhotosViewControllerDelegate)
], PhotoViewerDelegateImpl);
PhotoViewerDelegateImpl.ObjCProtocols = [NYTPhotosViewControllerDelegate];
return PhotoViewerDelegateImpl;
}(NSObject));
//# sourceMappingURL=photoviewer.ios.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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