mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
7959a63a1a
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/50976 This is the second part of the migration of `rn-tester` package to use root imports. In this diff the `CodegenTypes` namespace is used to define Codegen primitives. Changelog: [Internal] Reviewed By: huntie Differential Revision: D73780584 fbshipit-source-id: c13c2dfcfa4d023978a9463af1d2a3bf7b72476c
76 lines
2.1 KiB
JavaScript
76 lines
2.1 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict-local
|
|
* @format
|
|
*/
|
|
|
|
import type {CodegenTypes, HostComponent, ViewProps} from 'react-native';
|
|
|
|
import * as React from 'react';
|
|
import {codegenNativeCommands, codegenNativeComponent} from 'react-native';
|
|
|
|
type Event = $ReadOnly<{
|
|
values: $ReadOnlyArray<CodegenTypes.Int32>,
|
|
boolValues: $ReadOnlyArray<boolean>,
|
|
floats: $ReadOnlyArray<CodegenTypes.Float>,
|
|
doubles: $ReadOnlyArray<CodegenTypes.Double>,
|
|
yesNos: $ReadOnlyArray<'yep' | 'nope'>,
|
|
strings: $ReadOnlyArray<string>,
|
|
latLons: $ReadOnlyArray<{lat: CodegenTypes.Double, lon: CodegenTypes.Double}>,
|
|
multiArrays: $ReadOnlyArray<$ReadOnlyArray<CodegenTypes.Int32>>,
|
|
}>;
|
|
|
|
type LegacyStyleEvent = $ReadOnly<{
|
|
string: string,
|
|
}>;
|
|
|
|
type NativeProps = $ReadOnly<{
|
|
...ViewProps,
|
|
opacity?: CodegenTypes.Float,
|
|
values: $ReadOnlyArray<CodegenTypes.Int32>,
|
|
|
|
// Events
|
|
onIntArrayChanged?: ?CodegenTypes.BubblingEventHandler<Event>,
|
|
onLegacyStyleEvent?: ?CodegenTypes.BubblingEventHandler<
|
|
LegacyStyleEvent,
|
|
'alternativeLegacyName',
|
|
>,
|
|
}>;
|
|
|
|
export type MyNativeViewType = HostComponent<NativeProps>;
|
|
|
|
interface NativeCommands {
|
|
+callNativeMethodToChangeBackgroundColor: (
|
|
viewRef: React.ElementRef<MyNativeViewType>,
|
|
color: string,
|
|
) => void;
|
|
|
|
+callNativeMethodToAddOverlays: (
|
|
viewRef: React.ElementRef<MyNativeViewType>,
|
|
overlayColors: $ReadOnlyArray<string>,
|
|
) => void;
|
|
|
|
+callNativeMethodToRemoveOverlays: (
|
|
viewRef: React.ElementRef<MyNativeViewType>,
|
|
) => void;
|
|
|
|
+fireLagacyStyleEvent: (viewRef: React.ElementRef<MyNativeViewType>) => void;
|
|
}
|
|
|
|
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
supportedCommands: [
|
|
'callNativeMethodToChangeBackgroundColor',
|
|
'callNativeMethodToAddOverlays',
|
|
'callNativeMethodToRemoveOverlays',
|
|
'fireLagacyStyleEvent',
|
|
],
|
|
});
|
|
|
|
export default (codegenNativeComponent<NativeProps>(
|
|
'RNTMyNativeView',
|
|
): MyNativeViewType);
|