不要な内容の整理とコードの並び替え
This commit is contained in:
@@ -5,10 +5,12 @@ import Constants from "expo-constants";
|
|||||||
import { FixedTrain } from "./FixedPositionBox/FixedTrainBox";
|
import { FixedTrain } from "./FixedPositionBox/FixedTrainBox";
|
||||||
import { FixedStation } from "./FixedPositionBox/FixedStationBox";
|
import { FixedStation } from "./FixedPositionBox/FixedStationBox";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { useTrainMenu } from "@/stateBox/useTrainMenu";
|
||||||
|
|
||||||
export const FixedPositionBox = () => {
|
export const FixedPositionBox = () => {
|
||||||
const { fixedPosition, setFixedPosition } = useCurrentTrain();
|
const { mapSwitch } = useTrainMenu();
|
||||||
const [displaySize, setDisplaySize] = useState(76);
|
const { fixedPosition } = useCurrentTrain();
|
||||||
|
const [displaySize, setDisplaySize] = useState(mapSwitch == "true" ? 76 : 80);
|
||||||
|
|
||||||
useKeepAwake();
|
useKeepAwake();
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram";
|
|||||||
import { useAreaInfo } from "@/stateBox/useAreaInfo";
|
import { useAreaInfo } from "@/stateBox/useAreaInfo";
|
||||||
import { useCurrentTrain } from "@/stateBox/useCurrentTrain";
|
import { useCurrentTrain } from "@/stateBox/useCurrentTrain";
|
||||||
import { useStationList } from "@/stateBox/useStationList";
|
import { useStationList } from "@/stateBox/useStationList";
|
||||||
|
import { useTrainMenu } from "@/stateBox/useTrainMenu";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import { useNavigation } from "@react-navigation/native";
|
import { useNavigation } from "@react-navigation/native";
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ export const FixedStation: FC<props> = ({
|
|||||||
displaySize,
|
displaySize,
|
||||||
setDisplaySize,
|
setDisplaySize,
|
||||||
}) => {
|
}) => {
|
||||||
|
const { mapSwitch } = useTrainMenu();
|
||||||
const { currentTrain, setFixedPosition } = useCurrentTrain();
|
const { currentTrain, setFixedPosition } = useCurrentTrain();
|
||||||
const { getStationDataFromId } = useStationList();
|
const { getStationDataFromId } = useStationList();
|
||||||
const { navigate } = useNavigation();
|
const { navigate } = useNavigation();
|
||||||
@@ -48,7 +50,7 @@ export const FixedStation: FC<props> = ({
|
|||||||
////
|
////
|
||||||
|
|
||||||
const { allTrainDiagram } = useAllTrainDiagram();
|
const { allTrainDiagram } = useAllTrainDiagram();
|
||||||
const { areaInfo, areaStationID } = useAreaInfo();
|
const { areaStationID } = useAreaInfo();
|
||||||
const [stationDiagram, setStationDiagram] = useState({}); //当該駅の全時刻表
|
const [stationDiagram, setStationDiagram] = useState({}); //当該駅の全時刻表
|
||||||
const [isInfoArea, setIsInfoArea] = useState(false);
|
const [isInfoArea, setIsInfoArea] = useState(false);
|
||||||
|
|
||||||
@@ -283,10 +285,10 @@ export const FixedStation: FC<props> = ({
|
|||||||
duration: 500,
|
duration: 500,
|
||||||
update: { type: "spring", springDamping: 0.7 },
|
update: { type: "spring", springDamping: 0.7 },
|
||||||
});
|
});
|
||||||
if (displaySize === 76) {
|
if (displaySize === 226) {
|
||||||
setDisplaySize(226);
|
setDisplaySize(mapSwitch == "true" ? 76 : 80);
|
||||||
} else {
|
} else {
|
||||||
setDisplaySize(76);
|
setDisplaySize(226);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -316,7 +318,7 @@ export const FixedStation: FC<props> = ({
|
|||||||
pointerEvents="none"
|
pointerEvents="none"
|
||||||
>
|
>
|
||||||
<Ionicons
|
<Ionicons
|
||||||
name={displaySize == 76 ? "chevron-down" : "chevron-up"}
|
name={displaySize == 226 ? "chevron-up" : "chevron-down"}
|
||||||
size={15}
|
size={15}
|
||||||
color="white"
|
color="white"
|
||||||
/>
|
/>
|
||||||
@@ -328,7 +330,7 @@ export const FixedStation: FC<props> = ({
|
|||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{displaySize == 76 ? "時刻表を展開する" : "時刻表を縮小する"}
|
{displaySize == 226 ? "時刻表を縮小する" : "時刻表を展開する"}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@@ -362,7 +364,7 @@ const FixedStationBoxEachTrain = ({ d, station, displaySize }) => {
|
|||||||
style={{
|
style={{
|
||||||
backgroundColor: "white",
|
backgroundColor: "white",
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
height: displaySize == 76 ? "33%" : "7.5%",
|
height: displaySize == 226 ? "7.5%" : "33%",
|
||||||
overflow: "visible",
|
overflow: "visible",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { CustomTrainData, trainTypeID } from "@/lib/CommonTypes";
|
|||||||
import { getCurrentTrainData } from "@/lib/getCurrentTrainData";
|
import { getCurrentTrainData } from "@/lib/getCurrentTrainData";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
import { useTrainMenu } from "@/stateBox/useTrainMenu";
|
||||||
|
|
||||||
type props = {
|
type props = {
|
||||||
trainID: string;
|
trainID: string;
|
||||||
@@ -33,13 +34,10 @@ export const FixedTrain: FC<props> = ({
|
|||||||
displaySize,
|
displaySize,
|
||||||
setDisplaySize,
|
setDisplaySize,
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const { setFixedPosition, currentTrain, getCurrentStationData, getPosition } =
|
||||||
fixedPosition,
|
useCurrentTrain();
|
||||||
setFixedPosition,
|
|
||||||
currentTrain,
|
const { mapSwitch } = useTrainMenu();
|
||||||
getCurrentStationData,
|
|
||||||
getPosition,
|
|
||||||
} = useCurrentTrain();
|
|
||||||
const { allCustomTrainData, allTrainDiagram } = useAllTrainDiagram();
|
const { allCustomTrainData, allTrainDiagram } = useAllTrainDiagram();
|
||||||
|
|
||||||
const [train, setTrain] = useState<trainDataType>(null);
|
const [train, setTrain] = useState<trainDataType>(null);
|
||||||
@@ -84,7 +82,7 @@ export const FixedTrain: FC<props> = ({
|
|||||||
let betweenStationLine = "";
|
let betweenStationLine = "";
|
||||||
let baseStationNumberFirst = "";
|
let baseStationNumberFirst = "";
|
||||||
let baseStationNumberSecond = "";
|
let baseStationNumberSecond = "";
|
||||||
Object.keys(stationIDPair).forEach((d, index2, array) => {
|
Object.keys(stationIDPair).forEach((d, index2) => {
|
||||||
if (!d) return;
|
if (!d) return;
|
||||||
const haveFirst = firstItem[index2];
|
const haveFirst = firstItem[index2];
|
||||||
const haveSecond = secondItem[index2];
|
const haveSecond = secondItem[index2];
|
||||||
@@ -122,7 +120,7 @@ export const FixedTrain: FC<props> = ({
|
|||||||
});
|
});
|
||||||
let mainArray = [...trainData];
|
let mainArray = [...trainData];
|
||||||
let indexs = 0;
|
let indexs = 0;
|
||||||
trainData.forEach((d, index, array) => {
|
trainData.forEach((d, index) => {
|
||||||
indexs = indexs + 1;
|
indexs = indexs + 1;
|
||||||
if (!allThroughStationList[index]) return;
|
if (!allThroughStationList[index]) return;
|
||||||
if (allThroughStationList[index].length == 0) return;
|
if (allThroughStationList[index].length == 0) return;
|
||||||
@@ -221,7 +219,7 @@ export const FixedTrain: FC<props> = ({
|
|||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: displaySize === 76 ? "row" : "column",
|
flexDirection: displaySize === 226 ? "column" : "row",
|
||||||
backgroundColor: "black",
|
backgroundColor: "black",
|
||||||
//borderBottomColor: "black",
|
//borderBottomColor: "black",
|
||||||
//borderBottomWidth: 2,
|
//borderBottomWidth: 2,
|
||||||
@@ -229,15 +227,15 @@ export const FixedTrain: FC<props> = ({
|
|||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
flexDirection: displaySize === 76 ? "column" : "row",
|
flexDirection: displaySize === 226 ? "row" : "column",
|
||||||
flex: 1,
|
flex: 1,
|
||||||
backgroundColor: "white",
|
backgroundColor: "white",
|
||||||
height: displaySize === 76 ? 50 : 200,
|
height: displaySize === 226 ? 200 : 50,
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
style={{ flex: displaySize === 76 ? 1 : 5, flexDirection: "row" }}
|
style={{ flex: displaySize === 226 ? 1 : 5, flexDirection: "row" }}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
@@ -251,17 +249,17 @@ export const FixedTrain: FC<props> = ({
|
|||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
source={{ uri: customData.img }}
|
source={{ uri: customData.img }}
|
||||||
width={displaySize === 76 ? 14 : 23}
|
width={displaySize === 226 ? 23 : 14}
|
||||||
height={displaySize === 76 ? 17 : 26}
|
height={displaySize === 226 ? 26 : 17}
|
||||||
style={{ margin: 5 }}
|
style={{ margin: 5 }}
|
||||||
/>
|
/>
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
flexDirection: displaySize === 76 ? "row" : "column",
|
flexDirection: displaySize === 226 ? "column" : "row",
|
||||||
alignContent: "center",
|
alignContent: "center",
|
||||||
alignSelf: "center",
|
alignSelf: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
maxWidth: displaySize === 76 ? 100 : 60,
|
maxWidth: displaySize === 226 ? 60 : 100,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
@@ -286,7 +284,7 @@ export const FixedTrain: FC<props> = ({
|
|||||||
style={{
|
style={{
|
||||||
fontSize: trainNameText.length > 6 ? 8 : 14,
|
fontSize: trainNameText.length > 6 ? 8 : 14,
|
||||||
color: "white",
|
color: "white",
|
||||||
maxWidth: displaySize === 76 ? 60 : 200,
|
maxWidth: displaySize === 226 ? 200 : 60,
|
||||||
textAlignVertical: "center",
|
textAlignVertical: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -301,11 +299,11 @@ export const FixedTrain: FC<props> = ({
|
|||||||
borderLeftColor: customTrainType.color,
|
borderLeftColor: customTrainType.color,
|
||||||
borderTopColor: lineColor,
|
borderTopColor: lineColor,
|
||||||
borderBottomColor: lineColor,
|
borderBottomColor: lineColor,
|
||||||
borderTopWidth: displaySize === 76 ? 14 : 50,
|
borderTopWidth: displaySize === 226 ? 50 : 14,
|
||||||
borderBottomWidth: displaySize === 76 ? 14 : 50,
|
borderBottomWidth: displaySize === 226 ? 50 : 14,
|
||||||
borderLeftWidth: displaySize === 76 ? 10 : 30,
|
borderLeftWidth: displaySize === 226 ? 30 : 10,
|
||||||
borderRightWidth: 0,
|
borderRightWidth: 0,
|
||||||
//height: displaySize === 76 ? 20 : 100,
|
//height: displaySize === 226 ? 20 : 100,
|
||||||
height: "100%",
|
height: "100%",
|
||||||
}}
|
}}
|
||||||
></View>
|
></View>
|
||||||
@@ -368,7 +366,7 @@ export const FixedTrain: FC<props> = ({
|
|||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: "black",
|
backgroundColor: "black",
|
||||||
flex: displaySize === 76 ? 1 : 4,
|
flex: displaySize === 226 ? 4 : 1,
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
}}
|
}}
|
||||||
@@ -400,7 +398,7 @@ export const FixedTrain: FC<props> = ({
|
|||||||
>
|
>
|
||||||
{nextStationData[0]?.Station_JP || "不明"}
|
{nextStationData[0]?.Station_JP || "不明"}
|
||||||
</Text>
|
</Text>
|
||||||
{displaySize === 76 && (
|
{displaySize !== 226 && (
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: "white",
|
backgroundColor: "white",
|
||||||
@@ -422,7 +420,7 @@ export const FixedTrain: FC<props> = ({
|
|||||||
train={train}
|
train={train}
|
||||||
lineColor={lineColor}
|
lineColor={lineColor}
|
||||||
trainDataWithThrough={untilStationData}
|
trainDataWithThrough={untilStationData}
|
||||||
isSmall={displaySize === 76}
|
isSmall={displaySize !== 226}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View
|
<View
|
||||||
@@ -491,10 +489,10 @@ export const FixedTrain: FC<props> = ({
|
|||||||
duration: 200,
|
duration: 200,
|
||||||
update: { type: "easeInEaseOut", springDamping: 0.4 },
|
update: { type: "easeInEaseOut", springDamping: 0.4 },
|
||||||
});
|
});
|
||||||
if (displaySize === 76) {
|
if (displaySize === 226) {
|
||||||
setDisplaySize(226);
|
setDisplaySize(mapSwitch == "true" ? 76 : 80);
|
||||||
} else {
|
} else {
|
||||||
setDisplaySize(76);
|
setDisplaySize(226);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -523,7 +521,7 @@ export const FixedTrain: FC<props> = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Ionicons
|
<Ionicons
|
||||||
name={displaySize == 76 ? "chevron-down" : "chevron-up"}
|
name={displaySize == 226 ? "chevron-up" : "chevron-down"}
|
||||||
size={15}
|
size={15}
|
||||||
color="white"
|
color="white"
|
||||||
/>
|
/>
|
||||||
@@ -535,7 +533,7 @@ export const FixedTrain: FC<props> = ({
|
|||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{displaySize == 76 ? "列車情報展開" : "列車情報縮小"}
|
{displaySize == 226 ? "列車情報縮小" : "列車情報展開"}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@@ -553,7 +551,6 @@ const CurrentPositionBox = ({
|
|||||||
let firstText = "";
|
let firstText = "";
|
||||||
let secondText = "";
|
let secondText = "";
|
||||||
let marginText = "";
|
let marginText = "";
|
||||||
let externalText = "";
|
|
||||||
const { isBetween, Pos: PosData } = trainPosition(train);
|
const { isBetween, Pos: PosData } = trainPosition(train);
|
||||||
if (isBetween === true) {
|
if (isBetween === true) {
|
||||||
const { from, to } = PosData;
|
const { from, to } = PosData;
|
||||||
@@ -613,7 +610,7 @@ const CurrentPositionBox = ({
|
|||||||
overScrollMode="always"
|
overScrollMode="always"
|
||||||
>
|
>
|
||||||
{trainDataWithThrough.length > 0 &&
|
{trainDataWithThrough.length > 0 &&
|
||||||
trainDataWithThrough.map((d, index, array) => {
|
trainDataWithThrough.map((d, index) => {
|
||||||
if (!d) return null;
|
if (!d) return null;
|
||||||
if (d == "") return null;
|
if (d == "") return null;
|
||||||
const [station, se, time] = d.split(",");
|
const [station, se, time] = d.split(",");
|
||||||
|
|||||||
Reference in New Issue
Block a user