Skip to content
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
12 changes: 10 additions & 2 deletions app/__mocks__/rive-react-native.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { forwardRef, useImperativeHandle } from 'react';
import React, { forwardRef, useImperativeHandle, useEffect } from 'react';
import { View, ViewProps } from 'react-native';

export interface RiveRef {
Expand Down Expand Up @@ -27,6 +27,7 @@
alignment?: string;
autoplay?: boolean;
stateMachineName?: string;
onPlay?: () => void;
};

const DEFAULT_TEST_ID = 'mock-rive-animation';
Expand All @@ -48,12 +49,19 @@
};

const RiveMock = forwardRef<RiveRef, MockRiveProps>(
({ testID = DEFAULT_TEST_ID, mockedMethods, ...viewProps }, ref) => {
({ testID = DEFAULT_TEST_ID, mockedMethods, onPlay, ...viewProps }, ref) => {
const methods = createMockedMethods(mockedMethods);
updateLastMockedMethods(methods);

useImperativeHandle(ref, () => methods, [methods]);

useEffect(() => {
if (onPlay) {
onPlay();
}
// eslint-disable-next-line react-hooks/exhaustive-deps

Check warning on line 62 in app/__mocks__/rive-react-native.tsx

View workflow job for this annotation

GitHub Actions / scripts (lint)

React Compiler has skipped optimizing this component because one or more React ESLint rules were disabled. React Compiler only works when your components follow all the rules of React, disabling them may result in unexpected or incorrect behavior
}, []);

return <View testID={testID} {...viewProps} />;
},
);
Expand Down
14 changes: 10 additions & 4 deletions app/components/UI/FoxAnimation/FoxAnimation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useRef } from 'react';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { StyleSheet, Platform, View } from 'react-native';
import Rive, { Alignment, Fit, RiveRef } from 'rive-react-native';
import { useSafeAreaInsets, EdgeInsets } from 'react-native-safe-area-context';
Expand Down Expand Up @@ -77,6 +77,8 @@ const FoxAnimation = ({
const insets = useSafeAreaInsets();
const styles = createStyles(hasFooter, insets);

const [isPlaying, setIsPlaying] = useState(false);

const showFoxAnimation = useCallback(async () => {
if (foxRef.current && trigger) {
try {
Expand All @@ -88,8 +90,10 @@ const FoxAnimation = ({
}, [foxRef, trigger]);

useEffect(() => {
showFoxAnimation();
}, [showFoxAnimation]);
if (isPlaying) {
showFoxAnimation();
}
}, [showFoxAnimation, isPlaying]);

return (
<View style={[styles.foxAnimationWrapper]}>
Expand All @@ -99,9 +103,11 @@ const FoxAnimation = ({
source={FoxAnimationRive}
fit={Fit.Contain}
alignment={Alignment.Center}
autoplay={false}
stateMachineName="FoxRaiseUp"
testID="fox-animation"
onPlay={() => {
setIsPlaying(true);
}}
/>
</View>
);
Expand Down
18 changes: 14 additions & 4 deletions app/components/UI/OnboardingAnimation/OnboardingAnimation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
import React, {
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import { View, Animated, Easing, StyleSheet } from 'react-native';
import Rive, { Fit, Alignment, RiveRef } from 'rive-react-native';

Expand Down Expand Up @@ -67,6 +73,8 @@ const OnboardingAnimation = ({
const { themeAppearance } = useAppThemeFromContext();
const styles = createStyles();

const [isPlaying, setIsPlaying] = useState(false);

const moveLogoUp = useCallback(() => {
Animated.parallel([
Animated.timing(logoPosition, {
Expand Down Expand Up @@ -118,10 +126,10 @@ const OnboardingAnimation = ({
]);

useEffect(() => {
if (startOnboardingAnimation) {
if (startOnboardingAnimation && isPlaying) {
startRiveAnimation();
}
}, [startOnboardingAnimation, startRiveAnimation]);
}, [startRiveAnimation, startOnboardingAnimation, isPlaying]);

return (
<>
Expand All @@ -141,9 +149,11 @@ const OnboardingAnimation = ({
source={MetaMaskWordmarkAnimation}
fit={Fit.Contain}
alignment={Alignment.Center}
autoplay={false}
stateMachineName="WordmarkBuildUp"
testID="metamask-wordmark-animation"
onPlay={() => {
setIsPlaying(true);
}}
/>
</Animated.View>
</View>
Expand Down
Loading