Skip to content

Commit 9ce1374

Browse files
Native lib reorder and fix ios (#3750)
* Native lib - reorganize components in folders for convenience + bump version to 5.0.0 * pointing to index * revert naming change * fix api files * rename HighlighterOverlay web * Moving sub components to the parent * fix api file and move KeyboardUtils outside folder * Revert "fix api file and move KeyboardUtils outside folder" This reverts commit ff64327. * fix api json * fix folder name to match component name * remove specs * fix highligther view native registration * fix for SafeAreaSpacerView * fix types * fix for KeyboardTrackingView * trying to fix failed CI build * SafeAreaSpacesView - moving to react implementation using native SafeAreaManager * manager changes * fix safe area * fix SafeAreaSpacerView again * removing logs * Fix highlightViewTag type * Fix TS error * Typescript fixes \ revert * Revert --------- Co-authored-by: Miki Leib <[email protected]> Co-authored-by: M-i-k-e-l <[email protected]>
1 parent 938d001 commit 9ce1374

33 files changed

+388
-110
lines changed

demo/src/screens/nativeComponentScreens/SafeAreaSpacerViewScreen.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default class SafeAreaSpacerViewScreen extends PureComponent {
2323
<Text red50> SafeAreaSpacerView </Text>
2424
{'can be used as a BOTTOM or TOP spacer and will get the height of the safe area insets'}
2525
</Text>
26+
<SafeAreaSpacerView style={{width: 100, backgroundColor: 'red'}}/>
2627
</View>
2728
</ScrollView>
2829
<View style={styles.topView}>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import type {ViewProps} from 'react-native';
2+
import type {
3+
Float,
4+
Int32,
5+
WithDefault
6+
} from 'react-native/Libraries/Types/CodegenTypes';
7+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
8+
9+
export interface HighlightFrame {
10+
x: Float;
11+
y: Float;
12+
width: Float;
13+
height: Float;
14+
}
15+
16+
export interface MinimumRectSize {
17+
width: Float;
18+
height: Float;
19+
}
20+
21+
export interface HighlightViewTagParams {
22+
paddingLeft?: WithDefault<Float, 0>;
23+
paddingTop?: WithDefault<Float, 0>;
24+
paddingRight?: WithDefault<Float, 0>;
25+
paddingBottom?: WithDefault<Float, 0>;
26+
offsetX?: WithDefault<Float, 0>;
27+
offsetY?: WithDefault<Float, 0>;
28+
}
29+
30+
export interface NativeProps extends ViewProps {
31+
/**
32+
* The frame to highlight with x, y, width, height coordinates
33+
*/
34+
highlightFrame?: HighlightFrame;
35+
36+
/**
37+
* The overlay color (processed color int for Android)
38+
*/
39+
overlayColor?: WithDefault<Int32, 0>;
40+
41+
/**
42+
* The border radius for the highlighted area
43+
*/
44+
borderRadius?: WithDefault<Float, 0>;
45+
46+
/**
47+
* The stroke color (processed color int for Android)
48+
*/
49+
strokeColor?: WithDefault<Int32, 0>;
50+
51+
/**
52+
* The stroke width
53+
*/
54+
strokeWidth?: WithDefault<Float, 0>;
55+
56+
/**
57+
* The React tag of the view to highlight
58+
*/
59+
highlightViewTag?: Int32;
60+
61+
/**
62+
* Parameters for view-based highlighting including padding and offset
63+
*/
64+
highlightViewTagParams?: HighlightViewTagParams;
65+
66+
/**
67+
* Minimum rectangle size for the highlight area
68+
*/
69+
minimumRectSize?: MinimumRectSize;
70+
71+
/**
72+
* Inner padding for the highlight area
73+
*/
74+
innerPadding?: WithDefault<Float, 0>;
75+
}
76+
77+
export default codegenNativeComponent<NativeProps>('HighlighterView');

lib/components/HighlighterOverlayView.tsx renamed to lib/components/HighlighterOverlayView/index.tsx

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import React from 'react';
2-
import {requireNativeComponent, processColor, Platform, StyleSheet, Modal, ViewStyle} from 'react-native';
2+
import {processColor, StyleSheet, Modal, ViewStyle} from 'react-native';
3+
// Import the Codegen specification for New Architecture
4+
import HighlighterViewNativeComponent, {
5+
HighlightViewTagParams as NativeHighlightViewTagParams
6+
} from './HighlighterViewNativeComponent';
37

4-
const NativeHighlighterView = requireNativeComponent('HighlighterView');
58
const DefaultOverlayColor = 'rgba(0, 0, 0, 0.5)';
69

710
type HighlightFrameType = {
@@ -25,7 +28,7 @@ export type HighlighterOverlayViewProps = {
2528
onRequestClose?: () => void;
2629
highlightFrame?: HighlightFrameType;
2730
style?: ViewStyle;
28-
highlightViewTag?: number | null;
31+
highlightViewTag?: number;
2932
children?: JSX.Element[] | JSX.Element;
3033
highlightViewTagParams?: HighlightViewTagParams;
3134
minimumRectSize?: Pick<HighlightFrameType, 'width' | 'height'>;
@@ -34,7 +37,6 @@ export type HighlighterOverlayViewProps = {
3437
testID?: string;
3538
};
3639

37-
3840
const HighlighterOverlayView = (props: HighlighterOverlayViewProps) => {
3941
const {
4042
overlayColor,
@@ -52,13 +54,22 @@ const HighlighterOverlayView = (props: HighlighterOverlayViewProps) => {
5254
innerPadding
5355
} = props;
5456

55-
let overlayColorToUse = overlayColor || DefaultOverlayColor;
56-
let strokeColorToUse = strokeColor;
57-
if (Platform.OS === 'android') {
58-
// @ts-ignore
59-
overlayColorToUse = processColor(overlayColorToUse);
60-
// @ts-ignore
61-
strokeColorToUse = processColor(strokeColorToUse);
57+
// Process colors for New Architecture Codegen component
58+
const overlayColorToUse = processColor(overlayColor || DefaultOverlayColor) as number;
59+
const strokeColorToUse = strokeColor ? (processColor(strokeColor) as number) : undefined;
60+
61+
// Convert highlightViewTagParams to match native Codegen spec
62+
let nativeHighlightViewTagParams: NativeHighlightViewTagParams | undefined;
63+
if (highlightViewTagParams) {
64+
const padding = typeof highlightViewTagParams.padding === 'number' ? highlightViewTagParams.padding : 0;
65+
nativeHighlightViewTagParams = {
66+
paddingLeft: padding,
67+
paddingTop: padding,
68+
paddingRight: padding,
69+
paddingBottom: padding,
70+
offsetX: highlightViewTagParams.offset?.x || 0,
71+
offsetY: highlightViewTagParams.offset?.y || 0
72+
};
6273
}
6374

6475
return (
@@ -68,18 +79,19 @@ const HighlighterOverlayView = (props: HighlighterOverlayViewProps) => {
6879
transparent
6980
onRequestClose={() => onRequestClose?.()}
7081
>
71-
<NativeHighlighterView
72-
// @ts-ignore, this became private, not sure if I should remove it
82+
<HighlighterViewNativeComponent
7383
highlightFrame={highlightFrame}
7484
style={[style, {...StyleSheet.absoluteFillObject, backgroundColor: 'transparent'}]}
7585
overlayColor={overlayColorToUse}
7686
borderRadius={borderRadius}
7787
strokeColor={strokeColorToUse}
7888
strokeWidth={strokeWidth}
7989
highlightViewTag={highlightViewTag}
80-
highlightViewTagParams={highlightViewTagParams}
90+
highlightViewTagParams={nativeHighlightViewTagParams}
8191
minimumRectSize={minimumRectSize}
8292
innerPadding={innerPadding}
93+
testID={props.testID}
94+
accessible={props.accessible}
8395
/>
8496
{children}
8597
</Modal>

lib/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.tsx renamed to lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import {Keyboard, View} from 'react-native';
33
import KeyboardRegistry from '../KeyboardRegistry';
4-
import CustomKeyboardViewBase, {CustomKeyboardViewBaseProps} from '../CustomKeyboardViewBase';
4+
import CustomKeyboardViewBase, {CustomKeyboardViewBaseProps} from './CustomKeyboardViewBase';
55

66
export default class CustomKeyboardView extends CustomKeyboardViewBase<CustomKeyboardViewBaseProps> {
77
static displayName = 'IGNORE';

lib/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.ios.tsx renamed to lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.ios.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import TextInputKeyboardManager from './../TextInputKeyboardManager/TextInputKeyboardManager.ios';
2-
import KeyboardRegistry from './../KeyboardRegistry';
3-
import CustomKeyboardViewBase, {CustomKeyboardViewBaseProps} from './../CustomKeyboardViewBase';
1+
import TextInputKeyboardManager from '../TextInputKeyboardManager/TextInputKeyboardManager.ios';
2+
import KeyboardRegistry from '../KeyboardRegistry';
3+
import CustomKeyboardViewBase, {CustomKeyboardViewBaseProps} from './CustomKeyboardViewBase';
44

55
export type CustomKeyboardViewProps = CustomKeyboardViewBaseProps & {
66
/**

lib/components/Keyboard/KeyboardInput/CustomKeyboardViewBase.tsx renamed to lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardViewBase.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {Component} from 'react';
2-
import KeyboardRegistry from './KeyboardRegistry';
32
import {EventSubscription} from 'react-native';
3+
import KeyboardRegistry from '../KeyboardRegistry';
44

55
export type CustomKeyboardViewBaseProps = {
66
inputRef?: any;

lib/components/Keyboard/KeyboardInput/utils/__tests__/EventEmitterManager.spec.js renamed to lib/components/Keyboard/KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/__tests__/EventEmitterManager.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const EventEmitterManager = require('../EventEmitterManager').default;
1+
const EventEmitterManager = require('../index').default;
22

33
let EventEmitter;
44

0 commit comments

Comments
 (0)