From 347c8a0715679049b82e456bd105d18788207946 Mon Sep 17 00:00:00 2001 From: Guille Date: Fri, 8 Jul 2016 00:29:03 +0200 Subject: [PATCH] refactor(3dtouch): --- src/plugins/3dtouch.ts | 137 +++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 67 deletions(-) diff --git a/src/plugins/3dtouch.ts b/src/plugins/3dtouch.ts index 9f83f75dd..61e81c4d6 100644 --- a/src/plugins/3dtouch.ts +++ b/src/plugins/3dtouch.ts @@ -1,6 +1,9 @@ -import {Plugin, Cordova} from './plugin'; -import {Observable} from 'rxjs/Observable'; +import { Cordova, Plugin } from './plugin'; +import { Observable } from 'rxjs/Observable'; + + declare var window: any; + /** * @name 3DTouch * @description @@ -62,81 +65,81 @@ declare var window: any; * ``` */ @Plugin({ - plugin: 'cordova-plugin-3dtouch', - pluginRef: 'ThreeDeeTouch', - repo: 'https://github.com/EddyVerbruggen/cordova-plugin-3dtouch', - platforms: ['iOS'] + plugin: 'cordova-plugin-3dtouch', + pluginRef: 'ThreeDeeTouch', + repo: 'https://github.com/EddyVerbruggen/cordova-plugin-3dtouch', + 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. - * @returns {Promise} returns a promise that resolves with a boolean that indicates whether the plugin is available or not - */ - @Cordova() - static isAvailable(): Promise {return; } + /** + * 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. + * @returns {Promise} returns a promise that resolves with a boolean that indicates whether the plugin is available or not + */ + @Cordova() + static isAvailable(): Promise { 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. - * @returns {Observable} Returns an observable that sends a `ThreeDeeTouchForceTouch` object - */ - @Cordova({ - observable: true - }) - static watchForceTouches(): Observable {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. + * @returns {Observable} Returns an observable that sends a `ThreeDeeTouchForceTouch` object + */ + @Cordova({ + observable: true + }) + static watchForceTouches(): Observable { return; } - /** - * setup the 3D-touch actions, takes an array of objects with the following - * @param {string} type (optional) A type that can be used `onHomeIconPressed` callback - * @param {string} title Title for your action - * @param {string} subtitle (optional) A short description for your action - * @param {string} iconType (optional) Choose between Prohibit, Contact, Home, MarkLocation, Favorite, Love, Cloud, Invitation, Confirmation, Mail, Message, Date, Time, CapturePhoto, CaptureVideo, Task, TaskCompleted, Alarm, Bookmark, Shuffle, Audio, Update - */ - @Cordova({ - sync: true - }) - static configureQuickActions(quickActions: Array): void {} + /** + * setup the 3D-touch actions, takes an array of objects with the following + * @param {string} type (optional) A type that can be used `onHomeIconPressed` callback + * @param {string} title Title for your action + * @param {string} subtitle (optional) A short description for your action + * @param {string} iconType (optional) Choose between Prohibit, Contact, Home, MarkLocation, Favorite, Love, Cloud, Invitation, Confirmation, Mail, Message, Date, Time, CapturePhoto, CaptureVideo, Task, TaskCompleted, Alarm, Bookmark, Shuffle, Audio, Update + */ + @Cordova({ + sync: true + }) + static configureQuickActions(quickActions: Array): void { } - /** - * When a home icon is pressed, your app launches and this JS callback is invoked. - * @returns {Observable} returns an observable that notifies you when he user presses on the home screen icon - */ - static onHomeIconPressed(): Observable { - return new Observable(observer => { - if (window.ThreeDeeTouch && window.ThreeDeeTouch.onHomeIconPressed) window.ThreeDeeTouch.onHomeIconPressed = observer.next.bind(observer); - else { - observer.error('3dTouch plugin is not available.'); - observer.complete(); - } - }); - } + /** + * When a home icon is pressed, your app launches and this JS callback is invoked. + * @returns {Observable} returns an observable that notifies you when he user presses on the home screen icon + */ + static onHomeIconPressed(): Observable { + return new Observable(observer => { + if (window.ThreeDeeTouch && window.ThreeDeeTouch.onHomeIconPressed) window.ThreeDeeTouch.onHomeIconPressed = observer.next.bind(observer); + else { + observer.error('3dTouch plugin is not available.'); + observer.complete(); + } + }); + } - /** - * Enable Link Preview. - * UIWebView and WKWebView (the webviews powering Cordova apps) don't allow the fancy new link preview feature of iOS9. - */ - @Cordova({ - sync: true - }) - static enableLinkPreview(): void {} + /** + * Enable Link Preview. + * UIWebView and WKWebView (the webviews powering Cordova apps) don't allow the fancy new link preview feature of iOS9. + */ + @Cordova({ + sync: true + }) + static enableLinkPreview(): void { } - /** - * Disabled the link preview feature, if enabled. - */ - @Cordova({ - sync: true - }) - static disableLinkPreview(): void {} + /** + * Disabled the link preview feature, if enabled. + */ + @Cordova({ + sync: true + }) + static disableLinkPreview(): void { } } export interface ThreeDeeTouchQuickAction { - type?: string; - title: string; - subtitle?: string; - iconType?: string; + type?: string; + title: string; + subtitle?: string; + iconType?: string; } export interface ThreeDeeTouchForceTouch { - force: number; - timestamp: number; - x: number; - y: number; + force: number; + timestamp: number; + x: number; + y: number; }