途中まで分割
This commit is contained in:
parent
319e4b7b68
commit
5ce9ba9bea
@ -52,16 +52,6 @@ export const EachTrainInfo = (props) => {
|
|||||||
const [isConcatNear, setIsConcatNear] = useState(false);
|
const [isConcatNear, setIsConcatNear] = useState(false);
|
||||||
const [tailStation, setTailStation] = useState();
|
const [tailStation, setTailStation] = useState();
|
||||||
const [headStation, setHeadStation] = useState();
|
const [headStation, setHeadStation] = useState();
|
||||||
const { height, width } = useWindowDimensions();
|
|
||||||
const [isLandscape, setIsLandscape] = useState(false);
|
|
||||||
useEffect(() => {
|
|
||||||
if (height / width > 1.5) {
|
|
||||||
setIsLandscape(false);
|
|
||||||
}
|
|
||||||
if (height / width < 1.5) {
|
|
||||||
setIsLandscape(true);
|
|
||||||
}
|
|
||||||
}, [width, height]);
|
|
||||||
// const [actionSheetHorizonalScroll, setActionSheetHorizonalScroll] = useState(false);
|
// const [actionSheetHorizonalScroll, setActionSheetHorizonalScroll] = useState(false);
|
||||||
|
|
||||||
//裏列車探索
|
//裏列車探索
|
||||||
@ -85,102 +75,6 @@ export const EachTrainInfo = (props) => {
|
|||||||
});
|
});
|
||||||
}, [trainData, showNearTrain]);
|
}, [trainData, showNearTrain]);
|
||||||
|
|
||||||
const openBackTrainInfo = (stationInfo, currentTrainIndex) => {
|
|
||||||
const migrationArray = (stationInfo) => {
|
|
||||||
const mainTrainStationPosition = trainData.findIndex(
|
|
||||||
(d) => d.split(",")[0] == stationInfo
|
|
||||||
);
|
|
||||||
|
|
||||||
const relationMain = (() => {
|
|
||||||
if (mainTrainStationPosition == 0) return "head";
|
|
||||||
if (mainTrainStationPosition == trainData.length - 1) return "tail";
|
|
||||||
return "middle";
|
|
||||||
})();
|
|
||||||
|
|
||||||
const subTrainStationPosition = showNearTrain.findIndex(
|
|
||||||
(d) => d.split(",")[0] == stationInfo
|
|
||||||
);
|
|
||||||
const relationSub = (() => {
|
|
||||||
if (subTrainStationPosition == 0) return "head";
|
|
||||||
if (subTrainStationPosition == showNearTrain.length - 1) return "tail";
|
|
||||||
return "middle";
|
|
||||||
})();
|
|
||||||
|
|
||||||
switch (relationMain) {
|
|
||||||
case "head":
|
|
||||||
if (relationSub == "head") {
|
|
||||||
return;
|
|
||||||
} else if (relationSub == "tail") {
|
|
||||||
return [
|
|
||||||
...showNearTrain.slice(0, subTrainStationPosition),
|
|
||||||
...trainData,
|
|
||||||
];
|
|
||||||
} else if (relationSub == "middle") {
|
|
||||||
return [
|
|
||||||
...showNearTrain.slice(0, subTrainStationPosition),
|
|
||||||
...trainData,
|
|
||||||
];
|
|
||||||
} else return;
|
|
||||||
case "tail":
|
|
||||||
if (relationSub == "head") {
|
|
||||||
return [
|
|
||||||
...trainData.slice(0, mainTrainStationPosition),
|
|
||||||
...showNearTrain,
|
|
||||||
];
|
|
||||||
} else if (relationSub == "tail") {
|
|
||||||
return;
|
|
||||||
} else if (relationSub == "middle") {
|
|
||||||
return [
|
|
||||||
...trainData.slice(0, mainTrainStationPosition),
|
|
||||||
...showNearTrain.slice(subTrainStationPosition),
|
|
||||||
];
|
|
||||||
} else return;
|
|
||||||
case "middle":
|
|
||||||
if (relationSub == "head") {
|
|
||||||
return [
|
|
||||||
...trainData.slice(0, mainTrainStationPosition),
|
|
||||||
...showNearTrain,
|
|
||||||
];
|
|
||||||
} else if (relationSub == "tail") {
|
|
||||||
return [
|
|
||||||
...showNearTrain.slice(0, subTrainStationPosition),
|
|
||||||
...trainData.slice(mainTrainStationPosition),
|
|
||||||
];
|
|
||||||
} else return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const array = migrationArray(stationInfo);
|
|
||||||
if (!array) return;
|
|
||||||
setTrainData(array);
|
|
||||||
setIsConcatNear(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
const openTrainInfo = (d) => {
|
|
||||||
const train = customTrainDataDetector(d);
|
|
||||||
let TrainNumber = "";
|
|
||||||
if (train.trainNumDistance != undefined) {
|
|
||||||
const timeInfo =
|
|
||||||
parseInt(d.replace("M", "").replace("D", "")) - train.trainNumDistance;
|
|
||||||
TrainNumber = timeInfo + "号";
|
|
||||||
}
|
|
||||||
const payload = {
|
|
||||||
data: {
|
|
||||||
trainNum: d,
|
|
||||||
limited: `${getTrainType(train.type).data}:${
|
|
||||||
train.trainName
|
|
||||||
}${TrainNumber}`,
|
|
||||||
},
|
|
||||||
navigate,
|
|
||||||
originalStationList,
|
|
||||||
from: "AllTrainDiagramView",
|
|
||||||
};
|
|
||||||
SheetManager.hide("EachTrainInfo").then(() => {
|
|
||||||
//0.1秒待機してから開く
|
|
||||||
setTimeout(() => {
|
|
||||||
SheetManager.show("EachTrainInfo", { payload });
|
|
||||||
}, 1);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCurrentTrainData(
|
setCurrentTrainData(
|
||||||
checkDuplicateTrainData(
|
checkDuplicateTrainData(
|
||||||
@ -189,17 +83,6 @@ export const EachTrainInfo = (props) => {
|
|||||||
);
|
);
|
||||||
}, [currentTrain]);
|
}, [currentTrain]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
//列車現在地アイコン表示スイッチ
|
|
||||||
AS.getItem("trainPositionSwitch")
|
|
||||||
.then((d) => {
|
|
||||||
if (d) {
|
|
||||||
setTrainPositionSwitch(d);
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((d) => AS.setItem("trainPositionSwitch", "false"));
|
|
||||||
}, []);
|
|
||||||
//bconst insets = useSafeAreaInsets();
|
//bconst insets = useSafeAreaInsets();
|
||||||
const getStationData = (stationName) => {
|
const getStationData = (stationName) => {
|
||||||
const Stations = stationList.map((a) =>
|
const Stations = stationList.map((a) =>
|
||||||
@ -213,18 +96,6 @@ export const EachTrainInfo = (props) => {
|
|||||||
if (!Station[0]) return [];
|
if (!Station[0]) return [];
|
||||||
return Station.map((d) => d.StationNumber)[0];
|
return Station.map((d) => d.StationNumber)[0];
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
|
||||||
//currentTrainData.Pos = "鴨川~端岡"; //test
|
|
||||||
if (!currentTrainData?.Pos) return;
|
|
||||||
if (currentTrainData?.Pos.match("~")) {
|
|
||||||
const pos = currentTrainData?.Pos.replace("(下り)", "")
|
|
||||||
.replace("(上り)", "")
|
|
||||||
.split("~");
|
|
||||||
setCurrentPosition([getStationData(pos[0]), getStationData(pos[1])]);
|
|
||||||
} else {
|
|
||||||
setCurrentPosition([getStationData(currentTrainData?.Pos)]);
|
|
||||||
}
|
|
||||||
}, [currentTrainData]);
|
|
||||||
|
|
||||||
const stationList =
|
const stationList =
|
||||||
originalStationList &&
|
originalStationList &&
|
||||||
@ -361,37 +232,8 @@ export const EachTrainInfo = (props) => {
|
|||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 使用例
|
|
||||||
const points =
|
|
||||||
trainPositionSwitch == "true" ? findReversalPoints(currentPosition) : [];
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!data.trainNum) return;
|
|
||||||
const TD = trainList[data.trainNum];
|
|
||||||
if (!TD) {
|
|
||||||
setTrainData([]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setTrainData(TD.split("#").filter((d) => d != ""));
|
|
||||||
}, [data]);
|
|
||||||
const getType = (string) => {
|
|
||||||
switch (string) {
|
|
||||||
case "express":
|
|
||||||
return "特急";
|
|
||||||
case "rapid":
|
|
||||||
return "快速";
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const migrateTrainName = (string) => {
|
|
||||||
return string
|
|
||||||
.replace("マリン", "マリンライナー")
|
|
||||||
.replace("ライナーライナー", "ライナー");
|
|
||||||
};
|
|
||||||
const actionSheetRef = useRef(null);
|
const actionSheetRef = useRef(null);
|
||||||
const scrollHandlers = useScrollHandlers("scrollview-1", actionSheetRef);
|
|
||||||
return (
|
return (
|
||||||
<ActionSheet
|
<ActionSheet
|
||||||
gestureEnabled={true}
|
gestureEnabled={true}
|
||||||
@ -403,282 +245,37 @@ export const EachTrainInfo = (props) => {
|
|||||||
|
|
||||||
//useBottomSafeAreaPadding={Platform.OS == "android"}
|
//useBottomSafeAreaPadding={Platform.OS == "android"}
|
||||||
>
|
>
|
||||||
<View
|
<Hoge
|
||||||
style={{
|
{...{
|
||||||
backgroundColor: "#0099CC",
|
actionSheetRef,
|
||||||
borderTopRadius: 5,
|
data,
|
||||||
borderColor: "dark",
|
trainData,
|
||||||
borderWidth: 1,
|
isConcatNear,
|
||||||
|
nearTrainIDList,
|
||||||
|
navigate,
|
||||||
|
from,
|
||||||
|
currentTrainData,
|
||||||
|
currentPosition,
|
||||||
|
headStation,
|
||||||
|
tailStation,
|
||||||
|
stationList,
|
||||||
|
openStationACFromEachTrainInfo,
|
||||||
|
trainPositionSwitch,
|
||||||
|
findReversalPoints,
|
||||||
|
setTrainData,
|
||||||
|
trainList,
|
||||||
|
showNearTrain,
|
||||||
|
setIsConcatNear,
|
||||||
|
customTrainDataDetector,
|
||||||
|
getTrainType,
|
||||||
|
originalStationList,
|
||||||
|
SheetManager,
|
||||||
|
AS,
|
||||||
|
setTrainPositionSwitch,
|
||||||
|
getStationData,
|
||||||
|
setCurrentPosition,
|
||||||
}}
|
}}
|
||||||
>
|
/>
|
||||||
<View style={{ height: 26, width: "100%" }}>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
height: 6,
|
|
||||||
width: 45,
|
|
||||||
borderRadius: 100,
|
|
||||||
backgroundColor: "#f0f0f0",
|
|
||||||
marginVertical: 10,
|
|
||||||
alignSelf: "center",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View
|
|
||||||
style={{ padding: 10, flexDirection: "row", alignItems: "center" }}
|
|
||||||
>
|
|
||||||
<Text style={{ fontSize: 20, fontWeight: "bold", color: "white" }}>
|
|
||||||
{data.limited
|
|
||||||
? getType(data.limited.split(":")[0]) +
|
|
||||||
migrateTrainName(
|
|
||||||
data.limited.split(":")[1] ||
|
|
||||||
(trainData.length > 0
|
|
||||||
? trainData[trainData.length - 1].split(",")[0] + "行き"
|
|
||||||
: " ")
|
|
||||||
)
|
|
||||||
: ""}
|
|
||||||
</Text>
|
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
<Text style={{ fontSize: 20, fontWeight: "bold", color: "white" }}>
|
|
||||||
{data.trainNum}
|
|
||||||
{isConcatNear ? ` + ${nearTrainIDList}` : ""}
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
{data.limited != undefined &&
|
|
||||||
getType(data.limited.split(":")[0]) &&
|
|
||||||
!data.limited.split(":")[1].match("サンポート") && (
|
|
||||||
<Ionicons
|
|
||||||
name="subway"
|
|
||||||
color="white"
|
|
||||||
size={30}
|
|
||||||
style={{ margin: 5 }}
|
|
||||||
onPress={() => {
|
|
||||||
LayoutAnimation.easeInEaseOut(); //setLoadingDelayData(true);
|
|
||||||
navigate("trainbase", {
|
|
||||||
info: "train.html?tn=" + data.trainNum,
|
|
||||||
from,
|
|
||||||
});
|
|
||||||
SheetManager.hide("EachTrainInfo");
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
{isLandscape ? (
|
|
||||||
<LandscapeTrainInfo
|
|
||||||
scrollHandlers={scrollHandlers}
|
|
||||||
leftContent={
|
|
||||||
from == "AllTrainDiagramView" ? (
|
|
||||||
<></>
|
|
||||||
) : (
|
|
||||||
<LongHeader
|
|
||||||
currentTrainData={currentTrainData}
|
|
||||||
currentPosition={currentPosition}
|
|
||||||
nearTrainIDList={nearTrainIDList}
|
|
||||||
openTrainInfo={openTrainInfo}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
topStickyContent={
|
|
||||||
<ScrollStickyContent currentTrainData={currentTrainData} />
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{headStation && !isConcatNear && (
|
|
||||||
<TouchableOpacity
|
|
||||||
onPress={() => openBackTrainInfo(headStation)}
|
|
||||||
style={{
|
|
||||||
padding: 10,
|
|
||||||
flexDirection: "row",
|
|
||||||
borderColor: "blue",
|
|
||||||
borderWidth: 1,
|
|
||||||
margin: 10,
|
|
||||||
borderRadius: 5,
|
|
||||||
alignItems: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text
|
|
||||||
style={{ fontSize: 18, fontWeight: "bold", color: "black" }}
|
|
||||||
>
|
|
||||||
「本当の始発駅」を表示
|
|
||||||
</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
)}
|
|
||||||
{/* <LottieView
|
|
||||||
autoPlay
|
|
||||||
loop
|
|
||||||
style={{ width: 150, height: 150, backgroundColor: "#fff" }}
|
|
||||||
source={require("../../assets/51690-loading-diamonds.json")}
|
|
||||||
/>
|
|
||||||
<Text>ほげほげふがふが</Text> */}
|
|
||||||
|
|
||||||
{trainData.map((i, index) =>
|
|
||||||
i.split(",")[1] == "提" ? (
|
|
||||||
<DataFromButton i={i} />
|
|
||||||
) : (
|
|
||||||
<EachStopList
|
|
||||||
i={i}
|
|
||||||
index={index}
|
|
||||||
stationList={stationList}
|
|
||||||
points={points}
|
|
||||||
currentTrainData={currentTrainData}
|
|
||||||
openStationACFromEachTrainInfo={
|
|
||||||
openStationACFromEachTrainInfo
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
{tailStation && !isConcatNear && (
|
|
||||||
<TouchableOpacity
|
|
||||||
onPress={() => openBackTrainInfo(tailStation)}
|
|
||||||
style={{
|
|
||||||
padding: 10,
|
|
||||||
flexDirection: "row",
|
|
||||||
borderColor: "blue",
|
|
||||||
borderWidth: 1,
|
|
||||||
margin: 10,
|
|
||||||
borderRadius: 5,
|
|
||||||
alignItems: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text
|
|
||||||
style={{ fontSize: 18, fontWeight: "bold", color: "black" }}
|
|
||||||
>
|
|
||||||
「本当の終着駅」を表示
|
|
||||||
</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<View style={{ flexDirection: "row" }}>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
padding: 8,
|
|
||||||
flexDirection: "row",
|
|
||||||
borderBottomWidth: 1,
|
|
||||||
borderBottomColor: "#f0f0f0",
|
|
||||||
flex: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text style={{ fontSize: 20 }}> </Text>
|
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</LandscapeTrainInfo>
|
|
||||||
) : (
|
|
||||||
<DynamicHeaderScrollView
|
|
||||||
styles={styles}
|
|
||||||
containerProps={{
|
|
||||||
style: { maxHeight: heightPercentageToDP("70%") },
|
|
||||||
}}
|
|
||||||
Max_Header_Height={from == "AllTrainDiagramView" ? 0 : 200}
|
|
||||||
Min_Header_Height={from == "AllTrainDiagramView" ? 0 : 80}
|
|
||||||
shortHeader={
|
|
||||||
from == "AllTrainDiagramView" ? (
|
|
||||||
<></>
|
|
||||||
) : (
|
|
||||||
<ShortHeader
|
|
||||||
currentTrainData={currentTrainData}
|
|
||||||
currentPosition={currentPosition}
|
|
||||||
nearTrainIDList={nearTrainIDList}
|
|
||||||
openTrainInfo={openTrainInfo}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
longHeader={
|
|
||||||
from == "AllTrainDiagramView" ? (
|
|
||||||
<></>
|
|
||||||
) : (
|
|
||||||
<LongHeader
|
|
||||||
currentTrainData={currentTrainData}
|
|
||||||
currentPosition={currentPosition}
|
|
||||||
nearTrainIDList={nearTrainIDList}
|
|
||||||
openTrainInfo={openTrainInfo}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
topStickyContent={
|
|
||||||
<ScrollStickyContent currentTrainData={currentTrainData} />
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{headStation && !isConcatNear && (
|
|
||||||
<TouchableOpacity
|
|
||||||
onPress={() => openBackTrainInfo(headStation)}
|
|
||||||
style={{
|
|
||||||
padding: 10,
|
|
||||||
flexDirection: "row",
|
|
||||||
borderColor: "blue",
|
|
||||||
borderWidth: 1,
|
|
||||||
margin: 10,
|
|
||||||
borderRadius: 5,
|
|
||||||
alignItems: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text
|
|
||||||
style={{ fontSize: 18, fontWeight: "bold", color: "black" }}
|
|
||||||
>
|
|
||||||
「本当の始発駅」を表示
|
|
||||||
</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
)}
|
|
||||||
{/* <LottieView
|
|
||||||
autoPlay
|
|
||||||
loop
|
|
||||||
style={{ width: 150, height: 150, backgroundColor: "#fff" }}
|
|
||||||
source={require("../../assets/51690-loading-diamonds.json")}
|
|
||||||
/>
|
|
||||||
<Text>ほげほげふがふが</Text> */}
|
|
||||||
|
|
||||||
{trainData.map((i, index) =>
|
|
||||||
i.split(",")[1] == "提" ? (
|
|
||||||
<DataFromButton i={i} />
|
|
||||||
) : (
|
|
||||||
<EachStopList
|
|
||||||
i={i}
|
|
||||||
index={index}
|
|
||||||
stationList={stationList}
|
|
||||||
points={points}
|
|
||||||
currentTrainData={currentTrainData}
|
|
||||||
openStationACFromEachTrainInfo={
|
|
||||||
openStationACFromEachTrainInfo
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
{tailStation && !isConcatNear && (
|
|
||||||
<TouchableOpacity
|
|
||||||
onPress={() => openBackTrainInfo(tailStation)}
|
|
||||||
style={{
|
|
||||||
padding: 10,
|
|
||||||
flexDirection: "row",
|
|
||||||
borderColor: "blue",
|
|
||||||
borderWidth: 1,
|
|
||||||
margin: 10,
|
|
||||||
borderRadius: 5,
|
|
||||||
alignItems: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text
|
|
||||||
style={{ fontSize: 18, fontWeight: "bold", color: "black" }}
|
|
||||||
>
|
|
||||||
「本当の終着駅」を表示
|
|
||||||
</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<View style={{ flexDirection: "row" }}>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
padding: 8,
|
|
||||||
flexDirection: "row",
|
|
||||||
borderBottomWidth: 1,
|
|
||||||
borderBottomColor: "#f0f0f0",
|
|
||||||
flex: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text style={{ fontSize: 20 }}> </Text>
|
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</DynamicHeaderScrollView>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
</ActionSheet>
|
</ActionSheet>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -700,3 +297,464 @@ const styles = StyleSheet.create({
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const Hoge = ({
|
||||||
|
actionSheetRef,
|
||||||
|
data,
|
||||||
|
trainData,
|
||||||
|
isConcatNear,
|
||||||
|
nearTrainIDList,
|
||||||
|
navigate,
|
||||||
|
from,
|
||||||
|
currentTrainData,
|
||||||
|
currentPosition,
|
||||||
|
headStation,
|
||||||
|
tailStation,
|
||||||
|
stationList,
|
||||||
|
openStationACFromEachTrainInfo,
|
||||||
|
trainPositionSwitch,
|
||||||
|
findReversalPoints,
|
||||||
|
setTrainData,
|
||||||
|
trainList,
|
||||||
|
showNearTrain,
|
||||||
|
setIsConcatNear,
|
||||||
|
customTrainDataDetector,
|
||||||
|
getTrainType,
|
||||||
|
originalStationList,
|
||||||
|
SheetManager,
|
||||||
|
AS,
|
||||||
|
setTrainPositionSwitch,
|
||||||
|
getStationData,
|
||||||
|
setCurrentPosition,
|
||||||
|
}) => {
|
||||||
|
const scrollHandlers = useScrollHandlers("scrollview-1", actionSheetRef);
|
||||||
|
const migrateTrainName = (string) => {
|
||||||
|
return string
|
||||||
|
.replace("マリン", "マリンライナー")
|
||||||
|
.replace("ライナーライナー", "ライナー");
|
||||||
|
};
|
||||||
|
const getType = (string) => {
|
||||||
|
switch (string) {
|
||||||
|
case "express":
|
||||||
|
return "特急";
|
||||||
|
case "rapid":
|
||||||
|
return "快速";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 使用例
|
||||||
|
const points =
|
||||||
|
trainPositionSwitch == "true" ? findReversalPoints(currentPosition) : [];
|
||||||
|
const { height, width } = useWindowDimensions();
|
||||||
|
const [isLandscape, setIsLandscape] = useState(false);
|
||||||
|
useEffect(() => {
|
||||||
|
//currentTrainData.Pos = "鴨川~端岡"; //test
|
||||||
|
if (!currentTrainData?.Pos) return;
|
||||||
|
if (currentTrainData?.Pos.match("~")) {
|
||||||
|
const pos = currentTrainData?.Pos.replace("(下り)", "")
|
||||||
|
.replace("(上り)", "")
|
||||||
|
.split("~");
|
||||||
|
setCurrentPosition([getStationData(pos[0]), getStationData(pos[1])]);
|
||||||
|
} else {
|
||||||
|
setCurrentPosition([getStationData(currentTrainData?.Pos)]);
|
||||||
|
}
|
||||||
|
}, [currentTrainData]);
|
||||||
|
useEffect(() => {
|
||||||
|
if (height / width > 1.5) {
|
||||||
|
setIsLandscape(false);
|
||||||
|
}
|
||||||
|
if (height / width < 1.5) {
|
||||||
|
setIsLandscape(true);
|
||||||
|
}
|
||||||
|
}, [width, height]);
|
||||||
|
useEffect(() => {
|
||||||
|
if (!data.trainNum) return;
|
||||||
|
const TD = trainList[data.trainNum];
|
||||||
|
if (!TD) {
|
||||||
|
setTrainData([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setTrainData(TD.split("#").filter((d) => d != ""));
|
||||||
|
}, [data]);
|
||||||
|
useEffect(() => {
|
||||||
|
//列車現在地アイコン表示スイッチ
|
||||||
|
AS.getItem("trainPositionSwitch")
|
||||||
|
.then((d) => {
|
||||||
|
if (d) {
|
||||||
|
setTrainPositionSwitch(d);
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((d) => AS.setItem("trainPositionSwitch", "false"));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const openBackTrainInfo = (stationInfo, currentTrainIndex) => {
|
||||||
|
const migrationArray = (stationInfo) => {
|
||||||
|
const mainTrainStationPosition = trainData.findIndex(
|
||||||
|
(d) => d.split(",")[0] == stationInfo
|
||||||
|
);
|
||||||
|
|
||||||
|
const relationMain = (() => {
|
||||||
|
if (mainTrainStationPosition == 0) return "head";
|
||||||
|
if (mainTrainStationPosition == trainData.length - 1) return "tail";
|
||||||
|
return "middle";
|
||||||
|
})();
|
||||||
|
|
||||||
|
const subTrainStationPosition = showNearTrain.findIndex(
|
||||||
|
(d) => d.split(",")[0] == stationInfo
|
||||||
|
);
|
||||||
|
const relationSub = (() => {
|
||||||
|
if (subTrainStationPosition == 0) return "head";
|
||||||
|
if (subTrainStationPosition == showNearTrain.length - 1) return "tail";
|
||||||
|
return "middle";
|
||||||
|
})();
|
||||||
|
|
||||||
|
switch (relationMain) {
|
||||||
|
case "head":
|
||||||
|
if (relationSub == "head") {
|
||||||
|
return;
|
||||||
|
} else if (relationSub == "tail") {
|
||||||
|
return [
|
||||||
|
...showNearTrain.slice(0, subTrainStationPosition),
|
||||||
|
...trainData,
|
||||||
|
];
|
||||||
|
} else if (relationSub == "middle") {
|
||||||
|
return [
|
||||||
|
...showNearTrain.slice(0, subTrainStationPosition),
|
||||||
|
...trainData,
|
||||||
|
];
|
||||||
|
} else return;
|
||||||
|
case "tail":
|
||||||
|
if (relationSub == "head") {
|
||||||
|
return [
|
||||||
|
...trainData.slice(0, mainTrainStationPosition),
|
||||||
|
...showNearTrain,
|
||||||
|
];
|
||||||
|
} else if (relationSub == "tail") {
|
||||||
|
return;
|
||||||
|
} else if (relationSub == "middle") {
|
||||||
|
return [
|
||||||
|
...trainData.slice(0, mainTrainStationPosition),
|
||||||
|
...showNearTrain.slice(subTrainStationPosition),
|
||||||
|
];
|
||||||
|
} else return;
|
||||||
|
case "middle":
|
||||||
|
if (relationSub == "head") {
|
||||||
|
return [
|
||||||
|
...trainData.slice(0, mainTrainStationPosition),
|
||||||
|
...showNearTrain,
|
||||||
|
];
|
||||||
|
} else if (relationSub == "tail") {
|
||||||
|
return [
|
||||||
|
...showNearTrain.slice(0, subTrainStationPosition),
|
||||||
|
...trainData.slice(mainTrainStationPosition),
|
||||||
|
];
|
||||||
|
} else return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const array = migrationArray(stationInfo);
|
||||||
|
if (!array) return;
|
||||||
|
setTrainData(array);
|
||||||
|
setIsConcatNear(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const openTrainInfo = (d) => {
|
||||||
|
const train = customTrainDataDetector(d);
|
||||||
|
let TrainNumber = "";
|
||||||
|
if (train.trainNumDistance != undefined) {
|
||||||
|
const timeInfo =
|
||||||
|
parseInt(d.replace("M", "").replace("D", "")) - train.trainNumDistance;
|
||||||
|
TrainNumber = timeInfo + "号";
|
||||||
|
}
|
||||||
|
const payload = {
|
||||||
|
data: {
|
||||||
|
trainNum: d,
|
||||||
|
limited: `${getTrainType(train.type).data}:${
|
||||||
|
train.trainName
|
||||||
|
}${TrainNumber}`,
|
||||||
|
},
|
||||||
|
navigate,
|
||||||
|
originalStationList,
|
||||||
|
from: "AllTrainDiagramView",
|
||||||
|
};
|
||||||
|
SheetManager.hide("EachTrainInfo").then(() => {
|
||||||
|
//0.1秒待機してから開く
|
||||||
|
setTimeout(() => {
|
||||||
|
SheetManager.show("EachTrainInfo", { payload });
|
||||||
|
}, 1);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#0099CC",
|
||||||
|
borderTopRadius: 5,
|
||||||
|
borderColor: "dark",
|
||||||
|
borderWidth: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<View style={{ height: 26, width: "100%" }}>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
height: 6,
|
||||||
|
width: 45,
|
||||||
|
borderRadius: 100,
|
||||||
|
backgroundColor: "#f0f0f0",
|
||||||
|
marginVertical: 10,
|
||||||
|
alignSelf: "center",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={{ padding: 10, flexDirection: "row", alignItems: "center" }}>
|
||||||
|
<Text style={{ fontSize: 20, fontWeight: "bold", color: "white" }}>
|
||||||
|
{data.limited
|
||||||
|
? getType(data.limited.split(":")[0]) +
|
||||||
|
migrateTrainName(
|
||||||
|
data.limited.split(":")[1] ||
|
||||||
|
(trainData.length > 0
|
||||||
|
? trainData[trainData.length - 1].split(",")[0] + "行き"
|
||||||
|
: " ")
|
||||||
|
)
|
||||||
|
: ""}
|
||||||
|
</Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
<Text style={{ fontSize: 20, fontWeight: "bold", color: "white" }}>
|
||||||
|
{data.trainNum}
|
||||||
|
{isConcatNear ? ` + ${nearTrainIDList}` : ""}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
{data.limited != undefined &&
|
||||||
|
getType(data.limited.split(":")[0]) &&
|
||||||
|
!data.limited.split(":")[1].match("サンポート") && (
|
||||||
|
<Ionicons
|
||||||
|
name="subway"
|
||||||
|
color="white"
|
||||||
|
size={30}
|
||||||
|
style={{ margin: 5 }}
|
||||||
|
onPress={() => {
|
||||||
|
LayoutAnimation.easeInEaseOut(); //setLoadingDelayData(true);
|
||||||
|
navigate("trainbase", {
|
||||||
|
info: "train.html?tn=" + data.trainNum,
|
||||||
|
from,
|
||||||
|
});
|
||||||
|
SheetManager.hide("EachTrainInfo");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
{isLandscape ? (
|
||||||
|
<LandscapeTrainInfo
|
||||||
|
scrollHandlers={scrollHandlers}
|
||||||
|
leftContent={
|
||||||
|
from == "AllTrainDiagramView" ? (
|
||||||
|
<></>
|
||||||
|
) : (
|
||||||
|
<LongHeader
|
||||||
|
currentTrainData={currentTrainData}
|
||||||
|
currentPosition={currentPosition}
|
||||||
|
nearTrainIDList={nearTrainIDList}
|
||||||
|
openTrainInfo={openTrainInfo}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
topStickyContent={
|
||||||
|
<ScrollStickyContent currentTrainData={currentTrainData} />
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{headStation && !isConcatNear && (
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => openBackTrainInfo(headStation)}
|
||||||
|
style={{
|
||||||
|
padding: 10,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderColor: "blue",
|
||||||
|
borderWidth: 1,
|
||||||
|
margin: 10,
|
||||||
|
borderRadius: 5,
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
style={{ fontSize: 18, fontWeight: "bold", color: "black" }}
|
||||||
|
>
|
||||||
|
「本当の始発駅」を表示
|
||||||
|
</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
{/* <LottieView
|
||||||
|
autoPlay
|
||||||
|
loop
|
||||||
|
style={{ width: 150, height: 150, backgroundColor: "#fff" }}
|
||||||
|
source={require("../../assets/51690-loading-diamonds.json")}
|
||||||
|
/>
|
||||||
|
<Text>ほげほげふがふが</Text> */}
|
||||||
|
|
||||||
|
{trainData.map((i, index) =>
|
||||||
|
i.split(",")[1] == "提" ? (
|
||||||
|
<DataFromButton i={i} />
|
||||||
|
) : (
|
||||||
|
<EachStopList
|
||||||
|
i={i}
|
||||||
|
index={index}
|
||||||
|
stationList={stationList}
|
||||||
|
points={points}
|
||||||
|
currentTrainData={currentTrainData}
|
||||||
|
openStationACFromEachTrainInfo={openStationACFromEachTrainInfo}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
{tailStation && !isConcatNear && (
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => openBackTrainInfo(tailStation)}
|
||||||
|
style={{
|
||||||
|
padding: 10,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderColor: "blue",
|
||||||
|
borderWidth: 1,
|
||||||
|
margin: 10,
|
||||||
|
borderRadius: 5,
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
style={{ fontSize: 18, fontWeight: "bold", color: "black" }}
|
||||||
|
>
|
||||||
|
「本当の終着駅」を表示
|
||||||
|
</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<View style={{ flexDirection: "row" }}>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
padding: 8,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
borderBottomColor: "#f0f0f0",
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text style={{ fontSize: 20 }}> </Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</LandscapeTrainInfo>
|
||||||
|
) : (
|
||||||
|
<DynamicHeaderScrollView
|
||||||
|
styles={styles}
|
||||||
|
containerProps={{
|
||||||
|
style: { maxHeight: heightPercentageToDP("70%") },
|
||||||
|
}}
|
||||||
|
Max_Header_Height={from == "AllTrainDiagramView" ? 0 : 200}
|
||||||
|
Min_Header_Height={from == "AllTrainDiagramView" ? 0 : 80}
|
||||||
|
shortHeader={
|
||||||
|
from == "AllTrainDiagramView" ? (
|
||||||
|
<></>
|
||||||
|
) : (
|
||||||
|
<ShortHeader
|
||||||
|
currentTrainData={currentTrainData}
|
||||||
|
currentPosition={currentPosition}
|
||||||
|
nearTrainIDList={nearTrainIDList}
|
||||||
|
openTrainInfo={openTrainInfo}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
longHeader={
|
||||||
|
from == "AllTrainDiagramView" ? (
|
||||||
|
<></>
|
||||||
|
) : (
|
||||||
|
<LongHeader
|
||||||
|
currentTrainData={currentTrainData}
|
||||||
|
currentPosition={currentPosition}
|
||||||
|
nearTrainIDList={nearTrainIDList}
|
||||||
|
openTrainInfo={openTrainInfo}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
topStickyContent={
|
||||||
|
<ScrollStickyContent currentTrainData={currentTrainData} />
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{headStation && !isConcatNear && (
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => openBackTrainInfo(headStation)}
|
||||||
|
style={{
|
||||||
|
padding: 10,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderColor: "blue",
|
||||||
|
borderWidth: 1,
|
||||||
|
margin: 10,
|
||||||
|
borderRadius: 5,
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
style={{ fontSize: 18, fontWeight: "bold", color: "black" }}
|
||||||
|
>
|
||||||
|
「本当の始発駅」を表示
|
||||||
|
</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
{/* <LottieView
|
||||||
|
autoPlay
|
||||||
|
loop
|
||||||
|
style={{ width: 150, height: 150, backgroundColor: "#fff" }}
|
||||||
|
source={require("../../assets/51690-loading-diamonds.json")}
|
||||||
|
/>
|
||||||
|
<Text>ほげほげふがふが</Text> */}
|
||||||
|
|
||||||
|
{trainData.map((i, index) =>
|
||||||
|
i.split(",")[1] == "提" ? (
|
||||||
|
<DataFromButton i={i} />
|
||||||
|
) : (
|
||||||
|
<EachStopList
|
||||||
|
i={i}
|
||||||
|
index={index}
|
||||||
|
stationList={stationList}
|
||||||
|
points={points}
|
||||||
|
currentTrainData={currentTrainData}
|
||||||
|
openStationACFromEachTrainInfo={openStationACFromEachTrainInfo}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
{tailStation && !isConcatNear && (
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => openBackTrainInfo(tailStation)}
|
||||||
|
style={{
|
||||||
|
padding: 10,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderColor: "blue",
|
||||||
|
borderWidth: 1,
|
||||||
|
margin: 10,
|
||||||
|
borderRadius: 5,
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
style={{ fontSize: 18, fontWeight: "bold", color: "black" }}
|
||||||
|
>
|
||||||
|
「本当の終着駅」を表示
|
||||||
|
</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<View style={{ flexDirection: "row" }}>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
padding: 8,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
borderBottomColor: "#f0f0f0",
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text style={{ fontSize: 20 }}> </Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</DynamicHeaderScrollView>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user