mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
ff690283e0
Summary: Refs: [0.62 release](https://reactnative.dev/blog/#moving-apple-tv-to-react-native-tvos), https://github.com/facebook/react-native/issues/28706, https://github.com/facebook/react-native/issues/28743 Support for the tvOS with the 0.62 release has been moved out to the `react-native-tvos` package. This PR removes the legacy flag related to the tvOS in the RNTester app examples. Since Android TV support is still included in the Core I assume that the TV platform check cannot be removed completely. ## Changelog [Internal] [Removed] - remove 'supportsTVOS' flag from the RNTester examples ## Test Plan I have used the local working copy of `react-native` repo and test the changes in the RNTester app build from this code. Flow and List checks passed (but there is one, unrelated Prettier issue in the `AlertExample.js` file). Pull Request resolved: https://github.com/facebook/react-native/pull/29018 Reviewed By: kacieb Differential Revision: D22109549 Pulled By: TheSavior fbshipit-source-id: d0f71f3d5f5f89d554972ec194ebf2801386fcff
254 lines
6.3 KiB
JavaScript
254 lines
6.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.
|
|
*
|
|
* @format
|
|
* @flow
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const RNTesterActions = require('../utils/RNTesterActions');
|
|
const RNTesterExampleFilter = require('./RNTesterExampleFilter');
|
|
const React = require('react');
|
|
|
|
const {
|
|
Platform,
|
|
SectionList,
|
|
StyleSheet,
|
|
Text,
|
|
TouchableHighlight,
|
|
View,
|
|
} = require('react-native');
|
|
|
|
import type {ViewStyleProp} from '../../../Libraries/StyleSheet/StyleSheet';
|
|
import type {RNTesterExample} from '../types/RNTesterTypes';
|
|
|
|
import {RNTesterThemeContext} from './RNTesterTheme';
|
|
|
|
type Props = {
|
|
onNavigate: Function,
|
|
list: {
|
|
ComponentExamples: Array<RNTesterExample>,
|
|
APIExamples: Array<RNTesterExample>,
|
|
...
|
|
},
|
|
style?: ?ViewStyleProp,
|
|
...
|
|
};
|
|
|
|
class RowComponent extends React.PureComponent<{
|
|
item: Object,
|
|
onNavigate: Function,
|
|
onPress?: Function,
|
|
onShowUnderlay?: Function,
|
|
onHideUnderlay?: Function,
|
|
...
|
|
}> {
|
|
_onPress = () => {
|
|
if (this.props.onPress) {
|
|
this.props.onPress();
|
|
return;
|
|
}
|
|
this.props.onNavigate(RNTesterActions.ExampleAction(this.props.item.key));
|
|
};
|
|
render() {
|
|
const {item} = this.props;
|
|
return (
|
|
<RNTesterThemeContext.Consumer>
|
|
{theme => {
|
|
return (
|
|
<TouchableHighlight
|
|
onShowUnderlay={this.props.onShowUnderlay}
|
|
onHideUnderlay={this.props.onHideUnderlay}
|
|
onPress={this._onPress}>
|
|
<View
|
|
style={[
|
|
styles.row,
|
|
{backgroundColor: theme.SystemBackgroundColor},
|
|
]}>
|
|
<Text style={[styles.rowTitleText, {color: theme.LabelColor}]}>
|
|
{item.module.title}
|
|
</Text>
|
|
<Text
|
|
style={[
|
|
styles.rowDetailText,
|
|
{color: theme.SecondaryLabelColor},
|
|
]}>
|
|
{item.module.description}
|
|
</Text>
|
|
</View>
|
|
</TouchableHighlight>
|
|
);
|
|
}}
|
|
</RNTesterThemeContext.Consumer>
|
|
);
|
|
}
|
|
}
|
|
|
|
const renderSectionHeader = ({section}) => (
|
|
<RNTesterThemeContext.Consumer>
|
|
{theme => {
|
|
return (
|
|
<Text
|
|
style={[
|
|
styles.sectionHeader,
|
|
{
|
|
color: theme.SecondaryLabelColor,
|
|
backgroundColor: theme.GroupedBackgroundColor,
|
|
},
|
|
]}>
|
|
{section.title}
|
|
</Text>
|
|
);
|
|
}}
|
|
</RNTesterThemeContext.Consumer>
|
|
);
|
|
|
|
class RNTesterExampleList extends React.Component<Props, $FlowFixMeState> {
|
|
render(): React.Node {
|
|
const filter = ({example, filterRegex}) =>
|
|
filterRegex.test(example.module.title) && !Platform.isTV;
|
|
|
|
const sections = [
|
|
{
|
|
data: this.props.list.ComponentExamples,
|
|
title: 'COMPONENTS',
|
|
key: 'c',
|
|
},
|
|
{
|
|
data: this.props.list.APIExamples,
|
|
title: 'APIS',
|
|
key: 'a',
|
|
},
|
|
];
|
|
|
|
return (
|
|
<RNTesterThemeContext.Consumer>
|
|
{theme => {
|
|
return (
|
|
<View
|
|
style={[
|
|
styles.listContainer,
|
|
this.props.style,
|
|
{backgroundColor: theme.SecondaryGroupedBackgroundColor},
|
|
]}>
|
|
{this._renderTitleRow()}
|
|
<RNTesterExampleFilter
|
|
testID="explorer_search"
|
|
sections={sections}
|
|
filter={filter}
|
|
render={({filteredSections}) => (
|
|
<SectionList
|
|
ItemSeparatorComponent={ItemSeparator}
|
|
contentContainerStyle={{
|
|
backgroundColor: theme.SeparatorColor,
|
|
}}
|
|
style={{backgroundColor: theme.SystemBackgroundColor}}
|
|
sections={filteredSections}
|
|
renderItem={this._renderItem}
|
|
keyboardShouldPersistTaps="handled"
|
|
automaticallyAdjustContentInsets={false}
|
|
keyboardDismissMode="on-drag"
|
|
renderSectionHeader={renderSectionHeader}
|
|
/>
|
|
)}
|
|
/>
|
|
</View>
|
|
);
|
|
}}
|
|
</RNTesterThemeContext.Consumer>
|
|
);
|
|
}
|
|
|
|
_renderItem = ({item, separators}) => (
|
|
<RowComponent
|
|
item={item}
|
|
onNavigate={this.props.onNavigate}
|
|
onShowUnderlay={separators.highlight}
|
|
onHideUnderlay={separators.unhighlight}
|
|
/>
|
|
);
|
|
|
|
_renderTitleRow(): ?React.Element<any> {
|
|
/* $FlowFixMe(>=0.68.0 site=react_native_fb) This comment suppresses an
|
|
* error found when Flow v0.68 was deployed. To see the error delete this
|
|
* comment and run Flow. */
|
|
if (!this.props.displayTitleRow) {
|
|
return null;
|
|
}
|
|
return (
|
|
<RowComponent
|
|
item={{
|
|
module: {
|
|
title: 'RNTester',
|
|
description: 'React Native Examples',
|
|
},
|
|
}}
|
|
onNavigate={this.props.onNavigate}
|
|
onPress={() => {
|
|
this.props.onNavigate(RNTesterActions.ExampleList());
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
|
|
_handleRowPress(exampleKey: string): void {
|
|
this.props.onNavigate(RNTesterActions.ExampleAction(exampleKey));
|
|
}
|
|
}
|
|
|
|
const ItemSeparator = ({highlighted}) => (
|
|
<RNTesterThemeContext.Consumer>
|
|
{theme => {
|
|
return (
|
|
<View
|
|
style={
|
|
highlighted
|
|
? [
|
|
styles.separatorHighlighted,
|
|
{backgroundColor: theme.OpaqueSeparatorColor},
|
|
]
|
|
: [styles.separator, {backgroundColor: theme.SeparatorColor}]
|
|
}
|
|
/>
|
|
);
|
|
}}
|
|
</RNTesterThemeContext.Consumer>
|
|
);
|
|
|
|
const styles = StyleSheet.create({
|
|
listContainer: {
|
|
flex: 1,
|
|
},
|
|
sectionHeader: {
|
|
padding: 5,
|
|
fontWeight: '500',
|
|
fontSize: 11,
|
|
},
|
|
row: {
|
|
justifyContent: 'center',
|
|
paddingHorizontal: 15,
|
|
paddingVertical: 8,
|
|
},
|
|
separator: {
|
|
height: StyleSheet.hairlineWidth,
|
|
marginLeft: 15,
|
|
},
|
|
separatorHighlighted: {
|
|
height: StyleSheet.hairlineWidth,
|
|
},
|
|
rowTitleText: {
|
|
fontSize: 17,
|
|
fontWeight: '500',
|
|
},
|
|
rowDetailText: {
|
|
fontSize: 15,
|
|
lineHeight: 20,
|
|
},
|
|
});
|
|
|
|
module.exports = RNTesterExampleList;
|