Skip to content

Commit

Permalink
fix(Avatar):调整Avatar主题色配置
Browse files Browse the repository at this point in the history
  • Loading branch information
panbibi committed Apr 3, 2023
1 parent 4e2f15a commit e8d0af2
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions packages/core/src/Avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -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');

Expand Down Expand Up @@ -34,6 +29,11 @@ export interface AvatarProps extends ViewProps {
}

const Avatar: React.FC<AvatarProps> = (props) => {
const theme = useTheme<Theme>();
const styles = createStyles({
color: theme.colors.gray100,
});

const {
style,
src = defaultImage,
Expand Down Expand Up @@ -66,7 +66,7 @@ const Avatar: React.FC<AvatarProps> = (props) => {
},
]}
>
{loading && <ActivityIndicator size="small" color="gray" />}
{loading && <ActivityIndicator size="small" color={theme.colors.gray300} />}
</View>

<Image
Expand All @@ -79,3 +79,16 @@ const Avatar: React.FC<AvatarProps> = (props) => {
};

export default Avatar;

type CreStyle = {
color: string;
};

function createStyles({ color }: CreStyle) {
return StyleSheet.create({
default: {
backgroundColor: color,
overflow: 'hidden',
},
});
}

0 comments on commit e8d0af2

Please sign in to comment.