スイッチボックスをコンポーネント分離整理
This commit is contained in:
parent
833d93cf12
commit
a4030a8e4c
25
components/発車時刻表/LED_Vision_Component/SwitchBox.js
Normal file
25
components/発車時刻表/LED_Vision_Component/SwitchBox.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { Text } from "react-native";
|
||||||
|
import { Switch } from "react-native-elements";
|
||||||
|
import { AS } from "../../../storageControl";
|
||||||
|
export const SwitchBox = (props) => {
|
||||||
|
const { value, setValue, setKey, title } = props;
|
||||||
|
const textStyle = {
|
||||||
|
alignItems: "center",
|
||||||
|
alignContent: "center",
|
||||||
|
textAlign: "center",
|
||||||
|
textAlignVertical: "center",
|
||||||
|
color: "white",
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Text style={textStyle}>{title}</Text>
|
||||||
|
<Switch
|
||||||
|
value={value}
|
||||||
|
onValueChange={(v) => {
|
||||||
|
AS.setItem(setKey, v.toString());
|
||||||
|
setValue(v);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
@ -1,6 +1,5 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { View, Text, TouchableOpacity } from "react-native";
|
import { View, Text, TouchableOpacity } from "react-native";
|
||||||
import { Switch } from "react-native-elements";
|
|
||||||
import { widthPercentageToDP as wp } from "react-native-responsive-screen";
|
import { widthPercentageToDP as wp } from "react-native-responsive-screen";
|
||||||
import LottieView from "lottie-react-native";
|
import LottieView from "lottie-react-native";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
@ -14,6 +13,7 @@ import { useCurrentTrain } from "../../stateBox/useCurrentTrain";
|
|||||||
import { useAreaInfo } from "../../stateBox/useAreaInfo";
|
import { useAreaInfo } from "../../stateBox/useAreaInfo";
|
||||||
import { SheetManager } from "react-native-actions-sheet";
|
import { SheetManager } from "react-native-actions-sheet";
|
||||||
import { AS } from "../../storageControl";
|
import { AS } from "../../storageControl";
|
||||||
|
import { SwitchBox } from "./LED_Vision_Component/SwitchBox";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -86,15 +86,7 @@ export default function LED_vision(props) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
setStationDiagram(returnData);
|
setStationDiagram(returnData);
|
||||||
if (
|
setIsInfoArea(station.some((s) => areaStationID.includes(s.StationNumber)));
|
||||||
station.some((s) => {
|
|
||||||
return areaStationID.includes(s.StationNumber);
|
|
||||||
})
|
|
||||||
) {
|
|
||||||
setIsInfoArea(true);
|
|
||||||
} else {
|
|
||||||
setIsInfoArea(false);
|
|
||||||
}
|
|
||||||
}, [trainDiagram, station]);
|
}, [trainDiagram, station]);
|
||||||
|
|
||||||
const [trainTimeAndNumber, setTrainTimeAndNumber] = useState(null);
|
const [trainTimeAndNumber, setTrainTimeAndNumber] = useState(null);
|
||||||
@ -217,14 +209,16 @@ export default function LED_vision(props) {
|
|||||||
<Header getCurrentTrain={getCurrentTrain} />
|
<Header getCurrentTrain={getCurrentTrain} />
|
||||||
{selectedTrain.map((d) => (
|
{selectedTrain.map((d) => (
|
||||||
<EachData
|
<EachData
|
||||||
d={d}
|
{...{
|
||||||
trainIDSwitch={trainIDSwitch}
|
d,
|
||||||
trainDescriptionSwitch={trainDescriptionSwitch}
|
trainIDSwitch,
|
||||||
|
trainDescriptionSwitch,
|
||||||
|
customTrainDataDetector,
|
||||||
|
navigate,
|
||||||
|
originalStationList,
|
||||||
|
openStationACFromEachTrainInfo,
|
||||||
|
}}
|
||||||
station={station[0]}
|
station={station[0]}
|
||||||
customTrainDataDetector={customTrainDataDetector}
|
|
||||||
navigate={navigate}
|
|
||||||
originalStationList={originalStationList}
|
|
||||||
openStationACFromEachTrainInfo={openStationACFromEachTrainInfo}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
{areaString != "" && isInfoArea && (
|
{areaString != "" && isInfoArea && (
|
||||||
@ -300,56 +294,44 @@ const Footer = (props) => {
|
|||||||
setFinalSwitch,
|
setFinalSwitch,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const textStyle = {
|
|
||||||
alignItems: "center",
|
|
||||||
alignContent: "center",
|
|
||||||
textAlign: "center",
|
|
||||||
textAlignVertical: "center",
|
|
||||||
color: "white",
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{ flexDirection: "row", padding: 10, alignItems: "center" }}>
|
<View style={{ flexDirection: "row", padding: 10, alignItems: "center" }}>
|
||||||
<Text style={textStyle}>種別名 / 列番</Text>
|
<SwitchBox
|
||||||
<Switch
|
|
||||||
value={trainIDSwitch}
|
value={trainIDSwitch}
|
||||||
onValueChange={(value) => {
|
setValue={setTrainIDSwitch}
|
||||||
AS.setItem("LEDSettings/trainIDSwitch", value.toString());
|
setKey="LEDSettings/trainIDSwitch"
|
||||||
setTrainIDSwitch(value);
|
title="種別名 / 列番"
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Text style={textStyle}>列車情報</Text>
|
<SwitchBox
|
||||||
<Switch
|
|
||||||
value={trainDescriptionSwitch}
|
value={trainDescriptionSwitch}
|
||||||
onValueChange={(value) => {
|
setValue={setTrainDescriptionSwitch}
|
||||||
AS.setItem("LEDSettings/trainDescriptionSwitch", value.toString());
|
setKey="LEDSettings/trainDescriptionSwitch"
|
||||||
setTrainDescriptionSwitch(value);
|
title="列車情報"
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Text style={textStyle}>当駅止表示</Text>
|
<SwitchBox
|
||||||
<Switch
|
|
||||||
value={finalSwitch}
|
value={finalSwitch}
|
||||||
onValueChange={(value) => {
|
setValue={setFinalSwitch}
|
||||||
AS.setItem("LEDSettings/finalSwitch", value.toString());
|
setKey="LEDSettings/finalSwitch"
|
||||||
setFinalSwitch(value);
|
title="当駅止表示"
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const EachData = ({
|
const EachData = (props) => {
|
||||||
d,
|
const {
|
||||||
trainIDSwitch,
|
d,
|
||||||
trainDescriptionSwitch,
|
trainIDSwitch,
|
||||||
station,
|
trainDescriptionSwitch,
|
||||||
customTrainDataDetector,
|
station,
|
||||||
navigate,
|
customTrainDataDetector,
|
||||||
originalStationList,
|
navigate,
|
||||||
openStationACFromEachTrainInfo,
|
originalStationList,
|
||||||
}) => {
|
openStationACFromEachTrainInfo,
|
||||||
|
} = props;
|
||||||
const { currentTrain } = useCurrentTrain();
|
const { currentTrain } = useCurrentTrain();
|
||||||
const openTrainInfo = (d) => {
|
const openTrainInfo = (d) => {
|
||||||
let TrainNumber = "";
|
let TrainNumber = "";
|
||||||
|
Loading…
Reference in New Issue
Block a user