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