11import * as React from 'react' ;
22import { Image , View } from 'react-native' ;
3+ import { DeepPartial } from 'ts-essentials' ;
34
45import { Theme , withTheme } from '../../theme' ;
56import { FillColors } from '../../theme/ThemeInterface' ;
7+ import { mergeStyles , ReplaceReturnType } from '../../utils/mergeStyles' ;
68import { Text } from '../Typography' ;
79import { getTextStyles } from '../Typography/Text.styles' ;
8- import { GetAvatarStyles , getAvatarStyles } from './Avatar.styles' ;
10+ import {
11+ AvatarStyles ,
12+ GetAvatarStyles ,
13+ getAvatarStyles ,
14+ } from './Avatar.styles' ;
915
1016// https://github.com/segmentio/evergreen/blob/master/source/avatar/README.md
1117export type GetInitialsType = ( name ?: string , fallback ?: string ) => string ;
@@ -77,7 +83,7 @@ export interface AvatarProps {
7783 */
7884 theme : Theme ;
7985
80- getStyles ?: GetAvatarStyles ;
86+ getStyles ?: ReplaceReturnType < GetAvatarStyles , DeepPartial < AvatarStyles > > ;
8187}
8288
8389export const AvatarBase = ( props : AvatarProps ) => {
@@ -93,7 +99,7 @@ export const AvatarBase = (props: AvatarProps) => {
9399 color = 'automatic' ,
94100 forceShowInitials = false ,
95101 sizeLimitOneCharacter = 20 ,
96- getStyles = getAvatarStyles ,
102+ getStyles,
97103 } = props ;
98104
99105 const { imageHasFailedLoading } = { imageHasFailedLoading : false } ;
@@ -104,7 +110,10 @@ export const AvatarBase = (props: AvatarProps) => {
104110 initials = initials . substring ( 0 , 1 ) ;
105111 }
106112
107- const { boxStyle, textStyle, imageStyle } = getStyles (
113+ const { boxStyle, textStyle, imageStyle } = mergeStyles (
114+ getAvatarStyles ,
115+ getStyles ,
116+ ) (
108117 {
109118 color,
110119 hashValue,
0 commit comments