Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function getJazziconSeed(address: string) {
/**
* @deprecated Please update your code to use `AvatarAccount` from `@metamask/design-system-react-native`.
* The API may have changed — compare props before migrating.
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/AvatarAccount/README.md}
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/Jazzicon/README.md MMDS README}
* @see {@link https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/MIGRATION.md#jazzicon-temp-component Migration Guide}
*/
const AvatarAccount = ({
type: avatarType = DEFAULT_AVATARACCOUNT_TYPE,
Expand Down
30 changes: 26 additions & 4 deletions app/components/UI/Identicon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,34 @@
import React, { memo } from 'react';
import { Image, ImageStyle, StyleProp } from 'react-native';
import FadeIn from 'react-native-fade-in-image';
import {
AvatarAccount,
AvatarAccountSize,
AvatarAccountVariant,
} from '@metamask/design-system-react-native';
import { useTheme } from '../../../util/theme';
import { useSelector } from 'react-redux';
import AvatarAccount from '../../../component-library/components/Avatars/Avatar/variants/AvatarAccount';
import { AvatarSize } from '../../../component-library/components/Avatars/Avatar';
import { AvatarAccountType } from '../../../component-library/components/Avatars/Avatar/variants/AvatarAccount/AvatarAccount.types';
import { selectAvatarAccountType } from '../../../selectors/settings';

const AVATAR_SIZE_TO_ACCOUNT_SIZE: Record<AvatarSize, AvatarAccountSize> = {
[AvatarSize.Xs]: AvatarAccountSize.Xs,
[AvatarSize.Sm]: AvatarAccountSize.Sm,
[AvatarSize.Md]: AvatarAccountSize.Md,
[AvatarSize.Lg]: AvatarAccountSize.Lg,
[AvatarSize.Xl]: AvatarAccountSize.Xl,
};

const AVATAR_ACCOUNT_TYPE_TO_VARIANT: Record<
AvatarAccountType,
AvatarAccountVariant
> = {
[AvatarAccountType.JazzIcon]: AvatarAccountVariant.Jazzicon,
[AvatarAccountType.Blockies]: AvatarAccountVariant.Blockies,
[AvatarAccountType.Maskicon]: AvatarAccountVariant.Maskicon,
};

interface IdenticonProps {
/**
* Optional size of the avatar
Expand Down Expand Up @@ -79,9 +101,9 @@ const Identicon: React.FC<IdenticonProps> = ({

const avatar = (
<AvatarAccount
type={avatarAccountType}
accountAddress={address}
size={avatarSize}
variant={AVATAR_ACCOUNT_TYPE_TO_VARIANT[avatarAccountType]}
address={address}
size={AVATAR_SIZE_TO_ACCOUNT_SIZE[avatarSize]}
/>
);

Expand Down
Loading