Skip to content

Commit

Permalink
fix: rename src -> source to be compliant with other libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
hannojg committed Dec 12, 2023
1 parent b171da1 commit 488a84f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import HandsLottie from './Hands.json';
export default function App() {
return (
<SafeAreaView style={styles.flex1}>
<SkiaSkottieView style={styles.flex1} src={HandsLottie} />
<SkiaSkottieView style={styles.flex1} source={HandsLottie} />
</SafeAreaView>
);
}
Expand Down
4 changes: 2 additions & 2 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function SkottieAnimation({ source }: { source: AnimationObject }) {
<SkiaSkottieView
resizeMode="contain"
style={styles.flex1}
src={source}
source={source}
autoPlay={true}
loop={true}
/>
Expand Down Expand Up @@ -72,7 +72,7 @@ function SkottieImperativeAPI({ source }: { source: AnimationObject }) {
ref={skottieRef}
resizeMode="contain"
style={styles.flex1}
src={source}
source={source}
loop={true}
/>
</View>
Expand Down
16 changes: 8 additions & 8 deletions src/SkiaSkottieView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { Image } from 'react-native';
export type ResizeMode = 'cover' | 'contain' | 'stretch';

export type SkiaSkottieViewProps = NativeSkiaViewProps & {
src: number | string | AnimationObject;
source: number | string | AnimationObject;

/**
* A boolean flag indicating whether or not the animation should start automatically when
Expand Down Expand Up @@ -81,12 +81,12 @@ export const SkiaSkottieView = React.forwardRef<
//#region Compute values
const source = useMemo(() => {
let _source: string | { sourceDotLottieURI: string };
if (typeof props.src === 'string') {
_source = props.src;
} else if (typeof props.src === 'object') {
_source = JSON.stringify(props.src);
} else if (typeof props.src === 'number') {
const uri = Image.resolveAssetSource(props.src)?.uri;
if (typeof props.source === 'string') {
_source = props.source;
} else if (typeof props.source === 'object') {
_source = JSON.stringify(props.source);
} else if (typeof props.source === 'number') {
const uri = Image.resolveAssetSource(props.source)?.uri;
if (uri == null) {
throw Error(
'[react-native-skottie] Invalid src prop provided. Cant resolve asset source.'
Expand All @@ -97,7 +97,7 @@ export const SkiaSkottieView = React.forwardRef<
throw Error('[react-native-skottie] Invalid src prop provided.');
}
return _source;
}, [props.src]);
}, [props.source]);

const skottieAnimation = useMemo(() => {
if (typeof source === 'string') {
Expand Down

0 comments on commit 488a84f

Please sign in to comment.