コードの配置変更

This commit is contained in:
harukin-expo-dev-env 2025-03-21 17:02:10 +00:00
parent 9fe53f55e9
commit 3d75ab149f
3 changed files with 44 additions and 24 deletions

View File

@ -189,7 +189,8 @@ export const EachTrainInfoCore = ({
const count = position * 44 - 50;
// 0.5秒待機してからスクロール
setTimeout(
() => scrollHandlers.ref.current?.scrollTo({ y: count, animated: true }),
() =>
scrollHandlers.ref.current?.scrollTo({ y: count, animated: true }),
400
);
}
@ -291,7 +292,7 @@ export const EachTrainInfoCore = ({
} else if (pos[1] == "児島" && pos[0] == "宇多津") {
setCurrentPosition(["Y09", "M12"]);
return;
}else if (pos[0] == "伊予若宮" && pos[1] == "伊予白滝") {
} else if (pos[0] == "伊予若宮" && pos[1] == "伊予白滝") {
setCurrentPosition(["S18", "S14"]);
return;
} else if (pos[0] == "伊予白滝" && pos[1] == "伊予若宮") {
@ -380,13 +381,6 @@ export const EachTrainInfoCore = ({
}
};
const headerItem = {
currentTrainData,
currentPosition,
nearTrainIDList,
openTrainInfo,
navigate,
};
return (
<View
style={{
@ -431,8 +425,28 @@ export const EachTrainInfoCore = ({
maxHeight: isLandscape ? height - 94 : (height / 100) * 70,
},
}}
shortHeader={<ShortHeader {...headerItem} />}
longHeader={<LongHeader {...headerItem} />}
shortHeader={
<ShortHeader
{...{
currentTrainData,
currentPosition,
nearTrainIDList,
openTrainInfo,
navigate,
}}
/>
}
longHeader={
<LongHeader
{...{
currentTrainData,
currentPosition,
nearTrainIDList,
openTrainInfo,
navigate,
}}
/>
}
topStickyContent={
<ScrollStickyContent
{...{ currentTrainData, showThrew, setShowThrew, haveThrough }}

View File

@ -74,7 +74,7 @@ export const HeaderText: FC<Props> = ({
}
// 列車名、種別、フォントの取得
const [typeName, trainName, fontAvailable] = useMemo(() => {
const [typeName, trainName, fontAvailable, isOneMan] = useMemo(() => {
if (!limited) return "";
const limitedArray = limited.split(":");
const [type, fontAvailable] = (() => {
@ -101,14 +101,24 @@ export const HeaderText: FC<Props> = ({
return ["", false];
}
})();
const isOneMan = (() => {
const OneManRegex = new RegExp(/^4[1-9]\d\d[DM]$/);
const OneManRegex2 = new RegExp(/^5[1-7]\d\d[DM]$/);
const OneManRegex3 = new RegExp(/^3[2-9]\d\d[DM]$/);
return !!(
OneManRegex.test(trainNum) ||
OneManRegex2.test(trainNum) ||
OneManRegex3.test(trainNum)
);
})();
switch (true) {
case !!limitedArray[1]:
// 特急の場合は、列車名を取得
return [type, migrateTrainName(limitedArray[1]), fontAvailable];
return [type, migrateTrainName(limitedArray[1]), fontAvailable, isOneMan];
case trainData.length == 0:
// 特急以外の場合は、列車番号を取得
return [type, "", fontAvailable];
return [type, "", fontAvailable, isOneMan];
default:
// 行先がある場合は、行先を取得
return [
@ -117,20 +127,11 @@ export const HeaderText: FC<Props> = ({
trainData[trainData.length - 1].split(",")[0] + "行き"
),
fontAvailable,
isOneMan,
];
}
}, [limited, trainData]);
// 1人運転の判定
const isOneMan = useMemo(() => {
const OneManRegex = new RegExp(/^4[1-9]\d\d[DM]$/);
const OneManRegex2 = new RegExp(/^5[1-7]\d\d[DM]$/);
return !!(
OneManRegex.test(trainNum) ||
OneManRegex2.test(trainNum) ||
trainNum === "3621D"
);
}, [trainNum]);
return (
<View style={{ padding: 10, flexDirection: "row", alignItems: "center" }}>

View File

@ -49,6 +49,11 @@ export const AppsWebView = ({ openStationACFromEachTrainInfo }) => {
const onMessage = (event) => {
const { data } = event.nativeEvent;
/**
* {type,trainNum,limited}
* {type,currentLines}
* {type,event,id,name,pdf,map,url,chk}
*/
if (data.includes("train.html")) {
navigate("trainbase", { info: data, from: "Train" });
return;