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

feat: snaps dynamic UI #12429

Open
wants to merge 102 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
1a12630
added content from the original POC branch
Daniel-Cross Nov 22, 2024
280b4a7
working branch
Daniel-Cross Nov 26, 2024
fc9b773
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Nov 26, 2024
24f219e
fixed import issue
Daniel-Cross Nov 27, 2024
6c7f28d
add SnapInterfaceController to types
owencraston Nov 28, 2024
02f2054
add requestUserApproval snap method
owencraston Nov 28, 2024
f86e326
render snaps dialog
owencraston Nov 28, 2024
1426dc6
disable old state check
owencraston Nov 28, 2024
4bf801e
working dialogs except for custom
Daniel-Cross Dec 4, 2024
db88bb6
added updateInterface
Daniel-Cross Dec 5, 2024
2786acd
input on custom dialog now working
Daniel-Cross Dec 10, 2024
8d20924
removed some unused imports and comsole logs
Daniel-Cross Dec 13, 2024
f0d31c4
added missing components
Daniel-Cross Dec 13, 2024
351cebf
removed debounce
Daniel-Cross Dec 13, 2024
04876a5
resolved conflicts
Daniel-Cross Dec 16, 2024
34bed71
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Dec 16, 2024
d8aea79
changed import location
Daniel-Cross Dec 17, 2024
2f34a7d
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Dec 17, 2024
0b14396
updated snapshots
Daniel-Cross Dec 17, 2024
c141fb5
fix engine lint errors
owencraston Dec 18, 2024
93a3d17
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Dec 18, 2024
7bc4a32
fix engine tests
owencraston Dec 18, 2024
a3d5413
add @nobles/hashes
owencraston Dec 18, 2024
b180225
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Dec 18, 2024
683f4cd
updated snapshots
Daniel-Cross Dec 18, 2024
956aac3
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Dec 19, 2024
c5664c1
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Dec 19, 2024
8666385
updated based on feedback and synced files with the extension
Daniel-Cross Dec 21, 2024
4fecdd1
resolved conflicts
Daniel-Cross Dec 21, 2024
41923b1
added input props
Daniel-Cross Dec 25, 2024
26476fb
made changes to types for input
Daniel-Cross Dec 28, 2024
dcd89af
addressed footer type issue
Daniel-Cross Dec 29, 2024
29ea7f6
fixed some liter issues
Daniel-Cross Dec 31, 2024
ef4832b
fixed colours
Daniel-Cross Dec 31, 2024
5da4e2e
fixed colour import
Daniel-Cross Dec 31, 2024
e8bd935
fixed global element declaration issue
Daniel-Cross Dec 31, 2024
c8f3a18
removed the need to use flex on mobile
Daniel-Cross Dec 31, 2024
d7d00ad
changed enum related values in footer
Daniel-Cross Dec 31, 2024
d8e191c
fixed linting issues from enums
Daniel-Cross Dec 31, 2024
5f42682
removed enum usage
Daniel-Cross Jan 1, 2025
125e2da
removed unused import
Daniel-Cross Jan 1, 2025
53a16d9
added a package for handling html entities
Daniel-Cross Jan 7, 2025
cde7cee
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Jan 7, 2025
59f2c7d
yarn deduplicate
Daniel-Cross Jan 7, 2025
4a1d0fb
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Jan 7, 2025
79d81bf
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Jan 8, 2025
7d03e1b
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Jan 9, 2025
f9665d3
Add SnapInterfaceController:stateChange to permissions
owencraston Jan 11, 2025
82bbfd5
working snaps dialogs again
Daniel-Cross Jan 11, 2025
4c43ab0
fixed conflicts from main
Daniel-Cross Jan 12, 2025
ece756d
added some tests
Daniel-Cross Jan 12, 2025
02e9381
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Jan 13, 2025
d4bb190
added snapDialogApproval tests
Daniel-Cross Jan 13, 2025
8946c40
removed unused test
Daniel-Cross Jan 13, 2025
9313660
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Jan 13, 2025
b4cee38
moved test files
Daniel-Cross Jan 13, 2025
cb608e7
fixed conflicts from main
Daniel-Cross Jan 14, 2025
ea17669
added more tests for snapsInterfaceContext
Daniel-Cross Jan 14, 2025
e7b545e
added tests for snaps ui input
Daniel-Cross Jan 14, 2025
e11a162
added tests for formTextField
Daniel-Cross Jan 14, 2025
d5691e6
fixed liting issues on tests
Daniel-Cross Jan 14, 2025
fb7769a
fixed linting for heading tests
Daniel-Cross Jan 14, 2025
e02d763
added tests for box
Daniel-Cross Jan 14, 2025
1f7d313
added Box tests
Daniel-Cross Jan 14, 2025
2830669
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Jan 14, 2025
e548a60
updated tests for linter
Daniel-Cross Jan 14, 2025
96e2b62
more linter fixes
Daniel-Cross Jan 14, 2025
478cf3a
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Jan 14, 2025
1b7d9a7
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Jan 14, 2025
2302c37
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Jan 15, 2025
2ea5db0
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Jan 16, 2025
dbce24c
Update app/core/Permissions/specifications.js
Daniel-Cross Jan 17, 2025
2097ad7
Update app/core/Snaps/SnapsMethodMiddleware.ts
Daniel-Cross Jan 17, 2025
09d3ea4
Update app/components/Approvals/Snaps/SnapUIRenderer/SnapUIRenderer.tsx
Daniel-Cross Jan 17, 2025
590a82a
Update app/components/Approvals/Snaps/SnapUIRenderer/utils.ts
Daniel-Cross Jan 17, 2025
c522d51
Update app/components/Approvals/Snaps/SnapUIRenderer/utils.ts
Daniel-Cross Jan 17, 2025
a574fbd
working custom snaps buttons
Daniel-Cross Jan 28, 2025
ede58f0
working confirm button
Daniel-Cross Jan 28, 2025
9b3be41
added icons to custom buttons
Daniel-Cross Jan 29, 2025
f78b392
resolved conflicts
Daniel-Cross Jan 29, 2025
fc0fb8a
updated tests
Daniel-Cross Jan 29, 2025
2ff8865
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Jan 29, 2025
a79a624
get snap icon
owencraston Jan 30, 2025
221785e
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Feb 3, 2025
3fe8fd9
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Feb 3, 2025
67834d7
fixed some tests
Daniel-Cross Feb 3, 2025
1b55d6c
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Feb 4, 2025
9e9ea6c
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Feb 4, 2025
8537e3c
working footer tests
Daniel-Cross Feb 4, 2025
33b9cb6
fixed lint regarding avatar icon size
Daniel-Cross Feb 4, 2025
89e1765
updated text component to accept fontWeight
Daniel-Cross Feb 4, 2025
7237a9a
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Feb 4, 2025
b5a80d6
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Feb 5, 2025
44451ab
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Feb 5, 2025
f8f0b2f
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Feb 5, 2025
32fb7dd
removed button type
Daniel-Cross Feb 5, 2025
b5fef70
updated tests and snapshots
Daniel-Cross Feb 6, 2025
8fde153
Update app/components/Approvals/Snaps/SnapUIRenderer/components/box.ts
Daniel-Cross Feb 6, 2025
c8fb01e
Update app/components/Approvals/Snaps/SnapUIRenderer/components/conta…
Daniel-Cross Feb 6, 2025
563dab4
Merge branch 'main' into epic/snaps-ui
Daniel-Cross Feb 7, 2025
58e7fe6
snaps almost working, some performance issue and issues with the onPr…
Daniel-Cross Feb 9, 2025
526fcc9
merged main iand fixed conflicts
Daniel-Cross Feb 9, 2025
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 @@ -20,6 +20,7 @@ import {
} from './AvatarFavicon.constants';
import stylesheet from './AvatarFavicon.styles';
import { AvatarFaviconProps } from './AvatarFavicon.types';
import { AvatarSize } from '../../Avatar.types';

const AvatarFavicon = ({
imageSource,
Expand Down Expand Up @@ -50,7 +51,7 @@ const AvatarFavicon = ({
// requires that the domain is passed in as a prop from the parent
const renderFallbackFavicon = () => (
<Icon
size={ICONSIZE_BY_AVATARSIZE[size]}
size={ICONSIZE_BY_AVATARSIZE[size.toLowerCase() as AvatarSize]}
name={DEFAULT_AVATARFAVICON_ERROR_ICON}
/>
);
Expand Down Expand Up @@ -91,21 +92,26 @@ const AvatarFavicon = ({
/>
) : null;

const renderImage = () => (
<Image
testID={AVATARFAVICON_IMAGE_TESTID}
source={imageSource}
style={styles.image}
resizeMode={'contain'}
onError={onError}
/>
);
const renderImage = () =>
imageSource && (
<Image
testID={AVATARFAVICON_IMAGE_TESTID}
source={imageSource}
style={styles.image}
resizeMode={'contain'}
onError={onError}
/>
);

const renderFavicon = () => (svgSource ? renderSvg() : renderImage());

return (
<AvatarBase size={size} style={styles.base} {...props}>
{error || !isValidSource ? renderFallbackFavicon() : renderFavicon()}
<AvatarBase
size={size.toLowerCase() as AvatarSize}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not be modifying DS components to accept our props, that is what the mapping functions are for

style={styles.base}
{...props}
>
{error ? renderFallbackFavicon() : renderFavicon()}
</AvatarBase>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Third party dependencies.
import { ImageSourcePropType } from 'react-native';

// External dependencies.
import { AvatarBaseProps } from '../../foundation/AvatarBase';

/**
Expand All @@ -11,7 +9,7 @@ export interface AvatarFaviconProps extends AvatarBaseProps {
/**
* A favicon image from either a local or remote source.
*/
imageSource: ImageSourcePropType;
imageSource?: ImageSourcePropType;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`AvatarFavicon should match the snapshot 1`] = `
<AvatarBase
size="32"
size="md"
style={{}}
>
<Image
Expand All @@ -27,7 +27,7 @@ exports[`AvatarFavicon should match the snapshot 1`] = `

exports[`AvatarFavicon should render SVG 1`] = `
<AvatarBase
size="32"
size="md"
style={{}}
>
<Image
Expand All @@ -52,7 +52,7 @@ exports[`AvatarFavicon should render SVG 1`] = `

exports[`AvatarFavicon should render fallback when svg has error 1`] = `
<AvatarBase
size="32"
size="md"
style={{}}
>
<Image
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// Third party dependencies.
import { ColorValue, TouchableOpacityProps } from 'react-native';
import {
ColorValue,
StyleProp,
TextStyle,
TouchableOpacityProps,
} from 'react-native';

// External dependencies.
import { IconProps } from '../../../../Icons/Icon';
Expand Down Expand Up @@ -55,6 +60,10 @@ export interface ButtonBaseProps extends TouchableOpacityProps {
* An optional loading state of Button.
*/
loading?: boolean;
/**
* An optional text props of Button.
*/
textProps?: StyleProp<TextStyle>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const ButtonPrimary = ({
onPressOut,
isDanger = false,
label,
startIconName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @brianacnguyen pointed out, what is the goal of this change?

endIconName,
...props
}: ButtonPrimaryProps) => {
const [pressed, setPressed] = useState(false);
Expand Down Expand Up @@ -60,9 +62,9 @@ const ButtonPrimary = ({
label
);

const renderLoading = () => (
<ActivityIndicator size="small" color={DEFAULT_BUTTONPRIMARY_LABEL_COLOR} />
);
const renderLoading = () => (
<ActivityIndicator size="small" color={DEFAULT_BUTTONPRIMARY_LABEL_COLOR} />
);

return (
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,6 @@ exports[`ButtonPrimary render matches latest snapshot 1`] = `
}
}
>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of changes in here like this that seem irrelevant

<SvgMock
color="#ffffff"
height={16}
name="Add"
style={
{
"height": 16,
"marginRight": 8,
"width": 16,
}
}
width={16}
/>
<Text
accessibilityRole="text"
style={
Expand All @@ -50,18 +37,5 @@ exports[`ButtonPrimary render matches latest snapshot 1`] = `
>
Sample label
</Text>
<SvgMock
color="#ffffff"
height={16}
name="AddSquare"
style={
{
"height": 16,
"marginLeft": 8,
"width": 16,
}
}
width={16}
/>
</TouchableOpacity>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { ReactNode } from 'react';
import { TextColor } from '../Texts/Text/Text.types';
import Text from '../Texts/Text';
import { Box } from '../../../components/UI/Box';
import { RowVariant } from '../../../components/Snaps/SnapUIRenderer/components/row';
import { AlignItems } from '../../../components/Snaps/SnapUIRenderer/components/box.types';
import { FlexDirection } from '../../../components/Snaps/SnapUIRenderer/components/box.types';

export type ConfirmInfoRowValueDoubleProps = {
left: ReactNode;
right: ReactNode;
variant?: RowVariant;
};

const LEFT_TEXT_COLORS = {
[RowVariant.Default]: TextColor.Muted,
[RowVariant.Critical]: TextColor.ErrorAlternative,
[RowVariant.Warning]: TextColor.Warning,
};

export const ConfirmInfoRowValueDouble = ({
left,
right,
variant = RowVariant.Default,
}: ConfirmInfoRowValueDoubleProps) => {
return (
<Box
flexDirection={FlexDirection.Row}
alignItems={AlignItems.center}
gap={1}
>
{typeof left === 'string' ? (
<Text color={LEFT_TEXT_COLORS[variant] as TextColor}>{left}</Text>
) : (
left
)}
{typeof right === 'string' ? (
<Text color={TextColor.Default}>{right}</Text>
) : (
right
)}
</Box>
);
};
13 changes: 13 additions & 0 deletions app/component-library/components/Texts/Text/Text.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ export enum TextVariant {
BodyXSMedium = 'sBodyXSMedium',
}

/**
* Font weights
*/
export enum FontWeight {
Bold = 'bold',
Medium = 'medium',
Normal = 'normal',
}

/**
* Text colors
*/
Expand Down Expand Up @@ -60,4 +69,8 @@ export interface TextProps extends RNTextProps {
* Temporary prop to enable brand evolution fonts
*/
isBrandEvolution?: boolean;
/**
* Optional font weight for the text
*/
fontWeight?: FontWeight;
}
7 changes: 5 additions & 2 deletions app/components/Nav/Main/RootRPCMethodsUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import { updateSwapsTransaction } from '../../../util/swaps/swaps-transactions';
///: BEGIN:ONLY_INCLUDE_IF(preinstalled-snaps,external-snaps)
import InstallSnapApproval from '../../Approvals/InstallSnapApproval';
import { getGlobalEthQuery } from '../../../util/networks/global-network';
import SnapDialogApproval from '../../Snaps/SnapDialogApproval/SnapsDialogApproval';
///: END:ONLY_INCLUDE_IF
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
import SnapAccountCustomNameApproval from '../../Approvals/SnapAccountCustomNameApproval';
Expand Down Expand Up @@ -335,7 +336,7 @@ const RootRPCMethodsUI = (props) => {
transactionId: transactionMeta.id,
deviceId,
// eslint-disable-next-line no-empty-function
onConfirmationComplete: () => { },
onConfirmationComplete: () => {},
type: 'signTransaction',
}),
);
Expand Down Expand Up @@ -405,7 +406,8 @@ const RootRPCMethodsUI = (props) => {
data &&
data !== '0x' &&
to &&
(await getMethodData(data, networkClientId)).name === TOKEN_METHOD_TRANSFER
(await getMethodData(data, networkClientId)).name ===
TOKEN_METHOD_TRANSFER
) {
let asset = props.tokens.find(({ address }) =>
toLowerCaseEquals(address, to),
Expand Down Expand Up @@ -534,6 +536,7 @@ const RootRPCMethodsUI = (props) => {
///: BEGIN:ONLY_INCLUDE_IF(preinstalled-snaps,external-snaps)
}
<InstallSnapApproval />
<SnapDialogApproval />
{
///: END:ONLY_INCLUDE_IF
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { StyleSheet } from 'react-native';
import { Theme } from '../../../util/theme/models';
import Device from '../../../util/device';

/**
*
* @param params Style sheet params.
* @param params.theme App theme from ThemeContext.
* @param params.vars Inputs that the style sheet depends on.
* @returns StyleSheet object.
*/
const styleSheet = (params: { theme: Theme }) => {
const { theme } = params;
const { colors } = theme;
return StyleSheet.create({
root: {
backgroundColor: colors.background.default,
paddingTop: 24,
paddingLeft: 16,
paddingRight: 16,
borderTopLeftRadius: 20,
borderTopRightRadius: 20,
minHeight: 200,
paddingBottom: Device.isIphoneX() ? 20 : 0,
},
actionContainer: {
flex: 0,
paddingVertical: 16,
justifyContent: 'center',
},
});
};

export default styleSheet;
Loading
Loading