add 3D touch plugin

This commit is contained in:
Ibrahim Hadeed
2016-06-09 21:47:27 -04:00
parent 3efc81d470
commit 596948eeb3
2 changed files with 100 additions and 6 deletions
+3
View File
@@ -59,11 +59,13 @@ import {SpinnerDialog} from './plugins/spinnerdialog';
import {Splashscreen} from './plugins/splashscreen'; import {Splashscreen} from './plugins/splashscreen';
import {SQLite} from './plugins/sqlite'; import {SQLite} from './plugins/sqlite';
import {StatusBar} from './plugins/statusbar'; import {StatusBar} from './plugins/statusbar';
import {ThreeDeeTouch} from './plugins/3dtouch';
import {Toast} from './plugins/toast'; import {Toast} from './plugins/toast';
import {TouchID} from './plugins/touchid'; import {TouchID} from './plugins/touchid';
import {Vibration} from './plugins/vibration'; import {Vibration} from './plugins/vibration';
import {WebIntent} from './plugins/webintent'; import {WebIntent} from './plugins/webintent';
export * from './plugins/googlemaps'; export * from './plugins/googlemaps';
export * from './plugins/3dtouch';
export { export {
ActionSheet, ActionSheet,
AdMob, AdMob,
@@ -183,6 +185,7 @@ window['IonicNative'] = {
Splashscreen: Splashscreen, Splashscreen: Splashscreen,
SQLite: SQLite, SQLite: SQLite,
StatusBar: StatusBar, StatusBar: StatusBar,
ThreeDeeTouch: ThreeDeeTouch,
Toast: Toast, Toast: Toast,
TouchID: TouchID, TouchID: TouchID,
Transfer: Transfer, Transfer: Transfer,
+96 -5
View File
@@ -1,13 +1,104 @@
import {Plugin, Cordova} from './plugin'; import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
/** /**
* @name * @name 3DTouch
* @description * @description
* @usage * @usage
* ```
* import {ThreeDeeTouch, ThreeDeeTouchQuickAction, ThreeDeeTouchForceTouch} from 'ionic-native';
*
* ...
*
* ThreeDeeTouch.isAvailable().then(isAvailable => console.log("3D Touch available? " + isAvailable)):
*
* ThreeDeeTouch.watchForceTouches()
* .subscribe(
* (data: ThreeDeeTouchForceTouch) => {
* console.log("Force touch %" + data.force);
* console.log("Force touch timestamp: " + data.timestamp);
* console.log("Force touch x: " + data.x);
* console.log("Force touch y: " + data.y);
* }
* );
*
*
* let actions: Array<ThreeDeeTouchQuickAction> = [
* {
* type: 'checkin',
* title: 'Check in',
* subtitle: 'Quickly check in',
* iconType: 'Compose'
* },
* {
* type: 'share',
* title: 'Share',
* subtitle: 'Share like you care',
* iconType: 'Share'
* },
* {
* type: 'search',
* title: 'Search',
* iconType: 'Search'
* },
* {
* title: 'Show favorites',
* iconTemplate: 'HeartTemplate'
* }
* ];
* ThreeDeeTouch.configureQuickActions(actions);
* ```
*/ */
@Plugin({ @Plugin({
plugin: '', plugin: 'cordova-plugin-3dtouch',
pluginRef: '', pluginRef: 'ThreeDeeTouch',
repo: '', repo: 'https://github.com/EddyVerbruggen/cordova-plugin-3dtouch',
platforms: ['iOS'] platforms: ['iOS']
}) })
export class ThreeDeeTouch {
/**
* You need an iPhone 6S or some future tech to use the features of this plugin, so you can check at runtime if the user's device is supported.
*/
@Cordova()
static isAvailable(): Promise<boolean> {return; }
/**
* You can get a notification when the user force touches the webview. The plugin defines a Force Touch when at least 75% of the maximum force is applied to the screen. Your app will receive the x and y coordinates, so you have to figure out which UI element was touched.
*/
@Cordova({
observable: true
})
static watchForceTouches(): Observable<ThreeDeeTouchForceTouch> {return; }
@Cordova({
sync: true
})
static configureQuickActions(quickActions: Array<ThreeDeeTouchQuickAction>): void {}
@Cordova({
observable: true
})
static onHomeIconPressed(): Observable<any> {return; }
@Cordova({
sync: true
})
static enableLinkPreview(): void {}
@Cordova({
sync: true
})
static disableLinkPreview(): void {}
}
export interface ThreeDeeTouchQuickAction {
type?: string;
title: string;
subtitle?: string;
iconType?: string;
}
export interface ThreeDeeTouchForceTouch {
force: number;
timestamp: number;
x: number;
y: number;
}