文字フォントとワンマン対応改造

This commit is contained in:
harukin-expo-dev-env 2025-01-05 10:26:19 +00:00
parent e29b4f5da3
commit d9fb24840a
7 changed files with 162 additions and 29 deletions

Binary file not shown.

Binary file not shown.

View File

@ -6,6 +6,7 @@ import { getType } from "../../../lib/eachTrainInfoCoreLib/getType";
import { migrateTrainName } from "../../../lib/eachTrainInfoCoreLib/migrateTrainName";
import { TrainIconStatus } from "./trainIconStatus";
import { TrainViewIcon } from "./trainViewIcon";
import { useFonts } from "expo-font";
type Props = {
data: { trainNum: string; limited: string };
@ -34,6 +35,10 @@ export const HeaderText: FC<Props> = ({
navigate,
from,
}) => {
const [loaded, error] = useFonts({
"JR-Nishi": require("../../../assets/fonts/西日本方向幕ロゴ.otf"),
"Zou": require("../../../assets/fonts/DelaGothicOne-Regular.ttf"),
});
const [typeName, trainName] = useMemo(() => {
if (!data.limited) return "";
const limitedArray = data.limited.split(":");
@ -59,10 +64,111 @@ export const HeaderText: FC<Props> = ({
return (
<View style={{ padding: 10, flexDirection: "row", alignItems: "center" }}>
<TrainIconStatus {...{ data, navigate, from }} />
<Text style={textConfig}>
{typeName}{" "}
{trainName}
</Text>
<View
style={{
//backgroundColor: "rgb(69, 69, 69)",
borderRadius: 5,
//borderWidth: 1,
flexDirection: "row",
alignItems: "center",
}}
>
{loaded ? (
<>
<Text
style={{
fontSize: 20,
fontFamily: "JR-Nishi",
textShadowColor: "white",
textShadowOffset: { width: 0, height: 0 },
textShadowRadius: 0,
//margin: 2,
marginRight: 5,
//backgroundColor: "rgb(69, 69, 69)",
color: "white",
}}
>
{(() => {
if (typeName) return typeName;
switch (true) {
case !!data.trainNum.match("T"):
case !!data.trainNum.match("R"):
case !!data.trainNum.match("E"):
case !!data.trainNum.match("L"):
case !!data.trainNum.match("A"):
case !!data.trainNum.match("B"):
return "回送";
case !!data.trainNum.match("D"):
case !!data.trainNum.match("M"):
return "普通";
default:
return "";
}
})()}
</Text>
{new RegExp(/^4[1-9]\d\d[DM]$/).test(data.trainNum) || new RegExp(/^5[1-7]\d\d[DM]$/).test(data.trainNum) || data.trainNum ==="3621D" ?
<View style={{ flexDirection: "column", marginRight: 7 }}>
<Text
style={{
fontSize: 12,
textShadowColor: "white",
textShadowOffset: { width: 0, height: 0 },
textShadowRadius: 0,
margin: -2,
marginRight: 5,
color: "white",
fontFamily: "Zou",
}}
>
</Text>
<Text
style={{
fontSize: 12,
textShadowColor: "white",
textShadowOffset: { width: 0, height: 0 },
textShadowRadius: 0,
margin: -2,
color: "white",
fontFamily: "Zou",
}}
>
{" "}
</Text>
</View>
: null}
</>
) : (
<Text style={textConfig}>{typeName}</Text>
)}
<Text
style={{
fontSize: 18,
textShadowColor: "white",
textShadowOffset: { width: 0, height: 0 },
textShadowRadius: 0,
//borderWidth: 1,
//borderColor: "white",
fontWeight: "bold",
//fontStyle: "italic",
// color: (() => {
// switch (typeName) {
// case "快速":
// return "rgb(7, 124, 192)";
// case "特急":
// return "rgb(211, 13, 6)";
// default:
// return "white";
// }
// })(),
color: "white",
}}
>
{trainName}
</Text>
</View>
<View style={{ flex: 1 }} />
<Text style={textConfig}>
{showHeadStation.map((d) => `${headStation[d].id} + `)}

View File

@ -692,14 +692,28 @@ export const customTrainDataDetector = (TrainNumber: string) => {
};
default:
return {
type: "Normal",
trainName: "",
trainIcon: null,
infoUrl: null,
trainNumDistance: null,
info: null,
};
if (
new RegExp(/^4[1-9]\d\d[DM]$/).test(TrainNumber) ||
new RegExp(/^5[1-7]\d\d[DM]$/).test(TrainNumber) ||
TrainNumber === "3621D"
)
return {
type: "OneMan",
trainName: "",
trainIcon: null,
infoUrl: null,
trainNumDistance: null,
info: null,
};
else
return {
type: "Normal",
trainName: "",
trainIcon: null,
infoUrl: null,
trainNumDistance: null,
info: null,
};
break;
}
};

View File

@ -73,23 +73,27 @@ export const EachData: FC<Props> = (props) => {
const getTrainDataFromCurrentTrain = (trainNum: string) => {
const customTrainData = customTrainDataDetector(d.train);
if (customTrainData.type != "Normal") return customTrainData;
const currentTrainData = currentTrain.filter((a) => a.num == trainNum);
if (currentTrainData.length == 0) return customTrainData;
else if (currentTrainData[0].Type.includes("rapid:")) {
const typeText = currentTrainData[0].Type.split(":");
const returnData = {
type: "Rapid",
trainName: typeText[1].replace("\r", ""),
trainIcon: null,
trainNumDistance: null,
info: "",
};
return returnData;
switch (customTrainData.type) {
case "Normal":
case "OneMan":
const currentTrainData = currentTrain.filter((a) => a.num == trainNum);
if (currentTrainData.length == 0) return customTrainData;
else if (currentTrainData[0].Type.includes("rapid:")) {
const typeText = currentTrainData[0].Type.split(":");
const returnData = {
type: "Rapid",
trainName: typeText[1].replace("\r", ""),
trainIcon: null,
trainNumDistance: null,
info: "",
};
return returnData;
}
return customTrainData;
default:
return customTrainData;
}
return customTrainData;
};
const [train, setTrain] = useState(getTrainDataFromCurrentTrain(d.train));
useEffect(() => {
setTrain(getTrainDataFromCurrentTrain(d.train));

View File

@ -2,11 +2,17 @@ import React from "react";
import { View } from "react-native";
import { WebView } from "react-native-webview";
import { BigButton } from "./components/atom/BigButton";
import { useNavigation } from "@react-navigation/native";
export default ({ navigation: { navigate }, route }) => {
const { info, goTo, useShow } = route.params;
const { goBack } = useNavigation();
const onExit = () => {
navigate(goTo || "Apps");
useShow && useShow();
if(goTo != "NearTrainDiagramView") {
navigate(goTo || "Apps");
useShow && useShow();
} else {
goBack();
}
};
return (
<View style={styles}>

View File

@ -12,6 +12,7 @@ type trainTypeString =
| "寝台特急"
| "臨時"
| "普通列車"
| "普通列車(ワンマン)"
| "その他";
type trainTypeDataString = "rapid" | "express" | "normal";
type getTrainType = (d: nameString) => {
@ -29,6 +30,8 @@ export const getTrainType: getTrainType = (nameString) => {
return { color: "red", name: "寝台特急", data: "express" };
case "SPCL":
return { color: "blue", name: "臨時", data: "normal" };
case "OneMan":
return { color: "white", name: "普通列車(ワンマン)", data: "normal" };
case "Normal":
return { color: "white", name: "普通列車", data: "normal" };
default: