mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-04-03 05:11:55 +08:00
feat(device-feedback): add feedback interface
This commit is contained in:
parent
f11be24f74
commit
7cafebd0e8
@ -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,25 +49,25 @@ 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.
|
||||||
*/
|
*/
|
||||||
@Cordova({ sync: true })
|
@Cordova({ sync: true })
|
||||||
acoustic(): void { }
|
acoustic(): void {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user