mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-02-16 00:00:02 +08:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a8146b76c | ||
|
|
2d60db9d3b | ||
|
|
3378d7a398 | ||
|
|
61defd480c | ||
|
|
4e28295486 | ||
|
|
dee32c921c | ||
|
|
2475c57e00 | ||
|
|
79b522f832 | ||
|
|
ccb2e55435 | ||
|
|
f09c9cfe9a | ||
|
|
d96d3eef07 | ||
|
|
95daca166b | ||
|
|
196be026ea | ||
|
|
1fa7c91105 |
8
.github/ISSUE_TEMPLATE.md
vendored
8
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,7 +1,7 @@
|
||||
**I'm submitting a ...** (check one with "x")
|
||||
[ ] bug report
|
||||
[ ] feature request
|
||||
<!-- Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/ -->
|
||||
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/
|
||||
|
||||
**Current behavior:**
|
||||
<!-- Describe how the bug manifests. -->
|
||||
@@ -21,8 +21,8 @@ insert any relevant code here
|
||||
**Other information:**
|
||||
<!-- List any other information that is relevant to your issue. Stack traces, related issues, suggestions on how to fix, Stack Overflow links, forum links, etc. -->
|
||||
|
||||
**package.json info:**
|
||||
**Ionic info:** (run `ionic info` from a terminal/cmd prompt and paste output below):
|
||||
|
||||
```json
|
||||
insert the content here
|
||||
```
|
||||
insert the output from ionic info here
|
||||
```
|
||||
|
||||
51
CHANGELOG.md
51
CHANGELOG.md
@@ -1,5 +1,21 @@
|
||||
<a name="4.4.1"></a>
|
||||
## [4.4.1](https://github.com/ionic-team/ionic-native/compare/v4.4.0...v4.4.1) (2017-11-13)
|
||||
|
||||
|
||||
|
||||
<a name="4.4.0"></a>
|
||||
# [4.4.0](https://github.com/ionic-team/ionic-native/compare/v4.3.3...v4.4.0) (2017-11-09)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **google-maps:** accept own properties for `addMarker()` and others ([#2093](https://github.com/ionic-team/ionic-native/issues/2093)) ([196be02](https://github.com/ionic-team/ionic-native/commit/196be02))
|
||||
* **http:** add support for new methods ([#2054](https://github.com/ionic-team/ionic-native/issues/2054)) ([d96d3ee](https://github.com/ionic-team/ionic-native/commit/d96d3ee))
|
||||
|
||||
|
||||
|
||||
<a name="4.3.3"></a>
|
||||
## [4.3.3](https://github.com/ionic-team/ionic-native/compare/4.3.2...v4.3.3) (2017-11-01)
|
||||
## [4.3.3](https://github.com/ionic-team/ionic-native/compare/v4.3.2...v4.3.3) (2017-11-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
@@ -8,6 +24,11 @@
|
||||
|
||||
|
||||
|
||||
<a name="4.3.2"></a>
|
||||
## [4.3.2](https://github.com/ionic-team/ionic-native/compare/4.3.2...v4.3.2) (2017-10-18)
|
||||
|
||||
|
||||
|
||||
<a name="4.3.2"></a>
|
||||
## [4.3.2](https://github.com/ionic-team/ionic-native/compare/4.3.1...4.3.2) (2017-10-17)
|
||||
|
||||
@@ -24,17 +45,7 @@
|
||||
|
||||
|
||||
<a name="4.3.1"></a>
|
||||
## [4.3.1](https://github.com/ionic-team/ionic-native/compare/v4.3.1...4.3.1) (2017-10-06)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **pro:** Add support for Ionic Pro by incorporating cordova-plugin-ionic ([465d551](https://github.com/ionic-team/ionic-native/commit/465d551))
|
||||
|
||||
|
||||
|
||||
<a name="4.3.1"></a>
|
||||
## [4.3.1](https://github.com/ionic-team/ionic-native/compare/v4.3.0...v4.3.1) (2017-10-06)
|
||||
## [4.3.1](https://github.com/ionic-team/ionic-native/compare/v4.3.0...4.3.1) (2017-10-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
@@ -46,6 +57,7 @@
|
||||
|
||||
### Features
|
||||
|
||||
* **pro:** Add support for Ionic Pro by incorporating cordova-plugin-ionic ([465d551](https://github.com/ionic-team/ionic-native/commit/465d551))
|
||||
* **regula-document-reader:** separate initialization and scanning, add android ([#2013](https://github.com/ionic-team/ionic-native/issues/2013)) ([2179699](https://github.com/ionic-team/ionic-native/commit/2179699))
|
||||
|
||||
|
||||
@@ -58,7 +70,6 @@
|
||||
|
||||
* **google-maps:** convert JS classes to Ionic Native ([#1956](https://github.com/ionic-team/ionic-native/issues/1956)) ([57af5c5](https://github.com/ionic-team/ionic-native/commit/57af5c5))
|
||||
* **google-maps:** fix icons property of MarkerClusterOptions ([#1937](https://github.com/ionic-team/ionic-native/issues/1937)) ([8004790](https://github.com/ionic-team/ionic-native/commit/8004790))
|
||||
* **google-maps:** fix issue when creating new instance of BaseArrayClass ([#1931](https://github.com/ionic-team/ionic-native/issues/1931)) ([957396b](https://github.com/ionic-team/ionic-native/commit/957396b))
|
||||
* **google-maps:** the zoom option is missing in the GoogleMapOptions class ([#1948](https://github.com/ionic-team/ionic-native/issues/1948)) ([ef898ef](https://github.com/ionic-team/ionic-native/commit/ef898ef))
|
||||
* **http:** fix plugin ref ([#1934](https://github.com/ionic-team/ionic-native/issues/1934)) ([3a1034e](https://github.com/ionic-team/ionic-native/commit/3a1034e))
|
||||
* **launch-navigator:** fix navigate method ([#1940](https://github.com/ionic-team/ionic-native/issues/1940)) ([a150d4d](https://github.com/ionic-team/ionic-native/commit/a150d4d))
|
||||
@@ -83,6 +94,16 @@
|
||||
|
||||
|
||||
|
||||
<a name="4.2.1"></a>
|
||||
## [4.2.1](https://github.com/ionic-team/ionic-native/compare/v4.2.0...v4.2.1) (2017-08-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **google-maps:** fix issue when creating new instance of BaseArrayClass ([#1931](https://github.com/ionic-team/ionic-native/issues/1931)) ([957396b](https://github.com/ionic-team/ionic-native/commit/957396b))
|
||||
|
||||
|
||||
|
||||
<a name="4.2.0"></a>
|
||||
# [4.2.0](https://github.com/ionic-team/ionic-native/compare/v4.1.0...v4.2.0) (2017-08-26)
|
||||
|
||||
@@ -1832,13 +1853,13 @@ The whole implementation has changed now. You must update your code.
|
||||
* **geolocation:** call correct clearFunction ([9e86a40](https://github.com/ionic-team/ionic-native/commit/9e86a40))
|
||||
* **plugin:** return originalMethod return value ([240f0f8](https://github.com/ionic-team/ionic-native/commit/240f0f8))
|
||||
* **plugin:** use call for id based clearFunction ([c2fdf39](https://github.com/ionic-team/ionic-native/commit/c2fdf39))
|
||||
* datepicker plugin, pluginref, and [@Cordova](https://github.com/Cordova) wrapper ([499ead3](https://github.com/ionic-team/ionic-native/commit/499ead3))
|
||||
* datepicker plugin, pluginref, and @Cordova wrapper ([499ead3](https://github.com/ionic-team/ionic-native/commit/499ead3))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **DatePicker:** Added DatePicker ([5afa58f](https://github.com/ionic-team/ionic-native/commit/5afa58f))
|
||||
* **plugin:** add sync option to [@Cordova](https://github.com/Cordova) for sync functions ([17e3827](https://github.com/ionic-team/ionic-native/commit/17e3827))
|
||||
* **plugin:** add sync option to @Cordova for sync functions ([17e3827](https://github.com/ionic-team/ionic-native/commit/17e3827))
|
||||
* **plugin:** call clearFunction with original fn args ([8f27fc9](https://github.com/ionic-team/ionic-native/commit/8f27fc9))
|
||||
* add app version plugin ([20cb01f](https://github.com/ionic-team/ionic-native/commit/20cb01f))
|
||||
* add app version plugin ([8b78521](https://github.com/ionic-team/ionic-native/commit/8b78521))
|
||||
|
||||
6861
package-lock.json
generated
6861
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ionic-native",
|
||||
"version": "4.3.3",
|
||||
"version": "4.4.2",
|
||||
"description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support",
|
||||
"homepage": "https://ionicframework.com/",
|
||||
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
|
||||
@@ -10,12 +10,12 @@
|
||||
"@angular/compiler-cli": "4.4.4",
|
||||
"@angular/core": "4.4.4",
|
||||
"@types/cordova": "0.0.34",
|
||||
"@types/jasmine": "^2.5.51",
|
||||
"@types/node": "^7.0.27",
|
||||
"@types/jasmine": "^2.6.3",
|
||||
"@types/node": "^8.0.50",
|
||||
"canonical-path": "0.0.2",
|
||||
"child-process-promise": "2.2.1",
|
||||
"conventional-changelog-cli": "1.3.1",
|
||||
"cpr": "2.0.2",
|
||||
"conventional-changelog-cli": "1.3.4",
|
||||
"cpr": "2.0.0",
|
||||
"cz-conventional-changelog": "2.0.0",
|
||||
"decamelize": "1.2.0",
|
||||
"dgeni": "0.4.7",
|
||||
@@ -39,11 +39,11 @@
|
||||
"q": "1.5.0",
|
||||
"queue": "4.2.1",
|
||||
"rimraf": "2.6.1",
|
||||
"rxjs": "5.4.3",
|
||||
"rxjs": "5.5.2",
|
||||
"semver": "5.3.0",
|
||||
"tslint": "3.15.1",
|
||||
"tslint-ionic-rules": "0.0.8",
|
||||
"typescript": "2.3.4",
|
||||
"typescript": "~2.4.2",
|
||||
"zone.js": "0.8.18"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
import { Plugin, IonicNativePlugin } from '@ionic-native/core';
|
||||
/**
|
||||
* This is a template for new plugin wrappers
|
||||
*
|
||||
* TODO:
|
||||
* - Add/Change information below
|
||||
* - Document usage (importing, executing main functionality)
|
||||
* - Remove any imports that you are not using
|
||||
* - Add this file to /src/index.ts (follow style of other plugins)
|
||||
* - Remove all the comments included in this template, EXCEPT the @Plugin wrapper docs and any other docs you added
|
||||
* - Remove this note
|
||||
*
|
||||
*/
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Plugin, Cordova, CordovaProperty, CordovaInstance, InstanceProperty, IonicNativePlugin } from '@ionic-native/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
/**
|
||||
* @name {{ Plugin_Name }}
|
||||
* @description
|
||||
* This plugin does something
|
||||
*
|
||||
* @usage
|
||||
* ```typescript
|
||||
@@ -15,16 +29,33 @@ import { Injectable } from '@angular/core';
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.{{ pluginName }}.functionName('Hello', 123)
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: '{{ PluginName }}',
|
||||
plugin: '',
|
||||
pluginRef: '',
|
||||
repo: '',
|
||||
platforms: []
|
||||
plugin: '', // npm package name, example: cordova-plugin-camera
|
||||
pluginRef: '', // the variable reference to call the plugin, example: navigator.geolocation
|
||||
repo: '', // the github repository URL for the plugin
|
||||
install: '', // OPTIONAL install command, in case the plugin requires variables
|
||||
installVariables: [], // OPTIONAL the plugin requires variables
|
||||
platforms: [] // Array of platforms supported, example: ['Android', 'iOS']
|
||||
})
|
||||
@Injectable()
|
||||
export class {{ PluginName }} extends IonicNativePlugin {
|
||||
|
||||
/**
|
||||
* This function does something
|
||||
* @param arg1 {string} Some param to configure something
|
||||
* @param arg2 {number} Another param to configure something
|
||||
* @return {Promise<any>} Returns a promise that resolves when something happens
|
||||
*/
|
||||
@Cordova()
|
||||
functionName(arg1: string, arg2: number): Promise<any> {
|
||||
return; // We add return; here to avoid any IDE / Compiler errors
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,8 +40,9 @@ import { Observable } from 'rxjs/Observable';
|
||||
plugin: '', // npm package name, example: cordova-plugin-camera
|
||||
pluginRef: '', // the variable reference to call the plugin, example: navigator.geolocation
|
||||
repo: '', // the github repository URL for the plugin
|
||||
platforms: [], // Array of platforms supported, example: ['Android', 'iOS']
|
||||
install: '', // OPTIONAL install command, in case the plugin requires variables
|
||||
installVariables: [], // OPTIONAL the plugin requires variables
|
||||
platforms: [] // Array of platforms supported, example: ['Android', 'iOS']
|
||||
})
|
||||
@Injectable()
|
||||
export class {{ PluginName }} extends IonicNativePlugin {
|
||||
|
||||
@@ -105,17 +105,6 @@ export interface CordovaCheckOptions {
|
||||
observable?: boolean;
|
||||
}
|
||||
|
||||
export interface CordovaFiniteObservableOptions extends CordovaOptions {
|
||||
/**
|
||||
* Function that gets a result returned from plugin's success callback, and decides whether it is last value and observable should complete.
|
||||
*/
|
||||
resultFinalPredicate?: (result: any) => boolean;
|
||||
/**
|
||||
* Function that gets called after resultFinalPredicate, and removes service data that indicates end of stream from the result.
|
||||
*/
|
||||
resultTransform?: (result: any) => any;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
@@ -167,7 +156,6 @@ export function CordovaCheck(opts: CordovaCheckOptions = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
@@ -323,39 +311,3 @@ export function CordovaFunctionOverride(opts: any = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* Wraps method that returns an observable that can be completed. Provided opts.resultFinalPredicate dictates when the observable completes.
|
||||
*
|
||||
*/
|
||||
export function CordovaFiniteObservable(opts: CordovaFiniteObservableOptions = {}) {
|
||||
if (opts.observable === false) {
|
||||
throw new Error('CordovaFiniteObservable decorator can only be used on methods that returns observable. Please provide correct option.');
|
||||
}
|
||||
opts.observable = true;
|
||||
return (target: Object, methodName: string, descriptor: TypedPropertyDescriptor<any>) => {
|
||||
return {
|
||||
value: function(...args: any[]) {
|
||||
let wrappedObservable: Observable<any> = wrap(this, methodName, opts).apply(this, args);
|
||||
return new Observable<any>((observer) => {
|
||||
let wrappedSubscription = wrappedObservable.subscribe({
|
||||
next: (x) => {
|
||||
observer.next(opts.resultTransform ? opts.resultTransform(x) : x);
|
||||
if (opts.resultFinalPredicate && opts.resultFinalPredicate(x)) {
|
||||
observer.complete();
|
||||
}
|
||||
},
|
||||
error: (err) => { observer.error(err); },
|
||||
complete: () => { observer.complete(); }
|
||||
});
|
||||
return () => {
|
||||
wrappedSubscription.unsubscribe();
|
||||
};
|
||||
});
|
||||
},
|
||||
enumerable: true
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, CordovaCheck, CordovaInstance, Plugin, InstanceProperty, InstanceCheck, checkAvailability, IonicNativePlugin } from '@ionic-native/core';
|
||||
import { CordovaCheck, CordovaInstance, Plugin, InstanceProperty, InstanceCheck, checkAvailability, IonicNativePlugin } from '@ionic-native/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/observable/fromEvent';
|
||||
|
||||
@@ -93,6 +93,9 @@ export class LatLngBounds implements ILatLngBounds {
|
||||
|
||||
export interface GoogleMapOptions {
|
||||
|
||||
/**
|
||||
* MapType
|
||||
*/
|
||||
mapType?: MapType;
|
||||
|
||||
controls?: {
|
||||
@@ -124,9 +127,25 @@ export interface GoogleMapOptions {
|
||||
};
|
||||
|
||||
gestures?: {
|
||||
|
||||
/**
|
||||
* Set false to disable the scroll gesture (default: true)
|
||||
*/
|
||||
scroll?: boolean;
|
||||
|
||||
/**
|
||||
* Set false to disable the tilt gesture (default: true)
|
||||
*/
|
||||
tilt?: boolean;
|
||||
|
||||
/**
|
||||
* Set false to disable the zoom gesture (default: true)
|
||||
*/
|
||||
zoom?: boolean;
|
||||
|
||||
/**
|
||||
* Set false to disable the rotate gesture (default: true)
|
||||
*/
|
||||
rotate?: boolean;
|
||||
};
|
||||
|
||||
@@ -171,6 +190,23 @@ export interface GoogleMapOptions {
|
||||
export interface CameraPosition<T> {
|
||||
/**
|
||||
* The center location of the camera view.
|
||||
*
|
||||
* [usage 1]
|
||||
*
|
||||
* let cameraPos: CameraPosition<ILatLng> = {
|
||||
* target: {lat: ..., lng: ...},
|
||||
* zoom: 10
|
||||
* }
|
||||
*
|
||||
* [usage 2] The zoom property is ignored when you specify multiple position
|
||||
*
|
||||
* let cameraPos: CameraPosition<ILatLng[]> = {
|
||||
* target: [
|
||||
* {lat: ..., lng: ...},
|
||||
* {lat: ..., lng: ...},
|
||||
* {lat: ..., lng: ...}
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
target?: T;
|
||||
/**
|
||||
@@ -196,18 +232,91 @@ export interface CameraPosition<T> {
|
||||
}
|
||||
|
||||
export interface CircleOptions {
|
||||
center?: ILatLng;
|
||||
radius?: number;
|
||||
/**
|
||||
* Center position of circle
|
||||
*/
|
||||
center: ILatLng;
|
||||
|
||||
/**
|
||||
* Radius of circle in meter
|
||||
*/
|
||||
radius: number;
|
||||
|
||||
/**
|
||||
* Set the stroke color
|
||||
* (rgb, rgba, #RRGGBB, "colorname", ...etc)
|
||||
*/
|
||||
strokeColor?: string;
|
||||
|
||||
/**
|
||||
* Set the stroke width in pixel
|
||||
*/
|
||||
strokeWidth?: number;
|
||||
/**
|
||||
* Set the inside color of polygon
|
||||
* (rgb, rgba, #RRGGBB, "colorname", ...etc)
|
||||
*/
|
||||
fillColor?: string;
|
||||
|
||||
/**
|
||||
* Set to true to receive the CIRCLE_CLICK event
|
||||
* (default: false)
|
||||
*/
|
||||
clickable?: boolean;
|
||||
|
||||
/**
|
||||
* Set to false to hide
|
||||
*/
|
||||
visible?: boolean;
|
||||
|
||||
/**
|
||||
* Z-index
|
||||
*/
|
||||
zIndex?: number;
|
||||
|
||||
/**
|
||||
* Accept own properties
|
||||
* You can get the property later using `get()` method.
|
||||
*/
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface GeocoderRequest {
|
||||
|
||||
/**
|
||||
* The address property or position property is required.
|
||||
* You can not specify both property at the same time.
|
||||
*
|
||||
* [geocoding usage1]
|
||||
* let request: GeocoderRequest = {
|
||||
* address: "Los Angeles, California, USA"
|
||||
* };
|
||||
*
|
||||
* [geocoding usage2]
|
||||
* let request: GeocoderRequest = {
|
||||
* address: [
|
||||
* "Los Angeles, California, USA",
|
||||
* "San Francisco, California, USA",
|
||||
* ]
|
||||
* };
|
||||
*/
|
||||
address?: string | string[];
|
||||
|
||||
/**
|
||||
*
|
||||
* [reverse-geocoding usage1]
|
||||
* let request: GeocoderRequest = {
|
||||
* position: {"lat": 37.421655, "lng": -122.085637}
|
||||
* };
|
||||
*
|
||||
* [reverse-geocoding usage2]
|
||||
* let request: GeocoderRequest = {
|
||||
* address: [
|
||||
* {"lat": 37.421655, "lng": -122.085637},
|
||||
* {"lat": 37.332, "lng": -122.030781}
|
||||
* ]
|
||||
* };
|
||||
*/
|
||||
position?: ILatLng | ILatLng[];
|
||||
}
|
||||
|
||||
@@ -236,31 +345,44 @@ export interface GroundOverlayOptions {
|
||||
/**
|
||||
* URL of overlay
|
||||
*/
|
||||
url?: string;
|
||||
url: string;
|
||||
|
||||
/**
|
||||
* Bounds, array of ILatLng
|
||||
*/
|
||||
bounds?: Array<ILatLng>;
|
||||
bounds: Array<ILatLng>;
|
||||
|
||||
/**
|
||||
* Set to false to ignore click event
|
||||
* Set to true to receive the GROUND_OVERLAY_CLICK event
|
||||
* (default: false)
|
||||
*/
|
||||
clickable?: boolean;
|
||||
|
||||
/**
|
||||
* Set to false to hide
|
||||
*/
|
||||
visible?: boolean;
|
||||
|
||||
/**
|
||||
* Opacity. From 0.0 to 1.0 .
|
||||
*/
|
||||
opacity?: number;
|
||||
|
||||
/**
|
||||
* Bearing
|
||||
*/
|
||||
bearing?: number;
|
||||
|
||||
/**
|
||||
* Z-index
|
||||
*/
|
||||
zIndex?: number;
|
||||
|
||||
/**
|
||||
* Accept own properties
|
||||
* You can get the property later using `get()` method.
|
||||
*/
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface ILatLng {
|
||||
@@ -341,13 +463,52 @@ export interface MarkerOptions {
|
||||
* Set to true to disable auto panning when the marker is clicked.
|
||||
*/
|
||||
disableAutoPan?: boolean;
|
||||
|
||||
/**
|
||||
* Accept own properties
|
||||
* You can get the property later using `get()` method.
|
||||
*/
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface MarkerClusterOptions {
|
||||
/**
|
||||
* Maximum zoom level of clustering
|
||||
* (default: 15, max: 18)
|
||||
*/
|
||||
maxZoomLevel?: number;
|
||||
|
||||
/**
|
||||
* Draw a rectangle that contains all locations of clustered when you tap on a clister marker.
|
||||
* (default: true)
|
||||
*/
|
||||
boundsDraw?: boolean;
|
||||
|
||||
/**
|
||||
* Position list
|
||||
* [
|
||||
* {title: "store A", position: {lat: ..., lng: ...}},
|
||||
* {title: "store B", position: {lat: ..., lng: ...}},
|
||||
* {title: "store C", position: {lat: ..., lng: ...}}
|
||||
* ]
|
||||
*/
|
||||
markers: MarkerOptions[];
|
||||
|
||||
/**
|
||||
* Conditions of clustering
|
||||
* [
|
||||
* {icon: "assets/small.png", min: 2, max: 10},
|
||||
* {icon: "assets/middle.png", min: 11, max: 30},
|
||||
* {icon: "assets/large.png", min: 31},
|
||||
* ]
|
||||
*/
|
||||
icons: any[];
|
||||
|
||||
/**
|
||||
* Accept own properties
|
||||
* You can get the property later using `get()` method.
|
||||
*/
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface MyLocation {
|
||||
@@ -363,38 +524,159 @@ export interface MyLocation {
|
||||
}
|
||||
|
||||
export interface MyLocationOptions {
|
||||
/**
|
||||
* Set true if you want to try to use GPS mandatory.
|
||||
* (In false, the plugin try to use GPS and network)
|
||||
* (default: false)
|
||||
*/
|
||||
enableHighAccuracy?: boolean;
|
||||
}
|
||||
|
||||
export interface PolygonOptions {
|
||||
points?: Array<ILatLng>;
|
||||
/**
|
||||
* Pass ILatLng[] to specify the vertixes.
|
||||
* You need to contain two points at least.
|
||||
*/
|
||||
points: Array<ILatLng>;
|
||||
|
||||
/**
|
||||
* Set true if you want to draw the curve polygon based on the earth
|
||||
* (default: false)
|
||||
*/
|
||||
geodesic?: boolean;
|
||||
|
||||
/**
|
||||
* Set the stroke color
|
||||
* (rgb, rgba, #RRGGBB, "colorname", ...etc)
|
||||
*/
|
||||
strokeColor?: string;
|
||||
|
||||
/**
|
||||
* Set the stroke width in pixel
|
||||
*/
|
||||
strokeWidth?: number;
|
||||
|
||||
/**
|
||||
* Set the inside color of polygon
|
||||
* (rgb, rgba, #RRGGBB, "colorname", ...etc)
|
||||
*/
|
||||
fillColor?: string;
|
||||
|
||||
/**
|
||||
* Set false if you want to create invisible polygon
|
||||
* (Invisible polygon is not clickable, default true)
|
||||
*/
|
||||
visible?: boolean;
|
||||
|
||||
/**
|
||||
* Hierarchy z-index
|
||||
*/
|
||||
zIndex?: number;
|
||||
|
||||
/**
|
||||
* Pass ILatLng[][] to create holes in polygon
|
||||
*/
|
||||
addHole?: Array<Array<ILatLng>>;
|
||||
|
||||
/**
|
||||
* Set true if you want to receive the POLYGON_CLICK event
|
||||
* (default: false)
|
||||
*/
|
||||
clickable?: boolean;
|
||||
|
||||
/**
|
||||
* Accept own properties
|
||||
* You can get the property later using `get()` method.
|
||||
*/
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface PolylineOptions {
|
||||
points?: Array<ILatLng>;
|
||||
/**
|
||||
* Pass ILatLng[] to specify the vertixes.
|
||||
* You need to contain two points at least.
|
||||
*/
|
||||
points: Array<ILatLng>;
|
||||
|
||||
/**
|
||||
* Set false if you want to create invisible polyline
|
||||
* (Invisible polyline is not clickable, default true)
|
||||
*/
|
||||
visible?: boolean;
|
||||
|
||||
/**
|
||||
* Set true if you want to draw the curve polyline based on the earth
|
||||
* (default: false)
|
||||
*/
|
||||
geodesic?: boolean;
|
||||
|
||||
/**
|
||||
* Set the stroke color
|
||||
* (rgb, rgba, #RRGGBB, "colorname", ...etc)
|
||||
*/
|
||||
color?: string;
|
||||
|
||||
/**
|
||||
* Set the stroke width in pixel
|
||||
*/
|
||||
width?: number;
|
||||
|
||||
/**
|
||||
* Hierarchy z-index
|
||||
*/
|
||||
zIndex?: number;
|
||||
|
||||
/**
|
||||
* Set true if you want to receive the POLYLINE_CLICK event
|
||||
* (default: false)
|
||||
*/
|
||||
clickable?: boolean;
|
||||
|
||||
/**
|
||||
* Accept own properties
|
||||
* You can get the property later using `get()` method.
|
||||
*/
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface TileOverlayOptions {
|
||||
/**
|
||||
* This callback must return string of image URL.
|
||||
* If no tile, you need to return null.
|
||||
*/
|
||||
getTile: (x: number, y: number, zoom: number) => string;
|
||||
|
||||
/**
|
||||
* Set false if you want to create invisible tilelayer
|
||||
* (default true)
|
||||
*/
|
||||
visible?: boolean;
|
||||
|
||||
/**
|
||||
* Hierarchy z-index of tilelayer
|
||||
*/
|
||||
zIndex?: number;
|
||||
|
||||
/**
|
||||
* Default: 512px
|
||||
*/
|
||||
tileSize?: number;
|
||||
|
||||
/**
|
||||
* Default: 1.0
|
||||
*/
|
||||
opacity?: number;
|
||||
|
||||
/**
|
||||
* Set true if you want to display the tile information over the tile images.
|
||||
*/
|
||||
debug?: boolean;
|
||||
|
||||
/**
|
||||
* Accept own properties
|
||||
* You can get the property later using `get()` method.
|
||||
*/
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
|
||||
@@ -583,6 +865,7 @@ export const GoogleMapsMapTypeId: { [mapType: string]: MapType; } = {
|
||||
* Polygon
|
||||
* Polyline
|
||||
* Spherical
|
||||
* Poly
|
||||
* TileOverlay
|
||||
* BaseClass
|
||||
* BaseArrayClass
|
||||
@@ -623,7 +906,7 @@ export class GoogleMaps extends IonicNativePlugin {
|
||||
* @param options {any} Options
|
||||
* @return {GoogleMap}
|
||||
*/
|
||||
create(element: string | HTMLElement | GoogleMapOptions, options?: GoogleMapOptions): GoogleMap {
|
||||
static create(element: string | HTMLElement | GoogleMapOptions, options?: GoogleMapOptions): GoogleMap {
|
||||
if (element instanceof HTMLElement) {
|
||||
if (element.getAttribute('__pluginMapId')) {
|
||||
console.error('GoogleMaps', element.tagName + '[__pluginMapId=\'' + element.getAttribute('__pluginMapId') + '\'] has already map.');
|
||||
@@ -638,6 +921,15 @@ export class GoogleMaps extends IonicNativePlugin {
|
||||
return googleMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecation
|
||||
* @hidden
|
||||
*/
|
||||
create(element: string | HTMLElement | GoogleMapOptions, options?: GoogleMapOptions): GoogleMap {
|
||||
console.error('GoogleMaps', '[deprecated] Please use GoogleMaps.create()');
|
||||
return GoogleMaps.create(element, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1188,20 +1480,37 @@ export class Environment {
|
||||
* Get the open source software license information for Google Maps SDK for iOS.
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
getLicenseInfo(): Promise<any> {
|
||||
static getLicenseInfo(): Promise<any> {
|
||||
return new Promise<any>((resolve) => {
|
||||
GoogleMaps.getPlugin().environment.getLicenseInfo((text: string) => resolve(text));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecation
|
||||
* @hidden
|
||||
*/
|
||||
getLicenseInfo(): Promise<any> {
|
||||
console.error('GoogleMaps', '[deprecated] This method is static. Please use Environment.getLicenseInfo()');
|
||||
return Environment.getLicenseInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the background color of the app.
|
||||
* @param color
|
||||
*/
|
||||
setBackgroundColor(color: string): void {
|
||||
static setBackgroundColor(color: string): void {
|
||||
GoogleMaps.getPlugin().environment.setBackgroundColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecation
|
||||
* @hidden
|
||||
*/
|
||||
setBackgroundColor(color: string): void {
|
||||
console.error('GoogleMaps', '[deprecated] This method is static. Please use Environment.setBackgroundColor()');
|
||||
Environment.setBackgroundColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1214,12 +1523,22 @@ export class Environment {
|
||||
repo: ''
|
||||
})
|
||||
export class Geocoder {
|
||||
|
||||
/**
|
||||
* @deprecation
|
||||
* @hidden
|
||||
*/
|
||||
geocode(request: GeocoderRequest): Promise<GeocoderResult[] | BaseArrayClass<GeocoderResult>> {
|
||||
console.error('GoogleMaps', '[deprecated] This method is static. Please use Geocoder.geocode()');
|
||||
return Geocoder.geocode(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts position to address and vice versa
|
||||
* @param {GeocoderRequest} request Request object with either an address or a position
|
||||
* @return {Promise<GeocoderResult[] | BaseArrayClass<GeocoderResult>>}
|
||||
*/
|
||||
geocode(request: GeocoderRequest): Promise<GeocoderResult[] | BaseArrayClass<GeocoderResult>> {
|
||||
static geocode(request: GeocoderRequest): Promise<GeocoderResult[] | BaseArrayClass<GeocoderResult>> {
|
||||
|
||||
if (request.address instanceof Array || Array.isArray(request.address) ||
|
||||
request.position instanceof Array || Array.isArray(request.position)) {
|
||||
@@ -1269,22 +1588,71 @@ export class Geocoder {
|
||||
repo: ''
|
||||
})
|
||||
export class Encoding {
|
||||
|
||||
/**
|
||||
* @deprecation
|
||||
* @hidden
|
||||
*/
|
||||
decodePath(encoded: string, precision?: number): LatLng {
|
||||
console.error('GoogleMaps', '[deprecated] This method is static. Please use Encoding.decodePath()');
|
||||
return Encoding.decodePath(encoded, precision);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecation
|
||||
* @hidden
|
||||
*/
|
||||
encodePath(path: Array<ILatLng> | BaseArrayClass<ILatLng>): string {
|
||||
console.error('GoogleMaps', '[deprecated] This method is static. Please use Encoding.encodePath()');
|
||||
return Encoding.encodePath(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes an encoded path string into a sequence of LatLngs.
|
||||
* @param encoded {string} an encoded path string
|
||||
* @param precision? {number} default: 5
|
||||
* @return {LatLng}
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
decodePath(encoded: string, precision?: number): LatLng { return; }
|
||||
static decodePath(encoded: string, precision?: number): LatLng { return; }
|
||||
|
||||
/**
|
||||
* Encodes a sequence of LatLngs into an encoded path string.
|
||||
* @param path {Array<ILatLng> | BaseArrayClass<ILatLng>} a sequence of LatLngs
|
||||
* @return {string}
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
encodePath(path: Array<ILatLng> | BaseArrayClass<ILatLng>): string { return; }
|
||||
static encodePath(path: Array<ILatLng> | BaseArrayClass<ILatLng>): string { return; }
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'GoogleMaps',
|
||||
pluginRef: 'plugin.google.maps.geometry.poly',
|
||||
plugin: 'cordova-plugin-googlemaps',
|
||||
repo: ''
|
||||
})
|
||||
export class Poly {
|
||||
|
||||
/**
|
||||
* Returns true if the speicified location is in the polygon path
|
||||
* @param location {ILatLng}
|
||||
* @param path {ILatLng[]}
|
||||
* @return {boolean}
|
||||
*/
|
||||
static containsLocation(location: ILatLng, path: ILatLng[]): boolean {
|
||||
return GoogleMaps.getPlugin().geometry.poly.containsLocation(location, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the speicified location is on the polyline path
|
||||
* @param location {ILatLng}
|
||||
* @param path {ILatLng[]}
|
||||
* @return {boolean}
|
||||
*/
|
||||
static isLocationOnEdge(location: ILatLng, path: ILatLng[]): boolean {
|
||||
return GoogleMaps.getPlugin().geometry.poly.isLocationOnEdge(location, path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1297,13 +1665,92 @@ export class Encoding {
|
||||
repo: ''
|
||||
})
|
||||
export class Spherical {
|
||||
|
||||
/**
|
||||
* @deprecation
|
||||
* @hidden
|
||||
*/
|
||||
computeDistanceBetween(from: ILatLng, to: ILatLng): number {
|
||||
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.computeDistanceBetween()');
|
||||
return Spherical.computeDistanceBetween(from, to);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecation
|
||||
* @hidden
|
||||
*/
|
||||
computeOffset(from: ILatLng, distance: number, heading: number): LatLng {
|
||||
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.computeOffset()');
|
||||
return Spherical.computeOffset(from, distance, heading);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecation
|
||||
* @hidden
|
||||
*/
|
||||
computeOffsetOrigin(to: ILatLng, distance: number, heading: number): LatLng {
|
||||
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.computeOffsetOrigin()');
|
||||
return Spherical.computeOffsetOrigin(to, distance, heading);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecation
|
||||
* @hidden
|
||||
*/
|
||||
computeLength(path: Array<ILatLng> | BaseArrayClass<ILatLng>): number {
|
||||
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.computeLength()');
|
||||
return Spherical.computeLength(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecation
|
||||
* @hidden
|
||||
*/
|
||||
computeArea(path: Array<ILatLng> | BaseArrayClass<ILatLng>): number {
|
||||
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.computeArea()');
|
||||
return Spherical.computeArea(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecation
|
||||
* @hidden
|
||||
*/
|
||||
computeSignedArea(path: Array<ILatLng> | BaseArrayClass<ILatLng>): number {
|
||||
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.computeSignedArea()');
|
||||
return Spherical.computeSignedArea(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecation
|
||||
* @hidden
|
||||
*/
|
||||
computeHeading(from: ILatLng, to: ILatLng): number {
|
||||
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.computeHeading()');
|
||||
return Spherical.computeHeading(from, to);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecation
|
||||
* @hidden
|
||||
*/
|
||||
interpolate(from: ILatLng, to: ILatLng, fraction: number): LatLng {
|
||||
console.error('GoogleMaps', '[deprecated] This method is static. Please use Spherical.interpolate()');
|
||||
return Spherical.interpolate(from, to, fraction);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the distance, in meters, between two LatLngs.
|
||||
* @param locationA {ILatLng}
|
||||
* @param locationB {ILatLng}
|
||||
* @return {number}
|
||||
*/
|
||||
computeDistanceBetween(from: ILatLng, to: ILatLng): number {
|
||||
static computeDistanceBetween(from: ILatLng, to: ILatLng): number {
|
||||
return GoogleMaps.getPlugin().geometry.spherical.computeDistanceBetween(from, to);
|
||||
}
|
||||
|
||||
@@ -1314,7 +1761,7 @@ export class Spherical {
|
||||
* @param heading {number}
|
||||
* @return {LatLng}
|
||||
*/
|
||||
computeOffset(from: ILatLng, distance: number, heading: number): LatLng {
|
||||
static computeOffset(from: ILatLng, distance: number, heading: number): LatLng {
|
||||
return GoogleMaps.getPlugin().geometry.spherical.computeOffset(from, distance, heading);
|
||||
}
|
||||
|
||||
@@ -1325,7 +1772,7 @@ export class Spherical {
|
||||
* @param heading {number} The heading in degrees clockwise from north.
|
||||
* @return {LatLng}
|
||||
*/
|
||||
computeOffsetOrigin(to: ILatLng, distance: number, heading: number): LatLng {
|
||||
static computeOffsetOrigin(to: ILatLng, distance: number, heading: number): LatLng {
|
||||
return GoogleMaps.getPlugin().geometry.spherical.computeOffsetOrigin(to, distance, heading);
|
||||
}
|
||||
|
||||
@@ -1334,7 +1781,7 @@ export class Spherical {
|
||||
* @param path {Array<ILatLng> | BaseArrayClass<ILatLng>}
|
||||
* @return {number}
|
||||
*/
|
||||
computeLength(path: Array<ILatLng> | BaseArrayClass<ILatLng>): number {
|
||||
static computeLength(path: Array<ILatLng> | BaseArrayClass<ILatLng>): number {
|
||||
return GoogleMaps.getPlugin().geometry.spherical.computeLength(path);
|
||||
}
|
||||
|
||||
@@ -1343,7 +1790,7 @@ export class Spherical {
|
||||
* @param path {Array<ILatLng> | BaseArrayClass<ILatLng>}.
|
||||
* @return {number}
|
||||
*/
|
||||
computeArea(path: Array<ILatLng> | BaseArrayClass<ILatLng>): number {
|
||||
static computeArea(path: Array<ILatLng> | BaseArrayClass<ILatLng>): number {
|
||||
return GoogleMaps.getPlugin().geometry.spherical.computeArea(path);
|
||||
}
|
||||
|
||||
@@ -1352,7 +1799,7 @@ export class Spherical {
|
||||
* @param path {Array<ILatLng> | BaseArrayClass<ILatLng>}.
|
||||
* @return {number}
|
||||
*/
|
||||
computeSignedArea(path: Array<ILatLng> | BaseArrayClass<ILatLng>): number {
|
||||
static computeSignedArea(path: Array<ILatLng> | BaseArrayClass<ILatLng>): number {
|
||||
return GoogleMaps.getPlugin().geometry.spherical.computeSignedArea(path);
|
||||
}
|
||||
|
||||
@@ -1362,7 +1809,7 @@ export class Spherical {
|
||||
* @param to {ILatLng}
|
||||
* @return {number}
|
||||
*/
|
||||
computeHeading(from: ILatLng, to: ILatLng): number {
|
||||
static computeHeading(from: ILatLng, to: ILatLng): number {
|
||||
return GoogleMaps.getPlugin().geometry.spherical.computeHeading(from, to);
|
||||
}
|
||||
|
||||
@@ -1373,7 +1820,7 @@ export class Spherical {
|
||||
* @param fraction {number} A fraction of the distance to travel from 0.0 to 1.0 .
|
||||
* @return {LatLng}
|
||||
*/
|
||||
interpolate(from: ILatLng, to: ILatLng, fraction: number): LatLng {
|
||||
static interpolate(from: ILatLng, to: ILatLng, fraction: number): LatLng {
|
||||
return GoogleMaps.getPlugin().geometry.spherical.interpolate(from, to, fraction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +113,13 @@ export class HTTP extends IonicNativePlugin {
|
||||
@Cordova({ sync: true })
|
||||
removeCookies(url: string, cb: () => void): void { }
|
||||
|
||||
/**
|
||||
* Disable following redirects automatically
|
||||
* @param disable {boolean} Set to true to disable following redirects automatically
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
disableRedirect(disable: boolean): void { }
|
||||
|
||||
/**
|
||||
* Set request timeout
|
||||
* @param timeout {number} The timeout in seconds. Default 60
|
||||
@@ -140,14 +147,6 @@ export class HTTP extends IonicNativePlugin {
|
||||
@Cordova()
|
||||
acceptAllCerts(accept: boolean): Promise<void> { return; }
|
||||
|
||||
/**
|
||||
* Whether or not to validate the domain name in the certificate. This defaults to true.
|
||||
* @param validate {boolean} Set to true to validate
|
||||
* @returns {Promise<void>} returns a promise that will resolve on success, and reject on failure
|
||||
*/
|
||||
@Cordova()
|
||||
validateDomainName(validate: boolean): Promise<void> { return; }
|
||||
|
||||
/**
|
||||
* Make a POST request
|
||||
* @param url {string} The url to send the request to
|
||||
@@ -178,6 +177,16 @@ export class HTTP extends IonicNativePlugin {
|
||||
@Cordova()
|
||||
put(url: string, body: any, headers: any): Promise<HTTPResponse> { return; }
|
||||
|
||||
/**
|
||||
* Make a PATCH request
|
||||
* @param url {string} The url to send the request to
|
||||
* @param body {Object} The body of the request
|
||||
* @param headers {Object} The headers to set for this request
|
||||
* @returns {Promise<HTTPResponse>} returns a promise that resolve on success, and reject on failure
|
||||
*/
|
||||
@Cordova()
|
||||
patch(url: string, body: any, headers: any): Promise<HTTPResponse> { return; }
|
||||
|
||||
/**
|
||||
* Make a DELETE request
|
||||
* @param url {string} The url to send the request to
|
||||
|
||||
@@ -61,7 +61,7 @@ export interface LocalNotificationOptions {
|
||||
* import { PhonegapLocalNotification } from '@ionic-native/phonegap-local-notification';
|
||||
*
|
||||
*
|
||||
* constructor(private localNotification: PhonegapLocalNotifications) { }
|
||||
* constructor(private localNotification: PhonegapLocalNotification) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
|
||||
@@ -1,7 +1,54 @@
|
||||
import { Plugin, Cordova, CordovaFiniteObservable, IonicNativePlugin } from '@ionic-native/core';
|
||||
import { Plugin, Cordova, IonicNativePlugin, CordovaOptions, wrap } from '@ionic-native/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observer } from 'rxjs/Observer';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export interface CordovaFiniteObservableOptions extends CordovaOptions {
|
||||
/**
|
||||
* Function that gets a result returned from plugin's success callback, and decides whether it is last value and observable should complete.
|
||||
*/
|
||||
resultFinalPredicate?: string;
|
||||
/**
|
||||
* Function that gets called after resultFinalPredicate, and removes service data that indicates end of stream from the result.
|
||||
*/
|
||||
resultTransform?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*
|
||||
* Wraps method that returns an observable that can be completed. Provided opts.resultFinalPredicate dictates when the observable completes.
|
||||
*/
|
||||
export function CordovaFiniteObservable(opts: CordovaFiniteObservableOptions = {}) {
|
||||
opts.observable = true;
|
||||
return (target: Object, methodName: string, descriptor: TypedPropertyDescriptor<any>) => {
|
||||
return {
|
||||
value: function(...args: any[]) {
|
||||
const wrappedObservable: Observable<any> = wrap(this, methodName, opts).apply(this, args);
|
||||
return new Observable<any>((observer: Observer<any>) => {
|
||||
const wrappedSubscription = wrappedObservable.subscribe({
|
||||
next: (x: any) => {
|
||||
observer.next(opts.resultTransform ? x[opts.resultTransform] : x);
|
||||
if (opts.resultFinalPredicate && x[opts.resultFinalPredicate]) {
|
||||
observer.complete();
|
||||
}
|
||||
},
|
||||
error: (err: any) => { observer.error(err); },
|
||||
complete: () => { observer.complete(); }
|
||||
});
|
||||
return () => {
|
||||
wrappedSubscription.unsubscribe();
|
||||
};
|
||||
});
|
||||
},
|
||||
enumerable: true
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Photo Library
|
||||
* @description
|
||||
@@ -58,8 +105,8 @@ export class PhotoLibrary extends IonicNativePlugin {
|
||||
*/
|
||||
@CordovaFiniteObservable({
|
||||
callbackOrder: 'reverse',
|
||||
resultFinalPredicate: (result: { isLastChunk: boolean }) => { return result.isLastChunk; },
|
||||
resultTransform: (result: { library: LibraryItem[] }) => { return result.library; },
|
||||
resultFinalPredicate: 'isLastChunk',
|
||||
resultTransform: 'library'
|
||||
})
|
||||
getLibrary(options?: GetLibraryOptions): Observable<LibraryItem[]> { return; }
|
||||
|
||||
@@ -69,7 +116,7 @@ export class PhotoLibrary extends IonicNativePlugin {
|
||||
* @return { Promise<void>} Returns a promise that resolves when permissions are granted, and fails when not.
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
callbackOrder: 'reverse'
|
||||
})
|
||||
requestAuthorization(options?: RequestAuthorizationOptions): Promise<void> { return; }
|
||||
|
||||
@@ -78,7 +125,7 @@ export class PhotoLibrary extends IonicNativePlugin {
|
||||
* @return {Promise<AlbumItem[]>} Resolves to list of albums.
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
callbackOrder: 'reverse'
|
||||
})
|
||||
getAlbums(): Promise<AlbumItem[]> { return; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user