伊予若宮信号所の処理を詳細化
This commit is contained in:
@@ -249,7 +249,35 @@ export const EachTrainInfoCore = ({
|
||||
|
||||
useEffect(() => {
|
||||
const position = getPosition(currentTrainData);
|
||||
if (position) setCurrentPosition(position);
|
||||
if (position) {
|
||||
if (position.length > 1) {
|
||||
if (position[0] == "-Iyo") {
|
||||
position[0] =
|
||||
stopStationIDList[
|
||||
stopStationIDList.findIndex((d) => d.includes("U14")) - 1
|
||||
][0];
|
||||
}
|
||||
else if (position[0] == "+Iyo") {
|
||||
position[0] =
|
||||
stopStationIDList[
|
||||
stopStationIDList.findIndex((d) => d.includes("U14")) + 1
|
||||
][0];
|
||||
}
|
||||
if (position[1] == "+Iyo") {
|
||||
position[1] =
|
||||
stopStationIDList[
|
||||
stopStationIDList.findIndex((d) => d.includes("U14")) + 1
|
||||
][0];
|
||||
}else if (position[1] == "-Iyo") {
|
||||
position[1] =
|
||||
stopStationIDList[
|
||||
stopStationIDList.findIndex((d) => d.includes("U14")) - 1
|
||||
][0];
|
||||
}
|
||||
}
|
||||
|
||||
setCurrentPosition(position);
|
||||
}
|
||||
}, [currentTrainData]);
|
||||
|
||||
useEffect(() => {
|
||||
|
@@ -144,19 +144,50 @@ export const FixedTrain: FC<props> = ({
|
||||
const [currentPosition, setCurrentPosition] = useState<string[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
const position = getPosition(train);
|
||||
if (position) setCurrentPosition(position);
|
||||
let position = getPosition(train);
|
||||
if (position) {
|
||||
if (position.length > 1) {
|
||||
if (position[0] == "-Iyo") {
|
||||
position[0] =
|
||||
stopStationIDList[
|
||||
stopStationIDList.findIndex((d) => d.includes("U14")) - 1
|
||||
][0];
|
||||
}
|
||||
else if (position[0] == "+Iyo") {
|
||||
position[0] =
|
||||
stopStationIDList[
|
||||
stopStationIDList.findIndex((d) => d.includes("U14")) + 1
|
||||
][0];
|
||||
}
|
||||
if (position[1] == "+Iyo") {
|
||||
position[1] =
|
||||
stopStationIDList[
|
||||
stopStationIDList.findIndex((d) => d.includes("U14")) + 1
|
||||
][0];
|
||||
}else if (position[1] == "-Iyo") {
|
||||
position[1] =
|
||||
stopStationIDList[
|
||||
stopStationIDList.findIndex((d) => d.includes("U14")) - 1
|
||||
][0];
|
||||
}
|
||||
}
|
||||
|
||||
setCurrentPosition(position);
|
||||
}
|
||||
}, [train]);
|
||||
|
||||
const [nextStationData, setNextStationData] = useState<StationProps[]>([]);
|
||||
const [untilStationData, setUntilStationData] = useState<StationProps[]>([]);
|
||||
useEffect(() => {
|
||||
//棒線駅判定を入れて、棒線駅なら時間を見て分数がマイナスならcontinue;
|
||||
const points = findReversalPoints(currentPosition, stopStationIDList);
|
||||
if (!points) return;
|
||||
if (points.length == 0) return;
|
||||
let searchCountBase = points.findIndex((d) => d == true);
|
||||
let searchCountFirst = points.findIndex((d) => d == true);
|
||||
let searchCountLast = points.findLastIndex((d) => d == true);
|
||||
console.log("searchCountBase", searchCountFirst, searchCountLast);
|
||||
for (
|
||||
let searchCount = searchCountBase;
|
||||
let searchCount = searchCountFirst;
|
||||
searchCount < points.length;
|
||||
searchCount++
|
||||
) {
|
||||
@@ -172,7 +203,7 @@ export const FixedTrain: FC<props> = ({
|
||||
}
|
||||
let trainList = [];
|
||||
for (
|
||||
let searchCount = searchCountBase - 1;
|
||||
let searchCount = searchCountFirst - 1;
|
||||
searchCount < points.length;
|
||||
searchCount++
|
||||
) {
|
||||
@@ -259,12 +290,12 @@ export const FixedTrain: FC<props> = ({
|
||||
alignContent: "center",
|
||||
alignSelf: "center",
|
||||
alignItems: "center",
|
||||
maxWidth: displaySize === 226 ? 60 : 100,
|
||||
maxWidth: displaySize === 226 ? 80 : 100,
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 14,
|
||||
fontSize: trainNameText.length > 4 ? 12 : 14,
|
||||
fontFamily: customTrainType.fontAvailable
|
||||
? "JR-Nishi"
|
||||
: undefined,
|
||||
@@ -282,7 +313,7 @@ export const FixedTrain: FC<props> = ({
|
||||
{customData.trainName && (
|
||||
<Text
|
||||
style={{
|
||||
fontSize: trainNameText.length > 6 ? 8 : 14,
|
||||
fontSize: trainNameText.length > 4 ? 8 : 14,
|
||||
color: "white",
|
||||
maxWidth: displaySize === 226 ? 200 : 60,
|
||||
textAlignVertical: "center",
|
||||
@@ -610,116 +641,138 @@ const CurrentPositionBox = ({
|
||||
overScrollMode="always"
|
||||
>
|
||||
{trainDataWithThrough.length > 0 &&
|
||||
trainDataWithThrough.map((d, index) => {
|
||||
if (!d) return null;
|
||||
if (d == "") return null;
|
||||
const [station, se, time] = d.split(",");
|
||||
let distanceMinute = 0;
|
||||
if (time != "") {
|
||||
const now = dayjs();
|
||||
const hour = parseInt(time.split(":")[0]);
|
||||
const distanceTime = now
|
||||
.hour(hour < 4 ? hour + 24 : hour)
|
||||
.minute(time.split(":")[1]);
|
||||
distanceMinute = distanceTime.diff(now, "minute") + delayTime;
|
||||
if (now.hour() < 4) {
|
||||
if (hour < 4) {
|
||||
distanceMinute = distanceMinute - 1440;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "column",
|
||||
backgroundColor: "#6e6e6eff",
|
||||
borderRadius: 30,
|
||||
marginHorizontal: isSmall ? 2 : 4,
|
||||
marginVertical: isSmall ? 0 : 2,
|
||||
padding: isSmall ? 2 : 4,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
overflow: "hidden",
|
||||
}}
|
||||
key={d + "CurrentPositionBox"}
|
||||
>
|
||||
{station.split("").map((i, index) => {
|
||||
return (
|
||||
<Text
|
||||
key={i + index}
|
||||
style={{
|
||||
fontSize: isSmall ? 5 : 12,
|
||||
color: "white",
|
||||
margin: 0,
|
||||
padding: 0,
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{i}
|
||||
</Text>
|
||||
);
|
||||
})}
|
||||
<View style={{ flex: 1 }} />
|
||||
{isSmall ||
|
||||
(time != "" && (
|
||||
<Text
|
||||
style={{
|
||||
fontSize: isSmall ? 8 : 12,
|
||||
color: "black",
|
||||
backgroundColor: "white",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{distanceMinute}
|
||||
</Text>
|
||||
))}
|
||||
<Text
|
||||
style={{
|
||||
fontSize: isSmall ? 8 : 14,
|
||||
color: se.includes("通")
|
||||
? "#020202ff"
|
||||
: index == 1 && secondText == ""
|
||||
? "#ffe852ff"
|
||||
: "white",
|
||||
marginTop: isSmall ? 0 : 3,
|
||||
height: isSmall ? "auto" : 17,
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{se.includes("通")
|
||||
? null
|
||||
: index == 1 && secondText == ""
|
||||
? "→"
|
||||
: "●"}
|
||||
</Text>
|
||||
</View>
|
||||
{index == 0 && secondText != "" && (
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "column",
|
||||
backgroundColor: "#6e6e6e0e",
|
||||
borderRadius: 10,
|
||||
marginHorizontal: isSmall ? 2 : 4,
|
||||
padding: isSmall ? 2 : 4,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
overflow: "hidden",
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Ionicons
|
||||
name="arrow-forward"
|
||||
size={isSmall ? 8 : 14}
|
||||
color="black"
|
||||
style={{ marginTop: isSmall ? 0 : 3 }}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
})}
|
||||
trainDataWithThrough.map((d, index) => (
|
||||
<EachStopData
|
||||
d={d}
|
||||
index={index}
|
||||
key={d}
|
||||
delayTime={delayTime}
|
||||
isSmall={isSmall}
|
||||
secondText={secondText}
|
||||
/>
|
||||
))}
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
type eachStopType = {
|
||||
d: string;
|
||||
delayTime: number;
|
||||
isSmall: boolean;
|
||||
index: number;
|
||||
secondText: string;
|
||||
};
|
||||
|
||||
const EachStopData: FC<eachStopType> = (props) => {
|
||||
const { d, delayTime, isSmall, index, secondText } = props;
|
||||
if (!d) return null;
|
||||
if (d == "") return null;
|
||||
const [station, se, time] = d.split(",");
|
||||
let distanceMinute = 0;
|
||||
if (time != "") {
|
||||
const now = dayjs();
|
||||
const hour = parseInt(time.split(":")[0]);
|
||||
const distanceTime = now
|
||||
.hour(hour < 4 ? hour + 24 : hour)
|
||||
.minute(parseInt(time.split(":")[1]));
|
||||
distanceMinute = distanceTime.diff(now, "minute") + delayTime;
|
||||
if (now.hour() < 4) {
|
||||
if (hour < 4) {
|
||||
distanceMinute = distanceMinute - 1440;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "column",
|
||||
backgroundColor: se.includes("通") ? "#6e6e6e77" : "#6e6e6eff",
|
||||
borderRadius: 30,
|
||||
marginHorizontal: isSmall ? 2 : 4,
|
||||
marginVertical: isSmall ? 0 : 2,
|
||||
padding: isSmall ? 2 : 4,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
overflow: "hidden",
|
||||
}}
|
||||
key={d + "CurrentPositionBox"}
|
||||
>
|
||||
{station.split("").map((i, index, array) => {
|
||||
return (
|
||||
<Text
|
||||
key={i + index}
|
||||
style={{
|
||||
fontSize:
|
||||
array.length < 5 ? (isSmall ? 5 : 12) : isSmall ? 3 : 10,
|
||||
color: "white",
|
||||
margin: 0,
|
||||
padding: 0,
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{i}
|
||||
</Text>
|
||||
);
|
||||
})}
|
||||
<View style={{ flex: 1 }} />
|
||||
{isSmall ||
|
||||
(time != "" && (
|
||||
<Text
|
||||
style={{
|
||||
fontSize: isSmall ? 8 : 12,
|
||||
color: "black",
|
||||
backgroundColor: "white",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{distanceMinute}
|
||||
</Text>
|
||||
))}
|
||||
<Text
|
||||
style={{
|
||||
fontSize: isSmall ? 8 : 14,
|
||||
color:
|
||||
index == 1 && secondText == ""
|
||||
? "#ffe852ff"
|
||||
: se.includes("通")
|
||||
? "#020202ff"
|
||||
: "white",
|
||||
marginTop: isSmall ? 0 : 3,
|
||||
height: isSmall ? "auto" : 17,
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{index == 1 && secondText == ""
|
||||
? "→"
|
||||
: se.includes("通")
|
||||
? null
|
||||
: "●"}
|
||||
</Text>
|
||||
</View>
|
||||
{index == 0 && secondText != "" && (
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "column",
|
||||
backgroundColor: "#0000",
|
||||
borderRadius: 10,
|
||||
marginHorizontal: isSmall ? 2 : 4,
|
||||
padding: isSmall ? 2 : 4,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
overflow: "hidden",
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Ionicons
|
||||
name="arrow-forward"
|
||||
size={isSmall ? 8 : 14}
|
||||
color="black"
|
||||
style={{ marginTop: isSmall ? 0 : 3 }}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
@@ -131,9 +131,9 @@ export const CurrentTrainProvider: FC<props> = ({ children }) => {
|
||||
} else if (pos[0] == "伊予白滝" && pos[1] == "伊予若宮") {
|
||||
return ["S14", "S18"];
|
||||
} else if (pos[0] == "伊予大洲" && pos[1] == "伊予若宮") {
|
||||
return ["U14", "U14"];
|
||||
return ["U14", "+Iyo"];
|
||||
} else if (pos[0] == "伊予若宮" && pos[1] == "伊予大洲") {
|
||||
return ["U14", "U14"];
|
||||
return ["-Iyo", "U14"];
|
||||
}
|
||||
const currentPosID = Object.keys(originalStationList).map((key) => {
|
||||
let firstStation = false;
|
||||
|
Reference in New Issue
Block a user