Skip to content

Commit

Permalink
docs(qr-scanner): improve example
Browse files Browse the repository at this point in the history
fix: #1876
  • Loading branch information
danielsogl committed Apr 6, 2018
1 parent 4cb28c4 commit 707ca8e
Showing 1 changed file with 40 additions and 21 deletions.
61 changes: 40 additions & 21 deletions src/@ionic-native/plugins/qr-scanner/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -115,15 +110,16 @@ export interface QRScannerStatus {
})
@Injectable()
export class QRScanner extends IonicNativePlugin {

/**
* Request permission to use QR scanner.
* @return {Promise<QRScannerStatus>}
*/
@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.
Expand All @@ -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).
Expand All @@ -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.
Expand All @@ -173,7 +179,9 @@ export class QRScanner extends IonicNativePlugin {
@Cordova({
callbackStyle: 'node'
})
disableLight(): Promise<QRScannerStatus> { return; }
disableLight(): Promise<QRScannerStatus> {
return;
}

/**
* Use front camera
Expand All @@ -182,7 +190,9 @@ export class QRScanner extends IonicNativePlugin {
@Cordova({
callbackStyle: 'node'
})
useFrontCamera(): Promise<QRScannerStatus> { return; }
useFrontCamera(): Promise<QRScannerStatus> {
return;
}

/**
* Use back camera
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -231,5 +251,4 @@ export class QRScanner extends IonicNativePlugin {
sync: true
})
openSettings(): void {}

}

0 comments on commit 707ca8e

Please sign in to comment.