Skip to content

Commit

Permalink
feat(camera-preview): add wrapper for camera-preview (#301)
Browse files Browse the repository at this point in the history
* feat(camera-preview): add camera-preview

* feat(camera-preview): add camera-preview
  • Loading branch information
rbouleau authored and ihadeed committed Jul 17, 2016
1 parent 29de6b3 commit 3a1a3ce
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {BLE} from './plugins/ble';
import {BluetoothSerial} from './plugins/bluetoothserial';
import {Calendar} from './plugins/calendar';
import {Camera} from './plugins/camera';
import {CameraPreview} from './plugins/camera-preview';
import {CardIO} from './plugins/card-io';
import {Clipboard} from './plugins/clipboard';
import {Contacts} from './plugins/contacts';
Expand Down Expand Up @@ -113,6 +114,7 @@ export {
Brightness,
BLE,
BluetoothSerial,
CameraPreview,
Clipboard,
DBMeter,
Deeplinks,
Expand Down Expand Up @@ -165,6 +167,7 @@ window['IonicNative'] = {
BluetoothSerial: BluetoothSerial,
Calendar: Calendar,
Camera: Camera,
CameraPreview: CameraPreview,
CardIO: CardIO,
Clipboard: Clipboard,
Contacts: Contacts,
Expand Down
129 changes: 129 additions & 0 deletions src/plugins/camera-preview.ts
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
};

}

0 comments on commit 3a1a3ce

Please sign in to comment.