Skip to content

Commit

Permalink
fix: container props and its types
Browse files Browse the repository at this point in the history
  • Loading branch information
matinzd committed Apr 1, 2023
1 parent 377a8de commit 7f9766a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions apps/fabric/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const App = () => {
autoPlay={true}
loop={isLoop}
style={styles.lottie}
resizeMode={'contain'}
colorFilters={source === 'local' ? localColorFilter : undefined}
enableMergePathsAndroidForKitKatAndAbove
onAnimationFinish={() => {
Expand Down
22 changes: 10 additions & 12 deletions packages/core/src/LottieView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
NativeSyntheticEvent,
Animated,
processColor,
ViewProps,
} from 'react-native';

import type { AnimatedLottieViewProps } from './LottieView.types';
Expand All @@ -17,7 +18,9 @@ const AnimatedNativeLottieView = Animated.createAnimatedComponent(
NativeLottieAnimationView,
);

const defaultProps: AnimatedLottieViewProps = {
type Props = AnimatedLottieViewProps & { containerProps?: ViewProps };

const defaultProps: Props = {
source: undefined,
progress: 0,
speed: 1,
Expand All @@ -36,17 +39,14 @@ const defaultProps: AnimatedLottieViewProps = {
/**
* View hosting the lottie animation.
*/
export class AnimatedLottieView extends React.PureComponent<
AnimatedLottieViewProps,
{}
> {
export class AnimatedLottieView extends React.PureComponent<Props, {}> {
static defaultProps = defaultProps;

_lottieAnimationViewRef:
| React.ElementRef<typeof NativeLottieAnimationView>
| undefined;

constructor(props: AnimatedLottieViewProps) {
constructor(props: Props) {
super(props);
this.play = this.play.bind(this);
this.reset = this.reset.bind(this);
Expand Down Expand Up @@ -143,20 +143,18 @@ export class AnimatedLottieView extends React.PureComponent<
color: processColor(colorFilter.color),
}));

const defaultStyles = [aspectRatioStyle, sizeStyle];

return (
<View style={[aspectRatioStyle, sizeStyle, style]}>
<View {...this.props.containerProps} style={[...defaultStyles, style]}>
<AnimatedNativeLottieView
ref={this._captureRef}
{...rest}
colorFilters={colorFilters}
textFiltersAndroid={textFiltersAndroid}
textFiltersIOS={textFiltersIOS}
speed={speed}
style={[
aspectRatioStyle,
sizeStyle || { width: '100%', height: '100%' },
style,
]}
style={StyleSheet.absoluteFill}
sourceName={sourceName}
sourceJson={sourceJson}
sourceURL={sourceURL}
Expand Down

0 comments on commit 7f9766a

Please sign in to comment.