/** * 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 Platform = require('Platform'); const React = require('react'); const SectionList = require('SectionList'); const StyleSheet = require('StyleSheet'); const Text = require('Text'); const TouchableHighlight = require('TouchableHighlight'); const RNTesterActions = require('./RNTesterActions'); const RNTesterExampleFilter = require('./RNTesterExampleFilter'); const View = require('View'); import type {RNTesterExample} from 'RNTesterTypes'; import type {ViewStyleProp} from 'StyleSheet'; type Props = { onNavigate: Function, list: { ComponentExamples: Array, APIExamples: Array, }, 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 ( {item.module.title} {item.module.description} ); } } const renderSectionHeader = ({section}) => ( {section.title} ); class RNTesterExampleList extends React.Component { render() { const filter = ({example, filterRegex}) => filterRegex.test(example.module.title) && (!Platform.isTV || example.supportsTVOS); const sections = [ { data: this.props.list.ComponentExamples, title: 'COMPONENTS', key: 'c', }, { data: this.props.list.APIExamples, title: 'APIS', key: 'a', }, ]; return ( {this._renderTitleRow()} ( )} /> ); } _itemShouldUpdate(curr, prev) { return curr.item !== prev.item; } _renderItem = ({item, separators}) => ( ); _renderTitleRow(): ?React.Element { /* $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 ( { this.props.onNavigate(RNTesterActions.ExampleList()); }} /> ); } _handleRowPress(exampleKey: string): void { this.props.onNavigate(RNTesterActions.ExampleAction(exampleKey)); } } const ItemSeparator = ({highlighted}) => ( ); const styles = StyleSheet.create({ listContainer: { flex: 1, }, list: { backgroundColor: '#eeeeee', }, sectionHeader: { backgroundColor: '#eeeeee', padding: 5, fontWeight: '500', fontSize: 11, }, row: { backgroundColor: 'white', justifyContent: 'center', paddingHorizontal: 15, paddingVertical: 8, }, separator: { height: StyleSheet.hairlineWidth, backgroundColor: '#bbbbbb', marginLeft: 15, }, separatorHighlighted: { height: StyleSheet.hairlineWidth, backgroundColor: 'rgb(217, 217, 217)', }, sectionListContentContainer: { backgroundColor: 'white', }, rowTitleText: { fontSize: 17, fontWeight: '500', }, rowDetailText: { fontSize: 15, color: '#888888', lineHeight: 20, }, }); module.exports = RNTesterExampleList;