import React from 'react'; import {StyleProp, Text, View, ViewStyle} from 'react-native'; import {WithTheme, WithThemeStyles} from '../style'; import Item from './ListItem'; import {ListPropsType} from './PropsType'; import listStyles, {ListStyle} from './style'; export interface ListProps extends ListPropsType, WithThemeStyles { style?: StyleProp; } export default class List extends React.Component { static Item = Item; render() { const {children, style, renderHeader, renderFooter, styles, ...restProps} = this.props; return ( {(s) => { let headerDom: React.ReactElement | null = null; let footerDom: React.ReactElement | null = null; if (renderHeader) { let content = typeof renderHeader === 'function' ? renderHeader() : renderHeader; if (typeof content === 'string') { content = {content}; } headerDom = {content}; } if (renderFooter) { let content = typeof renderFooter === 'function' ? renderFooter() : renderFooter; if (typeof content === 'string') { content = {content}; } footerDom = {content}; } return ( {headerDom} {children ? children : null} {footerDom} ); }} ); } }