feat(device-feedback): add feedback interface

This commit is contained in:
Daniel Sogl 2018-03-16 15:17:29 +01:00 committed by GitHub
parent f11be24f74
commit 7cafebd0e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,14 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
export interface DeviceFeedbackEnabled {
/** Haptic Feedback */
haptic: boolean;
/** Acoustic Feedback */
acoustic: boolean;
}
/** /**
* @name Device Feedback * @name Device Feedback
* @description * @description
@ -19,8 +28,7 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
* *
* this.deviceFeedback.haptic(0); * this.deviceFeedback.haptic(0);
* *
* this.deviceFeedback.isFeedbackEnabled() * this.deviceFeedback.isFeedbackEnabled().then(feedback => {
* .then((feedback) => {
* console.log(feedback); * console.log(feedback);
* // { * // {
* // acoustic: true, * // acoustic: true,
@ -29,6 +37,8 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
* }); * });
* *
* ``` * ```
* @innterfaces
* DeviceFeedbackEnabled
*/ */
@Plugin({ @Plugin({
pluginName: 'DeviceFeedback', pluginName: 'DeviceFeedback',
@ -39,7 +49,6 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
}) })
@Injectable() @Injectable()
export class DeviceFeedback extends IonicNativePlugin { export class DeviceFeedback extends IonicNativePlugin {
/** /**
* Provide sound feedback to user, nevertheless respect user's settings and current active device profile as native feedback do. * Provide sound feedback to user, nevertheless respect user's settings and current active device profile as native feedback do.
*/ */
@ -48,16 +57,17 @@ export class DeviceFeedback extends IonicNativePlugin {
/** /**
* Provide vibrate feedback to user, nevertheless respect user's tactile feedback setting as native feedback do. * Provide vibrate feedback to user, nevertheless respect user's tactile feedback setting as native feedback do.
* @param type {Number} Specify type of vibration feedback. 0 for long press, 1 for virtual key, or 3 for keyboard tap. * @param type {number} Specify type of vibration feedback. 0 for long press, 1 for virtual key, or 3 for keyboard tap.
*/ */
@Cordova({ sync: true }) @Cordova({ sync: true })
haptic(type: number): void {} haptic(type: number): void {}
/** /**
* Check if haptic and acoustic feedback is enabled by user settings. * Check if haptic and acoustic feedback is enabled by user settings.
* @returns {Promise<any>} * @returns {Promise<DeviceFeedbackEnabled>}
*/ */
@Cordova() @Cordova()
isFeedbackEnabled(): Promise<{ haptic: boolean; acoustic: boolean; }> { return; } isFeedbackEnabled(): Promise<DeviceFeedbackEnabled> {
return;
}
} }