Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
28 changes: 13 additions & 15 deletions packages/react-native/Libraries/LogBox/UI/LogBoxButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as LogBoxStyle from './LogBoxStyle';
import * as React from 'react';
import {useState} from 'react';

type Props = Readonly<{
component LogBoxButton(
id?: string,
backgroundColor: Readonly<{
default: string,
Expand All @@ -29,40 +29,38 @@ type Props = Readonly<{
hitSlop?: ?EdgeInsetsProp,
onPress?: ?(event: GestureResponderEvent) => void,
style?: ViewStyleProp,
}>;

function LogBoxButton(props: Props): React.Node {
) {
const [pressed, setPressed] = useState(false);

let backgroundColor = props.backgroundColor;
if (!backgroundColor) {
backgroundColor = {
let resolvedBackgroundColor = backgroundColor;
if (!resolvedBackgroundColor) {
resolvedBackgroundColor = {
default: LogBoxStyle.getBackgroundColor(0.95),
pressed: LogBoxStyle.getBackgroundColor(0.6),
};
}

const content = (
<View
id={props.id}
id={id}
style={StyleSheet.compose(
{
backgroundColor: pressed
? backgroundColor.pressed
: backgroundColor.default,
? resolvedBackgroundColor.pressed
: resolvedBackgroundColor.default,
},
props.style,
style,
)}>
{props.children}
{children}
</View>
);

return props.onPress == null ? (
return onPress == null ? (
content
) : (
<TouchableWithoutFeedback
hitSlop={props.hitSlop}
onPress={props.onPress}
hitSlop={hitSlop}
onPress={onPress}
onPressIn={() => setPressed(true)}
onPressOut={() => setPressed(false)}>
{content}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ import LogBoxButton from './LogBoxButton';
import * as LogBoxStyle from './LogBoxStyle';
import * as React from 'react';

type Props = Readonly<{
component LogBoxInspectorStackFrame(
frame: StackFrame,
onPress?: ?(event: GestureResponderEvent) => void,
}>;

function LogBoxInspectorStackFrame(props: Props): React.Node {
const {frame, onPress} = props;
) {
const column = frame.column != null && parseInt(frame.column, 10);
const location =
getFileName(frame.file) +
Expand Down
Loading