docs(qr-scanner): improve example

fix: #1876
This commit is contained in:
Daniel 2018-04-06 22:57:43 +02:00
parent 4cb28c41c8
commit 707ca8ea3c

View File

@ -1,5 +1,5 @@
import { Plugin, IonicNativePlugin, Cordova } from '@ionic-native/core';
import { Injectable } from '@angular/core';
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Observable } from 'rxjs/Observable';
export interface QRScannerStatus {
@ -86,11 +86,6 @@ export interface QRScannerStatus {
* scanSub.unsubscribe(); // stop scanning
* });
*
* // show camera preview
* this.qrScanner.show();
*
* // wait for user to scan something, then the observable callback will be called
*
* } else if (status.denied) {
* // camera permission was permanently denied
* // you must use QRScanner.openSettings() method to guide the user to the settings page
@ -115,7 +110,6 @@ export interface QRScannerStatus {
})
@Injectable()
export class QRScanner extends IonicNativePlugin {
/**
* Request permission to use QR scanner.
* @return {Promise<QRScannerStatus>}
@ -123,7 +117,9 @@ export class QRScanner extends IonicNativePlugin {
@Cordova({
callbackStyle: 'node'
})
prepare(): Promise<QRScannerStatus> { return; }
prepare(): Promise<QRScannerStatus> {
return;
}
/**
* Call this method to enable scanning. You must then call the `show` method to make the camera preview visible.
@ -134,21 +130,27 @@ export class QRScanner extends IonicNativePlugin {
observable: true,
clearFunction: 'cancelScan'
})
scan(): Observable<string> { return; }
scan(): Observable<string> {
return;
}
/**
* Configures the native webview to have a transparent background, then sets the background of the <body> and <html> DOM elements to transparent, allowing the webview to re-render with the transparent background.
* @returns {Promise<QRScannerStatus>}
*/
@Cordova()
show(): Promise<QRScannerStatus> { return; }
show(): Promise<QRScannerStatus> {
return;
}
/**
* Configures the native webview to be opaque with a white background, covering the video preview.
* @returns {Promise<QRScannerStatus>}
*/
@Cordova()
hide(): Promise<QRScannerStatus> { return; }
hide(): Promise<QRScannerStatus> {
return;
}
/**
* Enable the device's light (for scanning in low-light environments).
@ -157,14 +159,18 @@ export class QRScanner extends IonicNativePlugin {
@Cordova({
callbackStyle: 'node'
})
enableLight(): Promise<QRScannerStatus> { return; }
enableLight(): Promise<QRScannerStatus> {
return;
}
/**
* Destroy the scanner instance.
* @returns {Promise<QRScannerStatus>}
*/
@Cordova()
destroy(): Promise<QRScannerStatus> { return; }
destroy(): Promise<QRScannerStatus> {
return;
}
/**
* Disable the device's light.
@ -173,7 +179,9 @@ export class QRScanner extends IonicNativePlugin {
@Cordova({
callbackStyle: 'node'
})
disableLight(): Promise<QRScannerStatus> { return; }
disableLight(): Promise<QRScannerStatus> {
return;
}
/**
* Use front camera
@ -182,7 +190,9 @@ export class QRScanner extends IonicNativePlugin {
@Cordova({
callbackStyle: 'node'
})
useFrontCamera(): Promise<QRScannerStatus> { return; }
useFrontCamera(): Promise<QRScannerStatus> {
return;
}
/**
* Use back camera
@ -191,7 +201,9 @@ export class QRScanner extends IonicNativePlugin {
@Cordova({
callbackStyle: 'node'
})
useBackCamera(): Promise<QRScannerStatus> { return; }
useBackCamera(): Promise<QRScannerStatus> {
return;
}
/**
* Set camera to be used.
@ -201,28 +213,36 @@ export class QRScanner extends IonicNativePlugin {
@Cordova({
callbackStyle: 'node'
})
useCamera(camera: number): Promise<QRScannerStatus> { return; }
useCamera(camera: number): Promise<QRScannerStatus> {
return;
}
/**
* Pauses the video preview on the current frame and pauses scanning.
* @return {Promise<QRScannerStatus>}
*/
@Cordova()
pausePreview(): Promise<QRScannerStatus> { return; }
pausePreview(): Promise<QRScannerStatus> {
return;
}
/**
* Resumse the video preview and resumes scanning.
* @return {Promise<QRScannerStatus>}
*/
@Cordova()
resumePreview(): Promise<QRScannerStatus> { return; }
resumePreview(): Promise<QRScannerStatus> {
return;
}
/**
* Returns permission status
* @return {Promise<QRScannerStatus>}
*/
@Cordova()
getStatus(): Promise<QRScannerStatus> { return; }
getStatus(): Promise<QRScannerStatus> {
return;
}
/**
* Opens settings to edit app permissions.
@ -231,5 +251,4 @@ export class QRScanner extends IonicNativePlugin {
sync: true
})
openSettings(): void {}
}