@@ -2,7 +2,7 @@ import * as React from 'react';
22import { Image , ImageSourcePropType , View } from 'react-native' ;
33import { DeepPartial } from 'ts-essentials' ;
44
5- import { Theme , withTheme } from '../../theme' ;
5+ import { useTheme } from '../../theme' ;
66import { FillColors } from '../../theme/ThemeInterface' ;
77import { mergeStyles , ReplaceReturnType } from '../../utils/mergeStyles' ;
88import { Text } from '../Typography' ;
@@ -15,7 +15,7 @@ import {
1515// https://github.com/segmentio/evergreen/blob/master/source/avatar/README.md
1616export type GetInitialsType = ( name ?: string , fallback ?: string ) => string ;
1717
18- export const globalGetInitials : GetInitialsType = ( name , fallback = '?' ) => {
18+ const globalGetInitials : GetInitialsType = ( name , fallback = '?' ) => {
1919 if ( ! name ) return fallback ;
2020
2121 return name
@@ -77,20 +77,13 @@ export interface AvatarProps {
7777 */
7878 sizeLimitOneCharacter ?: number ;
7979
80- /**
81- * Theme provided by ThemeProvider.
82- */
83- theme : Theme ;
84-
8580 getStyles ?: ReplaceReturnType < GetAvatarStyles , DeepPartial < AvatarStyles > > ;
8681
8782 testID ?: string ;
8883}
8984
90- export const AvatarBase = ( props : AvatarProps ) => {
85+ export const Avatar = ( props : AvatarProps ) => {
9186 const {
92- theme,
93-
9487 source,
9588 size = 48 ,
9689 name,
@@ -104,6 +97,8 @@ export const AvatarBase = (props: AvatarProps) => {
10497 testID,
10598 } = props ;
10699
100+ const theme = useTheme ( ) ;
101+
107102 const { imageHasFailedLoading } = { imageHasFailedLoading : false } ;
108103 const imageUnavailable = ! source || imageHasFailedLoading ;
109104
@@ -144,6 +139,3 @@ export const AvatarBase = (props: AvatarProps) => {
144139 </ View >
145140 ) ;
146141} ;
147-
148- export const Avatar = withTheme ( AvatarBase ) ;
149- export default Avatar ;
0 commit comments