Files
react-native/Libraries/LogBox/UI/LogBoxInspectorFooter.js
T
Rick Hanlon a64e5bc251 LogBox - Use Modal for full screen inspector
Summary:
This diff switches LogBox over to use a Modal component so that the log inspector is always full screen.

In order to do that, it needed to add an `internal_excludeLogBox` flag to AppContainer so that it's not recursively rendered  as: AppContainer -> LogBox -> Modal -> AppContainer. Not thrilled about the prop but it's necessary for now until this is rendered as it's own root (which we're working on next).

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D18461394

fbshipit-source-id: e1a80dfffbbe6c5467ac6f8d3c445a3280829020
2019-11-27 08:27:31 -08:00

113 lines
2.5 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/
'use strict';
import type {LogLevel} from '../Data/LogBoxLog';
import * as React from 'react';
import DeviceInfo from '../../Utilities/DeviceInfo';
import StyleSheet from '../../StyleSheet/StyleSheet';
import Text from '../../Text/Text';
import View from '../../Components/View/View';
import LogBoxButton from './LogBoxButton';
import * as LogBoxStyle from './LogBoxStyle';
type Props = $ReadOnly<{|
onDismiss: () => void,
onMinimize: () => void,
level?: ?LogLevel,
|}>;
function LogBoxInspectorFooter(props: Props): React.Node {
if (props.level === 'syntax') {
return (
<View style={styles.root}>
<View style={styles.button}>
<Text style={styles.syntaxErrorText}>
This error cannot be dismissed.
</Text>
</View>
</View>
);
}
return (
<View style={styles.root}>
<FooterButton text="Dismiss" onPress={props.onDismiss} />
<FooterButton text="Minimize" onPress={props.onMinimize} />
</View>
);
}
type ButtonProps = $ReadOnly<{|
onPress: () => void,
text: string,
|}>;
function FooterButton(props: ButtonProps): React.Node {
return (
<LogBoxButton
backgroundColor={{
default: 'transparent',
pressed: LogBoxStyle.getBackgroundDarkColor(),
}}
onPress={props.onPress}
style={buttonStyles.safeArea}>
<View style={buttonStyles.content}>
<Text style={buttonStyles.label}>{props.text}</Text>
</View>
</LogBoxButton>
);
}
const buttonStyles = StyleSheet.create({
safeArea: {
flex: 1,
paddingBottom: DeviceInfo.getConstants().isIPhoneX_deprecated ? 30 : 0,
},
content: {
alignItems: 'center',
height: 48,
justifyContent: 'center',
},
label: {
color: LogBoxStyle.getTextColor(1),
fontSize: 14,
includeFontPadding: false,
lineHeight: 20,
},
});
const styles = StyleSheet.create({
root: {
backgroundColor: LogBoxStyle.getBackgroundColor(1),
shadowColor: '#000',
shadowOffset: {width: 0, height: -2},
shadowRadius: 2,
shadowOpacity: 0.5,
flexDirection: 'row',
},
button: {
flex: 1,
},
syntaxErrorText: {
textAlign: 'center',
width: '100%',
fontSize: 14,
paddingTop: 15,
paddingBottom: 15,
fontStyle: 'italic',
color: LogBoxStyle.getTextColor(0.6),
},
});
export default LogBoxInspectorFooter;