不要な内容の整理とコードの並び替え

This commit is contained in:
harukin-expo-dev-env
2025-09-24 07:11:34 +00:00
parent 7ae6bc8801
commit f7e59cd75b
3 changed files with 42 additions and 41 deletions

View File

@@ -5,10 +5,12 @@ import Constants from "expo-constants";
import { FixedTrain } from "./FixedPositionBox/FixedTrainBox";
import { FixedStation } from "./FixedPositionBox/FixedStationBox";
import { useState } from "react";
import { useTrainMenu } from "@/stateBox/useTrainMenu";
export const FixedPositionBox = () => {
const { fixedPosition, setFixedPosition } = useCurrentTrain();
const [displaySize, setDisplaySize] = useState(76);
const { mapSwitch } = useTrainMenu();
const { fixedPosition } = useCurrentTrain();
const [displaySize, setDisplaySize] = useState(mapSwitch == "true" ? 76 : 80);
useKeepAwake();
return (

View File

@@ -15,6 +15,7 @@ import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram";
import { useAreaInfo } from "@/stateBox/useAreaInfo";
import { useCurrentTrain } from "@/stateBox/useCurrentTrain";
import { useStationList } from "@/stateBox/useStationList";
import { useTrainMenu } from "@/stateBox/useTrainMenu";
import { Ionicons } from "@expo/vector-icons";
import { useNavigation } from "@react-navigation/native";
@@ -33,6 +34,7 @@ export const FixedStation: FC<props> = ({
displaySize,
setDisplaySize,
}) => {
const { mapSwitch } = useTrainMenu();
const { currentTrain, setFixedPosition } = useCurrentTrain();
const { getStationDataFromId } = useStationList();
const { navigate } = useNavigation();
@@ -48,7 +50,7 @@ export const FixedStation: FC<props> = ({
////
const { allTrainDiagram } = useAllTrainDiagram();
const { areaInfo, areaStationID } = useAreaInfo();
const { areaStationID } = useAreaInfo();
const [stationDiagram, setStationDiagram] = useState({}); //当該駅の全時刻表
const [isInfoArea, setIsInfoArea] = useState(false);
@@ -283,10 +285,10 @@ export const FixedStation: FC<props> = ({
duration: 500,
update: { type: "spring", springDamping: 0.7 },
});
if (displaySize === 76) {
setDisplaySize(226);
if (displaySize === 226) {
setDisplaySize(mapSwitch == "true" ? 76 : 80);
} else {
setDisplaySize(76);
setDisplaySize(226);
}
}}
>
@@ -316,7 +318,7 @@ export const FixedStation: FC<props> = ({
pointerEvents="none"
>
<Ionicons
name={displaySize == 76 ? "chevron-down" : "chevron-up"}
name={displaySize == 226 ? "chevron-up" : "chevron-down"}
size={15}
color="white"
/>
@@ -328,7 +330,7 @@ export const FixedStation: FC<props> = ({
fontSize: 15,
}}
>
{displaySize == 76 ? "時刻表を展開する" : "時刻表を縮小する"}
{displaySize == 226 ? "時刻表を縮小する" : "時刻表を展開する"}
</Text>
</View>
</TouchableOpacity>
@@ -362,7 +364,7 @@ const FixedStationBoxEachTrain = ({ d, station, displaySize }) => {
style={{
backgroundColor: "white",
flexDirection: "row",
height: displaySize == 76 ? "33%" : "7.5%",
height: displaySize == 226 ? "7.5%" : "33%",
overflow: "visible",
}}
>

View File

@@ -21,6 +21,7 @@ import { CustomTrainData, trainTypeID } from "@/lib/CommonTypes";
import { getCurrentTrainData } from "@/lib/getCurrentTrainData";
import { Ionicons } from "@expo/vector-icons";
import dayjs from "dayjs";
import { useTrainMenu } from "@/stateBox/useTrainMenu";
type props = {
trainID: string;
@@ -33,13 +34,10 @@ export const FixedTrain: FC<props> = ({
displaySize,
setDisplaySize,
}) => {
const {
fixedPosition,
setFixedPosition,
currentTrain,
getCurrentStationData,
getPosition,
} = useCurrentTrain();
const { setFixedPosition, currentTrain, getCurrentStationData, getPosition } =
useCurrentTrain();
const { mapSwitch } = useTrainMenu();
const { allCustomTrainData, allTrainDiagram } = useAllTrainDiagram();
const [train, setTrain] = useState<trainDataType>(null);
@@ -84,7 +82,7 @@ export const FixedTrain: FC<props> = ({
let betweenStationLine = "";
let baseStationNumberFirst = "";
let baseStationNumberSecond = "";
Object.keys(stationIDPair).forEach((d, index2, array) => {
Object.keys(stationIDPair).forEach((d, index2) => {
if (!d) return;
const haveFirst = firstItem[index2];
const haveSecond = secondItem[index2];
@@ -122,7 +120,7 @@ export const FixedTrain: FC<props> = ({
});
let mainArray = [...trainData];
let indexs = 0;
trainData.forEach((d, index, array) => {
trainData.forEach((d, index) => {
indexs = indexs + 1;
if (!allThroughStationList[index]) return;
if (allThroughStationList[index].length == 0) return;
@@ -221,7 +219,7 @@ export const FixedTrain: FC<props> = ({
<View
style={{
flex: 1,
flexDirection: displaySize === 76 ? "row" : "column",
flexDirection: displaySize === 226 ? "column" : "row",
backgroundColor: "black",
//borderBottomColor: "black",
//borderBottomWidth: 2,
@@ -229,15 +227,15 @@ export const FixedTrain: FC<props> = ({
>
<View
style={{
flexDirection: displaySize === 76 ? "column" : "row",
flexDirection: displaySize === 226 ? "row" : "column",
flex: 1,
backgroundColor: "white",
height: displaySize === 76 ? 50 : 200,
height: displaySize === 226 ? 200 : 50,
overflow: "hidden",
}}
>
<View
style={{ flex: displaySize === 76 ? 1 : 5, flexDirection: "row" }}
style={{ flex: displaySize === 226 ? 1 : 5, flexDirection: "row" }}
>
<View
style={{
@@ -251,17 +249,17 @@ export const FixedTrain: FC<props> = ({
>
<Image
source={{ uri: customData.img }}
width={displaySize === 76 ? 14 : 23}
height={displaySize === 76 ? 17 : 26}
width={displaySize === 226 ? 23 : 14}
height={displaySize === 226 ? 26 : 17}
style={{ margin: 5 }}
/>
<View
style={{
flexDirection: displaySize === 76 ? "row" : "column",
flexDirection: displaySize === 226 ? "column" : "row",
alignContent: "center",
alignSelf: "center",
alignItems: "center",
maxWidth: displaySize === 76 ? 100 : 60,
maxWidth: displaySize === 226 ? 60 : 100,
}}
>
<Text
@@ -286,7 +284,7 @@ export const FixedTrain: FC<props> = ({
style={{
fontSize: trainNameText.length > 6 ? 8 : 14,
color: "white",
maxWidth: displaySize === 76 ? 60 : 200,
maxWidth: displaySize === 226 ? 200 : 60,
textAlignVertical: "center",
}}
>
@@ -301,11 +299,11 @@ export const FixedTrain: FC<props> = ({
borderLeftColor: customTrainType.color,
borderTopColor: lineColor,
borderBottomColor: lineColor,
borderTopWidth: displaySize === 76 ? 14 : 50,
borderBottomWidth: displaySize === 76 ? 14 : 50,
borderLeftWidth: displaySize === 76 ? 10 : 30,
borderTopWidth: displaySize === 226 ? 50 : 14,
borderBottomWidth: displaySize === 226 ? 50 : 14,
borderLeftWidth: displaySize === 226 ? 30 : 10,
borderRightWidth: 0,
//height: displaySize === 76 ? 20 : 100,
//height: displaySize === 226 ? 20 : 100,
height: "100%",
}}
></View>
@@ -368,7 +366,7 @@ export const FixedTrain: FC<props> = ({
<View
style={{
backgroundColor: "black",
flex: displaySize === 76 ? 1 : 4,
flex: displaySize === 226 ? 4 : 1,
flexDirection: "row",
alignItems: "center",
}}
@@ -400,7 +398,7 @@ export const FixedTrain: FC<props> = ({
>
{nextStationData[0]?.Station_JP || "不明"}
</Text>
{displaySize === 76 && (
{displaySize !== 226 && (
<View
style={{
backgroundColor: "white",
@@ -422,7 +420,7 @@ export const FixedTrain: FC<props> = ({
train={train}
lineColor={lineColor}
trainDataWithThrough={untilStationData}
isSmall={displaySize === 76}
isSmall={displaySize !== 226}
/>
</View>
<View
@@ -491,10 +489,10 @@ export const FixedTrain: FC<props> = ({
duration: 200,
update: { type: "easeInEaseOut", springDamping: 0.4 },
});
if (displaySize === 76) {
setDisplaySize(226);
if (displaySize === 226) {
setDisplaySize(mapSwitch == "true" ? 76 : 80);
} else {
setDisplaySize(76);
setDisplaySize(226);
}
}}
>
@@ -523,7 +521,7 @@ export const FixedTrain: FC<props> = ({
}}
>
<Ionicons
name={displaySize == 76 ? "chevron-down" : "chevron-up"}
name={displaySize == 226 ? "chevron-up" : "chevron-down"}
size={15}
color="white"
/>
@@ -535,7 +533,7 @@ export const FixedTrain: FC<props> = ({
fontSize: 15,
}}
>
{displaySize == 76 ? "列車情報展開" : "列車情報縮小"}
{displaySize == 226 ? "列車情報縮小" : "列車情報展開"}
</Text>
</View>
</TouchableOpacity>
@@ -553,7 +551,6 @@ const CurrentPositionBox = ({
let firstText = "";
let secondText = "";
let marginText = "";
let externalText = "";
const { isBetween, Pos: PosData } = trainPosition(train);
if (isBetween === true) {
const { from, to } = PosData;
@@ -613,7 +610,7 @@ const CurrentPositionBox = ({
overScrollMode="always"
>
{trainDataWithThrough.length > 0 &&
trainDataWithThrough.map((d, index, array) => {
trainDataWithThrough.map((d, index) => {
if (!d) return null;
if (d == "") return null;
const [station, se, time] = d.split(",");