Merge commit '135bb79bf6f48c00d0465b3bd73e6455f7be64be' into patch/5.0.x

This commit is contained in:
harukin-expo-dev-env 2024-10-24 17:22:39 +00:00
commit 8fe24cca7c
8 changed files with 229 additions and 125 deletions

View File

@ -1,5 +1,5 @@
export default [
{"Station_JP" : "徳島", "Station_EN" : "Tokushima", "MyStation" : "0", "StationNumber" : "T00", "DispNum" : "3", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/tokushima.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.074642,134.550764", "JrHpUrl" : "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/tokushima/"},
{"Station_JP" : "徳島", "Station_EN" : "Tokushima", "MyStation" : "0", "StationNumber" : "B00", "DispNum" : "3", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/tokushima.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.074642,134.550764", "JrHpUrl" : "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/tokushima/"},
{"Station_JP" : "佐古", "Station_EN" : "Sako", "MyStation" : "0", "StationNumber" : "B01", "DispNum" : "2", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/sako.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.080616,134.538576", "JrHpUrl" : ""},
{"Station_JP" : "蔵本", "Station_EN" : "Kuramoto", "MyStation" : "1", "StationNumber" : "B02", "DispNum" : "2", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/kuramoto.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.079332,134.518705", "JrHpUrl" : ""},
{"Station_JP" : "府中", "Station_EN" : "Kō", "MyStation" : "2", "StationNumber" : "B04", "DispNum" : "2", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/ko.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.074134,134.482939", "JrHpUrl" : ""},

View File

@ -10,7 +10,9 @@ export const EachStopList = ({
points,
currentTrainData,
openStationACFromEachTrainInfo,
showThrew,
}) => {
if (!showThrew && i.split(",")[1] == "通過") return null;
const [station, se, time] = i.split(","); // 阿波池田,発,6:21
const Stations = stationList
.map((a) => a.filter((d) => d.StationName == station))
@ -43,7 +45,7 @@ export const EachStopList = ({
.set("hour", parseInt(time.split(":")[0]))
.set("minute", parseInt(time.split(":")[1]))
.add(isNaN(currentTrainData?.delay) ? 0 : currentTrainData.delay, "minute");
const timeString = dates.format("HH:mm").split(":");
const timeString = se == "通過" ? "" : dates.format("HH:mm").split(":");
return (
<TouchableWithoutFeedback
@ -66,7 +68,9 @@ export const EachStopList = ({
{lineIDs.map((lineID, index) => (
<View
style={{
backgroundColor: lineColorList[lineID],
backgroundColor: `${lineColorList[lineID]}${
se == "通過" ? "80" : ""
}`,
flex: 1,
}}
key={lineID}
@ -97,11 +101,20 @@ export const EachStopList = ({
flex: 1,
}}
>
<Text style={{ fontSize: 20 }}>{station}</Text>
<Text
style={{ fontSize: 20, color: `#000${se == "通過" ? "5" : ""}` }}
>
{station}
</Text>
<View style={{ flex: 1 }} />
{points && points.findIndex((d) => d == index) >= 0 ? (
<Text style={{ fontSize: 20, marginRight: 70 }}>🚊</Text>
) : null}
<View style={{ position: "relative", width: 0 }}>
{points ? (
<Text style={{ fontSize: 20, position: "absolute", left: -60 }}>
🚊
</Text>
) : null}
</View>
{!isNaN(currentTrainData?.delay) && currentTrainData?.delay != 0 && (
<Text
style={{
@ -128,7 +141,7 @@ export const EachStopList = ({
width: 60,
}}
>
{timeString[0]}:{timeString[1]}
{se == "通過" ? "レ" : `${timeString[0]}:${timeString[1]}`}
</Text>
<Text style={{ fontSize: 18, width: 50 }}>
{se?.replace("発", "出発").replace("着", "到着")}

View File

@ -1,7 +1,8 @@
import React from "react";
import { View, Text } from "react-native";
import { View, Text, LayoutAnimation, TouchableOpacity } from "react-native";
export const ScrollStickyContent = ({ currentTrainData }) => {
export const ScrollStickyContent = (props) => {
const { currentTrainData, showThrew, setShowThrew, haveThrough } = props;
return (
<View
style={{
@ -49,7 +50,32 @@ export const ScrollStickyContent = ({ currentTrainData }) => {
>
見込
</Text>
<Text style={{ fontSize: 20, width: 50 }}></Text>
<TouchableOpacity
onPress={() => {
if (!haveThrough) return;
LayoutAnimation.configureNext({
duration: 200,
update: { type: "easeInEaseOut", springDamping: 0.6 },
});
setShowThrew(!showThrew);
}}
>
<View style={{ flex: 1 }} />
<Text
style={{
fontSize: 12,
width: 50,
paddingBottom: 0,
margin: "auto",
textAlign: "center",
textAlignVertical: "center",
opacity: haveThrough ? 1 : 0,
}}
>
(通過{showThrew ? "▼" : "▶"})
</Text>
<View style={{ flex: 1 }} />
</TouchableOpacity>
</View>
</View>
</View>

View File

@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useState } from "react";
import React, { useEffect, useMemo, useRef, useState } from "react";
import {
View,
Text,
@ -7,11 +7,12 @@ import {
useWindowDimensions,
BackHandler,
Linking,
LayoutAnimation,
} from "react-native";
import { SheetManager } from "react-native-actions-sheet";
import { AS } from "../../storageControl";
import trainList from "../../assets/originData/trainList";
import { lineList } from "../../lib/getStationList";
import { lineList, lineListPair } from "../../lib/getStationList";
import { useCurrentTrain } from "../../stateBox/useCurrentTrain";
import { checkDuplicateTrainData } from "../../lib/checkDuplicateTrainData";
import { getTrainType } from "../../lib/getTrainType";
@ -34,6 +35,7 @@ import { ShowSpecialTrain } from "./EachTrainInfo/ShowSpecialTrain";
import { useTrainMenu } from "../../stateBox/useTrainMenu";
import { HeaderText } from "./EachTrainInfoCore/HeaderText";
import { useStationList } from "../../stateBox/useStationList";
import { stationIDPair } from "../../lib/getStationList2";
export const EachTrainInfoCore = ({
actionSheetRef,
@ -80,6 +82,9 @@ export const EachTrainInfoCore = ({
const [trainPositionSwitch, setTrainPositionSwitch] = useState("false");
const [currentPosition, setCurrentPosition] = useState([]);
const [trainData, setTrainData] = useState([]);
const [trainDataWidhThrough, setTrainDataWithThrough] = useState([]);
const [showThrew, setShowThrew] = useState(false);
const [haveThrough, setHaveThrough] = useState(false);
const stationList =
originalStationList &&
@ -91,7 +96,7 @@ export const EachTrainInfoCore = ({
);
// 使用例
const stopStationIDList = trainData.map((i) => {
const stopStationIDList = trainDataWidhThrough.map((i) => {
const [station, se, time] = i.split(",");
const Stations = stationList.map((a) =>
a.filter((d) => d.StationName == station)
@ -100,15 +105,98 @@ export const EachTrainInfoCore = ({
Stations &&
Stations.reduce((newArray, e) => {
return newArray.concat(e);
}, [])
.filter((d) => d.StationNumber)
.map((d) => d.StationNumber);
return StationNumbers[0];
}, []).map((d) => d.StationNumber);
return StationNumbers;
});
useEffect(() => {
const stopStationList = trainData.map((i) => {
const [station, se, time] = i.split(",");
return stationList.map((a) => a.filter((d) => d.StationName == station));
});
const allThroughStationList = stopStationList.map((i, index, array) => {
let allThroughStation = [];
if (index == array.length - 1) return;
const firstItem = array[index];
const secondItem = array[index + 1];
let betweenStationLine = "";
let baseStationNumberFirst = "";
let baseStationNumberSecond = "";
Object.keys(stationIDPair).forEach((d, index2, array) => {
if (!d) return;
const haveFirst = firstItem[index2];
const haveSecond = secondItem[index2];
if (haveFirst.length && haveSecond.length) {
betweenStationLine = d;
baseStationNumberFirst = haveFirst[0].StationNumber;
baseStationNumberSecond = haveSecond[0].StationNumber;
}
});
if (!betweenStationLine) return;
let reverse = false;
originalStationList[
lineListPair[stationIDPair[betweenStationLine]]
].forEach((d) => {
if (
d.StationNumber > baseStationNumberFirst &&
d.StationNumber < baseStationNumberSecond
) {
allThroughStation.push(`${d.Station_JP},通過,`);
setHaveThrough(true);
reverse = false;
} else {
if (
d.StationNumber < baseStationNumberFirst &&
d.StationNumber > baseStationNumberSecond
) {
allThroughStation.push(`${d.Station_JP},通過,`);
setHaveThrough(true);
reverse = true;
}
}
});
if (reverse) allThroughStation.reverse();
return allThroughStation;
});
let mainArray = [...trainData];
let indexs = 0;
trainData.forEach((d, index, array) => {
indexs = indexs + 1;
if (!allThroughStationList[index]) return;
if (allThroughStationList[index].length == 0) return;
mainArray.splice(indexs, 0, ...allThroughStationList[index]);
indexs = indexs + allThroughStationList[index].length;
});
setTrainDataWithThrough(mainArray);
}, [trainData]);
const points =
trainPositionSwitch == "true"
? findReversalPoints(currentPosition, stopStationIDList)
: [];
: stopStationIDList.map(() => false);
const [isJumped, setIsJumped] = useState(false);
useEffect(() => {
if (isJumped) return () => {};
if (!points) return () => {};
if (points.length == 0) return () => {};
const position = points.findIndex((d) => d == true);
if (position == -1) return () => {};
if (trainDataWidhThrough[position].split(",")[1] == "通過") {
LayoutAnimation.configureNext({
duration: 400,
update: { type: "easeInEaseOut", springDamping: 0.6 },
});
setShowThrew(true);
}
if(position < 5) return() => {}; // 5駅以内の場合はスクロールしない
const count = position * 44-50;
// 0.5秒待機してからスクロール
setTimeout(
() => ScrollViewRef.current?.scrollTo({ y: count, animated: true }),
400
);
setIsJumped(true);
}, [points]);
const trainName = useMemo(() => {
if (!data.limited) return "";
const limitedArray = data.limited.split(":");
@ -134,6 +222,7 @@ export const EachTrainInfoCore = ({
const { height } = useWindowDimensions();
const { isLandscape } = useDeviceOrientationChange();
const ScrollViewRef = useRef();
const [trueTrainID, setTrueTrainID] = useState();
useEffect(() => {
@ -193,9 +282,41 @@ export const EachTrainInfoCore = ({
if (currentTrainData?.Pos.match("")) {
const pos = currentTrainData?.Pos.replace("(下り)", "")
.replace("(上り)", "")
.replace("(徳島線)", "")
.replace("(高徳線)", "")
.split("");
const direction = parseInt(currentTrainData?.Direction) || 0;
if (direction == 0) {
if (pos[0] == "児島" && pos[1] == "宇多津") {
setCurrentPosition(["M12", "Y09"]);
return;
} else if (pos[1] == "児島" && pos[0] == "宇多津") {
setCurrentPosition(["Y09", "M12"]);
return;
}
const currentPosID = Object.keys(originalStationList).map((key) => {
let firstStation = false;
let firstStationID = "";
let secondStation = false;
let secondStationID = "";
originalStationList[key].forEach((station) => {
if (station.Station_JP === pos[0]) {
firstStation = true;
firstStationID = station.StationNumber;
}
if (station.Station_JP === pos[1]) {
secondStation = true;
secondStationID = station.StationNumber;
}
});
if (firstStation && secondStation) {
return [firstStationID, secondStationID];
} else return false;
});
const currentPos = currentPosID.filter((d) => d != false)[0];
if (currentPos) {
if (direction == 0) setCurrentPosition(currentPos.reverse());
else setCurrentPosition(currentPos);
} else if (direction == 0) {
setCurrentPosition([
getStationID(pos[1], stationList),
getStationID(pos[0], stationList),
@ -293,6 +414,7 @@ export const EachTrainInfoCore = ({
from={from}
styles={styles}
actionSheetRef={actionSheetRef}
ScrollViewRef={ScrollViewRef}
containerProps={{
style: {
maxHeight: isLandscape ? height - 94 : (height / 100) * 70,
@ -301,7 +423,9 @@ export const EachTrainInfoCore = ({
shortHeader={<ShortHeader {...headerItem} />}
longHeader={<LongHeader {...headerItem} />}
topStickyContent={
<ScrollStickyContent currentTrainData={currentTrainData} />
<ScrollStickyContent
{...{ currentTrainData, showThrew, setShowThrew, haveThrough }}
/>
}
>
{headStation.length != 0 &&
@ -360,17 +484,20 @@ export const EachTrainInfoCore = ({
</Text>
</TouchableOpacity>
)}
{trainData.map((i, index) =>
{trainDataWidhThrough.map((i, index) =>
i.split(",")[1] == "提" ? (
<DataFromButton i={i} />
) : (
<EachStopList
i={i}
index={index}
stationList={stationList}
points={points}
currentTrainData={currentTrainData}
openStationACFromEachTrainInfo={openStationACFromEachTrainInfo}
{...{
i,
index,
stationList,
points: points ? points[index] : false,
currentTrainData,
openStationACFromEachTrainInfo,
showThrew,
}}
/>
)
)}

View File

@ -13,14 +13,13 @@ export const DynamicHeaderScrollView = (props) => {
topStickyContent,
styles,
from,
ScrollViewRef,
} = props;
const [headerSize, setHeaderSize] = useState("default");
useLayoutEffect(() => {
AS.getItem("headerSize")
.then((res) => {
if (res) {
setHeaderSize(res);
}
if (res) setHeaderSize(res);
})
.catch((e) => {
AS.setItem("headerSize", "default");
@ -160,6 +159,7 @@ export const DynamicHeaderScrollView = (props) => {
stickyHeaderIndices={[1]}
scrollEventThrottle={16}
onScroll={onScroll}
ref={ScrollViewRef}
>
<View style={{ height: Scroll_Distance, flexDirection: "column" }} />
{topStickyContent && (

View File

@ -131,7 +131,7 @@ export const LayoutSettings = ({
bool={trainPosition}
setBool={setTrainPosition}
color="red"
str="列車の現在位置をアイコン表示"
str="列車の現在地表示/ジャンプ"
/>
</SwitchArea>
</View>

View File

@ -141,7 +141,7 @@ export const EachData: FC<Props> = (props) => {
<Description
info={`${
trainIDSwitch
? currentTrainData?.PosNum
? currentTrainData?.PosNum+currentTrainData?.Line
: trainPositionText(currentTrainData)
} ${platformNumber ? platformNumber + "番線" : ""}`}
onLongClick={() => {

View File

@ -7,105 +7,43 @@ export const findReversalPoints = (array, stopStationIDList) => {
if (!array instanceof Array) return [];
if (!array) return [];
if (array[0] instanceof Array) return [];
const arrayNumber = array.map((d) => ({
line: d
.split("")
.filter((s) => "A" < s && s < "Z")
.join(""),
ID: d
.split("")
.filter((s) => "0" <= s && s <= "9")
.join(""),
}));
const stopStationIDListNumber = stopStationIDList.map((d) => {
if (!d) return { line: [], ID: [] };
return {
line: d
.split("")
.filter((s) => "A" < s && s < "Z")
.join(""),
ID: d
.split("")
.filter((s) => "0" <= s && s <= "9")
.join(""),
};
});
// 完全一致
if (array.length == 1) {
const index = stopStationIDList.indexOf(array[0]);
if (index != -1) return [index];
// 通過駅の場合
for (let i = 0; i < stopStationIDListNumber.length - 1; i++) {
if (stopStationIDListNumber[i].ID < arrayNumber[0].ID) {
if (stopStationIDListNumber[i + 1].ID > arrayNumber[0].ID) {
return [i + 1];
}
}
if (stopStationIDListNumber[i].ID > arrayNumber[0].ID) {
if (stopStationIDListNumber[i + 1].ID < arrayNumber[0].ID) {
return [i + 1];
}
}
}
const index = stopStationIDList.map((d) => {
let a = false;
d.forEach((x) => {
if (x == array[0]) a = true;
});
return a;
});
if (index != -1) return index;
}
// 駅間の場合
if (array.length == 2) {
const index1 = stopStationIDList.indexOf(array[0]);
const index2 = stopStationIDList.indexOf(array[1]);
if (index1 != -1 && index2 != -1) {
// 駅間で通過駅も無い場合
if (index1 < index2) {
if (index1 + 1 == index2) {
return [index2];
} else {
const returnArray = [];
for (let i = index1 + 1; i <= index2; i++) {
returnArray.push(i);
}
return returnArray;
}
}
if (index1 > index2) {
if (index2 + 1 == index1) return [index1];
else {
const returnArray = [];
for (let i = index2 + 1; i <= index1; i++) {
returnArray.push(i);
}
return returnArray;
}
}
} else {
const getNearStationID = (stationID) => {
for (let i = 0; i <= stopStationIDListNumber.length; i++) {
if (stopStationIDListNumber[i].ID < stationID) {
if (stopStationIDListNumber[i + 1].ID > stationID) {
return i + 1;
}
}
if (stopStationIDListNumber[i].ID > stationID) {
if (stopStationIDListNumber[i + 1].ID < stationID) {
return i + 1;
}
}
}
};
let newIndex1 = index1;
let newIndex2 = index2;
if (index1 == -1) {
newIndex1 = getNearStationID(arrayNumber[0].ID);
}
if (index2 == -1) {
newIndex2 = getNearStationID(arrayNumber[1].ID);
}
if (newIndex1 && newIndex2) {
return [newIndex1, newIndex2];
}
const allThroughStation = stopStationIDList.map((d) => {
if (
(array[0] == "M12" && array[1] == "Y09") ||
(array[0] == "Y09" && array[1] == "M12")
)
return d[0] == "M12" ? true : false;
// 通過駅の場合
}
let returndata = false;
d.forEach((x) => {
if (array[0] < x && x < array[1]) {
returndata = true;
} else if (array[0] < x && x == array[1]) {
returndata = true;
} else if (array[1] == x && x < array[0]) {
returndata = true;
} else if (array[1] < x && x < array[0]) {
returndata = true;
}
});
return [];
return returndata;
});
return allThroughStation;
}
} catch (e) {
console.log(e);