diff --git a/README.md b/README.md
index 27eac58..3236f67 100644
--- a/README.md
+++ b/README.md
@@ -1,40 +1,78 @@
-# nativescript-image-popup
+Image Popup plugin for NativeScript.
-Add your plugin badges here. See [nativescript-urlhandler](https://github.com/hypery2k/nativescript-urlhandler) for example.
+Based on:
-Then describe what's the purpose of your plugin.
+- Android [chathuralakmal/AndroidImagePopup](https://github.com/chathuralakmal/AndroidImagePopup)
+- iOS - Coming Soon.
-In case you develop UI plugin, this is where you can add some screenshots.
+# Install
-## (Optional) Prerequisites / Requirements
+### NativeScript 6x
-Describe the prerequisites that the user need to have installed before using your plugin. See [nativescript-firebase plugin](https://github.com/eddyverbruggen/nativescript-plugin-firebase) for example.
+```bash
+tns plugin add nativescript-image-popup
+```
-## Installation
+
-Describe your plugin installation steps. Ideally it would be something like:
-```javascript
-tns plugin add nativescript-image-popup
+
+
+
+# Android Specifications
+
+#### Usage Examples
+
+
+```js
+import { ImagePopup } from 'nativescript-image-popup';
+import { ImagePopupOptions } from 'nativescript-image-popup/classes';
+
+// basic use
+ImagePopup.localImagePopup("~/assets/images/nmb.jpg");
+
+// or
+
+ImagePopup.networkImagePopup("https://i.hizliresim.com/kx47Db.png");
+
+
+// with options
+const options: ImagePopupOptions = {
+ path: "https://i.hizliresim.com/kx47Db.png",
+ width: 500,
+ height: 500,
+ fullScreen: true,
+ backgroundColor:ImagePopupBackgroundColors.TRANSPARENT, // or manuel color ( red, blue #ffd200)
+ hideCloseIcon: false;
+ imageOnClickClose: true
+};
+
```
-## Usage
+#### NativeScript Image Popup - Methods
+
+- `localImagePopup(options: ImagePopupOptions | string)`
+- `networkImagePopup(options: ImagePopupOptions | string)`
+
+
+
+## Why the TNS prefixed name?
+
+`TNS` stands for **T**elerik **N**ative**S**cript
+
+iOS uses classes prefixed with `NS` (stemming from the [NeXTSTEP](https://en.wikipedia.org/wiki/NeXTSTEP) days of old):
+https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/
+
+To avoid confusion with iOS native classes, `TNS` is used instead.
+
+## Demo
+
+Need extra help getting these Image Popup working in your application? Check out these tutorials that make use of the plugin:
-Describe any usage specifics for your plugin. Give examples for Android, iOS, Angular if needed. See [nativescript-drop-down](https://www.npmjs.com/package/nativescript-drop-down) for example.
-
- ```javascript
- Usage code snippets here
- ```)
+[Image Popup in a NativeScript Core Demo](https://github.com/NazimMertBilgi/nativescript-image-popup/blob/master/demo/app/home/home-page.ts)
-## API
+[Image Popup in a NativeScript Angular Demo](https://github.com/NazimMertBilgi/nativescript-image-popup/blob/master/demo-angular/src/app/home/home.component.ts)
-Describe your plugin methods and properties here. See [nativescript-feedback](https://github.com/EddyVerbruggen/nativescript-feedback) for example.
-
-| Property | Default | Description |
-| --- | --- | --- |
-| some property | property default value | property description, default values, etc.. |
-| another property | property default value | property description, default values, etc.. |
-
## License
-Apache License Version 2.0, January 2004
+MIT
\ No newline at end of file
diff --git a/android_example.gif b/android_example.gif
new file mode 100644
index 0000000..aadb65e
Binary files /dev/null and b/android_example.gif differ
diff --git a/demo-angular/src/app/app.component.ts b/demo-angular/src/app/app.component.ts
index 24b740f..d8e94cb 100644
--- a/demo-angular/src/app/app.component.ts
+++ b/demo-angular/src/app/app.component.ts
@@ -1,5 +1,3 @@
-import { ImagePopup } from 'nativescript-image-popup';
-console.log(new ImagePopup().message);
import { Component } from "@angular/core";
@Component({
diff --git a/demo-angular/src/app/home/home.component.html b/demo-angular/src/app/home/home.component.html
index 364bb38..e41685c 100644
--- a/demo-angular/src/app/home/home.component.html
+++ b/demo-angular/src/app/home/home.component.html
@@ -1,7 +1,12 @@
-
+
-
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/demo-angular/src/app/home/home.component.ts b/demo-angular/src/app/home/home.component.ts
index c48ac92..157b3b3 100644
--- a/demo-angular/src/app/home/home.component.ts
+++ b/demo-angular/src/app/home/home.component.ts
@@ -1,16 +1,51 @@
-import { Component, OnInit } from "@angular/core";
+import { Component } from "@angular/core";
+import { ImagePopup } from 'nativescript-image-popup';
+import { ImagePopupOptions, ImagePopupBackgroundColors } from "nativescript-image-popup/classes";
@Component({
selector: "Home",
templateUrl: "./home.component.html"
})
-export class HomeComponent implements OnInit {
+export class HomeComponent {
- constructor() {
- // Use the component constructor to inject providers.
+ showDefaultImage() {
+ ImagePopup.localImagePopup("~/assets/images/nmb.jpg");
}
- ngOnInit(): void {
- // Init your component properties here.
+ showDefaultNetworkImage() {
+ ImagePopup.networkImagePopup("https://i.hizliresim.com/kx47Db.png");
+ }
+
+ showWidthHeightImage() {
+ const options: ImagePopupOptions = {
+ path: "https://i.hizliresim.com/kx47Db.png",
+ width: 300,
+ height: 300
+ };
+ ImagePopup.networkImagePopup(options);
+ }
+
+ showFullScreenImage() {
+ const options: ImagePopupOptions = {
+ path: "https://i.hizliresim.com/kx47Db.png",
+ fullScreen: true
+ };
+ ImagePopup.networkImagePopup(options);
+ }
+
+ showBackgroundTransparentImage() {
+ const options: ImagePopupOptions = {
+ path: "https://i.hizliresim.com/kx47Db.png",
+ backgroundColor: ImagePopupBackgroundColors.TRANSPARENT
+ };
+ ImagePopup.networkImagePopup(options);
+ }
+
+ showBackgroundColorImage() {
+ const options: ImagePopupOptions = {
+ path: "https://i.hizliresim.com/kx47Db.png",
+ backgroundColor: "#2980b9" // red, blue #ffd200 and others..
+ };
+ ImagePopup.networkImagePopup(options);
}
}
diff --git a/demo-angular/src/assets/images/nmb.jpg b/demo-angular/src/assets/images/nmb.jpg
new file mode 100644
index 0000000..589c4c1
Binary files /dev/null and b/demo-angular/src/assets/images/nmb.jpg differ
diff --git a/demo/app/assets/images/nmb.jpg b/demo/app/assets/images/nmb.jpg
new file mode 100644
index 0000000..589c4c1
Binary files /dev/null and b/demo/app/assets/images/nmb.jpg differ
diff --git a/demo/app/home/home-page.ts b/demo/app/home/home-page.ts
index 4e6d08b..7495a18 100644
--- a/demo/app/home/home-page.ts
+++ b/demo/app/home/home-page.ts
@@ -1,13 +1,7 @@
import { ImagePopup } from 'nativescript-image-popup';
-console.log(new ImagePopup().message);
-/*
-In NativeScript, a file with the same name as an XML file is known as
-a code-behind file. The code-behind is a great place to place your view
-logic, and to set up your page’s data binding.
-*/
+import { ImagePopupOptions, ImagePopupBackgroundColors } from 'nativescript-image-popup/classes';
import { NavigatedData, Page } from "tns-core-modules/ui/page";
-
import { HomeViewModel } from "./home-view-model";
export function onNavigatingTo(args: NavigatedData) {
@@ -15,3 +9,44 @@ export function onNavigatingTo(args: NavigatedData) {
page.bindingContext = new HomeViewModel();
}
+
+export function showDefaultImage() {
+ ImagePopup.localImagePopup("~/assets/images/nmb.jpg");
+}
+
+export function showDefaultNetworkImage() {
+ ImagePopup.networkImagePopup("https://i.hizliresim.com/kx47Db.png");
+}
+
+export function showWidthHeightImage() {
+ const options: ImagePopupOptions = {
+ path: "https://i.hizliresim.com/kx47Db.png",
+ width: 300,
+ height: 300
+ };
+ ImagePopup.networkImagePopup(options);
+}
+
+export function showFullScreenImage() {
+ const options: ImagePopupOptions = {
+ path: "https://i.hizliresim.com/kx47Db.png",
+ fullScreen: true
+ };
+ ImagePopup.networkImagePopup(options);
+}
+
+export function showBackgroundTransparentImage() {
+ const options: ImagePopupOptions = {
+ path: "https://i.hizliresim.com/kx47Db.png",
+ backgroundColor: ImagePopupBackgroundColors.TRANSPARENT
+ };
+ ImagePopup.networkImagePopup(options);
+}
+
+export function showBackgroundColorImage() {
+ const options: ImagePopupOptions = {
+ path: "https://i.hizliresim.com/kx47Db.png",
+ backgroundColor: "#2980b9" // red, blue #ffd200 and others..
+ };
+ ImagePopup.networkImagePopup(options);
+}
\ No newline at end of file
diff --git a/demo/app/home/home-page.xml b/demo/app/home/home-page.xml
index 2b91ae1..97e0f99 100644
--- a/demo/app/home/home-page.xml
+++ b/demo/app/home/home-page.xml
@@ -1,12 +1,15 @@
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
diff --git a/publish/package-lock.json b/publish/package-lock.json
new file mode 100644
index 0000000..bc29a5f
--- /dev/null
+++ b/publish/package-lock.json
@@ -0,0 +1,111 @@
+{
+ "name": "nativescript-publish",
+ "version": "1.0.0",
+ "lockfileVersion": 1,
+ "requires": true,
+ "dependencies": {
+ "balanced-match": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
+ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
+ "dev": true
+ },
+ "brace-expansion": {
+ "version": "1.1.11",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
+ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
+ "dev": true,
+ "requires": {
+ "balanced-match": "^1.0.0",
+ "concat-map": "0.0.1"
+ }
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
+ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
+ "dev": true
+ },
+ "fs.realpath": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
+ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
+ "dev": true
+ },
+ "glob": {
+ "version": "7.1.6",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
+ "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
+ "dev": true,
+ "requires": {
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^3.0.4",
+ "once": "^1.3.0",
+ "path-is-absolute": "^1.0.0"
+ }
+ },
+ "inflight": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
+ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
+ "dev": true,
+ "requires": {
+ "once": "^1.3.0",
+ "wrappy": "1"
+ }
+ },
+ "inherits": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
+ "dev": true
+ },
+ "minimatch": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
+ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
+ "dev": true,
+ "requires": {
+ "brace-expansion": "^1.1.7"
+ }
+ },
+ "ncp": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz",
+ "integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=",
+ "dev": true
+ },
+ "once": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
+ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
+ "dev": true,
+ "requires": {
+ "wrappy": "1"
+ }
+ },
+ "path-is-absolute": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
+ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
+ "dev": true
+ },
+ "rimraf": {
+ "version": "2.7.1",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
+ "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
+ "dev": true,
+ "requires": {
+ "glob": "^7.1.3"
+ }
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
+ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
+ "dev": true
+ }
+ }
+}
diff --git a/src/classes/index.ts b/src/classes/index.ts
new file mode 100644
index 0000000..ff95228
--- /dev/null
+++ b/src/classes/index.ts
@@ -0,0 +1,13 @@
+export class ImagePopupOptions {
+ path: string;
+ width?: number;
+ height?: number;
+ backgroundColor?: string;
+ fullScreen?: boolean;
+ hideCloseIcon?: boolean;
+ imageOnClickClose?: boolean
+}
+
+export enum ImagePopupBackgroundColors {
+ TRANSPARENT = "#00ffffff"
+}
\ No newline at end of file
diff --git a/src/image-popup.android.ts b/src/image-popup.android.ts
index 066c5fa..ff17cb0 100644
--- a/src/image-popup.android.ts
+++ b/src/image-popup.android.ts
@@ -1,5 +1,94 @@
-import { Common } from './image-popup.common';
+import * as application from "tns-core-modules/application";
+import * as types from "tns-core-modules/utils/types";
+import * as fs from "tns-core-modules/file-system";
+import { ImagePopupOptions } from "./classes";
-export class ImagePopup extends Common {
+declare const com;
+
+export class ImagePopup {
+
+ public static localImagePopup(options: ImagePopupOptions | string) {
+ const context = application.android.foregroundActivity;
+
+ const imagePopup = new com.ceylonlabs.imageviewpopup.ImagePopup(context);
+
+ if (options instanceof Object) {
+
+ if (options.width) {
+ imagePopup.setWindowWidth(options.width);
+ }
+ if (options.height) {
+ imagePopup.setWindowHeight(options.height);
+ }
+ if (options.backgroundColor) {
+ imagePopup.setBackgroundColor(android.graphics.Color.parseColor(options.backgroundColor));
+ }
+ if (options.fullScreen) {
+ imagePopup.setFullScreen(options.fullScreen);
+ }
+ if (options.hideCloseIcon) {
+ imagePopup.setHideCloseIcon(options.hideCloseIcon);
+ }
+ if (options.imageOnClickClose) {
+ imagePopup.setImageOnClickClose(options.imageOnClickClose);
+ }
+
+ const drawable = this.localImageProcess(options.path);
+
+ imagePopup.initiatePopup(drawable);
+
+ }
+ else {
+ const drawable = this.localImageProcess(options);
+ imagePopup.initiatePopup(drawable);
+ }
+ imagePopup.viewPopup();
+ }
+
+ public static networkImagePopup(options: ImagePopupOptions | string) {
+ const context = application.android.foregroundActivity;
+
+ const imagePopup = new com.ceylonlabs.imageviewpopup.ImagePopup(context);
+
+ if (options instanceof Object) {
+
+ if (options.width) {
+ imagePopup.setWindowWidth(options.width);
+ }
+ if (options.height) {
+ imagePopup.setWindowHeight(options.height);
+ }
+ if (options.backgroundColor) {
+ imagePopup.setBackgroundColor(android.graphics.Color.parseColor(options.backgroundColor));
+ }
+ if (options.fullScreen) {
+ imagePopup.setFullScreen(options.fullScreen);
+ }
+ if (options.hideCloseIcon) {
+ imagePopup.setHideCloseIcon(options.hideCloseIcon);
+ }
+ if (options.imageOnClickClose) {
+ imagePopup.setImageOnClickClose(options.imageOnClickClose);
+ }
+
+ imagePopup.initiatePopupWithPicasso(options.path);
+
+ }
+ else {
+ imagePopup.initiatePopupWithPicasso(options);
+ }
+
+ imagePopup.viewPopup();
+ }
+
+ private static localImageProcess(path: string): globalAndroid.graphics.drawable.Drawable {
+ let fileName = types.isString(path) ? path.trim() : "";
+ if (fileName.indexOf("~/") === 0) {
+ fileName = fs.path.join(fs.knownFolders.currentApp().path, fileName.replace("~/", ""));
+ }
+
+ const drawable = android.graphics.drawable.Drawable.createFromPath(fileName);
+ return drawable;
+ }
}
diff --git a/src/image-popup.common.ts b/src/image-popup.common.ts
deleted file mode 100644
index c5801f9..0000000
--- a/src/image-popup.common.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { Observable } from 'tns-core-modules/data/observable';
-import * as app from 'tns-core-modules/application';
-import * as dialogs from 'tns-core-modules/ui/dialogs';
-
-export class Common extends Observable {
- public message: string;
-
- constructor() {
- super();
- this.message = Utils.SUCCESS_MSG();
- }
-
- public greet() {
- return "Hello, NS";
- }
-}
-
-export class Utils {
- public static SUCCESS_MSG(): string {
- let msg = `Your plugin is working on ${app.android ? 'Android' : 'iOS'}.`;
-
- setTimeout(() => {
- dialogs.alert(`${msg} For real. It's really working :)`).then(() => console.log(`Dialog closed.`));
- }, 2000);
-
- return msg;
- }
-}
diff --git a/src/image-popup.ios.ts b/src/image-popup.ios.ts
index 066c5fa..a58a532 100644
--- a/src/image-popup.ios.ts
+++ b/src/image-popup.ios.ts
@@ -1,5 +1,3 @@
-import { Common } from './image-popup.common';
-
-export class ImagePopup extends Common {
+export class ImagePopup {
}
diff --git a/src/index.d.ts b/src/index.d.ts
index 605ec30..b110552 100644
--- a/src/index.d.ts
+++ b/src/index.d.ts
@@ -1,6 +1,7 @@
-import { Common } from './image-popup.common';
-export declare class ImagePopup extends Common {
- // define your typings manually
- // or..
- // take the ios or android .d.ts files and copy/paste them here
+import { ImagePopupOptions } from "./classes";
+
+export declare class ImagePopup {
+ static localImagePopup(options: ImagePopupOptions | string)
+
+ static networkImagePopup(options: ImagePopupOptions | string)
}
diff --git a/src/package.json b/src/package.json
index 22b07d4..4a1f63a 100644
--- a/src/package.json
+++ b/src/package.json
@@ -1,7 +1,7 @@
{
"name": "nativescript-image-popup",
"version": "1.0.0",
- "description": "Your awesome NativeScript plugin.",
+ "description": "Image Popup plugin for NativeScript.",
"main": "image-popup",
"typings": "index.d.ts",
"nativescript": {
@@ -34,11 +34,13 @@
"NativeScript",
"JavaScript",
"Android",
- "iOS"
+ "iOS",
+ "Image",
+ "Popup"
],
"author": {
- "name": "Your Name",
- "email": "youremail@yourdomain.com"
+ "name": "Nazım Mert Bilgi",
+ "email": "nmbjobs@outlook.com.tr"
},
"bugs": {
"url": "https://github.com/NazimMertBilgi/nativescript-image-popup/issues"
diff --git a/src/platforms/android/include.gradle b/src/platforms/android/include.gradle
index 612a631..6143010 100644
--- a/src/platforms/android/include.gradle
+++ b/src/platforms/android/include.gradle
@@ -4,8 +4,12 @@ android {
}
+repositories {
+ maven {
+ url "https://jitpack.io"
+ }
+}
+
dependencies {
- // Describe plugin native Android dependencies like
- // implementation "groupName:pluginName:ver"
- // EXAMPLE: implementation "com.facebook.fresco:fresco:0.9.0+"
+ compile 'com.github.chathuralakmal:AndroidImagePopup:1.2.2'
}
\ No newline at end of file
diff --git a/src/platforms/android/nativescript_image_popup.aar b/src/platforms/android/nativescript_image_popup.aar
new file mode 100644
index 0000000..f13fd2a
Binary files /dev/null and b/src/platforms/android/nativescript_image_popup.aar differ