Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TM] Add Spec for ImageEditor #24921

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Libraries/Image/ImageEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
* @format
*/
'use strict';

const RCTImageEditingManager = require('../BatchedBridge/NativeModules')
.ImageEditingManager;
import NativeImageEditor from './NativeImageEditor';

type ImageCropData = {
/**
Expand Down Expand Up @@ -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);
}
}

Expand Down
48 changes: 48 additions & 0 deletions Libraries/Image/NativeImageEditor.js
Original file line number Diff line number Diff line change
@@ -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,
|},

displaySize?: ?{|
width: number,
height: number,
|},

resizeMode?: ?$Enum<{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these optional because android doesn't have them? if so, group and mark: // iOS only

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<Spec>('NativeImageEditor');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be ImageEditingManager instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it ! do I need to update call-sites too?