LottieDelayViewで不必要と思われるPropsを削除

This commit is contained in:
harukin-expo-dev-env 2024-08-31 08:44:08 +00:00
parent 8a8af6f5a3
commit ab8de7a8c0
2 changed files with 12 additions and 33 deletions

View File

@ -1,17 +1,11 @@
import React, { CSSProperties, FC, useEffect, useState } from "react"; import React, { FC, useEffect, useRef, useState } from "react";
import LottieView, { AnimationObject } from "lottie-react-native"; import LottieView from "lottie-react-native";
import { ViewStyle } from "react-native";
type Props = { type Props = {
progress: number; progress: number;
speed: number;
style: ViewStyle;
source: AnimationObject;
lottieRef: React.RefObject<LottieView>;
loop: boolean;
}; };
export const LottieDelayView: FC<Props> = (props) => { export const LottieDelayView: FC<Props> = ({ progress }) => {
const { progress, speed, style, source, lottieRef, loop } = props; const lottieRef = useRef<LottieView>();
const [progressState, setProgressState] = useState(undefined); const [progressState, setProgressState] = useState(undefined);
useEffect(() => { useEffect(() => {
if (progress == 0) { if (progress == 0) {
@ -23,11 +17,11 @@ export const LottieDelayView: FC<Props> = (props) => {
return ( return (
<LottieView <LottieView
progress={progressState} progress={progressState}
speed={speed} speed={1.4}
style={style} style={{ width: 80, height: 80 }}
source={source} loop={false}
source={require("../../assets/939-star.json")}
ref={lottieRef} ref={lottieRef}
loop={loop}
onAnimationFinish={(isCanceled) => { onAnimationFinish={(isCanceled) => {
setProgressState(progress); setProgressState(progress);
}} }}

View File

@ -97,7 +97,6 @@ export default function Sign(props) {
setPreStation(returnData[0]); setPreStation(returnData[0]);
setNexStation(returnData[1]); setNexStation(returnData[1]);
}; };
const lottieRef = useRef();
const isMatsuyama = currentStation[0].StationNumber == "Y55"; const isMatsuyama = currentStation[0].StationNumber == "Y55";
//const isMatsuyama = true; //const isMatsuyama = true;
const favoliteChanger = () => { const favoliteChanger = () => {
@ -133,18 +132,12 @@ export default function Sign(props) {
backgroundColor: "#fff", backgroundColor: "#fff",
}} }}
source={{ source={{
uri: "https://cdn.lottielab.com/l/D4m3dmEqsjVN77.json?s", uri: "https://cdn.lottielab.com/l/D4m3dmEqsjVN77.json",
}} }}
/> />
)} )}
<StationNumberMaker <StationNumberMaker {...{ currentStation, isMatsuyama }} />
currentStation={currentStation} <StationNameArea {...{ currentStation, isMatsuyama }} />
isMatsuyama={isMatsuyama}
/>
<StationNameArea
currentStation={currentStation}
isMatsuyama={isMatsuyama}
/>
{isCurrentStation ? ( {isCurrentStation ? (
<View style={{ position: "absolute", right: 0, top: 0 }}> <View style={{ position: "absolute", right: 0, top: 0 }}>
<MaterialCommunityIcons <MaterialCommunityIcons
@ -159,14 +152,7 @@ export default function Sign(props) {
style={{ position: "absolute", right: -15, top: -20 }} style={{ position: "absolute", right: -15, top: -20 }}
onPress={favoliteChanger} onPress={favoliteChanger}
> >
<LottieDelayView <LottieDelayView progress={testButtonStatus ? 1 : 0} />
progress={testButtonStatus ? 1 : 0}
speed={1.4}
style={{ width: 80, height: 80 }}
source={require("../../assets/939-star.json")}
lottieRef={lottieRef}
loop={false}
/>
</TouchableOpacity> </TouchableOpacity>
)} )}
@ -179,7 +165,6 @@ export default function Sign(props) {
); );
} }
const styleSheet = { const styleSheet = {
外枠: { 外枠: {
width: wp("80%"), width: wp("80%"),