UNPKG

@uiw/react-native

Version:
43 lines 867 B
import React from 'react'; import { View, Image, StyleSheet } from 'react-native'; const styles = StyleSheet.create({ defalut: { backgroundColor: '#e4e4e4', overflow: 'hidden' }, logo: { width: 66, height: 58 } }); const defaultImage = require('./assets/user.png'); export default function Avatar(props) { const { style, src, size, shape, rounded, imageProps, ...otherProps } = props; return <View style={[styles.defalut, style, { width: size, height: size }, { borderRadius: shape === 'circle' ? size / 2 : rounded }]} {...otherProps}> <Image style={{ width: size, height: size }} source={typeof src === 'number' ? src : { uri: src }} {...imageProps} /> </View>; } Avatar.defaultProps = { src: defaultImage, shape: 'square', rounded: 3, size: 40 };