import * as React from 'react'; import { StyleSheet, View, ViewStyle, Image, StyleProp } from 'react-native'; import { withTheme } from '../../core/theming'; import { grey200 } from '../../styles/colors'; type Props = React.ComponentPropsWithRef & { /** * @internal */ index?: number; /** * @internal */ total?: number; style?: StyleProp; /** * @optional */ theme: ReactNativePaper.Theme; }; /** * A component to show a cover image inside a Card. * *
*
* *
*
* * ## Usage * ```js * import * as React from 'react'; * import { Card } from 'react-native-paper'; * * const MyComponent = () => ( * * * * ); * * export default MyComponent; * ``` * * @extends Image props https://reactnative.dev/docs/image#props */ const CardCover = ({ index, total, style, theme, ...rest }: Props) => { const { roundness } = theme; let coverStyle; if (index === 0) { if (total === 1) { coverStyle = { borderRadius: roundness, }; } else { coverStyle = { borderTopLeftRadius: roundness, borderTopRightRadius: roundness, }; } } else if (typeof total === 'number' && index === total - 1) { coverStyle = { borderBottomLeftRadius: roundness, }; } return ( ); }; CardCover.displayName = 'Card.Cover'; const styles = StyleSheet.create({ container: { height: 195, backgroundColor: grey200, overflow: 'hidden', }, image: { flex: 1, height: undefined, width: undefined, padding: 16, justifyContent: 'flex-end', }, }); export default withTheme(CardCover); // @component-docs ignore-next-line export { CardCover };