This commit is contained in:
Ibrahim Hadeed 2016-06-09 21:31:06 -04:00
commit 3efc81d470
7 changed files with 188 additions and 22 deletions

View File

@ -1,5 +1,4 @@
import {initAngular1} from './ng1'; import {initAngular1} from './ng1';
initAngular1();
const DEVICE_READY_TIMEOUT = 2000; const DEVICE_READY_TIMEOUT = 2000;
@ -25,6 +24,7 @@ import {Clipboard} from './plugins/clipboard';
import {Contacts} from './plugins/contacts'; import {Contacts} from './plugins/contacts';
import {DatePicker} from './plugins/datepicker'; import {DatePicker} from './plugins/datepicker';
import {DBMeter} from './plugins/dbmeter'; import {DBMeter} from './plugins/dbmeter';
import {Deeplinks} from './plugins/deeplinks';
import {Device} from './plugins/device'; import {Device} from './plugins/device';
import {DeviceAccounts} from './plugins/deviceaccounts'; import {DeviceAccounts} from './plugins/deviceaccounts';
import {DeviceMotion} from './plugins/devicemotion'; import {DeviceMotion} from './plugins/devicemotion';
@ -86,6 +86,7 @@ export {
Contacts, Contacts,
DatePicker, DatePicker,
DBMeter, DBMeter,
Deeplinks,
Device, Device,
DeviceAccounts, DeviceAccounts,
DeviceMotion, DeviceMotion,
@ -149,6 +150,7 @@ window['IonicNative'] = {
Contacts: Contacts, Contacts: Contacts,
DatePicker: DatePicker, DatePicker: DatePicker,
DBMeter: DBMeter, DBMeter: DBMeter,
Deeplinks: Deeplinks,
Device: Device, Device: Device,
DeviceAccounts: DeviceAccounts, DeviceAccounts: DeviceAccounts,
DeviceMotion: DeviceMotion, DeviceMotion: DeviceMotion,
@ -188,6 +190,8 @@ window['IonicNative'] = {
WebIntent: WebIntent WebIntent: WebIntent
}; };
initAngular1(window['IonicNative']);
// To help developers using cordova, we listen for the device ready event and // To help developers using cordova, we listen for the device ready event and
// log an error if it didn't fire in a reasonable amount of time. Generally, // log an error if it didn't fire in a reasonable amount of time. Generally,
// when this happens, developers should remove and reinstall plugins, since // when this happens, developers should remove and reinstall plugins, since

View File

@ -1,24 +1,28 @@
declare var window; declare var window;
/** /**
* Initialize the ngCordova Angular module if we're running in ng1 * Initialize the ionic.native Angular module if we're running in ng1.
* This iterates through the list of registered plugins and dynamically
* creates Angular 1 services of the form $cordovaSERVICE, ex: $cordovStatusBar.
*/ */
export function initAngular1() { export function initAngular1(plugins) {
if (window.angular) { if (window.angular) {
window.angular.module('ngCordova', []); window.angular.module('ionic.native', []);
}
}
/** for (var name in plugins) {
* Publish a new Angular 1 service for this plugin. let serviceName = '$cordova' + name;
*/ let cls = plugins[name];
export function publishAngular1Service(config: any, cls: any) {
let serviceName = '$cordova' + cls.name; (function(serviceName, cls, name) {
console.log('Registering Angular1 service', serviceName); window.angular.module('ionic.native').service(serviceName, [function() {
window.angular.module('ngCordova').service(serviceName, [function() {
let funcs = {}; let funcs = {};
for (var k in cls) { for (var k in cls) {
funcs[k] = cls[k];
} }
funcs['name'] = name;
return funcs; return funcs;
}]); }]);
})(serviceName, cls, name);
}
}
} }

74
src/plugins/deeplinks.ts Normal file
View File

@ -0,0 +1,74 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
export interface DeeplinkMatch {
/**
* The route info for the matched route
*/
routeInfo: any;
/**
* The arguments passed to the route through GET params along with
* any internal native data available as "extras" at the time
* the route was matched (for example, Facebook sometimes adds extra data)
*/
args: any;
}
/**
* @name Ionic Deeplinks
* @description This plugin handles deeplinks on iOS and Android for both custom URL scheme links
* and Universal App Links.
*
* @usage
* ```ts
* import {IonicDeeplinks} from 'ionic-native';
*
* ```
*/
@Plugin({
plugin: 'ionic-plugin-deeplinks',
pluginRef: 'IonicDeeplink',
repo: 'https://github.com/driftyo/ionic-plugin-deeplinks',
platforms: ['iOS', 'Android']
})
export class Deeplinks {
/**
* Define a set of paths to match against incoming deeplinks.
*
* @param {paths} Define a set of paths to match against incoming deeplinks.
* paths takes an object of the form { 'path': data }. If a deeplink
* matches the path, the resulting path-data pair will be returned in the
* promise result which you can then use to navigate in the app as you see fit.
* @returns {Promise} Returns a Promise that resolves when a deeplink comes through, and
* is rejected if a deeplink comes through that does not match a given path.
*/
@Cordova({
observable: true
})
static route(paths): Observable<DeeplinkMatch> {return; }
/**
*
* This is a convenience version of `route` that takes a reference to a NavController
* from Ionic 2, or a custom class that conforms to this protocol:
*
* NavController.push = function(View, Params){}
*
* This handler will automatically navigate when a route matches. If you need finer-grained
* control over the behavior of a matching deeplink, use the plain `route` method.
*
* @param {paths} Define a set of paths to match against incoming deeplinks.
* paths takes an object of the form { 'path': data }. If a deeplink
* matches the path, the resulting path-data pair will be returned in the
* promise result which you can then use to navigate in the app as you see fit.
*
* @returns {Promise} Returns a Promise that resolves when a deeplink comes through, and
* is rejected if a deeplink comes through that does not match a given path.
*/
@Cordova({
observable: true
})
static routeWithNavController(navController, paths): Observable<DeeplinkMatch> {return; }
}

View File

@ -89,7 +89,7 @@ export class DeviceOrientation {
@Cordova({ @Cordova({
callbackOrder: 'reverse', callbackOrder: 'reverse',
observable: true, observable: true,
cancelFunction: 'clearWatch' clearFunction: 'clearWatch'
}) })
static watchHeading(options?: CompassOptions): Observable<CompassHeading> { return; } static watchHeading(options?: CompassOptions): Observable<CompassHeading> { return; }

View File

@ -2,10 +2,12 @@ import {Cordova, Plugin} from './plugin';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {CordovaInstance} from './plugin'; import {CordovaInstance} from './plugin';
/** /**
* @private
* Created by Ibrahim on 3/29/2016. * Created by Ibrahim on 3/29/2016.
*/ */
declare var plugin: any; declare var plugin: any;
/** /**
* @private
* You can listen to these events where appropriate * You can listen to these events where appropriate
*/ */
export const GoogleMapsEvent = { export const GoogleMapsEvent = {
@ -29,10 +31,14 @@ export const GoogleMapsEvent = {
MARKER_DRAG_END: 'drag_end' MARKER_DRAG_END: 'drag_end'
}; };
/**
* @private
*/
export const GoogleMapsAnimation = { export const GoogleMapsAnimation = {
BOUNCE: 'BOUNCE', BOUNCE: 'BOUNCE',
DROP: 'DROP' DROP: 'DROP'
}; };
/** /**
* @name Google Maps * @name Google Maps
* @description This plugin uses the native Google Maps SDK * @description This plugin uses the native Google Maps SDK
@ -352,6 +358,10 @@ export class GoogleMap {
} }
} }
/**
* @private
*/
export interface AnimateCameraOptions { export interface AnimateCameraOptions {
target?: GoogleMapsLatLng; target?: GoogleMapsLatLng;
tilt?: number; tilt?: number;
@ -359,22 +369,38 @@ export interface AnimateCameraOptions {
bearing?: number; bearing?: number;
duration?: number; duration?: number;
} }
/**
* @private
*/
export interface CameraPosition { export interface CameraPosition {
target?: GoogleMapsLatLng; target?: GoogleMapsLatLng;
zoom?: number; zoom?: number;
tilt?: number; tilt?: number;
bearing?: number; bearing?: number;
} }
/**
* @private
*/
export interface MyLocation { export interface MyLocation {
latLng?: GoogleMapsLatLng; latLng?: GoogleMapsLatLng;
speed?: number; speed?: number;
time?: string; time?: string;
bearing?: number; bearing?: number;
} }
/**
* @private
*/
export interface VisibleRegion { export interface VisibleRegion {
northeast?: any; northeast?: any;
southwest?: any; southwest?: any;
} }
/**
* @private
*/
export interface GoogleMapsMarkerOptions { export interface GoogleMapsMarkerOptions {
icon?: any; icon?: any;
title?: string; title?: string;
@ -389,6 +415,10 @@ export interface GoogleMapsMarkerOptions {
animation?: string; animation?: string;
zIndex?: number; zIndex?: number;
} }
/**
* @private
*/
export interface GoogleMapsMarkerIcon { export interface GoogleMapsMarkerIcon {
url?: string; url?: string;
size?: { size?: {
@ -396,6 +426,10 @@ export interface GoogleMapsMarkerIcon {
height?: number; height?: number;
}; };
} }
/**
* @private
*/
export class GoogleMapsMarker { export class GoogleMapsMarker {
constructor(private _objectInstance: any) { constructor(private _objectInstance: any) {
@ -573,6 +607,10 @@ export class GoogleMapsMarker {
} }
/**
* @private
*/
export interface GoogleMapsCircleOptions { export interface GoogleMapsCircleOptions {
center?: GoogleMapsLatLng; center?: GoogleMapsLatLng;
radius?: number; radius?: number;
@ -582,6 +620,10 @@ export interface GoogleMapsCircleOptions {
visible?: boolean; visible?: boolean;
zIndex?: number; zIndex?: number;
} }
/**
* @private
*/
export class GoogleMapsCircle { export class GoogleMapsCircle {
constructor(private _objectInstance: any) { constructor(private _objectInstance: any) {
@ -689,6 +731,10 @@ export class GoogleMapsCircle {
} }
/**
* @private
*/
export interface GoogleMapsPolylineOptions { export interface GoogleMapsPolylineOptions {
points?: Array<GoogleMapsLatLng>; points?: Array<GoogleMapsLatLng>;
visible?: boolean; visible?: boolean;
@ -697,6 +743,10 @@ export interface GoogleMapsPolylineOptions {
width?: number; width?: number;
zIndex?: number; zIndex?: number;
} }
/**
* @private
*/
export class GoogleMapsPolyline { export class GoogleMapsPolyline {
constructor(private _objectInstance: any) { constructor(private _objectInstance: any) {
} }
@ -770,6 +820,10 @@ export class GoogleMapsPolyline {
} }
} }
/**
* @private
*/
export interface GoogleMapsPolygonOptions { export interface GoogleMapsPolygonOptions {
points?: Array<GoogleMapsLatLng>; points?: Array<GoogleMapsLatLng>;
geodesic?: boolean; geodesic?: boolean;
@ -780,6 +834,10 @@ export interface GoogleMapsPolygonOptions {
zIndex?: number; zIndex?: number;
addHole?: Array<GoogleMapsLatLng>; addHole?: Array<GoogleMapsLatLng>;
} }
/**
* @private
*/
export class GoogleMapsPolygon { export class GoogleMapsPolygon {
constructor(private _objectInstance: any) { constructor(private _objectInstance: any) {
@ -862,6 +920,10 @@ export class GoogleMapsPolygon {
setGeodesic(geodesic: boolean): void { setGeodesic(geodesic: boolean): void {
} }
} }
/**
* @private
*/
export interface GoogleMapsTileOverlayOptions { export interface GoogleMapsTileOverlayOptions {
titleUrilFormat?: string; titleUrilFormat?: string;
visible?: boolean; visible?: boolean;
@ -869,6 +931,10 @@ export interface GoogleMapsTileOverlayOptions {
tileSize?: number; tileSize?: number;
opacity?: number; opacity?: number;
} }
/**
* @private
*/
export class GoogleMapsTileOverlay { export class GoogleMapsTileOverlay {
constructor(private _objectInstance: any) { constructor(private _objectInstance: any) {
@ -919,6 +985,10 @@ export class GoogleMapsTileOverlay {
} }
} }
/**
* @private
*/
export interface GoogleMapsGroundOverlayOptions { export interface GoogleMapsGroundOverlayOptions {
url?: string; url?: string;
bounds?: Array<GoogleMapsLatLng>; bounds?: Array<GoogleMapsLatLng>;
@ -927,6 +997,10 @@ export interface GoogleMapsGroundOverlayOptions {
bearing?: number; bearing?: number;
zIndex?: number; zIndex?: number;
} }
/**
* @private
*/
export class GoogleMapsGroundOverlay { export class GoogleMapsGroundOverlay {
constructor(private _objectInstance: any) { constructor(private _objectInstance: any) {
@ -968,11 +1042,19 @@ export class GoogleMapsGroundOverlay {
} }
} }
/**
* @private
*/
export interface GoogleMapsKmlOverlayOptions { export interface GoogleMapsKmlOverlayOptions {
url?: string; url?: string;
preserveViewport?: boolean; preserveViewport?: boolean;
animation?: boolean; animation?: boolean;
} }
/**
* @private
*/
export class GoogleMapsKmlOverlay { export class GoogleMapsKmlOverlay {
constructor(private _objectInstance: any) { constructor(private _objectInstance: any) {
@ -987,6 +1069,10 @@ export class GoogleMapsKmlOverlay {
return; return;
} }
} }
/**
* @private
*/
export class GoogleMapsLatLng { export class GoogleMapsLatLng {
private _objectInstance: any; private _objectInstance: any;

View File

@ -1,7 +1,5 @@
import {get} from '../util'; import {get} from '../util';
import {publishAngular1Service} from '../ng1';
declare var window; declare var window;
declare var Promise; declare var Promise;
declare var $q; declare var $q;

View File

@ -15,7 +15,7 @@ import {Plugin, Cordova} from './plugin';
* if(available){ * if(available){
* *
* SafariViewController.show({ * SafariViewController.show({
* utl: 'http://ionic.io', * url: 'http://ionic.io',
* hidden: false, * hidden: false,
* animated: false, * animated: false,
* transition: 'curl', * transition: 'curl',