-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29975 from software-mansion-labs/@kosmydel/lottie…
…-react-native-web-support
- Loading branch information
Showing
45 changed files
with
138 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = 'test-file-stub'; |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,39 @@ | ||
import LottieView, {LottieViewProps} from 'lottie-react-native'; | ||
import React, {forwardRef} from 'react'; | ||
import React, {ForwardedRef, forwardRef} from 'react'; | ||
import {View} from 'react-native'; | ||
import DotLottieAnimation from '@components/LottieAnimations/types'; | ||
import useNetwork from '@hooks/useNetwork'; | ||
import styles from '@styles/styles'; | ||
|
||
const Lottie = forwardRef<LottieView, LottieViewProps>((props: LottieViewProps, ref) => { | ||
const aspectRatioStyle = styles.aspectRatioLottie(props.source); | ||
type Props = { | ||
source: DotLottieAnimation; | ||
} & Omit<LottieViewProps, 'source'>; | ||
|
||
function Lottie({source, webStyle, ...props}: Props, ref: ForwardedRef<LottieView>) { | ||
const [isError, setIsError] = React.useState(false); | ||
|
||
useNetwork({onReconnect: () => setIsError(false)}); | ||
|
||
const aspectRatioStyle = styles.aspectRatioLottie(source); | ||
|
||
// If the image fails to load, we'll just render an empty view | ||
if (isError) { | ||
return <View style={aspectRatioStyle} />; | ||
} | ||
|
||
return ( | ||
<View style={[aspectRatioStyle, styles.w100]}> | ||
<LottieView | ||
// eslint-disable-next-line | ||
{...props} | ||
ref={ref} | ||
style={[aspectRatioStyle, props.style]} | ||
webStyle={{...aspectRatioStyle, ...props.webStyle}} | ||
/> | ||
</View> | ||
<LottieView | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
source={source.file} | ||
ref={ref} | ||
style={[aspectRatioStyle, props.style]} | ||
webStyle={{...aspectRatioStyle, ...webStyle}} | ||
onAnimationFailure={() => setIsError(true)} | ||
/> | ||
); | ||
}); | ||
} | ||
|
||
Lottie.displayName = 'Lottie'; | ||
|
||
export default Lottie; | ||
export default forwardRef(Lottie); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import DotLottieAnimation from './types'; | ||
|
||
const DotLottieAnimations: Record<string, DotLottieAnimation> = { | ||
ExpensifyLounge: { | ||
file: require('@assets/animations/ExpensifyLounge.lottie'), | ||
w: 1920, | ||
h: 1080, | ||
}, | ||
FastMoney: { | ||
file: require('@assets/animations/FastMoney.lottie'), | ||
w: 375, | ||
h: 240, | ||
}, | ||
Fireworks: { | ||
file: require('@assets/animations/Fireworks.lottie'), | ||
w: 360, | ||
h: 360, | ||
}, | ||
Hands: { | ||
file: require('@assets/animations/Hands.lottie'), | ||
w: 375, | ||
h: 375, | ||
}, | ||
PreferencesDJ: { | ||
file: require('@assets/animations/PreferencesDJ.lottie'), | ||
w: 375, | ||
h: 240, | ||
}, | ||
ReviewingBankInfo: { | ||
file: require('@assets/animations/ReviewingBankInfo.lottie'), | ||
w: 280, | ||
h: 280, | ||
}, | ||
WorkspacePlanet: { | ||
file: require('@assets/animations/WorkspacePlanet.lottie'), | ||
w: 375, | ||
h: 240, | ||
}, | ||
SaveTheWorld: { | ||
file: require('@assets/animations/SaveTheWorld.lottie'), | ||
w: 375, | ||
h: 240, | ||
}, | ||
Safe: { | ||
file: require('@assets/animations/Safe.lottie'), | ||
w: 625, | ||
h: 400, | ||
}, | ||
Magician: { | ||
file: require('@assets/animations/Magician.lottie'), | ||
w: 853, | ||
h: 480, | ||
}, | ||
}; | ||
|
||
export default DotLottieAnimations; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {LottieViewProps} from 'lottie-react-native'; | ||
|
||
type DotLottieAnimation = { | ||
file: LottieViewProps['source']; | ||
w: number; | ||
h: number; | ||
}; | ||
|
||
export default DotLottieAnimation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters