iosでもlottieアニメが動作するように修正

This commit is contained in:
harukin-OneMix4 2023-02-22 20:03:39 +09:00
parent 97d05571e5
commit 1c67d1d486

View File

@ -99,7 +99,6 @@ export default function Sign(props) {
style={{ position: "absolute", right: -15, top: -20 }} style={{ position: "absolute", right: -15, top: -20 }}
onPress={() => { onPress={() => {
if (testButtonStatus) { if (testButtonStatus) {
lottieRef.current.play(35, 7);
const otherData = favoriteStation.filter((d) => { const otherData = favoriteStation.filter((d) => {
const compare = JSON.stringify(d); const compare = JSON.stringify(d);
const current = JSON.stringify(currentStation); const current = JSON.stringify(currentStation);
@ -112,7 +111,6 @@ export default function Sign(props) {
AS.setItem("favoriteStation", JSON.stringify(otherData)); AS.setItem("favoriteStation", JSON.stringify(otherData));
setFavoriteStation(otherData); setFavoriteStation(otherData);
} else { } else {
lottieRef.current.play(7, 35);
let ret = favoriteStation; let ret = favoriteStation;
console.log(currentStation); console.log(currentStation);
ret.push(currentStation); ret.push(currentStation);
@ -122,12 +120,12 @@ export default function Sign(props) {
setTestButtonStatus(!testButtonStatus); setTestButtonStatus(!testButtonStatus);
}} }}
> >
<LottieView <LottieDelayView
progress={testButtonStatus ? 1 : 0} progress={testButtonStatus ? 1 : 0}
speed={1.4} speed={1.4}
style={{ width: 80, height: 80 }} style={{ width: 80, height: 80 }}
source={require("../../assets/939-star.json")} source={require("../../assets/939-star.json")}
ref={lottieRef} lottieRef={lottieRef}
loop={false} loop={false}
/> />
</TouchableOpacity> </TouchableOpacity>
@ -141,6 +139,37 @@ export default function Sign(props) {
); );
} }
const LottieDelayView = ({
progress,
speed,
style,
source,
lottieRef,
loop,
}) => {
const [progressState, setProgressState] = useState(undefined);
useEffect(() => {
if (progress == 0) {
lottieRef.current.play(progressState !== undefined ? 35 : 7, 7);
} else {
lottieRef.current.play(progressState !== undefined ? 7 : 35, 35);
}
}, [progress]);
return (
<LottieView
progress={progressState}
speed={speed}
style={style}
source={source}
ref={lottieRef}
loop={loop}
onAnimationFinish={(isCanceled) => {
console.log("finish");
setProgressState(progress);
}}
/>
);
};
const NexPreStationLine = ({ nexStation, preStation }) => { const NexPreStationLine = ({ nexStation, preStation }) => {
return ( return (
<View style={styleSheet.下枠フレーム}> <View style={styleSheet.下枠フレーム}>