From e8d0af2f001fe03ad5cae9442c896cc3987c0820 Mon Sep 17 00:00:00 2001 From: panbibi <1265629139@qq.com> Date: Mon, 3 Apr 2023 14:06:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(Avatar):=E8=B0=83=E6=95=B4Avatar=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E8=89=B2=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/Avatar/index.tsx | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/packages/core/src/Avatar/index.tsx b/packages/core/src/Avatar/index.tsx index c607e01ca..92ab3382c 100644 --- a/packages/core/src/Avatar/index.tsx +++ b/packages/core/src/Avatar/index.tsx @@ -1,12 +1,7 @@ import React from 'react'; import { View, ViewProps, Image, ImageProps, StyleSheet, ActivityIndicator, Text } from 'react-native'; - -const styles = StyleSheet.create({ - default: { - backgroundColor: '#e4e4e4', - overflow: 'hidden', - }, -}); +import { useTheme } from '@shopify/restyle'; +import { Theme } from '../theme'; const defaultImage = require('./assets/user.png'); @@ -34,6 +29,11 @@ export interface AvatarProps extends ViewProps { } const Avatar: React.FC = (props) => { + const theme = useTheme(); + const styles = createStyles({ + color: theme.colors.gray100, + }); + const { style, src = defaultImage, @@ -66,7 +66,7 @@ const Avatar: React.FC = (props) => { }, ]} > - {loading && } + {loading && } = (props) => { }; export default Avatar; + +type CreStyle = { + color: string; +}; + +function createStyles({ color }: CreStyle) { + return StyleSheet.create({ + default: { + backgroundColor: color, + overflow: 'hidden', + }, + }); +}