import React from 'react'; import { StyleSheet, View } from 'react-native'; import { Avatar } from './Avatar'; import { AvatarGroupProps } from './types'; export const AvatarGroup: React.FC = ({ items, style, size, showCountText, textColor, type, backgroundColor, innerBorderColor, max, textStyle, itemStyle, onMoreItems, separatePercentage, bordered, moreProps, borderColor, imageProps = {} }) => { const internalItems = max ? [...items].splice(0, max + 1) : items; return ( {internalItems.map((item, index) => { const sizeFull = item?.size || size; let percentage = separatePercentage; if (typeof percentage === 'undefined') { percentage = sizeFull <= 25 ? 0.25 : 0.35; } const marginLeft = (sizeFull || 40) * percentage; if (index === max) { let maxValue = items.length - max; if (maxValue <= 0) { return null; } if (maxValue > 9) { maxValue = 9; } return ( { onMoreItems?.(); moreProps?.onPress?.(event); }} text={moreProps?.text ?? `+${maxValue}`} style={StyleSheet.flatten([ { marginLeft: index === 0 ? 0 : -marginLeft }, itemStyle, moreProps?.style ])} /> ); } return ( ); })} ); }; const styles = StyleSheet.create({ container: { flexDirection: 'row', alignItems: 'center' } });