Merge commit 'ac9d4afdd87f9cbaae1d2e38065aa4832032bc7d' into patch/6.x
This commit is contained in:
commit
7bbb5b972f
122
components/ActionSheetComponents/EachTrainInfo/PositionBox.tsx
Normal file
122
components/ActionSheetComponents/EachTrainInfo/PositionBox.tsx
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
import { trainPosition } from "@/lib/trainPositionTextArray";
|
||||||
|
import React, { FC } from "react";
|
||||||
|
import { View, Text, TextStyle, ViewStyle } from "react-native";
|
||||||
|
|
||||||
|
type stateBox = {
|
||||||
|
currentTrainData: any;
|
||||||
|
platformNumber: any;
|
||||||
|
title: string;
|
||||||
|
style?: ViewStyle;
|
||||||
|
mode?: number;
|
||||||
|
platformDescription: string;
|
||||||
|
lineNumber: string;
|
||||||
|
};
|
||||||
|
export const PositionBox: FC<stateBox> = (props) => {
|
||||||
|
const {
|
||||||
|
currentTrainData,
|
||||||
|
platformNumber,
|
||||||
|
title,
|
||||||
|
style,
|
||||||
|
mode,
|
||||||
|
platformDescription,
|
||||||
|
lineNumber,
|
||||||
|
} = props;
|
||||||
|
let firstText = "";
|
||||||
|
let secondText = "";
|
||||||
|
let marginText = "";
|
||||||
|
let externalText = "";
|
||||||
|
const { isBetween, Pos: PosData } = trainPosition(currentTrainData);
|
||||||
|
if (isBetween === true) {
|
||||||
|
const { from, to } = PosData;
|
||||||
|
firstText = from;
|
||||||
|
secondText = to;
|
||||||
|
marginText = mode == 2 ? "→" : "↓";
|
||||||
|
} else {
|
||||||
|
const { Pos } = PosData;
|
||||||
|
if (Pos !== "") {
|
||||||
|
firstText = Pos;
|
||||||
|
if (platformNumber) {
|
||||||
|
secondText = `${platformNumber}番乗り場`;
|
||||||
|
if (lineNumber) {
|
||||||
|
externalText = `${lineNumber}番線`;
|
||||||
|
}
|
||||||
|
} else if (lineNumber) {
|
||||||
|
secondText = `${lineNumber}番線`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<View style={{ ...(mode == 2 ? boxStyle2 : boxStyle), ...style }}>
|
||||||
|
<Text style={{ fontSize: 12, color: "#0099CC" }}>{title}</Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
<View style={{ flexDirection: mode == 2 ? "row" : "column" }}>
|
||||||
|
{firstText && (
|
||||||
|
<Text style={mode == 2 ? boxTextStyle2 : (isBetween ? boxTextStyle : boxTextStyleBig)}>
|
||||||
|
{firstText}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
{marginText && (
|
||||||
|
<Text style={{ color: "#0099CC", textAlign: "right" }}>
|
||||||
|
{marginText}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
{secondText && (
|
||||||
|
<Text style={mode == 2 ? boxTextStyle2 :(isBetween ? boxTextStyle : boxTextStyleMini)}>
|
||||||
|
{secondText}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
{(platformDescription || externalText) && (
|
||||||
|
<View style={{ flexDirection: mode == 2 ? "row" : "column" }}>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
...{ ...(mode == 2 ? boxTextStyle2 : boxTextStyle) },
|
||||||
|
fontSize: 10,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{" " + externalText}
|
||||||
|
{" " + platformDescription}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const boxStyle: ViewStyle = {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: "white",
|
||||||
|
borderRadius: 10,
|
||||||
|
padding: 10,
|
||||||
|
margin: 10,
|
||||||
|
};
|
||||||
|
const boxStyle2: ViewStyle = {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: "white",
|
||||||
|
borderRadius: 10,
|
||||||
|
padding: 5,
|
||||||
|
margin: 5,
|
||||||
|
};
|
||||||
|
const boxTextStyle2: TextStyle = {
|
||||||
|
fontSize: 18,
|
||||||
|
color: "#0099CC",
|
||||||
|
textAlign: "right",
|
||||||
|
};
|
||||||
|
const boxTextStyleBig: TextStyle = {
|
||||||
|
fontSize: 28,
|
||||||
|
color: "#0099CC",
|
||||||
|
textAlign: "right",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const boxTextStyleMini: TextStyle = {
|
||||||
|
fontSize: 16,
|
||||||
|
color: "#0099CC",
|
||||||
|
textAlign: "right",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const boxTextStyle: TextStyle = {
|
||||||
|
fontSize: 25,
|
||||||
|
color: "#0099CC",
|
||||||
|
textAlign: "right",
|
||||||
|
};
|
@ -15,21 +15,7 @@ export const StateBox: FC<stateBox> = (props) => {
|
|||||||
<Text style={{ fontSize: 12, color: "#0099CC" }}>{title}</Text>
|
<Text style={{ fontSize: 12, color: "#0099CC" }}>{title}</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<View style={{ flexDirection: mode == 2 ? "row" : "column" }}>
|
<View style={{ flexDirection: mode == 2 ? "row" : "column" }}>
|
||||||
{text?.match("~") ? (
|
<Text style={mode == 2 ? boxTextStyle2 : boxTextStyle}>{text}</Text>
|
||||||
<>
|
|
||||||
<Text style={mode == 2 ? boxTextStyle2 : boxTextStyle}>
|
|
||||||
{text.split("~")[0]}
|
|
||||||
</Text>
|
|
||||||
<Text style={{ color: "#0099CC", textAlign: "right" }}>
|
|
||||||
{mode == 2 ? "→" : "↓"}
|
|
||||||
</Text>
|
|
||||||
<Text style={mode == 2 ? boxTextStyle2 : boxTextStyle}>
|
|
||||||
{text.split("~")[1]}
|
|
||||||
</Text>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Text style={mode == 2 ? boxTextStyle2 : boxTextStyle}>{text}</Text>
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
{endText && (
|
{endText && (
|
||||||
<View style={{ flexDirection: mode == 2 ? "row" : "column" }}>
|
<View style={{ flexDirection: mode == 2 ? "row" : "column" }}>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { View, TouchableOpacity, useWindowDimensions } from "react-native";
|
import { View, TouchableOpacity, useWindowDimensions } from "react-native";
|
||||||
import { StateBox } from "./StateBox";
|
import { StateBox } from "./StateBox";
|
||||||
|
import { PositionBox } from "./PositionBox";
|
||||||
import { useDeviceOrientationChange } from "../../../stateBox/useDeviceOrientationChange";
|
import { useDeviceOrientationChange } from "../../../stateBox/useDeviceOrientationChange";
|
||||||
import { getStationList2 } from "../../../lib/getStationList";
|
import { getStationList2 } from "../../../lib/getStationList";
|
||||||
import { useCurrentTrain } from "../../../stateBox/useCurrentTrain";
|
import { useCurrentTrain } from "../../../stateBox/useCurrentTrain";
|
||||||
@ -26,54 +27,58 @@ export const TrainDataView = ({
|
|||||||
const [mapsStationData, setMapsStationData] = useState(undefined);
|
const [mapsStationData, setMapsStationData] = useState(undefined);
|
||||||
|
|
||||||
const [platformNumber, setPlatformNumber] = useState();
|
const [platformNumber, setPlatformNumber] = useState();
|
||||||
|
const [lineNumber, setLineNumber] = useState();
|
||||||
const [platformDescription, setPlatformDescription] = useState();
|
const [platformDescription, setPlatformDescription] = useState();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//currentTrainData.Pos = "鴨川~端岡"; //test
|
//currentTrainData.Pos = "鴨川~端岡"; //test
|
||||||
if (!currentTrainData) return;
|
if (!currentTrainData) return;
|
||||||
fetch(
|
fetch(
|
||||||
`https://n8n.haruk.in/webhook/JR-shikoku-PosID?PosNum=${currentTrainData?.PosNum}&Line=${currentTrainData?.Line}`
|
`https://n8n.haruk.in/webhook/JR-shikoku-PosID-v3?PosId=${currentTrainData?.PosNum}&lineName=${currentTrainData?.Line}&StationName=${currentTrainData?.Pos}`
|
||||||
)
|
)
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
setPlatformNumber(data?.type == "Station" ? data?.platform : undefined);
|
if (!data) return;
|
||||||
setPlatformDescription(
|
const {
|
||||||
data?.type == "Station" ? data?.description : undefined
|
type,
|
||||||
);
|
stationName,
|
||||||
|
lineNumber,
|
||||||
|
platformNumber,
|
||||||
|
position,
|
||||||
|
description,
|
||||||
|
} = data;
|
||||||
|
if (type == "Station") {
|
||||||
|
setLineNumber(lineNumber);
|
||||||
|
setPlatformNumber(platformNumber);
|
||||||
|
setPlatformDescription(description);
|
||||||
|
} else {
|
||||||
|
setLineNumber(undefined);
|
||||||
|
setPlatformNumber(undefined);
|
||||||
|
setPlatformDescription(undefined);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, [currentTrainData]);
|
}, [currentTrainData]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getStationList2().then(setMapsStationData);
|
getStationList2().then(setMapsStationData);
|
||||||
}, []);
|
}, []);
|
||||||
const onLine = !!currentPosition?.toString().length;
|
const onLine = !!currentPosition?.toString().length;
|
||||||
const trainPositionText = (trainData) => {
|
|
||||||
const { isBetween, Pos: PosData } = trainPosition(trainData);
|
|
||||||
const { from, to, Pos } = PosData;
|
|
||||||
if (isBetween === true) return `${from}~${to}`;
|
|
||||||
if (Pos == "") return "";
|
|
||||||
return `${Pos}${platformNumber ? ` ${platformNumber}番線` : ""}`;
|
|
||||||
};
|
|
||||||
const [dialog, setDialog] = useState(false);
|
const [dialog, setDialog] = useState(false);
|
||||||
const [deleteDialog, setDeleteDialog] = useState(false);
|
|
||||||
const [posInput, setPosInput] = useState("");
|
const [posInput, setPosInput] = useState("");
|
||||||
const [descInput, setDescInput] = useState("");
|
const [descInput, setDescInput] = useState("");
|
||||||
const [stationInput, setStationInput] = useState("");
|
|
||||||
const [stationNumberInput, setStationNumberInput] = useState("");
|
const [stationNumberInput, setStationNumberInput] = useState("");
|
||||||
|
const [lineInput, setLineInput] = useState("");
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TrainPositionDataPush
|
<TrainPositionDataPush
|
||||||
dialog={dialog}
|
dialog={dialog}
|
||||||
setDialog={setDialog}
|
setDialog={setDialog}
|
||||||
currentTrainData={currentTrainData}
|
currentTrainData={currentTrainData}
|
||||||
stationInput={stationInput}
|
|
||||||
stationNumberInput={stationNumberInput}
|
stationNumberInput={stationNumberInput}
|
||||||
|
lineInput={lineInput}
|
||||||
|
setLineInput={setLineInput}
|
||||||
posInput={posInput}
|
posInput={posInput}
|
||||||
descInput={descInput}
|
|
||||||
setPosInput={setPosInput}
|
setPosInput={setPosInput}
|
||||||
|
descInput={descInput}
|
||||||
setDescInput={setDescInput}
|
setDescInput={setDescInput}
|
||||||
station={{
|
|
||||||
Station_JP: trainPositionText(currentTrainData),
|
|
||||||
StationNumber: currentPosition[0],
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
@ -95,19 +100,18 @@ export const TrainDataView = ({
|
|||||||
platformDescription == undefined
|
platformDescription == undefined
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
setStationInput(`${Pos.from}→${Pos.to}間`);
|
|
||||||
setStationNumberInput(
|
setStationNumberInput(
|
||||||
getStationID(currentTrainData?.Pos, stationList)
|
getStationID(currentTrainData?.Pos, stationList)
|
||||||
);
|
);
|
||||||
setPosInput(platformNumber?.toString() || "");
|
setPosInput(platformNumber?.toString() || "");
|
||||||
setDeleteDialog(true);
|
setLineInput(lineNumber?.toString() || "");
|
||||||
} else {
|
} else {
|
||||||
setStationInput(Pos.Pos);
|
|
||||||
setStationNumberInput(
|
setStationNumberInput(
|
||||||
getStationID(currentTrainData?.Pos, stationList)
|
getStationID(currentTrainData?.Pos, stationList)
|
||||||
);
|
);
|
||||||
setDescInput(platformDescription || "");
|
setDescInput(platformDescription || "");
|
||||||
setPosInput(platformNumber?.toString() || "");
|
setPosInput(platformNumber?.toString() || "");
|
||||||
|
setLineInput(lineNumber?.toString() || "");
|
||||||
setDialog(true);
|
setDialog(true);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@ -134,11 +138,13 @@ export const TrainDataView = ({
|
|||||||
SheetManager.hide("EachTrainInfo");
|
SheetManager.hide("EachTrainInfo");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<StateBox
|
<PositionBox
|
||||||
mode={mode}
|
mode={mode}
|
||||||
title={`現在地 ${currentPosition?.toString()}${onLine ? "▶️" : ""}`}
|
title={`現在地 ${currentPosition?.toString()}${onLine ? "▶️" : ""}`}
|
||||||
text={trainPositionText(currentTrainData)}
|
currentTrainData={currentTrainData}
|
||||||
endText={platformDescription ? `${platformDescription}` : ""}
|
platformNumber={platformNumber}
|
||||||
|
lineNumber={lineNumber}
|
||||||
|
platformDescription={platformDescription || ""}
|
||||||
style={
|
style={
|
||||||
onLine
|
onLine
|
||||||
? { borderWidth: 1, borderColor: "red", borderStyle: "solid" }
|
? { borderWidth: 1, borderColor: "red", borderStyle: "solid" }
|
||||||
|
@ -50,45 +50,66 @@ export const HeaderText: FC<Props> = ({
|
|||||||
const { expoPushToken } = useNotification();
|
const { expoPushToken } = useNotification();
|
||||||
|
|
||||||
// 列車名、種別、フォントの取得
|
// 列車名、種別、フォントの取得
|
||||||
const [typeName, trainName, fontAvailable, isOneMan, infogram, isEdit] =
|
const [
|
||||||
useMemo(() => {
|
typeName,
|
||||||
const { type, trainName, trainNumDistance, infogram, isEdit } =
|
trainName,
|
||||||
customTrainDataDetector(trainNum, allCustomTrainData);
|
fontAvailable,
|
||||||
const [typeString, fontAvailable, isOneMan] = getStringConfig(
|
isOneMan,
|
||||||
type,
|
infogram,
|
||||||
trainNum
|
isEdit,
|
||||||
);
|
uwasa,
|
||||||
switch (true) {
|
vehicleFormation,
|
||||||
case trainName !== "":
|
] = useMemo(() => {
|
||||||
// 特急の場合は、列車名を取得
|
const { type, trainName, trainNumDistance, infogram, isEdit, uwasa, vehicleFormation } =
|
||||||
// 列番対称データがある場合はそれから列車番号を取得
|
customTrainDataDetector(trainNum, allCustomTrainData);
|
||||||
return [
|
const [typeString, fontAvailable, isOneMan] = getStringConfig(
|
||||||
typeString,
|
type,
|
||||||
trainName +
|
trainNum
|
||||||
(trainNumDistance !== null
|
);
|
||||||
? ` ${parseInt(trainNum) - trainNumDistance}号`
|
switch (true) {
|
||||||
: ""),
|
case trainName !== "":
|
||||||
fontAvailable,
|
// 特急の場合は、列車名を取得
|
||||||
isOneMan,
|
// 列番対称データがある場合はそれから列車番号を取得
|
||||||
infogram,
|
return [
|
||||||
isEdit,
|
typeString,
|
||||||
];
|
trainName +
|
||||||
case trainData[trainData.length - 1] === undefined:
|
(trainNumDistance !== null
|
||||||
return [typeString, "", fontAvailable, isOneMan, infogram, isEdit];
|
? ` ${parseInt(trainNum) - trainNumDistance}号`
|
||||||
default:
|
: ""),
|
||||||
// 行先がある場合は、行先を取得
|
fontAvailable,
|
||||||
return [
|
isOneMan,
|
||||||
typeString,
|
infogram,
|
||||||
migrateTrainName(
|
isEdit,
|
||||||
trainData[trainData.length - 1].split(",")[0] + "行き"
|
uwasa,
|
||||||
),
|
vehicleFormation
|
||||||
fontAvailable,
|
];
|
||||||
isOneMan,
|
case trainData[trainData.length - 1] === undefined:
|
||||||
infogram,
|
return [
|
||||||
isEdit
|
typeString,
|
||||||
];
|
"",
|
||||||
}
|
fontAvailable,
|
||||||
}, [trainData]);
|
isOneMan,
|
||||||
|
infogram,
|
||||||
|
isEdit,
|
||||||
|
uwasa,
|
||||||
|
vehicleFormation
|
||||||
|
];
|
||||||
|
default:
|
||||||
|
// 行先がある場合は、行先を取得
|
||||||
|
return [
|
||||||
|
typeString,
|
||||||
|
migrateTrainName(
|
||||||
|
trainData[trainData.length - 1].split(",")[0] + "行き"
|
||||||
|
),
|
||||||
|
fontAvailable,
|
||||||
|
isOneMan,
|
||||||
|
infogram,
|
||||||
|
isEdit,
|
||||||
|
uwasa,
|
||||||
|
vehicleFormation
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}, [trainData]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
@ -121,7 +142,19 @@ export const HeaderText: FC<Props> = ({
|
|||||||
{isOneMan && <OneManText />}
|
{isOneMan && <OneManText />}
|
||||||
<Text style={textConfig}>{trainName}</Text>
|
<Text style={textConfig}>{trainName}</Text>
|
||||||
<InfogramText infogram={infogram} />
|
<InfogramText infogram={infogram} />
|
||||||
{isEdit &&<FontAwesome name="commenting-o" size={20} color="white" style={{ marginLeft: 5 }} onPress={()=>alert("このアイコン、列車データはコミュニティによってリアルタイム追加されています。")} />}
|
{isEdit && (
|
||||||
|
<FontAwesome
|
||||||
|
name="commenting-o"
|
||||||
|
size={20}
|
||||||
|
color="white"
|
||||||
|
style={{ marginLeft: 5 }}
|
||||||
|
onPress={() =>
|
||||||
|
alert(
|
||||||
|
`[このアイコン、列車データはコミュニティによってリアルタイム追加されています。]\n使用車両情報:\n${vehicleFormation}\n投稿者メモ:\n${uwasa || "なし"}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
|
@ -197,6 +197,19 @@ export const FixedContentBottom = (props) => {
|
|||||||
</Text>
|
</Text>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
<Text style={{ fontWeight: "bold", fontSize: 20 }}>その他</Text>
|
<Text style={{ fontWeight: "bold", fontSize: 20 }}>その他</Text>
|
||||||
|
<TextBox
|
||||||
|
backgroundColor="rgb(88, 101, 242)"
|
||||||
|
flex={1}
|
||||||
|
onPressButton={() => Linking.openURL("https://twitter.com/Xprocess_main/status/1955242437817012300")}
|
||||||
|
|
||||||
|
>
|
||||||
|
<Text style={{ color: "white", fontWeight: "bold", fontSize: 20 }}>
|
||||||
|
公式Discordのご案内
|
||||||
|
</Text>
|
||||||
|
<Text style={{ color: "white", fontSize: 18 }}>
|
||||||
|
皆さんの目撃情報をアプリに反映しませんか?Discordに登録して運用を報告しましょう!
|
||||||
|
</Text>
|
||||||
|
</TextBox>
|
||||||
<TextBox
|
<TextBox
|
||||||
backgroundColor="linear-gradient(120deg, rgba(247,135,54,0.208) 0%, rgba(54,125,247,0.208) 100%)"
|
backgroundColor="linear-gradient(120deg, rgba(247,135,54,0.208) 0%, rgba(54,125,247,0.208) 100%)"
|
||||||
flex={1}
|
flex={1}
|
||||||
|
@ -17,7 +17,7 @@ import { SwitchArea } from "../atom/SwitchArea";
|
|||||||
import { useNotification } from "../../stateBox/useNotifications";
|
import { useNotification } from "../../stateBox/useNotifications";
|
||||||
import { SheetHeaderItem } from "@/components/atom/SheetHeaderItem";
|
import { SheetHeaderItem } from "@/components/atom/SheetHeaderItem";
|
||||||
|
|
||||||
const versionCode = "6.1.3"; // Update this version code as needed
|
const versionCode = "6.1.4"; // Update this version code as needed
|
||||||
|
|
||||||
export const SettingTopPage = ({
|
export const SettingTopPage = ({
|
||||||
testNFC,
|
testNFC,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import React, { FC, useEffect, useState } from "react";
|
import React, { FC, useEffect, useState } from "react";
|
||||||
import { Linking, TouchableOpacity, Text } from "react-native";
|
import { TouchableOpacity } from "react-native";
|
||||||
import { Dialog, Button, Input } from "react-native-elements";
|
|
||||||
import { checkDuplicateTrainData } from "../../lib/checkDuplicateTrainData";
|
import { checkDuplicateTrainData } from "../../lib/checkDuplicateTrainData";
|
||||||
import { getTrainDelayStatus } from "../../lib/getTrainDelayStatus";
|
import { getTrainDelayStatus } from "../../lib/getTrainDelayStatus";
|
||||||
import { getTrainType } from "../../lib/getTrainType";
|
import { getTrainType } from "../../lib/getTrainType";
|
||||||
@ -121,6 +120,7 @@ export const EachData: FC<Props> = (props) => {
|
|||||||
const [dialog, setDialog] = useState(false);
|
const [dialog, setDialog] = useState(false);
|
||||||
const [deleteDialog, setDeleteDialog] = useState(false);
|
const [deleteDialog, setDeleteDialog] = useState(false);
|
||||||
const [posInput, setPosInput] = useState("");
|
const [posInput, setPosInput] = useState("");
|
||||||
|
const [lineInput, setLineInput] = useState("");
|
||||||
const [descInput, setDescInput] = useState("");
|
const [descInput, setDescInput] = useState("");
|
||||||
const [stationInput, setStationInput] = useState("");
|
const [stationInput, setStationInput] = useState("");
|
||||||
const [stationNumberInput, setStationNumberInput] = useState("");
|
const [stationNumberInput, setStationNumberInput] = useState("");
|
||||||
@ -157,13 +157,13 @@ export const EachData: FC<Props> = (props) => {
|
|||||||
setDialog={setDialog}
|
setDialog={setDialog}
|
||||||
{...{
|
{...{
|
||||||
currentTrainData,
|
currentTrainData,
|
||||||
stationInput,
|
|
||||||
stationNumberInput,
|
stationNumberInput,
|
||||||
|
lineInput,
|
||||||
|
setLineInput,
|
||||||
posInput,
|
posInput,
|
||||||
descInput,
|
|
||||||
setPosInput,
|
setPosInput,
|
||||||
setDescInput,
|
descInput,
|
||||||
station,
|
setDescInput
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
@ -215,6 +215,8 @@ export const EachData: FC<Props> = (props) => {
|
|||||||
setPlatformNumber={setPlatformNumber}
|
setPlatformNumber={setPlatformNumber}
|
||||||
platformDescription={platformDescription}
|
platformDescription={platformDescription}
|
||||||
platformNumber={platformNumber}
|
platformNumber={platformNumber}
|
||||||
|
lineInput={lineInput}
|
||||||
|
setLineInput={setLineInput}
|
||||||
key={d.train + "-trainPosition"}
|
key={d.train + "-trainPosition"}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { FC, useEffect } from "react";
|
import React, { FC, useEffect, useState } from "react";
|
||||||
import { Text, TextStyle, View, TouchableOpacity } from "react-native";
|
import { Text, TextStyle, View, TouchableOpacity } from "react-native";
|
||||||
import { useStationList } from "../../../stateBox/useStationList";
|
import { useStationList } from "../../../stateBox/useStationList";
|
||||||
import {
|
import {
|
||||||
@ -24,9 +24,11 @@ type Props = {
|
|||||||
setDialog: (dialog: boolean) => void;
|
setDialog: (dialog: boolean) => void;
|
||||||
setDeleteDialog: (dialog: boolean) => void;
|
setDeleteDialog: (dialog: boolean) => void;
|
||||||
platformDescription: string;
|
platformDescription: string;
|
||||||
platformNumber: number;
|
platformNumber: string;
|
||||||
setPlatformDescription: (desc: string) => void;
|
setPlatformDescription: (desc: string) => void;
|
||||||
setPlatformNumber: (num: number) => void;
|
setPlatformNumber: (num: string) => void;
|
||||||
|
lineInput: string;
|
||||||
|
setLineInput: (line: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TrainPosition: FC<Props> = ({
|
export const TrainPosition: FC<Props> = ({
|
||||||
@ -43,28 +45,55 @@ export const TrainPosition: FC<Props> = ({
|
|||||||
setPlatformNumber,
|
setPlatformNumber,
|
||||||
platformDescription,
|
platformDescription,
|
||||||
platformNumber,
|
platformNumber,
|
||||||
|
setLineInput,
|
||||||
}) => {
|
}) => {
|
||||||
const { currentTrain } = useCurrentTrain();
|
|
||||||
const { stationList } = useStationList();
|
const { stationList } = useStationList();
|
||||||
|
type data = {
|
||||||
|
type: string;
|
||||||
|
lineNumber: string;
|
||||||
|
platformNumber: string;
|
||||||
|
position: string;
|
||||||
|
stationName: string;
|
||||||
|
description: string;
|
||||||
|
};
|
||||||
|
const [database, setDatabase] = useState<data>(null);
|
||||||
|
const [text, setText] = useState("");
|
||||||
|
const [masterText, setMasterText] = useState("");
|
||||||
|
useEffect(() => {
|
||||||
|
const text = `${currentTrainData?.PosNum} ${currentTrainData?.Line} ${currentTrainData?.Pos}`;
|
||||||
|
setText(trainIDSwitch ? text : masterText);
|
||||||
|
return () => {
|
||||||
|
setText("");
|
||||||
|
};
|
||||||
|
}, [masterText, trainIDSwitch]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch(
|
fetch(
|
||||||
`https://n8n.haruk.in/webhook/JR-shikoku-PosID?PosNum=${currentTrainData?.PosNum}&Line=${currentTrainData?.Line}`
|
`https://n8n.haruk.in/webhook/JR-shikoku-PosID-v3?PosId=${currentTrainData?.PosNum}&lineName=${currentTrainData?.Line}&StationName=${currentTrainData?.Pos}`
|
||||||
)
|
)
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data: { type: string; platform: number; description: string }) => {
|
.then((data: data) => {
|
||||||
setPlatformNumber(data?.type == "Station" ? data?.platform : undefined);
|
const { type, platformNumber, description, lineNumber } = data;
|
||||||
setPlatformDescription(
|
setDatabase(data);
|
||||||
data?.type == "Station" ? data?.description : undefined
|
const { isBetween, Pos } = trainPosition(currentTrainData);
|
||||||
);
|
if (isBetween === true) {
|
||||||
|
// 移動中
|
||||||
|
setMasterText(`現在地:${Pos.from}→${Pos.to}間を走行中`);
|
||||||
|
} else {
|
||||||
|
if (Pos.Pos) {
|
||||||
|
let platform = platformNumber ? `${platformNumber}番乗り場` : "";
|
||||||
|
let line = lineNumber ? `${lineNumber}番線` : "";
|
||||||
|
setMasterText(
|
||||||
|
`現在地:${Pos.Pos} ${platform || line} ${description || ""}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
setMasterText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, [currentTrainData, currentTrain]);
|
return () => {
|
||||||
|
setMasterText("");
|
||||||
const trainPositionText = (trainData: trainDataType) => {
|
};
|
||||||
const { isBetween, Pos } = trainPosition(trainData);
|
}, [currentTrainData?.PosNum, currentTrainData?.Line, currentTrainData?.Pos]);
|
||||||
if (isBetween === true) return `現在地:${Pos.from}→${Pos.to}間を走行中`;
|
|
||||||
else return Pos.Pos == "" ? "" : `現在地:${Pos.Pos}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
@ -80,22 +109,18 @@ export const TrainPosition: FC<Props> = ({
|
|||||||
}}
|
}}
|
||||||
onLongPress={() => {
|
onLongPress={() => {
|
||||||
const { isBetween, Pos } = trainPosition(currentTrainData);
|
const { isBetween, Pos } = trainPosition(currentTrainData);
|
||||||
|
setStationNumberInput(getStationID(currentTrainData?.Pos, stationList));
|
||||||
|
setPosInput(database?.platformNumber?.toString() || "");
|
||||||
if (isBetween === true) {
|
if (isBetween === true) {
|
||||||
if (platformNumber == undefined && platformDescription == undefined)
|
if (database?.platformNumber == undefined && database?.description == undefined)
|
||||||
return;
|
return;
|
||||||
setStationInput(`${Pos.from}→${Pos.to}間`);
|
setStationInput(`${Pos.from}→${Pos.to}間`);
|
||||||
setStationNumberInput(
|
|
||||||
getStationID(currentTrainData?.Pos, stationList)
|
|
||||||
);
|
|
||||||
setPosInput(platformNumber?.toString() || "");
|
|
||||||
setDeleteDialog(true);
|
setDeleteDialog(true);
|
||||||
} else {
|
} else {
|
||||||
setStationInput(Pos.Pos);
|
setStationInput(currentTrainData?.Pos);
|
||||||
setStationNumberInput(
|
setDescInput(database?.description || "");
|
||||||
getStationID(currentTrainData?.Pos, stationList)
|
setLineInput(database?.lineNumber?.toString() || "");
|
||||||
);
|
setPlatformNumber(database?.platformNumber?.toString() || "");
|
||||||
setDescInput(platformDescription || "");
|
|
||||||
setPosInput(platformNumber?.toString() || "");
|
|
||||||
setDialog(true);
|
setDialog(true);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@ -105,13 +130,7 @@ export const TrainPosition: FC<Props> = ({
|
|||||||
style={{ ...descriptionStyle, color: "green" }}
|
style={{ ...descriptionStyle, color: "green" }}
|
||||||
numberOfLines={numberOfLines}
|
numberOfLines={numberOfLines}
|
||||||
>
|
>
|
||||||
{`${
|
{text}
|
||||||
trainIDSwitch
|
|
||||||
? currentTrainData?.PosNum + currentTrainData?.Line
|
|
||||||
: trainPositionText(currentTrainData)
|
|
||||||
} ${platformNumber ? platformNumber + "番線" : ""} ${
|
|
||||||
platformDescription ? "(" + platformDescription + ")" : ""
|
|
||||||
}`}
|
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
@ -17,7 +17,7 @@ export const TrainPositionDataDelete: FC<Props> = ({
|
|||||||
stationNumberInput,
|
stationNumberInput,
|
||||||
}) => {
|
}) => {
|
||||||
const sendPlatformData = () => {
|
const sendPlatformData = () => {
|
||||||
fetch(`https://n8n.haruk.in/webhook/JR-shikoku-PosID`, {
|
fetch(`https://n8n.haruk.in/webhook/JR-shikoku-PosID-v3`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
@ -1,46 +1,47 @@
|
|||||||
import React, { FC, useState } from "react";
|
import React, { FC } from "react";
|
||||||
import { Text } from "react-native";
|
import { Text } from "react-native";
|
||||||
import { Dialog, Input, Button } from "react-native-elements";
|
import { Dialog, Input, Button } from "react-native-elements";
|
||||||
import { trainDataType } from "../../../lib/trainPositionTextArray";
|
import { trainDataType } from "../../../lib/trainPositionTextArray";
|
||||||
import { useCurrentTrain } from "../../../stateBox/useCurrentTrain";
|
import { getStationID } from "@/lib/eachTrainInfoCoreLib/getStationData";
|
||||||
|
import { useStationList } from "@/stateBox/useStationList";
|
||||||
type Props = {
|
type Props = {
|
||||||
dialog: boolean;
|
dialog: boolean;
|
||||||
setDialog: (dialog: boolean) => void;
|
setDialog: (dialog: boolean) => void;
|
||||||
currentTrainData: trainDataType;
|
currentTrainData: trainDataType;
|
||||||
stationInput: string;
|
|
||||||
stationNumberInput: string;
|
stationNumberInput: string;
|
||||||
posInput: string;
|
posInput: string;
|
||||||
descInput: string;
|
descInput: string;
|
||||||
|
lineInput: string;
|
||||||
setPosInput: (pos: string) => void;
|
setPosInput: (pos: string) => void;
|
||||||
setDescInput: (desc: string) => void;
|
setDescInput: (desc: string) => void;
|
||||||
station: {
|
setLineInput: (line: string) => void;
|
||||||
Station_JP: string;
|
|
||||||
StationNumber: string;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
export const TrainPositionDataPush: FC<Props> = ({
|
export const TrainPositionDataPush: FC<Props> = ({
|
||||||
dialog,
|
dialog,
|
||||||
setDialog,
|
setDialog,
|
||||||
currentTrainData,
|
currentTrainData,
|
||||||
stationInput,
|
|
||||||
stationNumberInput,
|
stationNumberInput,
|
||||||
|
lineInput,
|
||||||
|
setLineInput,
|
||||||
posInput,
|
posInput,
|
||||||
descInput,
|
|
||||||
setPosInput,
|
setPosInput,
|
||||||
|
descInput,
|
||||||
setDescInput,
|
setDescInput,
|
||||||
station,
|
|
||||||
}) => {
|
}) => {
|
||||||
|
const { stationList } = useStationList();
|
||||||
const sendPlatformData = () => {
|
const sendPlatformData = () => {
|
||||||
fetch(`https://n8n.haruk.in/webhook/JR-shikoku-PosID`, {
|
fetch(`https://n8n.haruk.in/webhook/JR-shikoku-PosID-v3`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
PosId: currentTrainData?.PosNum,
|
PosId: currentTrainData?.PosNum, //自動:位置情報ID
|
||||||
lineName: currentTrainData?.Line,
|
StationId: getStationID(currentTrainData?.Pos, stationList), //自動:駅ID
|
||||||
PlatformNum: parseInt(posInput),
|
StationName: currentTrainData?.Pos, //自動:駅名、漢字
|
||||||
Description: descInput,
|
lineName: currentTrainData?.Line, //自動:位置情報路線ID(koutoku/yosan)
|
||||||
StationName: station.Station_JP,
|
Description: descInput, //手動入力、参考情報
|
||||||
StationId: station.StationNumber,
|
platformNumber: parseInt(posInput), //手動入力、乗り場表記
|
||||||
|
lineNumber: parseInt(lineInput), //手動入力、番線表記
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@ -55,22 +56,30 @@ export const TrainPositionDataPush: FC<Props> = ({
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Dialog isVisible={dialog} onBackdropPress={() => setDialog(false)}>
|
<Dialog isVisible={dialog} onBackdropPress={() => setDialog(false)}>
|
||||||
|
<Text style={{ fontSize: 20, fontWeight: "bold" }}>駅番線情報投稿機能</Text>
|
||||||
<Text>路線: {currentTrainData?.Line}</Text>
|
<Text>路線: {currentTrainData?.Line}</Text>
|
||||||
<Text>地点ID: {currentTrainData?.PosNum}</Text>
|
<Text>地点ID: {currentTrainData?.PosNum}</Text>
|
||||||
<Text>駅名: {stationInput}</Text>
|
<Text>駅名: {currentTrainData?.Pos}</Text>
|
||||||
<Text>駅ナンバー: {stationNumberInput}</Text>
|
<Text>駅ナンバー: {stationNumberInput}</Text>
|
||||||
<Input
|
<Input
|
||||||
label="番線"
|
label="乗り場"
|
||||||
inputMode="numeric"
|
inputMode="numeric"
|
||||||
value={posInput}
|
value={posInput}
|
||||||
onChangeText={setPosInput}
|
onChangeText={setPosInput}
|
||||||
/>
|
/>
|
||||||
|
<Input
|
||||||
|
label="番線"
|
||||||
|
inputMode="numeric"
|
||||||
|
value={lineInput}
|
||||||
|
onChangeText={setLineInput}
|
||||||
|
/>
|
||||||
<Input
|
<Input
|
||||||
label="参考情報"
|
label="参考情報"
|
||||||
inputMode="text"
|
inputMode="text"
|
||||||
value={descInput}
|
value={descInput}
|
||||||
onChangeText={setDescInput}
|
onChangeText={setDescInput}
|
||||||
/>
|
/>
|
||||||
|
<Text style={{ fontSize: 12, fontWeight: "bold" }}>この機能は駅の停車位置に関する情報を投稿する機能です。列車の遅れ、運行情報を投稿するフォームではありませんのでご注意ください。</Text>
|
||||||
<Button title="送信" onPress={sendPlatformData} />
|
<Button title="送信" onPress={sendPlatformData} />
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user