mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-21 00:23:00 +08:00
feat(camera-preview): add wrapper for camera-preview (#301)
* feat(camera-preview): add camera-preview * feat(camera-preview): add camera-preview
This commit is contained in:
parent
29de6b394e
commit
3a1a3ceabc
@ -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';
|
||||
@ -113,6 +114,7 @@ export {
|
||||
Brightness,
|
||||
BLE,
|
||||
BluetoothSerial,
|
||||
CameraPreview,
|
||||
Clipboard,
|
||||
DBMeter,
|
||||
Deeplinks,
|
||||
@ -165,6 +167,7 @@ window['IonicNative'] = {
|
||||
BluetoothSerial: BluetoothSerial,
|
||||
Calendar: Calendar,
|
||||
Camera: Camera,
|
||||
CameraPreview: CameraPreview,
|
||||
CardIO: CardIO,
|
||||
Clipboard: Clipboard,
|
||||
Contacts: Contacts,
|
||||
|
129
src/plugins/camera-preview.ts
Normal file
129
src/plugins/camera-preview.ts
Normal file
@ -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
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user