Files
react-native/packages/rn-tester/js/components/ExamplePage.js
T
Andrew 47b0be5f55 Fix a couple of places RNTester is using non-theme values (#31479)
Summary:
A few places in RNTester where using hard coded color values, which meant the UI looks broken in dark themes.

The area behind the bookmark button was using a solid color png file, which I've replaced with a color from the theme object.

## Changelog

[Internal] [Fixed] - Fix a couple of places RNTester is using non-theme values

Pull Request resolved: https://github.com/facebook/react-native/pull/31479

Test Plan: Verified in RNTester in react-native-windows in light+dark theme.

Reviewed By: TheSavior

Differential Revision: D28290192

Pulled By: rozele

fbshipit-source-id: 78192200ac2dc8629759c10f8e8b3ec2f6699acd
2021-06-03 07:46:28 -07:00

63 lines
1.4 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.
*
* @format
* @flow
*/
import * as React from 'react';
import {StyleSheet, View, Text} from 'react-native';
import {RNTesterThemeContext} from './RNTesterTheme';
type Props = $ReadOnly<{|
children?: React.Node,
title: string,
description?: ?string,
category?: ?string,
ios?: ?boolean,
android?: ?boolean,
|}>;
export default function ExamplePage(props: Props): React.Node {
const description = props.description ?? '';
const theme = React.useContext(RNTesterThemeContext);
return (
<>
<View
style={[styles.titleView, {backgroundColor: theme.BackgroundColor}]}>
<Text style={styles.title}>{props.title}</Text>
<Text style={styles.description}>{description}</Text>
</View>
<View style={styles.examplesContainer}>{props.children}</View>
</>
);
}
const styles = StyleSheet.create({
titleView: {
paddingHorizontal: 25,
paddingTop: 4,
paddingBottom: 8,
overflow: 'hidden',
},
title: {
alignSelf: 'center',
fontSize: 12,
},
description: {
fontSize: 16,
paddingTop: 4,
},
iconContainer: {
flexDirection: 'row',
justifyContent: 'flex-end',
},
examplesContainer: {
flexGrow: 1,
flex: 1,
},
});