/** * 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. * * @format * @flow strict-local */ 'use strict'; import type {ElementsHierarchy, InspectedElement} from './Inspector'; import SafeAreaView from '../Components/SafeAreaView/SafeAreaView'; const ScrollView = require('../Components/ScrollView/ScrollView'); const TouchableHighlight = require('../Components/Touchable/TouchableHighlight'); const View = require('../Components/View/View'); const StyleSheet = require('../StyleSheet/StyleSheet'); const Text = require('../Text/Text'); const ElementProperties = require('./ElementProperties'); const NetworkOverlay = require('./NetworkOverlay'); const PerformanceOverlay = require('./PerformanceOverlay'); const React = require('react'); type Props = $ReadOnly<{| devtoolsIsOpen: boolean, inspecting: boolean, setInspecting: (val: boolean) => void, perfing: boolean, setPerfing: (val: boolean) => void, touchTargeting: boolean, setTouchTargeting: (val: boolean) => void, networking: boolean, setNetworking: (val: boolean) => void, hierarchy?: ?ElementsHierarchy, selection?: ?number, setSelection: number => mixed, inspected?: ?InspectedElement, |}>; class InspectorPanel extends React.Component { renderWaiting(): React.Node { if (this.props.inspecting) { return ( Tap something to inspect it ); } return Nothing is inspected; } render(): React.Node { let contents; if (this.props.inspected) { contents = ( ); } else if (this.props.perfing) { contents = ; } else if (this.props.networking) { contents = ; } else { contents = {this.renderWaiting()}; } return ( {!this.props.devtoolsIsOpen && contents} {global.RN$Bridgeless === true ? null : ( // These Inspector Panel sub-features are removed under the New Arch. // See https://github.com/react-native-community/discussions-and-proposals/pull/777 <> )} ); } } type InspectorPanelButtonProps = $ReadOnly<{| onClick: (val: boolean) => void, pressed: boolean, title: string, |}>; class InspectorPanelButton extends React.Component { render(): React.Node { return ( this.props.onClick(!this.props.pressed)} style={[styles.button, this.props.pressed && styles.buttonPressed]}> {this.props.title} ); } } const styles = StyleSheet.create({ buttonRow: { flexDirection: 'row', }, button: { backgroundColor: 'rgba(0, 0, 0, 0.3)', margin: 2, height: 30, justifyContent: 'center', alignItems: 'center', }, buttonPressed: { backgroundColor: 'rgba(255, 255, 255, 0.3)', }, buttonText: { textAlign: 'center', color: 'white', margin: 5, }, container: { backgroundColor: 'rgba(0, 0, 0, 0.7)', }, properties: { height: 200, }, waiting: { height: 100, }, waitingText: { fontSize: 20, textAlign: 'center', marginVertical: 20, color: 'white', }, }); module.exports = InspectorPanel;