license import React from 'react' ; import { Image , ImageProps , ImageStyle , StyleSheet , } from 'react-native' ; import { EvaSize , Overwrite , LiteralUnion , } from '../../devsupport' ; import { styled , StyledComponentProps , StyleType , } from '../../theme' ; type AvatarStyledProps = Overwrite < StyledComponentProps , { appearance ? : LiteralUnion < 'default' > ; } > ; export type AvatarProps < P = ImageProps > = AvatarStyledProps & P & { shape ? : 'round' | 'rounded' | 'square' | string ; size ? : EvaSize ; /**
     * We use `any` here to prevent ts complains for most of the libraries that use
     * React.ComponentType & SomeType to describe static / instance methods for the components.
     */ ImageComponent ? : React . ComponentType < P > & any ; } ; export type AvatarElement = React . ReactElement < AvatarProps > ; extends React . Component property property property property overview-example overview-example overview-example overview-example @ styled ( 'Avatar' ) export class Avatar extends React . Component < AvatarProps > { static defaultProps : Partial < AvatarProps > = { ImageComponent : Image , } ; private getComponentStyle = ( source ) => { const { roundCoefficient , ... containerParameters } = source ; const baseStyle = StyleSheet . flatten ( [ containerParameters , this . props . style , ] ) ; const borderRadius = roundCoefficient * baseStyle . height ; return { borderRadius , ... baseStyle , } ; } ; public render ( ) { const { eva , ImageComponent , ... imageProps } = this . props ; const evaStyle = this . getComponentStyle ( eva . style ) ; return ( < ImageComponent { ... imageProps } style = { [ styles . image , evaStyle ] } / > ) ; } } const styles = StyleSheet . create ( { image : { overflow : 'hidden' , } , } ) ;