import React from 'react'; import { FlatList, PixelRatio, StyleSheet, Text, TouchableHighlight, View, ListRenderItem, } from 'react-native'; import { withNavigation, NavigationScreenProps } from 'react-navigation'; import { EvilIcons } from '@expo/vector-icons'; import ExpoAPIIcon from '../components/ExpoAPIIcon'; interface ListElement { name: string; isAvailable?: boolean; } interface Props { apis: ListElement[]; } class ComponentListScreen extends React.Component { _listView?: FlatList; _renderExampleSection: ListRenderItem = ({ item: { name: exampleName, isAvailable }, }) => { return ( this.props.navigation.navigate(exampleName) : undefined} > {exampleName} ); } _keyExtractor = (item: ListElement) => item.name; render() { return ( // @ts-ignore ref={view => { this._listView = view!; }} stickySectionHeadersEnabled removeClippedSubviews={false} keyboardShouldPersistTaps="handled" keyboardDismissMode="on-drag" contentContainerStyle={{ backgroundColor: '#fff' }} data={this.props.apis} keyExtractor={this._keyExtractor} renderItem={this._renderExampleSection} /> ); } _scrollToTop = () => { // @ts-ignore this._listView!.scrollTo({ x: 0, y: 0 }); } } const styles = StyleSheet.create({ container: { flex: 1, paddingTop: 100, }, row: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', }, rowDecorator: { alignSelf: 'flex-end', paddingRight: 4, }, rowTouchable: { paddingHorizontal: 10, paddingVertical: 14, borderBottomWidth: 1.0 / PixelRatio.get(), borderBottomColor: '#dddddd', }, disabledRow: { opacity: 0.3, }, rowLabel: { flex: 1, fontSize: 15, }, rowIcon: { marginRight: 10, marginLeft: 6, }, }); export default withNavigation(ComponentListScreen);