react-native-ios-utilities
Version:
Utilities for react-native + iOS and wrappers for using swift together with fabric/paper + JSI
40 lines (39 loc) • 1.67 kB
JavaScript
;
import * as React from 'react';
import { StyleSheet, View } from 'react-native';
import { RNIWrapperView } from "../../native_components/RNIWrapperView/index.js";
import { DEFAULT_DETACHED_SUBVIEW_ENTRY } from "./DetachedSubviewsMap.js";
import { IS_USING_NEW_ARCH } from "../../constants/LibEnv.js";
import { jsx as _jsx } from "react/jsx-runtime";
export function RNIDetachedViewContent(props) {
const [viewID, setViewID] = React.useState();
const wrapperStyle = [props.shouldEnableDebugBackgroundColors && styles.wrapperViewDebug, props.contentContainerStyle];
const detachedSubviewEntry = (viewID != null ? props.detachedSubviewsMap?.[viewID] : undefined) ?? DEFAULT_DETACHED_SUBVIEW_ENTRY;
const didDetach = (props.isParentDetached ?? false) || detachedSubviewEntry.didDetachFromOriginalParent;
return /*#__PURE__*/_jsx(RNIWrapperView, {
...props,
style: [...(IS_USING_NEW_ARCH ? wrapperStyle : []), didDetach ? styles.wrapperViewDetached : styles.wrapperViewAttached, props.style],
onDidSetViewID: event => {
props.onDidSetViewID?.(event);
setViewID(event.nativeEvent.viewID);
props.onDidSetViewID?.(event);
event.stopPropagation();
},
children: IS_USING_NEW_ARCH ? props.children : /*#__PURE__*/_jsx(View, {
style: [styles.innerWrapperContainerForPaper, ...wrapperStyle],
children: props.children
})
});
}
;
const styles = StyleSheet.create({
wrapperViewAttached: {},
wrapperViewDetached: {},
wrapperViewDebug: {
backgroundColor: 'rgba(255,0,255,0.3)'
},
innerWrapperContainerForPaper: {
flex: 1
}
});
//# sourceMappingURL=RNIDetachedViewContent.js.map