-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(camera-preview): add wrapper for camera-preview (#301)
* feat(camera-preview): add camera-preview * feat(camera-preview): add camera-preview
- Loading branch information
Showing
2 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import {Plugin, Cordova} from './plugin'; | ||
import {Observable} from 'rxjs/Observable'; | ||
|
||
export interface CameraPreviewOptions { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
/** | ||
* Choose the camera to use (front- or back-facing). | ||
* 'front' for front camera | ||
* 'rear' for rear camera | ||
*/ | ||
camera: string; | ||
/** Take photo on tap */ | ||
tapPhoto: boolean; | ||
/** */ | ||
previewDrag: boolean; | ||
/** */ | ||
toBack: boolean; | ||
/** Alpha use when toBack is set to true */ | ||
alpha: number; | ||
} | ||
|
||
export interface CameraPreviewSize { | ||
maxWidth: number; | ||
maxHeight: number; | ||
} | ||
|
||
/** | ||
* @name CameraPreview | ||
* @description | ||
* Showing camera preview in HTML | ||
* | ||
* Requires {@link module:driftyco/ionic-native} and the Cordova plugin: `cordova-plugin-camera-preview`. For more info, please see the [Cordova Camera Preview Plugin Docs](https://github.com/westonganger/cordova-plugin-camera-preview). | ||
* | ||
*/ | ||
@Plugin({ | ||
plugin: 'cordova-plugin-camera-preview', | ||
pluginRef: 'cordova.plugins.camerapreview', | ||
repo: 'https://github.com/westonganger/cordova-plugin-camera-preview', | ||
platforms: ['Android', 'iOS'] | ||
}) | ||
export class CameraPreview { | ||
|
||
/** | ||
* Starts the camera preview instance. | ||
* @param {CameraPreviewOptions} options for the preview | ||
*/ | ||
@Cordova({ | ||
sync: true | ||
}) | ||
static startCamera(options: CameraPreviewOptions): void {}; | ||
|
||
/** | ||
* Stops the camera preview instance. | ||
*/ | ||
@Cordova({ | ||
sync: true | ||
}) | ||
static stopCamera(): void {}; | ||
|
||
/** | ||
* Take the picture, the parameter size is optional | ||
*/ | ||
@Cordova({ | ||
sync: true | ||
}) | ||
static takePicture(size: CameraPreviewSize): void {}; | ||
|
||
/** | ||
* Register a callback function that receives the original picture and the image captured from the preview box. | ||
*/ | ||
@Cordova({ | ||
observable: true | ||
}) | ||
static setOnPictureTakenHandler(): Observable<any> { return; }; | ||
|
||
/** | ||
* Switch from the rear camera and front camera, if available. | ||
*/ | ||
@Cordova({ | ||
sync: true | ||
}) | ||
static switchCamera(): void {}; | ||
|
||
/** | ||
* Show the camera preview box. | ||
*/ | ||
@Cordova({ | ||
sync: true | ||
}) | ||
static show(): void {}; | ||
|
||
/** | ||
* Hide the camera preview box. | ||
*/ | ||
@Cordova({ | ||
sync: true | ||
}) | ||
static hide(): void {}; | ||
|
||
/** | ||
* Set the default mode for the Flash. | ||
*/ | ||
@Cordova({ | ||
sync: true | ||
}) | ||
static setFlashMode(mode: number): void {}; | ||
|
||
/** | ||
* Set camera color effect. | ||
*/ | ||
@Cordova({ | ||
sync: true | ||
}) | ||
static setColorEffect(effect: string): void {}; | ||
|
||
/** | ||
* @private | ||
* @enum {number} | ||
*/ | ||
static FlashMode = { | ||
OFF: 0, | ||
ON: 1, | ||
AUTO: 2 | ||
}; | ||
|
||
} |