diff --git a/Libraries/Image/ImageEditor.js b/Libraries/Image/ImageEditor.js index caeeccae7c34c0..d2fad1b3d77068 100644 --- a/Libraries/Image/ImageEditor.js +++ b/Libraries/Image/ImageEditor.js @@ -8,9 +8,7 @@ * @format */ 'use strict'; - -const RCTImageEditingManager = require('../BatchedBridge/NativeModules') - .ImageEditingManager; +import NativeImageEditor from './NativeImageEditor'; type ImageCropData = { /** @@ -66,7 +64,7 @@ class ImageEditor { success: (uri: string) => void, failure: (error: Object) => void, ) { - RCTImageEditingManager.cropImage(uri, cropData, success, failure); + NativeImageEditor.cropImage(uri, cropData, success, failure); } } diff --git a/Libraries/Image/NativeImageEditor.js b/Libraries/Image/NativeImageEditor.js new file mode 100644 index 00000000000000..daae96fd5ce661 --- /dev/null +++ b/Libraries/Image/NativeImageEditor.js @@ -0,0 +1,48 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ + +'use strict'; + +import type {TurboModule} from 'RCTExport'; +import * as TurboModuleRegistry from 'TurboModuleRegistry'; + +type cropOptions = { + offset: {| + x: number, + y: number, + |}, + + size: {| + width: number, + height: number, + |}, + // IOS ONLY + displaySize?: ?{| + width: number, + height: number, + |}, + // IOS ONLY + resizeMode?: ?$Enum<{ + contain: string, + cover: string, + stretch: string, + }>, +}; + +export interface Spec extends TurboModule { + +cropImage: ( + uri: string, + options: cropOptions, + success: (uri: string) => void, + error: (error: string) => void, + ) => void; +} + +export default TurboModuleRegistry.getEnforcing('ImageEditingManager');