-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Upgrade lottie-react-native to 6.3.1 #28267
Changes from 1 commit
c0b5f21
4b1e93f
d9ff6fa
7393ec5
65383b6
4c6d87a
32431f4
cd253bb
2d3bfdc
0e8bd09
4b6c82a
4123599
1c08452
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
diff --git a/node_modules/lottie-react-native/src/LottieView.tsx b/node_modules/lottie-react-native/src/LottieView.tsx | ||
index 6372ca2..c5cfad7 100644 | ||
--- a/node_modules/lottie-react-native/src/LottieView.tsx | ||
+++ b/node_modules/lottie-react-native/src/LottieView.tsx | ||
@@ -4,6 +4,7 @@ import { | ||
NativeSyntheticEvent, | ||
ViewProps, | ||
processColor, | ||
+ StyleSheet, | ||
} from 'react-native'; | ||
|
||
import type { LottieViewProps } from './LottieView.types'; | ||
@@ -12,7 +13,7 @@ import NativeLottieAnimationView, { | ||
Commands, | ||
} from './specs/LottieAnimationViewNativeComponent'; | ||
|
||
-type Props = LottieViewProps & { containerProps?: ViewProps }; | ||
+type Props = LottieViewProps & { containerProps?: ViewProps; autoSize?: boolean }; | ||
|
||
const defaultProps: Props = { | ||
source: undefined, | ||
@@ -27,6 +28,7 @@ const defaultProps: Props = { | ||
colorFilters: [], | ||
textFiltersAndroid: [], | ||
textFiltersIOS: [], | ||
+ autoSize: false, | ||
}; | ||
|
||
export class LottieView extends React.PureComponent<Props, {}> { | ||
@@ -132,6 +134,7 @@ export class LottieView extends React.PureComponent<Props, {}> { | ||
textFiltersAndroid, | ||
textFiltersIOS, | ||
resizeMode, | ||
+ autoSize, | ||
...rest | ||
} = this.props; | ||
|
||
@@ -149,6 +152,22 @@ export class LottieView extends React.PureComponent<Props, {}> { | ||
color: processColor(colorFilter.color), | ||
})); | ||
|
||
+ const aspectRatioStyle = sources.sourceJson | ||
+ ? { aspectRatio: (source as any).w / (source as any).h } | ||
+ : undefined; | ||
+ | ||
+ const styleObject = StyleSheet.flatten(style); | ||
+ let sizeStyle; | ||
+ if ( | ||
+ !styleObject || | ||
+ (styleObject.width === undefined && styleObject.height === undefined) | ||
+ ) { | ||
+ sizeStyle = | ||
+ autoSize && sources.sourceJson | ||
+ ? { width: (source as any).w } | ||
+ : StyleSheet.absoluteFill; | ||
+ } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that we want to simply revert the breaking changes in the patch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kosmydel There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we override using props? I don't really like patching There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might also consider passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can be done ) Or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably also put it into some But there is a problem with this approach. When we move to the cc @situchan @roryabraham what do you think? |
||
+ | ||
return ( | ||
<NativeLottieAnimationView | ||
ref={this.captureRef} | ||
@@ -157,7 +176,11 @@ export class LottieView extends React.PureComponent<Props, {}> { | ||
textFiltersAndroid={textFiltersAndroid} | ||
textFiltersIOS={textFiltersIOS} | ||
speed={speed} | ||
- style={style} | ||
+ style={[ | ||
+ aspectRatioStyle, | ||
+ sizeStyle, | ||
+ style, | ||
+ ]} | ||
onAnimationFinish={this.onAnimationFinish} | ||
onAnimationFailure={this.onAnimationFailure} | ||
autoPlay={autoPlay} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only need to update lottie related frameworks. Revert all other changes which are out of scope.
Just replace with this file I generated:
Podfile.lock.zip