From 18df9a5aeb436ade2676c20137353fee58afd1d9 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Sun, 6 Mar 2016 15:08:19 -0500 Subject: [PATCH 1/4] feat(plugin): add launch navigator https://github.com/driftyco/ionic-native/issues/18 --- src/plugins/launchnavigator.ts | 90 ++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/plugins/launchnavigator.ts diff --git a/src/plugins/launchnavigator.ts b/src/plugins/launchnavigator.ts new file mode 100644 index 000000000..8b930090f --- /dev/null +++ b/src/plugins/launchnavigator.ts @@ -0,0 +1,90 @@ +import {Plugin, Cordova} from './plugin'; + +export interface launchNavigatorOptions { + + /** + * iOS, Android, Windows + * If true, the plugin will NOT attempt to use the geolocation plugin to determine the current device position when the start location parameter is omitted. Defaults to false. + */ + disableAutoGeolocation? : boolean, + + /** + * iOS, Android, Windows + * Transportation mode for navigation: "driving", "walking" or "transit". Defaults to "driving" if not specified. + */ + transportMode? : string, + + /** + * iOS + * If true, plugin will attempt to launch Google Maps instead of Apple Maps. If Google Maps is not available, it will fall back to Apple Maps. + */ + preferGoogleMaps? : boolean, + + /** + * iOS + * If using Google Maps and the app has a URL scheme, passing this to Google Maps will display a button which returns to the app. + */ + urlScheme? : string, + + /** + * iOS + * If using Google Maps with a URL scheme, this specifies the text of the button in Google Maps which returns to the app. Defaults to "Back" if not specified. + */ + backButtonText? : string, + + /** + * iOS + * If true, debug log output will be generated by the plugin. Defaults to false. + */ + enableDebug? : boolean, + + /** + * Android + * Navigation mode in which to open Google Maps app: "maps" or "turn-by-turn". Defaults to "maps" if not specified. + */ + navigationMode? : string, + +} + +/** + * + * Requires Cordova plugin: uk.co.workingedge.phonegap.plugin.launchnavigator. For more info, please see the [LaunchNavigator plugin docs](https://github.com/dpa99c/phonegap-launch-navigator). + * + * ``` + * cordova plugin add https://github.com/dpa99c/phonegap-launch-navigator.git + * ``` + * + * @usage + * ```js + * Badge.set(10); + * Badge.increase(); + * Badge.clear(); + * ``` + */ +@Plugin({ + plugin: 'https://github.com/dpa99c/phonegap-launch-navigator', + pluginRef: 'launchnavigator' +}) +export class LaunchNavigator { + + /** + * Launches navigator app + * @param destination Location name or coordinates + * @param start Location name or coordinates + * @param options + * @returns {Promise} + */ + @Cordova({ + successIndex: 2, + errorIndex: 3 + }) + static navigate(destination : any, start : any, options? : launchNavigatorOptions) : Promise { + // This Promise is replaced by one from the @Cordova decorator that wraps + // the plugin's callbacks. We provide a dummy one here so TypeScript + // knows that the correct return type is Promise, because there's no way + // for it to know the return type from a decorator. + // See https://github.com/Microsoft/TypeScript/issues/4881 + return new Promise((res, rej) => {}); + } + +} From 984e7fc9d1fcde19682bad7d7fe49c2668710bdf Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Sun, 6 Mar 2016 15:11:19 -0500 Subject: [PATCH 2/4] feat(plugin): add launch navigator https://github.com/driftyco/ionic-native/issues/18 --- src/plugins/launchnavigator.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/launchnavigator.ts b/src/plugins/launchnavigator.ts index 8b930090f..2e42da1e1 100644 --- a/src/plugins/launchnavigator.ts +++ b/src/plugins/launchnavigator.ts @@ -56,9 +56,11 @@ export interface launchNavigatorOptions { * * @usage * ```js - * Badge.set(10); - * Badge.increase(); - * Badge.clear(); + * LaunchNavigator.navigate("Toronto, ON", "London, ON") + * .then( + * success => console.log("Launched navigator"), + * error => console.log("Error launching navigator", error) + * ); * ``` */ @Plugin({ From 9e17e2542776d32a0b5c9e8f3e99c73f4adb1637 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Sun, 6 Mar 2016 15:17:49 -0500 Subject: [PATCH 3/4] fix(launchnavigator): fix Plugin decorator property value --- src/plugins/launchnavigator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/launchnavigator.ts b/src/plugins/launchnavigator.ts index 2e42da1e1..295e1abad 100644 --- a/src/plugins/launchnavigator.ts +++ b/src/plugins/launchnavigator.ts @@ -64,7 +64,7 @@ export interface launchNavigatorOptions { * ``` */ @Plugin({ - plugin: 'https://github.com/dpa99c/phonegap-launch-navigator', + plugin: 'https://github.com/dpa99c/phonegap-launch-navigator.git', pluginRef: 'launchnavigator' }) export class LaunchNavigator { From c71f8d49e1dace06dd60855c2b53f40be7fe4e17 Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Tue, 8 Mar 2016 14:25:22 -0500 Subject: [PATCH 4/4] fix: fix options params --- src/plugins/launchnavigator.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/launchnavigator.ts b/src/plugins/launchnavigator.ts index 295e1abad..70805c37b 100644 --- a/src/plugins/launchnavigator.ts +++ b/src/plugins/launchnavigator.ts @@ -6,43 +6,43 @@ export interface launchNavigatorOptions { * iOS, Android, Windows * If true, the plugin will NOT attempt to use the geolocation plugin to determine the current device position when the start location parameter is omitted. Defaults to false. */ - disableAutoGeolocation? : boolean, + disableAutoGeolocation : boolean, /** * iOS, Android, Windows * Transportation mode for navigation: "driving", "walking" or "transit". Defaults to "driving" if not specified. */ - transportMode? : string, + transportMode : string, /** * iOS * If true, plugin will attempt to launch Google Maps instead of Apple Maps. If Google Maps is not available, it will fall back to Apple Maps. */ - preferGoogleMaps? : boolean, + preferGoogleMaps : boolean, /** * iOS * If using Google Maps and the app has a URL scheme, passing this to Google Maps will display a button which returns to the app. */ - urlScheme? : string, + urlScheme : string, /** * iOS * If using Google Maps with a URL scheme, this specifies the text of the button in Google Maps which returns to the app. Defaults to "Back" if not specified. */ - backButtonText? : string, + backButtonText : string, /** * iOS * If true, debug log output will be generated by the plugin. Defaults to false. */ - enableDebug? : boolean, + enableDebug : boolean, /** * Android * Navigation mode in which to open Google Maps app: "maps" or "turn-by-turn". Defaults to "maps" if not specified. */ - navigationMode? : string, + navigationMode : string, }