Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix pills colors #6083

Merged
merged 2 commits into from
Feb 17, 2025
Merged
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
18 changes: 8 additions & 10 deletions src/components/Modal/WalletVaultCreationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import HexagonIcon from '../HexagonIcon';
import KeeperModal from '../KeeperModal';
import Text from '../KeeperText';
import CardPill from '../CardPill';
import { getWalletTags } from 'src/utils/utilities';
import WalletIcon from 'src/assets/images/daily_wallet.svg';
import CollaborativeIcon from 'src/assets/images/collaborative_vault_white.svg';
import VaultIcon from 'src/assets/images/vault_icon.svg';
import { EntityKind, VaultType } from 'src/services/wallets/enums';
import Colors from 'src/theme/Colors';
import useWalletAsset from 'src/hooks/useWalletAsset';

const getWalletIcon = (walletType) => {
if (walletType === EntityKind.VAULT) {
Expand All @@ -34,14 +34,8 @@ function WalletCreatedModalContent(props) {
borderColor={`${colorMode}.dullGreyBorder`}
>
<Box style={styles.pillsContainer}>
{props.tags?.map((tag, index) => {
return (
<CardPill
key={tag}
heading={tag}
backgroundColor={index % 2 !== 0 ? null : `${colorMode}.SignleSigCardPillBackColor`}
/>
);
{props.tags?.map(({ tag, color }) => {
return <CardPill key={tag} heading={tag} backgroundColor={color} />;
})}
</Box>
<Box style={styles.walletVaultInfoWrapper}>
Expand Down Expand Up @@ -75,7 +69,11 @@ function WalletCreatedModalContent(props) {
);
}
function WalletVaultCreationModal(props) {
const { getWalletTags } = useWalletAsset();
const { colorMode } = useColorMode();
const wallet = {
type: props.walletType,
};

const Content = useCallback(() => {
return (
Expand All @@ -84,7 +82,7 @@ function WalletVaultCreationModal(props) {
walletType={props.walletType}
walletName={props.walletName}
walletDescription={props.walletDescription}
tags={getWalletTags(props.walletType)}
tags={getWalletTags(wallet)}
/>
);
}, [props.descriptionMessage, props.walletType, props.walletName, props.walletDescription]);
Expand Down
63 changes: 32 additions & 31 deletions src/hooks/useWalletAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,43 +46,45 @@ const useWalletAsset = () => {
? 'Single-key'
: `${wallet.scheme.m} of ${wallet.scheme.n}`;

const TAG_COLORS = [
Colors.LabelLight3,
Colors.DesertSand,
Colors.Aquamarine,
Colors.mintGreen,
Colors.LightMossGreen,
];

const getWalletTags = (wallet: Wallet | Vault) => {
let tags: { tag: string; color?: string }[] = [];

if (wallet.entityKind === EntityKind.VAULT) {
switch (wallet.type) {
case VaultType.SINGE_SIG:
return [
{ tag: 'Cold', color: Colors.mintGreen },
{ tag: 'Single-key', color: Colors.LabelLight3 },
];
tags = [{ tag: 'Cold' }, { tag: 'Single-key' }];
break;
case VaultType.COLLABORATIVE:
return [
{ tag: 'Collaborative', color: Colors.mintGreen },
{ tag: getSchemeTag(wallet as Vault), color: Colors.DesertSand },
];
tags = [{ tag: 'Collaborative' }, { tag: getSchemeTag(wallet as Vault) }];
break;
case VaultType.ASSISTED:
return [
{ tag: 'Assisted', color: Colors.LightMossGreen },
{ tag: getSchemeTag(wallet as Vault), color: Colors.DesertSand },
];
tags = [{ tag: 'Assisted' }, { tag: getSchemeTag(wallet as Vault) }];
break;
case VaultType.TIMELOCKED:
return [
{ tag: 'Timelocked', color: Colors.mintGreen },
{ tag: getSchemeTag(wallet as Vault), color: Colors.DesertSand },
];
tags = [{ tag: 'Timelocked' }, { tag: getSchemeTag(wallet as Vault) }];
break;
case VaultType.CANARY:
return [{ tag: 'Canary', color: Colors.LightMossGreen }];
tags = [{ tag: 'Canary' }];
break;
case VaultType.MINISCRIPT:
return [
tags = [
wallet.scheme.m !== 1 || wallet.scheme.n !== 1 ? { tag: 'Multi-key' } : null,
wallet.scheme.miniscriptScheme?.usedMiniscriptTypes.includes(
MiniscriptTypes.INHERITANCE
) && { tag: 'Inheritance Key', color: Colors.Aquamarine },
{ tag: getSchemeTag(wallet as Vault), color: Colors.DesertSand },
) && { tag: getSchemeTag(wallet as Vault) },
{ tag: 'Inheritance key' },
].filter(Boolean);
break;
default:
return [
{ tag: 'Multi-key', color: Colors.LabelLight3 },
{ tag: getSchemeTag(wallet as Vault), color: Colors.DesertSand },
];
tags = [{ tag: 'Multi-key' }, { tag: getSchemeTag(wallet as Vault) }];
}
} else {
let walletKind = wallet.type === WalletType.DEFAULT ? 'Hot Wallet' : 'Imported Wallet';
Expand All @@ -93,14 +95,13 @@ const useWalletAsset = () => {
const isTaprootWallet =
derivationPath && WalletUtilities.getPurpose(derivationPath) === DerivationPurpose.BIP86;

return [
{ tag: walletKind, color: Colors.DesertSand },
{
tag: isTaprootWallet ? 'Taproot' : 'Single-Key',
color: isTaprootWallet ? Colors.PaleCyan : Colors.LabelLight3,
},
];
tags = [{ tag: walletKind }, { tag: isTaprootWallet ? 'Taproot' : 'Single-Key' }];
}

return tags.map((tag, index) => ({
...tag,
color: TAG_COLORS[index % TAG_COLORS.length],
}));
};

return { getWalletIcon, getWalletCardGradient, getWalletTags };
Expand Down
25 changes: 5 additions & 20 deletions src/screens/AddWalletScreen/ConfirmWalletDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,8 @@ function ConfirmWalletDetails({ route }) {
<Box>
<Box backgroundColor={`${colorMode}.seashellWhite`} style={styles.walletVaultInfoContainer}>
<Box style={styles.pillsContainer}>
{tags?.map((tag, index) => {
return (
<CardPill
key={tag.key}
heading={tag.tag}
backgroundColor={
index % 2 !== 0 ? null : `${colorMode}.SignleSigCardPillBackColor`
}
/>
);
{tags?.map(({ tag, color }) => {
return <CardPill key={tag} heading={tag} backgroundColor={color} />;
})}
</Box>
<Box style={styles.walletVaultInfoWrapper}>
Expand Down Expand Up @@ -286,20 +278,13 @@ function ConfirmWalletDetails({ route }) {
...tag,
key: `tag-${index}-${tag.tag}`,
}));

return (
<Box>
<Box backgroundColor={`${colorMode}.seashellWhite`} style={styles.walletVaultInfoContainer}>
<Box style={styles.pillsContainer}>
{tags?.map((tag, index) => {
return (
<CardPill
key={tag.key}
heading={tag.tag}
backgroundColor={
index % 2 !== 0 ? null : `${colorMode}.SignleSigCardPillBackColor`
}
/>
);
{tags?.map(({ tag, color }) => {
return <CardPill key={tag} heading={tag} backgroundColor={color} />;
})}
</Box>
<Box style={styles.walletVaultInfoWrapper}>
Expand Down
9 changes: 2 additions & 7 deletions src/screens/Home/components/Wallet/WalletCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React from 'react';
import { Box } from 'native-base';
import { StyleSheet } from 'react-native';
import Text from 'src/components/KeeperText';
Expand Down Expand Up @@ -65,12 +65,7 @@ const WalletCard: React.FC<WalletCardProps> = ({
<WalletLine style={styles.walletLine} width={wp(180)} height={hp(200)} />
<Box style={styles.pillsContainer}>
{tags?.map(({ tag, color }, index) => (
<CardPill
key={tag}
heading={tag}
backgroundColor={color}
cardStyle={index % 2 !== 0 && styles.secondCard}
/>
<CardPill key={tag} heading={tag} backgroundColor={color} />
))}
</Box>

Expand Down
Loading