- ActionSheet内外のLayoutAnimation.configureNext/easeInEaseOutを削除 (グローバルにレイアウト更新を乗っ取り、シートの開閉アニメーションと競合するため) - trainIconStatus: reanimated withRepeat→useInterval+setStateに変更 (UIスレッドの無限アニメーションがActionSheetスプリングと競合するため) - EachTrainInfo: Rules of Hooks違反修正(useRef/useSheetMaxHeightを条件分岐前に移動) - useAutoScroll: InteractionManager.runAfterInteractionsでシート展開完了後に実行 Co-Authored-By: Claude Opus 4.6 <[email protected]>
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import React, { FC, useEffect, useState } from "react";
|
|
import { Ionicons } from "@expo/vector-icons";
|
|
import { SheetManager } from "react-native-actions-sheet";
|
|
import { getType } from "../../../lib/eachTrainInfoCoreLib/getType";
|
|
import { useThemeColors } from "@/lib/theme";
|
|
import type { NavigateFunction } from "@/types";
|
|
|
|
type Props = {
|
|
data: { trainNum: string; limited: string };
|
|
navigate: NavigateFunction;
|
|
from: string;
|
|
};
|
|
export const TrainViewIcon: FC<Props> = ({ data, navigate, from }) => {
|
|
const { fixed } = useThemeColors();
|
|
const [isTrainView, setIsTrainView] = useState(false);
|
|
//トレインビュー表示対象(特急、マリン)かを判定
|
|
useEffect(() => {
|
|
if (!data.limited) return () => {};
|
|
setIsTrainView(
|
|
getType(data.limited.split(":")[0]) &&
|
|
!data.limited.split(":")[1].match("サンポート")
|
|
);
|
|
}, [data.limited]);
|
|
const onPressTrainView = () => {
|
|
navigate("trainbase", {
|
|
info: "train.html?tn=" + data.trainNum,
|
|
from,
|
|
});
|
|
SheetManager.hide("EachTrainInfo");
|
|
};
|
|
return isTrainView ? (
|
|
<Ionicons
|
|
name="subway"
|
|
color={fixed.textOnPrimary}
|
|
size={30}
|
|
style={{ margin: 5 }}
|
|
onPress={onPressTrainView}
|
|
/>
|
|
) : (
|
|
<></>
|
|
);
|
|
};
|