Files
react-native/Libraries/LogBox/UI/LogBoxInspectorFooter.js
T
Rick Hanlon 38b3cbcca9 LogBox - Update press backfround for inspector footers
Summary:
Previously the background for the LogBox inspector footer buttons bleed into the background behind them. This change gives them more distinct on press backgrounds.

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D18337437

fbshipit-source-id: c0cefd4464d94dc23316208135a9bf922fb510cb
2019-11-06 10:17:47 -08:00

142 lines
3.3 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 SafeAreaView from '../../Components/SafeAreaView/SafeAreaView';
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,
fatalType?: ?LogLevel,
|}>;
function LogBoxInspectorFooter(props: Props): React.Node {
if (props.fatalType === 'fatal' || props.fatalType === 'syntax') {
return (
<View style={styles.root}>
<LogBoxButton
backgroundColor={{
default: LogBoxStyle.getFatalColor(),
pressed: LogBoxStyle.getFatalDarkColor(),
}}
onPress={() =>
require('../../Utilities/DevSettings').reload('LogBox fatal')
}
style={fatalStyles.button}>
<View style={[fatalStyles.content]}>
<Text style={fatalStyles.label}>Reload</Text>
<Text style={fatalStyles.subtextLabel}>
{{fatal: 'Fatal', syntax: 'Syntax'}[props.fatalType]} errors
require a full reload
</Text>
</View>
<SafeAreaView />
</LogBoxButton>
</View>
);
}
return (
<View style={styles.root}>
<FooterButton text="Minimize" onPress={props.onMinimize} />
<FooterButton text="Dismiss" onPress={props.onDismiss} />
</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.button}>
<View style={buttonStyles.content}>
<Text style={buttonStyles.label}>{props.text}</Text>
</View>
<SafeAreaView />
</LogBoxButton>
);
}
const fatalStyles = StyleSheet.create({
button: {
flex: 1,
},
content: {
alignItems: 'center',
height: 60,
justifyContent: 'center',
},
subtext: {
height: 60,
},
label: {
color: LogBoxStyle.getTextColor(1),
fontSize: 14,
fontWeight: '600',
includeFontPadding: false,
lineHeight: 20,
},
subtextLabel: {
color: LogBoxStyle.getTextColor(0.8),
fontSize: 11,
includeFontPadding: false,
lineHeight: 12,
},
});
const buttonStyles = StyleSheet.create({
button: {
flex: 1,
},
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,
elevation: 1,
flexDirection: 'row',
},
});
export default LogBoxInspectorFooter;