段階調整
This commit is contained in:
parent
6518b53de9
commit
8102680ba7
@ -1,6 +1,6 @@
|
|||||||
import { trainPosition } from "@/lib/trainPositionTextArray";
|
import { trainPosition } from "@/lib/trainPositionTextArray";
|
||||||
import React, { CSSProperties, FC } from "react";
|
import React, { FC } from "react";
|
||||||
import { View, Text, StyleProp, TextStyle, ViewStyle } from "react-native";
|
import { View, Text, TextStyle, ViewStyle } from "react-native";
|
||||||
|
|
||||||
type stateBox = {
|
type stateBox = {
|
||||||
currentTrainData: any;
|
currentTrainData: any;
|
||||||
@ -8,7 +8,7 @@ type stateBox = {
|
|||||||
title: string;
|
title: string;
|
||||||
style?: ViewStyle;
|
style?: ViewStyle;
|
||||||
mode?: number;
|
mode?: number;
|
||||||
endText?: string;
|
platformDescription: string;
|
||||||
lineNumber: string;
|
lineNumber: string;
|
||||||
};
|
};
|
||||||
export const PositionBox: FC<stateBox> = (props) => {
|
export const PositionBox: FC<stateBox> = (props) => {
|
||||||
@ -18,44 +18,55 @@ export const PositionBox: FC<stateBox> = (props) => {
|
|||||||
title,
|
title,
|
||||||
style,
|
style,
|
||||||
mode,
|
mode,
|
||||||
endText,
|
platformDescription,
|
||||||
lineNumber,
|
lineNumber,
|
||||||
} = props;
|
} = props;
|
||||||
const trainPositionText = (trainData) => {
|
let firstText = "";
|
||||||
const { isBetween, Pos: PosData } = trainPosition(trainData);
|
let secondText = "";
|
||||||
if (isBetween === true) {
|
let marginText = "";
|
||||||
const { from, to } = PosData;
|
let externalText = "";
|
||||||
return `${from}~${to}`;
|
const { isBetween, Pos: PosData } = trainPosition(currentTrainData);
|
||||||
} else {
|
if (isBetween === true) {
|
||||||
const { Pos } = PosData;
|
const { from, to } = PosData;
|
||||||
if (Pos == "") return "";
|
firstText = from;
|
||||||
if (platformNumber) return `${Pos} ${platformNumber}番乗り場`;
|
secondText = to;
|
||||||
if (lineNumber) return `${Pos} ${lineNumber}番線`;
|
marginText = mode == 2 ? "→" : "↓";
|
||||||
|
} else {
|
||||||
|
const { Pos } = PosData;
|
||||||
|
if (Pos !== "") {
|
||||||
|
firstText = Pos;
|
||||||
|
if (platformNumber) {
|
||||||
|
secondText = `${platformNumber}番乗り場`;
|
||||||
|
if (lineNumber) {
|
||||||
|
externalText = `${lineNumber}番線`;
|
||||||
|
}
|
||||||
|
} else if (lineNumber) {
|
||||||
|
secondText = `${lineNumber}番線`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
const text = trainPositionText(currentTrainData);
|
|
||||||
return (
|
return (
|
||||||
<View style={{ ...(mode == 2 ? boxStyle2 : boxStyle), ...style }}>
|
<View style={{ ...(mode == 2 ? boxStyle2 : boxStyle), ...style }}>
|
||||||
<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("~") ? (
|
{firstText && (
|
||||||
<>
|
<Text style={mode == 2 ? boxTextStyle2 : boxTextStyle}>
|
||||||
<Text style={mode == 2 ? boxTextStyle2 : boxTextStyle}>
|
{firstText}
|
||||||
{text.split("~")[0]}
|
</Text>
|
||||||
</Text>
|
)}
|
||||||
<Text style={{ color: "#0099CC", textAlign: "right" }}>
|
{marginText && (
|
||||||
{mode == 2 ? "→" : "↓"}
|
<Text style={{ color: "#0099CC", textAlign: "right" }}>
|
||||||
</Text>
|
{marginText}
|
||||||
<Text style={mode == 2 ? boxTextStyle2 : boxTextStyle}>
|
</Text>
|
||||||
{text.split("~")[1]}
|
)}
|
||||||
</Text>
|
{secondText && (
|
||||||
</>
|
<Text style={mode == 2 ? boxTextStyle2 : boxTextStyle}>
|
||||||
) : (
|
{secondText}
|
||||||
<Text style={mode == 2 ? boxTextStyle2 : boxTextStyle}>{text}</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
{endText && (
|
{(platformDescription || externalText) && (
|
||||||
<View style={{ flexDirection: mode == 2 ? "row" : "column" }}>
|
<View style={{ flexDirection: mode == 2 ? "row" : "column" }}>
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
@ -63,7 +74,8 @@ export const PositionBox: FC<stateBox> = (props) => {
|
|||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{endText}
|
{" " + externalText}
|
||||||
|
{" " + platformDescription}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
@ -147,7 +147,7 @@ export const TrainDataView = ({
|
|||||||
currentTrainData={currentTrainData}
|
currentTrainData={currentTrainData}
|
||||||
platformNumber={platformNumber}
|
platformNumber={platformNumber}
|
||||||
lineNumber={lineNumber}
|
lineNumber={lineNumber}
|
||||||
endText={platformDescription ? `${platformDescription}` : ""}
|
platformDescription={platformDescription ? `${platformDescription}` : ""}
|
||||||
style={
|
style={
|
||||||
onLine
|
onLine
|
||||||
? { borderWidth: 1, borderColor: "red", borderStyle: "solid" }
|
? { borderWidth: 1, borderColor: "red", borderStyle: "solid" }
|
||||||
|
Loading…
Reference in New Issue
Block a user