設定機能を実装
This commit is contained in:
parent
e90ffd8926
commit
d511b80437
20
Apps.js
20
Apps.js
@ -56,6 +56,7 @@ export default function Apps({
|
||||
const [stationBoardData, setStationBoardData] = useState(undefined);
|
||||
const [originalStationList, setOriginalStationList] = useState();
|
||||
const [selectedStation, setSelectedStation] = useState(undefined);
|
||||
const [trainMenu, setTrainMenu] = useState("true");
|
||||
let once = false;
|
||||
useEffect(() => {
|
||||
getStationList().then(setOriginalStationList);
|
||||
@ -66,7 +67,8 @@ export default function Apps({
|
||||
const injectJavascript = injectJavascriptData(
|
||||
mapSwitch,
|
||||
iconSetting,
|
||||
stationMenu
|
||||
stationMenu,
|
||||
trainMenu
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@ -109,7 +111,7 @@ export default function Apps({
|
||||
AS.getItem("stationSwitch")
|
||||
.then((d) => {
|
||||
if (d) {
|
||||
setStationMenu(d);
|
||||
setTrainMenu(d);
|
||||
} else {
|
||||
AS.setItem("stationSwitch", "true").then(Updates.reloadAsync);
|
||||
}
|
||||
@ -118,6 +120,20 @@ export default function Apps({
|
||||
AS.setItem("stationSwitch", "true").then(Updates.reloadAsync)
|
||||
);
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
//列車メニュースイッチ
|
||||
AS.getItem("trainSwitch")
|
||||
.then((d) => {
|
||||
if (d) {
|
||||
setStationMenu(d);
|
||||
} else {
|
||||
AS.setItem("trainSwitch", "true").then(Updates.reloadAsync);
|
||||
}
|
||||
})
|
||||
.catch((d) =>
|
||||
AS.setItem("trainSwitch", "true").then(Updates.reloadAsync)
|
||||
);
|
||||
}, []);
|
||||
|
||||
const onMessage = (event) => {
|
||||
if (event.nativeEvent.data.includes("train.html")) {
|
||||
|
@ -12,6 +12,7 @@ import {
|
||||
} from "react-native";
|
||||
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import ActionSheet from "react-native-actions-sheet";
|
||||
import { AS } from "../../storageControl";
|
||||
import LottieView from "lottie-react-native";
|
||||
import trainList from "../../assets/originData/trainList";
|
||||
import { lineList } from "../../lib/getStationList";
|
||||
@ -33,6 +34,20 @@ export const EachTrainInfo = ({
|
||||
const [isTop, setIsTop] = useState(true);
|
||||
const [currentPosition, setCurrentPosition] = useState([]);
|
||||
|
||||
const [trainPositionSwitch, setTrainPositionSwitch] = useState("false");
|
||||
|
||||
useEffect(() => {
|
||||
//列車現在地アイコン表示スイッチ
|
||||
AS.getItem("trainPositionSwitch")
|
||||
.then((d) => {
|
||||
if (d) {
|
||||
setTrainPositionSwitch(d);
|
||||
} else {
|
||||
}
|
||||
})
|
||||
.catch((d) => AS.setItem("trainPositionSwitch", "false"));
|
||||
}, []);
|
||||
|
||||
const getStationData = (stationName) => {
|
||||
const Stations = stationList.map((a) =>
|
||||
a.filter((d) => d.StationName == stationName)
|
||||
@ -128,7 +143,6 @@ export const EachTrainInfo = ({
|
||||
if (array.length == 2) {
|
||||
const index1 = stopStationIDList.indexOf(array[0]);
|
||||
const index2 = stopStationIDList.indexOf(array[1]);
|
||||
console.log(index1, index2);
|
||||
if (index1 != -1 && index2 != -1) {
|
||||
// 駅間で通過駅も無い場合
|
||||
if (index1 < index2) {
|
||||
@ -153,20 +167,44 @@ export const EachTrainInfo = ({
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const getNearStationID = (stationID) => {
|
||||
for (let i = 0; i <= stopStationIDListNumber.length; i++) {
|
||||
console.log(stopStationIDListNumber[i].ID, stationID);
|
||||
if (stopStationIDListNumber[i].ID < stationID) {
|
||||
if (stopStationIDListNumber[i + 1].ID > stationID) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
if (stopStationIDListNumber[i].ID > stationID) {
|
||||
if (stopStationIDListNumber[i + 1].ID < stationID) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let newIndex1 = index1;
|
||||
let newIndex2 = index2;
|
||||
if (index1 == -1) {
|
||||
newIndex1 = getNearStationID(arrayNumber[0].ID);
|
||||
}
|
||||
if (index2 == -1) {
|
||||
newIndex2 = getNearStationID(arrayNumber[1].ID);
|
||||
}
|
||||
if (newIndex1 && newIndex2) {
|
||||
return [newIndex1, newIndex2];
|
||||
}
|
||||
|
||||
// 通過駅の場合
|
||||
}
|
||||
|
||||
// 通過駅の場合
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
// 使用例
|
||||
const points = findReversalPoints(currentPosition);
|
||||
console.log(points);
|
||||
const points =
|
||||
trainPositionSwitch == "true" ? findReversalPoints(currentPosition) : [];
|
||||
|
||||
useEffect(() => {
|
||||
console.log(data);
|
||||
setIsTop(true);
|
||||
if (!data.trainNum) return;
|
||||
const TD = trainList[data.trainNum];
|
||||
@ -368,7 +406,7 @@ export const EachTrainInfo = ({
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View
|
||||
{/* <View
|
||||
style={{
|
||||
flexDirection: "column",
|
||||
height: heightPercentageToDP("20%"),
|
||||
@ -446,7 +484,7 @@ export const EachTrainInfo = ({
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View> */}
|
||||
</ScrollView>
|
||||
<ScrollView
|
||||
style={{ maxHeight: heightPercentageToDP("55%") }}
|
||||
@ -551,7 +589,6 @@ export const EachTrainInfo = ({
|
||||
if (time) {
|
||||
date.setHours(time.split(":")[0], time.split(":")[1]);
|
||||
}
|
||||
console.log(date.toString());
|
||||
if (!isNaN(data.trainData?.delay)) {
|
||||
date.setMinutes(date.getMinutes() + data.trainData?.delay);
|
||||
}
|
||||
|
@ -13,10 +13,14 @@ export default function Setting(props) {
|
||||
const [iconSetting, setIconSetting] = useState(undefined);
|
||||
const [mapSwitch, setMapSwitch] = useState(undefined);
|
||||
const [stationMenu, setStationMenu] = useState(undefined);
|
||||
const [trainMenu, setTrainMenu] = useState(undefined);
|
||||
const [trainPosition, setTrainPosition] = useState(undefined);
|
||||
useEffect(() => {
|
||||
AS.getItem("iconSwitch").then(setIconSetting);
|
||||
AS.getItem("mapSwitch").then(setMapSwitch);
|
||||
AS.getItem("stationSwitch").then(setStationMenu);
|
||||
AS.getItem("trainSwitch").then(setTrainMenu);
|
||||
AS.getItem("trainPositionSwitch").then(setTrainPosition);
|
||||
}, []);
|
||||
return (
|
||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
||||
@ -83,7 +87,7 @@ export default function Setting(props) {
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
駅メニューを表示(beta)
|
||||
駅メニューを表示
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Switch
|
||||
@ -92,6 +96,44 @@ export default function Setting(props) {
|
||||
onValueChange={(value) => setStationMenu(value.toString())}
|
||||
/>
|
||||
</View>
|
||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 25,
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
textAlign: "center",
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
列車メニュー
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Switch
|
||||
value={trainMenu == "true" ? true : false}
|
||||
color={trainMenu == "true" ? "red" : null}
|
||||
onValueChange={(value) => setTrainMenu(value.toString())}
|
||||
/>
|
||||
</View>
|
||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 25,
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
textAlign: "center",
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
→列車現在位置表示(alpha)
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Switch
|
||||
value={trainPosition == "true" ? true : false}
|
||||
color={trainPosition == "true" ? "red" : null}
|
||||
onValueChange={(value) => setTrainPosition(value.toString())}
|
||||
/>
|
||||
</View>
|
||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||
<Text
|
||||
style={{
|
||||
@ -137,6 +179,8 @@ export default function Setting(props) {
|
||||
AS.setItem("iconSwitch", iconSetting.toString()),
|
||||
AS.setItem("mapSwitch", mapSwitch.toString()),
|
||||
AS.setItem("stationSwitch", stationMenu.toString()),
|
||||
AS.setItem("trainSwitch", trainMenu.toString()),
|
||||
AS.setItem("trainPositionSwitch", trainPosition.toString()),
|
||||
]).then(() => {
|
||||
Updates.reloadAsync();
|
||||
});
|
||||
|
@ -706,8 +706,7 @@ makeTrainView.observe(document.getElementById('modal_content'), {
|
||||
});
|
||||
`;
|
||||
const makeTrainMenu =
|
||||
//trainMenu == "true"
|
||||
true
|
||||
trainMenu == "true"
|
||||
? `
|
||||
// これの中身抽出ShowTrainTimeInfo("1228M","normal")
|
||||
function setTrainMenuDialog(d){
|
||||
@ -725,7 +724,7 @@ makeTrainView.observe(document.getElementById('modal_content'), {
|
||||
window.ReactNativeWebView.postMessage(JSON.stringify({type:"ShowTrainTimeInfo",trainNum,limited}));
|
||||
};
|
||||
`
|
||||
: ``;
|
||||
: `function setTrainMenuDialog(d){}`;
|
||||
|
||||
const makeStationMenu =
|
||||
stationMenu == "true"
|
||||
|
Loading…
Reference in New Issue
Block a user