Merge commit 'eae47cae846c216098bcb6e264496c7abf72faf3' into develop
This commit is contained in:
commit
b1924dffd9
11
App.js
11
App.js
@ -19,6 +19,7 @@ import "./components/ActionSheetComponents/sheets.js";
|
|||||||
import { TrainDelayDataProvider } from "./stateBox/useTrainDelayData.js";
|
import { TrainDelayDataProvider } from "./stateBox/useTrainDelayData.js";
|
||||||
import { SafeAreaProvider } from "react-native-safe-area-context";
|
import { SafeAreaProvider } from "react-native-safe-area-context";
|
||||||
import { DeviceOrientationChangeProvider } from "./stateBox/useDeviceOrientationChange.js";
|
import { DeviceOrientationChangeProvider } from "./stateBox/useDeviceOrientationChange.js";
|
||||||
|
import { TrainMenuProvider } from "./stateBox/useTrainMenu.js";
|
||||||
LogBox.ignoreLogs([
|
LogBox.ignoreLogs([
|
||||||
"ViewPropTypes will be removed",
|
"ViewPropTypes will be removed",
|
||||||
"ColorPropType will be removed",
|
"ColorPropType will be removed",
|
||||||
@ -42,9 +43,11 @@ export default function App() {
|
|||||||
<AreaInfoProvider>
|
<AreaInfoProvider>
|
||||||
<AllTrainDiagramProvider>
|
<AllTrainDiagramProvider>
|
||||||
<BusAndTrainDataProvider>
|
<BusAndTrainDataProvider>
|
||||||
<SheetProvider>
|
<TrainMenuProvider>
|
||||||
<AppContainer />
|
<SheetProvider>
|
||||||
</SheetProvider>
|
<AppContainer />
|
||||||
|
</SheetProvider>
|
||||||
|
</TrainMenuProvider>
|
||||||
</BusAndTrainDataProvider>
|
</BusAndTrainDataProvider>
|
||||||
</AllTrainDiagramProvider>
|
</AllTrainDiagramProvider>
|
||||||
</AreaInfoProvider>
|
</AreaInfoProvider>
|
||||||
@ -63,6 +66,8 @@ export function AppContainer() {
|
|||||||
<NavigationContainer name="Root" style={{ flex: 1 }} ref={navigationRef}>
|
<NavigationContainer name="Root" style={{ flex: 1 }} ref={navigationRef}>
|
||||||
<Tab.Navigator
|
<Tab.Navigator
|
||||||
tabBarOptions={{ keyboardHidesTabBar: Platform.OS === "android" }}
|
tabBarOptions={{ keyboardHidesTabBar: Platform.OS === "android" }}
|
||||||
|
initialRouteName="menuPage"
|
||||||
|
lazy={false}
|
||||||
>
|
>
|
||||||
<Tab.Screen
|
<Tab.Screen
|
||||||
name="login"
|
name="login"
|
||||||
|
26
Apps.js
26
Apps.js
@ -14,7 +14,7 @@ import * as Updates from "expo-updates";
|
|||||||
|
|
||||||
import { AS } from "./storageControl";
|
import { AS } from "./storageControl";
|
||||||
import { news } from "./config/newsUpdate";
|
import { news } from "./config/newsUpdate";
|
||||||
import { getStationList, lineList } from "./lib/getStationList";
|
import { getStationList, lineList, lineListPair } from "./lib/getStationList";
|
||||||
import { injectJavascriptData } from "./lib/webViewInjectjavascript";
|
import { injectJavascriptData } from "./lib/webViewInjectjavascript";
|
||||||
import { checkDuplicateTrainData } from "./lib/checkDuplicateTrainData";
|
import { checkDuplicateTrainData } from "./lib/checkDuplicateTrainData";
|
||||||
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
||||||
@ -25,11 +25,13 @@ import TrainMenu from "./components/trainMenu";
|
|||||||
import { EachTrainInfoCore } from "./components/ActionSheetComponents/EachTrainInfoCore";
|
import { EachTrainInfoCore } from "./components/ActionSheetComponents/EachTrainInfoCore";
|
||||||
|
|
||||||
import { useNavigation } from "@react-navigation/native";
|
import { useNavigation } from "@react-navigation/native";
|
||||||
|
import { useTrainMenu } from "./stateBox/useTrainMenu";
|
||||||
|
import { stationNamePair } from "./lib/getStationList2";
|
||||||
/*
|
/*
|
||||||
import StatusbarDetect from './StatusbarDetect';
|
import StatusbarDetect from './StatusbarDetect';
|
||||||
var Status = StatusbarDetect(); */
|
var Status = StatusbarDetect(); */
|
||||||
|
|
||||||
export default function Apps({ stationData }) {
|
export default function Apps() {
|
||||||
const { webview, currentTrain } = useCurrentTrain();
|
const { webview, currentTrain } = useCurrentTrain();
|
||||||
const { height, width } = useWindowDimensions();
|
const { height, width } = useWindowDimensions();
|
||||||
const { navigate } = useNavigation();
|
const { navigate } = useNavigation();
|
||||||
@ -37,6 +39,11 @@ export default function Apps({ stationData }) {
|
|||||||
const { favoriteStation } = useFavoriteStation();
|
const { favoriteStation } = useFavoriteStation();
|
||||||
const { isLandscape, setIsLandscape } = useDeviceOrientationChange();
|
const { isLandscape, setIsLandscape } = useDeviceOrientationChange();
|
||||||
const handleLayout = () => {};
|
const handleLayout = () => {};
|
||||||
|
const {
|
||||||
|
setSelectedLine,
|
||||||
|
setInjectJavaScript,
|
||||||
|
mapsStationData: stationData,
|
||||||
|
} = useTrainMenu();
|
||||||
|
|
||||||
//画面表示関連
|
//画面表示関連
|
||||||
const [iconSetting, setIconSetting] = useState(undefined);
|
const [iconSetting, setIconSetting] = useState(undefined);
|
||||||
@ -164,6 +171,13 @@ export default function Apps({ stationData }) {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
case "currentLines": {
|
||||||
|
const lineInfo = dataSet.currentLines.split("\n")[0];
|
||||||
|
const lineID = stationNamePair[lineInfo];
|
||||||
|
|
||||||
|
setSelectedLine(lineID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -322,7 +336,10 @@ export default function Apps({ stationData }) {
|
|||||||
)}
|
)}
|
||||||
{isLandscape || (
|
{isLandscape || (
|
||||||
<MapsButton
|
<MapsButton
|
||||||
onPress={() => navigate("trainMenu", { webview })}
|
onPress={() => {
|
||||||
|
setInjectJavaScript("");
|
||||||
|
navigate("trainMenu", { webview });
|
||||||
|
}}
|
||||||
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
||||||
mapSwitch={mapSwitch == "true" ? "flex" : "none"}
|
mapSwitch={mapSwitch == "true" ? "flex" : "none"}
|
||||||
/>
|
/>
|
||||||
@ -467,12 +484,13 @@ const MapsButton = ({ onPress, top, mapSwitch }) => {
|
|||||||
textAlignVertical: "center",
|
textAlignVertical: "center",
|
||||||
fontWeight: "bold",
|
fontWeight: "bold",
|
||||||
color: "white",
|
color: "white",
|
||||||
|
fontSize: 20,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity onPress={onPress} style={styles.touch}>
|
<TouchableOpacity onPress={onPress} style={styles.touch}>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Text style={styles.text}>三</Text>
|
<Text style={styles.text}>≡</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
|
21
Top.js
21
Top.js
@ -14,14 +14,16 @@ import { optionData } from "./lib/stackOption.js";
|
|||||||
import { useNavigation } from "@react-navigation/native";
|
import { useNavigation } from "@react-navigation/native";
|
||||||
import { useCurrentTrain } from "./stateBox/useCurrentTrain.js";
|
import { useCurrentTrain } from "./stateBox/useCurrentTrain.js";
|
||||||
import { AS } from "./storageControl.js";
|
import { AS } from "./storageControl.js";
|
||||||
|
import { useTrainMenu } from "./stateBox/useTrainMenu";
|
||||||
const Stack = createStackNavigator();
|
const Stack = createStackNavigator();
|
||||||
export const Top = ({ navigationRef }) => {
|
export const Top = ({ navigationRef }) => {
|
||||||
const { webview, getCurrentTrain } = useCurrentTrain();
|
const { webview } = useCurrentTrain();
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
const { navigate, addListener } = navigation;
|
const { navigate, addListener } = navigation;
|
||||||
|
|
||||||
//地図用
|
//地図用
|
||||||
const [mapsStationData, setMapsStationData] = useState(undefined);
|
const { setMapsStationData, injectJavaScript, setInjectJavaScript } =
|
||||||
|
useTrainMenu();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getStationList2().then(setMapsStationData);
|
getStationList2().then(setMapsStationData);
|
||||||
@ -47,15 +49,22 @@ export const Top = ({ navigationRef }) => {
|
|||||||
if (navigationRef.current?.getCurrentRoute().name == "Apps") {
|
if (navigationRef.current?.getCurrentRoute().name == "Apps") {
|
||||||
if (mapSwitch == "true") {
|
if (mapSwitch == "true") {
|
||||||
navigation.navigate("trainMenu");
|
navigation.navigate("trainMenu");
|
||||||
|
setInjectJavaScript("");
|
||||||
} else {
|
} else {
|
||||||
webview.current?.injectJavaScript(`AccordionClassEvent()`);
|
webview.current?.injectJavaScript(`AccordionClassEvent()`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (mapSwitch == "true") {
|
||||||
|
if (injectJavaScript) {
|
||||||
|
webview.current?.injectJavaScript(injectJavaScript);
|
||||||
|
setInjectJavaScript("");
|
||||||
|
}
|
||||||
|
}
|
||||||
navigation.navigate("Apps");
|
navigation.navigate("Apps");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return unsubscribe;
|
return unsubscribe;
|
||||||
}, [navigation, mapSwitch]);
|
}, [navigation, mapSwitch, injectJavaScript]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack.Navigator>
|
<Stack.Navigator>
|
||||||
@ -66,7 +75,7 @@ export const Top = ({ navigationRef }) => {
|
|||||||
gestureEnabled: true,
|
gestureEnabled: true,
|
||||||
headerTransparent: true,
|
headerTransparent: true,
|
||||||
}}
|
}}
|
||||||
children={() => <Apps stationData={mapsStationData} />}
|
component={Apps}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="trainbase"
|
name="trainbase"
|
||||||
@ -84,13 +93,13 @@ export const Top = ({ navigationRef }) => {
|
|||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="trainMenu"
|
name="trainMenu"
|
||||||
options={optionData}
|
options={optionData}
|
||||||
children={() => <TrainMenu stationData={mapsStationData} />}
|
component={TrainMenu}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="favoriteList"
|
name="favoriteList"
|
||||||
options={{ ...optionData, gestureEnabled: false }}
|
options={{ ...optionData, gestureEnabled: false }}
|
||||||
children={() => <FavoriteList stationData={mapsStationData} />}
|
component={FavoriteList}
|
||||||
/>
|
/>
|
||||||
</Stack.Navigator>
|
</Stack.Navigator>
|
||||||
);
|
);
|
||||||
|
BIN
assets/reccha-small.png
Normal file
BIN
assets/reccha-small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
BIN
assets/reccha.png
Normal file
BIN
assets/reccha.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 128 KiB |
@ -17,7 +17,9 @@ export const StateBox = ({ text, title, style, mode }) => (
|
|||||||
<Text style={mode == 2 ? boxTextStyle2 : boxTextStyle}>
|
<Text style={mode == 2 ? boxTextStyle2 : boxTextStyle}>
|
||||||
{text.split("~")[0]}
|
{text.split("~")[0]}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={{ color: "#0099CC", textAlign: "right" }}>~</Text>
|
<Text style={{ color: "#0099CC", textAlign: "right" }}>
|
||||||
|
{mode == 2 ? "→" : "↓"}
|
||||||
|
</Text>
|
||||||
<Text style={mode == 2 ? boxTextStyle2 : boxTextStyle}>
|
<Text style={mode == 2 ? boxTextStyle2 : boxTextStyle}>
|
||||||
{text.split("~")[1]}
|
{text.split("~")[1]}
|
||||||
</Text>
|
</Text>
|
||||||
|
@ -17,7 +17,7 @@ export const TrainDataView = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { width, height } = useWindowDimensions();
|
const { width, height } = useWindowDimensions();
|
||||||
const { isLandscape } = useDeviceOrientationChange();
|
const { isLandscape } = useDeviceOrientationChange();
|
||||||
const { webview, getCurrentTrain } = useCurrentTrain();
|
const { webview, getCurrentTrain, inject } = useCurrentTrain();
|
||||||
const [mapsStationData, setMapsStationData] = useState(undefined);
|
const [mapsStationData, setMapsStationData] = useState(undefined);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getStationList2().then(setMapsStationData);
|
getStationList2().then(setMapsStationData);
|
||||||
@ -51,10 +51,10 @@ export const TrainDataView = ({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!test.length) return;
|
if (!test.length) return;
|
||||||
webview.current?.injectJavaScript(
|
|
||||||
`MoveDisplayStation('${test[0].line}_${test[0].station.MyStation}_${test[0].station.Station_JP}');setStrings();`
|
|
||||||
);
|
|
||||||
navigate("Apps");
|
navigate("Apps");
|
||||||
|
inject(
|
||||||
|
`MoveDisplayStation('${test[0].line}_${test[0].station.MyStation}_${test[0].station.Station_JP}');document.getElementById("disp").insertAdjacentHTML("afterbegin", "<div />");`
|
||||||
|
);
|
||||||
SheetManager.hide("EachTrainInfo");
|
SheetManager.hide("EachTrainInfo");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -66,11 +66,11 @@ export const TrainDataView = ({
|
|||||||
? `${
|
? `${
|
||||||
currentTrainData?.Pos.replace("(下り)", "")
|
currentTrainData?.Pos.replace("(下り)", "")
|
||||||
.replace("(上り)", "")
|
.replace("(上り)", "")
|
||||||
.split("~")[0]
|
.split("~")[currentTrainData?.Direction == 1 ? 0 : 1]
|
||||||
}~${
|
}~${
|
||||||
currentTrainData?.Pos.replace("(下り)", "")
|
currentTrainData?.Pos.replace("(下り)", "")
|
||||||
.replace("(上り)", "")
|
.replace("(上り)", "")
|
||||||
.split("~")[1]
|
.split("~")[currentTrainData?.Direction == 1 ? 1 : 0]
|
||||||
}`
|
}`
|
||||||
: currentTrainData?.Pos
|
: currentTrainData?.Pos
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
StyleSheet,
|
StyleSheet,
|
||||||
useWindowDimensions,
|
useWindowDimensions,
|
||||||
BackHandler,
|
BackHandler,
|
||||||
|
Linking,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import { SheetManager } from "react-native-actions-sheet";
|
import { SheetManager } from "react-native-actions-sheet";
|
||||||
@ -25,7 +26,7 @@ import { DynamicHeaderScrollView } from "../DynamicHeaderScrollView";
|
|||||||
import { LongHeader } from "./EachTrainInfo/LongHeader";
|
import { LongHeader } from "./EachTrainInfo/LongHeader";
|
||||||
import { ShortHeader } from "./EachTrainInfo/ShortHeader";
|
import { ShortHeader } from "./EachTrainInfo/ShortHeader";
|
||||||
import { ScrollStickyContent } from "./EachTrainInfo/ScrollStickyContent";
|
import { ScrollStickyContent } from "./EachTrainInfo/ScrollStickyContent";
|
||||||
import { getStationData } from "../../lib/eachTrainInfoCoreLib/getStationData";
|
import { getStationID } from "../../lib/eachTrainInfoCoreLib/getStationData";
|
||||||
import { findReversalPoints } from "../../lib/eachTrainInfoCoreLib/findReversalPoints";
|
import { findReversalPoints } from "../../lib/eachTrainInfoCoreLib/findReversalPoints";
|
||||||
import { migrateTrainName } from "../../lib/eachTrainInfoCoreLib/migrateTrainName";
|
import { migrateTrainName } from "../../lib/eachTrainInfoCoreLib/migrateTrainName";
|
||||||
import { getType } from "../../lib/eachTrainInfoCoreLib/getType";
|
import { getType } from "../../lib/eachTrainInfoCoreLib/getType";
|
||||||
@ -193,12 +194,20 @@ export const EachTrainInfoCore = ({
|
|||||||
const pos = currentTrainData?.Pos.replace("(下り)", "")
|
const pos = currentTrainData?.Pos.replace("(下り)", "")
|
||||||
.replace("(上り)", "")
|
.replace("(上り)", "")
|
||||||
.split("~");
|
.split("~");
|
||||||
setCurrentPosition([
|
const direction = parseInt(currentTrainData?.Direction) || 0;
|
||||||
getStationData(pos[0], stationList),
|
if (direction == 0) {
|
||||||
getStationData(pos[1], stationList),
|
setCurrentPosition([
|
||||||
]);
|
getStationID(pos[1], stationList),
|
||||||
|
getStationID(pos[0], stationList),
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
setCurrentPosition([
|
||||||
|
getStationID(pos[0], stationList),
|
||||||
|
getStationID(pos[1], stationList),
|
||||||
|
]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setCurrentPosition([getStationData(currentTrainData?.Pos, stationList)]);
|
setCurrentPosition([getStationID(currentTrainData?.Pos, stationList)]);
|
||||||
}
|
}
|
||||||
}, [currentTrainData]);
|
}, [currentTrainData]);
|
||||||
|
|
||||||
@ -235,12 +244,18 @@ export const EachTrainInfoCore = ({
|
|||||||
} else {
|
} else {
|
||||||
SheetManager.hide("EachTrainInfo").then(() => {
|
SheetManager.hide("EachTrainInfo").then(() => {
|
||||||
//0.1秒待機してから開く
|
//0.1秒待機してから開く
|
||||||
setTimeout(() => {
|
setTimeout(() => SheetManager.show("EachTrainInfo", { payload }), 2);
|
||||||
SheetManager.show("EachTrainInfo", { payload });
|
|
||||||
}, 2);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const headerItem = {
|
||||||
|
currentTrainData,
|
||||||
|
currentPosition,
|
||||||
|
nearTrainIDList,
|
||||||
|
openTrainInfo,
|
||||||
|
navigate,
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
@ -303,24 +318,8 @@ export const EachTrainInfoCore = ({
|
|||||||
maxHeight: isLandscape ? height - 94 : (height / 100) * 70,
|
maxHeight: isLandscape ? height - 94 : (height / 100) * 70,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
shortHeader={
|
shortHeader={<ShortHeader {...headerItem} />}
|
||||||
<ShortHeader
|
longHeader={<LongHeader {...headerItem} />}
|
||||||
currentTrainData={currentTrainData}
|
|
||||||
currentPosition={currentPosition}
|
|
||||||
nearTrainIDList={nearTrainIDList}
|
|
||||||
openTrainInfo={openTrainInfo}
|
|
||||||
navigate={navigate}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
longHeader={
|
|
||||||
<LongHeader
|
|
||||||
currentTrainData={currentTrainData}
|
|
||||||
currentPosition={currentPosition}
|
|
||||||
nearTrainIDList={nearTrainIDList}
|
|
||||||
openTrainInfo={openTrainInfo}
|
|
||||||
navigate={navigate}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
topStickyContent={
|
topStickyContent={
|
||||||
<ScrollStickyContent currentTrainData={currentTrainData} />
|
<ScrollStickyContent currentTrainData={currentTrainData} />
|
||||||
}
|
}
|
||||||
@ -361,6 +360,26 @@ export const EachTrainInfoCore = ({
|
|||||||
trainList={trainList}
|
trainList={trainList}
|
||||||
trueTrainID={trueTrainID}
|
trueTrainID={trueTrainID}
|
||||||
/>
|
/>
|
||||||
|
{!trainData.length && (
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() =>
|
||||||
|
Linking.openURL(`https://twitter.com/search?q=${data.trainNum}`)
|
||||||
|
}
|
||||||
|
style={{
|
||||||
|
padding: 10,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderColor: "blue",
|
||||||
|
borderWidth: 1,
|
||||||
|
margin: 10,
|
||||||
|
borderRadius: 5,
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text style={{ fontSize: 18, fontWeight: "bold", color: "black" }}>
|
||||||
|
Twitterで検索
|
||||||
|
</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
{trainData.map((i, index) =>
|
{trainData.map((i, index) =>
|
||||||
i.split(",")[1] == "提" ? (
|
i.split(",")[1] == "提" ? (
|
||||||
<DataFromButton i={i} />
|
<DataFromButton i={i} />
|
||||||
@ -376,11 +395,11 @@ export const EachTrainInfoCore = ({
|
|||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
{tailStation.length != 0 &&
|
{tailStation.length != 0 &&
|
||||||
tailStation.map((i, index) =>
|
tailStation.map(({ station, dia }, index) =>
|
||||||
showTailStation.findIndex((d) => d == index) == -1 ? (
|
showTailStation.findIndex((d) => d == index) == -1 ? (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
const array = openBackTrainInfo(i.station, trainData, i.dia);
|
const array = openBackTrainInfo(station, trainData, dia);
|
||||||
|
|
||||||
if (!array) return;
|
if (!array) return;
|
||||||
setTrainData(array);
|
setTrainData(array);
|
||||||
|
@ -262,9 +262,9 @@ const NexPreStationLine = ({ currentStation, originalStationList }) => {
|
|||||||
"土讃線(多度津-高知間)[D]",
|
"土讃線(多度津-高知間)[D]",
|
||||||
"土讃線(高知-窪川間)[K]",
|
"土讃線(高知-窪川間)[K]",
|
||||||
"高徳線(高松-徳島間)[T]",
|
"高徳線(高松-徳島間)[T]",
|
||||||
"徳島線(徳島-阿波池田)[B]",
|
"徳島線(徳島-阿波池田間)[B]",
|
||||||
"鳴門線(池谷-鳴門間)[N]",
|
"鳴門線(池谷-鳴門間)[N]",
|
||||||
"瀬戸大橋線(宇多津-児島間)[M]",
|
"瀬戸大橋線(児島-宇多津間)[M]",
|
||||||
];
|
];
|
||||||
let returnData;
|
let returnData;
|
||||||
lineList.forEach((d) => {
|
lineList.forEach((d) => {
|
||||||
|
138
components/ActionSheetComponents/TrainMenuLineSelector.js
Normal file
138
components/ActionSheetComponents/TrainMenuLineSelector.js
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
import React, { useEffect, useRef } from "react";
|
||||||
|
import {
|
||||||
|
View,
|
||||||
|
LayoutAnimation,
|
||||||
|
ScrollView,
|
||||||
|
Linking,
|
||||||
|
Text,
|
||||||
|
TouchableOpacity,
|
||||||
|
Platform,
|
||||||
|
BackHandler,
|
||||||
|
} from "react-native";
|
||||||
|
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
|
import ActionSheet, {
|
||||||
|
SheetManager,
|
||||||
|
useScrollHandlers,
|
||||||
|
} from "react-native-actions-sheet";
|
||||||
|
import LottieView from "lottie-react-native";
|
||||||
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||||
|
import ViewShot from "react-native-view-shot";
|
||||||
|
import * as Sharing from "expo-sharing";
|
||||||
|
import { useTrainDelayData } from "../../stateBox/useTrainDelayData";
|
||||||
|
import { useTrainMenu } from "../../stateBox/useTrainMenu";
|
||||||
|
import lineColorList from "../../assets/originData/lineColorList";
|
||||||
|
import { stationIDPair } from "../../lib/getStationList2";
|
||||||
|
import { lineListPair } from "../../lib/getStationList";
|
||||||
|
|
||||||
|
export const TrainMenuLineSelector = () => {
|
||||||
|
const { getTime, delayData, loadingDelayData, setLoadingDelayData } =
|
||||||
|
useTrainDelayData();
|
||||||
|
const {
|
||||||
|
selectedLine,
|
||||||
|
setSelectedLine,
|
||||||
|
mapsStationData: stationData,
|
||||||
|
setMapsStationData,
|
||||||
|
} = useTrainMenu();
|
||||||
|
const actionSheetRef = useRef(null);
|
||||||
|
const scrollHandlers = useScrollHandlers("scrollview-1", actionSheetRef);
|
||||||
|
const insets = useSafeAreaInsets();
|
||||||
|
const viewShot = useRef(null);
|
||||||
|
const platformIs = Platform.OS == "android";
|
||||||
|
return (
|
||||||
|
<ActionSheet
|
||||||
|
gestureEnabled
|
||||||
|
CustomHeaderComponent={<></>}
|
||||||
|
ref={actionSheetRef}
|
||||||
|
isModal={Platform.OS == "ios"}
|
||||||
|
containerStyle={platformIs ? { paddingBottom: insets.bottom } : {}}
|
||||||
|
useBottomSafeAreaPadding={platformIs}
|
||||||
|
>
|
||||||
|
<Handler />
|
||||||
|
<View style={{ height: 26, width: "100%", backgroundColor: "white" }}>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
height: 6,
|
||||||
|
width: 45,
|
||||||
|
borderRadius: 100,
|
||||||
|
backgroundColor: "#f0f0f0",
|
||||||
|
marginVertical: 10,
|
||||||
|
alignSelf: "center",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
{Object.keys(stationData).map((d) => (
|
||||||
|
<TouchableOpacity
|
||||||
|
style={{
|
||||||
|
flexDirection: "row",
|
||||||
|
backgroundColor: selectedLine == d ? "#0099CC33" : "white",
|
||||||
|
}}
|
||||||
|
onPress={() => {
|
||||||
|
SheetManager.hide("TrainMenuLineSelector");
|
||||||
|
setSelectedLine(selectedLine == d ? undefined : d);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
width: 35,
|
||||||
|
position: "relative",
|
||||||
|
marginHorizontal: 15,
|
||||||
|
flexDirection: "row",
|
||||||
|
height: "101%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
backgroundColor: lineColorList[stationIDPair[d]],
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
color: "white",
|
||||||
|
textAlign: "center",
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: "bold",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{stationIDPair[d]}
|
||||||
|
</Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
padding: 8,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
borderBottomColor: "#f0f0f0",
|
||||||
|
flex: 1,
|
||||||
|
alignContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text style={{ fontSize: 20 }}>
|
||||||
|
{lineListPair[stationIDPair[d]]}
|
||||||
|
</Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
</View>
|
||||||
|
</TouchableOpacity>
|
||||||
|
))}
|
||||||
|
</ActionSheet>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const Handler = () => {
|
||||||
|
useEffect(() => {
|
||||||
|
const backAction = () => {
|
||||||
|
SheetManager.hide("TrainMenuLineSelector");
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
const backHandler = BackHandler.addEventListener(
|
||||||
|
"hardwareBackPress",
|
||||||
|
backAction
|
||||||
|
);
|
||||||
|
return () => backHandler.remove();
|
||||||
|
}, []);
|
||||||
|
return <></>;
|
||||||
|
};
|
@ -2,9 +2,11 @@ import { registerSheet } from "react-native-actions-sheet";
|
|||||||
import { EachTrainInfo } from "./EachTrainInfo";
|
import { EachTrainInfo } from "./EachTrainInfo";
|
||||||
import { JRSTraInfo } from "./JRSTraInfo";
|
import { JRSTraInfo } from "./JRSTraInfo";
|
||||||
import { StationDeteilView } from "./StationDeteilView";
|
import { StationDeteilView } from "./StationDeteilView";
|
||||||
|
import { TrainMenuLineSelector } from "./TrainMenuLineSelector";
|
||||||
|
|
||||||
registerSheet("EachTrainInfo", EachTrainInfo);
|
registerSheet("EachTrainInfo", EachTrainInfo);
|
||||||
registerSheet("JRSTraInfo", JRSTraInfo);
|
registerSheet("JRSTraInfo", JRSTraInfo);
|
||||||
registerSheet("StationDetailView", StationDeteilView);
|
registerSheet("StationDetailView", StationDeteilView);
|
||||||
|
registerSheet("TrainMenuLineSelector", TrainMenuLineSelector);
|
||||||
|
|
||||||
export {};
|
export {};
|
||||||
|
@ -81,17 +81,15 @@ export function InfoWidget({ time, text }) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{text ? (
|
{text ? (
|
||||||
<FlexWidget
|
<TextWidget
|
||||||
style={{
|
style={{
|
||||||
flexDirection: "row",
|
color: "#000000",
|
||||||
width: "match_parent",
|
|
||||||
backgroundColor: "#ffffff",
|
fontSize: 20,
|
||||||
flex: 1,
|
|
||||||
}}
|
}}
|
||||||
clickAction="WIDGET_CLICK"
|
clickAction="OPEN_APP"
|
||||||
>
|
text={text}
|
||||||
<FlexText flex={3} text={text} />
|
/>
|
||||||
</FlexWidget>
|
|
||||||
) : (
|
) : (
|
||||||
<TextWidget
|
<TextWidget
|
||||||
style={{
|
style={{
|
||||||
|
@ -33,7 +33,9 @@ export async function widgetTaskHandler(props) {
|
|||||||
switch (WidgetName) {
|
switch (WidgetName) {
|
||||||
case "Info_Widget": {
|
case "Info_Widget": {
|
||||||
const { time, text } = await getInfoString();
|
const { time, text } = await getInfoString();
|
||||||
renderWidget(<InfoWidget time={time} text={text} />);
|
renderWidget(
|
||||||
|
<InfoWidget time={time} text={text && text.toString()} />
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "JR_shikoku_train_info":
|
case "JR_shikoku_train_info":
|
||||||
|
@ -5,11 +5,13 @@ import Icon from "react-native-vector-icons/Entypo";
|
|||||||
import { useFavoriteStation } from "../stateBox/useFavoriteStation";
|
import { useFavoriteStation } from "../stateBox/useFavoriteStation";
|
||||||
import { useCurrentTrain } from "../stateBox/useCurrentTrain";
|
import { useCurrentTrain } from "../stateBox/useCurrentTrain";
|
||||||
import { useNavigation } from "@react-navigation/native";
|
import { useNavigation } from "@react-navigation/native";
|
||||||
|
import { useTrainMenu } from "../stateBox/useTrainMenu";
|
||||||
import { FavoriteListItem } from "./atom/FavoriteListItem";
|
import { FavoriteListItem } from "./atom/FavoriteListItem";
|
||||||
export default function FavoriteList({ stationData }) {
|
export default function FavoriteList() {
|
||||||
const { favoriteStation } = useFavoriteStation();
|
const { favoriteStation } = useFavoriteStation();
|
||||||
const { webview } = useCurrentTrain();
|
const { webview } = useCurrentTrain();
|
||||||
const { navigate, goBack } = useNavigation();
|
const { navigate, goBack } = useNavigation();
|
||||||
|
const { mapsStationData: stationData } = useTrainMenu();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
||||||
@ -45,7 +47,7 @@ export default function FavoriteList({ stationData }) {
|
|||||||
|
|
||||||
webview.current?.injectJavaScript(
|
webview.current?.injectJavaScript(
|
||||||
`MoveDisplayStation('${lineName}_${currentStation[0].MyStation}_${currentStation[0].Station_JP}');
|
`MoveDisplayStation('${lineName}_${currentStation[0].MyStation}_${currentStation[0].Station_JP}');
|
||||||
setStrings();`
|
document.getElementById("disp").insertAdjacentHTML("afterbegin", "<div />");`
|
||||||
);
|
);
|
||||||
navigate("Apps");
|
navigate("Apps");
|
||||||
}}
|
}}
|
||||||
|
@ -34,7 +34,7 @@ export const WidgetSettings = ({ navigate }) => {
|
|||||||
});
|
});
|
||||||
getInfoString().then(({ time, text }) => {
|
getInfoString().then(({ time, text }) => {
|
||||||
setTime(time);
|
setTime(time);
|
||||||
setTrainInfo(text);
|
setTrainInfo(text.toString());
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
return (
|
return (
|
||||||
|
@ -1,21 +1,30 @@
|
|||||||
import React, { useRef, useState, useEffect } from "react";
|
import React, { useRef, useState, useEffect } from "react";
|
||||||
import { View, Text, TouchableOpacity, Linking } from "react-native";
|
import { View, Text, TouchableOpacity, Linking, Platform } from "react-native";
|
||||||
import MapView, { Marker } from "react-native-maps";
|
import MapView, { Marker } from "react-native-maps";
|
||||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
import Constants from "expo-constants";
|
||||||
|
import { MaterialCommunityIcons, Ionicons } from "@expo/vector-icons";
|
||||||
import { useCurrentTrain } from "../stateBox/useCurrentTrain";
|
import { useCurrentTrain } from "../stateBox/useCurrentTrain";
|
||||||
import { useNavigation } from "@react-navigation/native";
|
import { useNavigation } from "@react-navigation/native";
|
||||||
import lineColorList from "../assets/originData/lineColorList";
|
import lineColorList from "../assets/originData/lineColorList";
|
||||||
import { stationIDPair } from "../lib/getStationList2";
|
import { stationIDPair } from "../lib/getStationList2";
|
||||||
import { lineListPair } from "../lib/getStationList";
|
import { lineListPair } from "../lib/getStationList";
|
||||||
export default function TrainMenu({ stationData, style }) {
|
import { SheetManager } from "react-native-actions-sheet";
|
||||||
|
import { useTrainMenu } from "../stateBox/useTrainMenu";
|
||||||
|
export default function TrainMenu({ style }) {
|
||||||
const { webview } = useCurrentTrain();
|
const { webview } = useCurrentTrain();
|
||||||
const mapRef = useRef();
|
const mapRef = useRef();
|
||||||
const { navigate } = useNavigation();
|
const { navigate } = useNavigation();
|
||||||
const [stationPin, setStationPin] = useState([]);
|
const [stationPin, setStationPin] = useState([]);
|
||||||
const [selectedLine, setSelectedLine] = useState(undefined);
|
const {
|
||||||
|
selectedLine,
|
||||||
|
setSelectedLine,
|
||||||
|
injectJavaScript,
|
||||||
|
setInjectJavaScript,
|
||||||
|
mapsStationData: stationData,
|
||||||
|
} = useTrainMenu();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const stationPinData = [];
|
const stationPinData = [];
|
||||||
Object.keys(stationData).map((d, indexBase) =>
|
Object.keys(stationData).map((d, indexBase) => {
|
||||||
stationData[d].map((D, index) => {
|
stationData[d].map((D, index) => {
|
||||||
if (!D.StationMap) return null;
|
if (!D.StationMap) return null;
|
||||||
if (selectedLine && selectedLine != d) return;
|
if (selectedLine && selectedLine != d) return;
|
||||||
@ -24,9 +33,15 @@ export default function TrainMenu({ stationData, style }) {
|
|||||||
""
|
""
|
||||||
).split(",");
|
).split(",");
|
||||||
if (latlng.length == 0) return null;
|
if (latlng.length == 0) return null;
|
||||||
|
if (index == 0 && stationPin.length > 0) {
|
||||||
|
setInjectJavaScript(
|
||||||
|
`MoveDisplayStation('${d}_${D.MyStation}_${D.Station_JP}');
|
||||||
|
document.getElementById("disp").insertAdjacentHTML("afterbegin", "<div />");`
|
||||||
|
);
|
||||||
|
}
|
||||||
stationPinData.push({ D, d, latlng, indexBase: 0, index });
|
stationPinData.push({ D, d, latlng, indexBase: 0, index });
|
||||||
})
|
});
|
||||||
);
|
});
|
||||||
setStationPin(stationPinData);
|
setStationPin(stationPinData);
|
||||||
}, [stationData, selectedLine]);
|
}, [stationData, selectedLine]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -35,37 +50,11 @@ export default function TrainMenu({ stationData, style }) {
|
|||||||
latitude: parseFloat(latlng[0]),
|
latitude: parseFloat(latlng[0]),
|
||||||
longitude: parseFloat(latlng[1]),
|
longitude: parseFloat(latlng[1]),
|
||||||
})),
|
})),
|
||||||
{ edgePadding: { top: 100, bottom: 50, left: 50, right: 50 } } // Add margin values here
|
{ edgePadding: { top: 80, bottom: 120, left: 50, right: 50 } } // Add margin values here
|
||||||
);
|
);
|
||||||
}, [stationPin]);
|
}, [stationPin]);
|
||||||
return (
|
return (
|
||||||
<View style={{ height: "100%", backgroundColor: "#0099CC", ...style }}>
|
<View style={{ height: "100%", backgroundColor: "#0099CC", ...style }}>
|
||||||
{selectedLine && (
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
backgroundColor: lineColorList[stationIDPair[selectedLine]],
|
|
||||||
padding: 10,
|
|
||||||
zIndex: 100,
|
|
||||||
alignItems: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
color: "white",
|
|
||||||
fontWeight: "bold",
|
|
||||||
fontSize: 20,
|
|
||||||
textAlign: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{selectedLine ? lineListPair[stationIDPair[selectedLine]] : "全線"}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<MapView
|
<MapView
|
||||||
style={{ flex: 1, width: "100%", height: "100%" }}
|
style={{ flex: 1, width: "100%", height: "100%" }}
|
||||||
showsUserLocation={true}
|
showsUserLocation={true}
|
||||||
@ -105,6 +94,44 @@ export default function TrainMenu({ stationData, style }) {
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<TouchableOpacity
|
||||||
|
style={{
|
||||||
|
backgroundColor: selectedLine
|
||||||
|
? lineColorList[stationIDPair[selectedLine]]
|
||||||
|
: "#0099CC",
|
||||||
|
padding: 10,
|
||||||
|
zIndex: 1,
|
||||||
|
alignItems: "center",
|
||||||
|
position: "absolute",
|
||||||
|
bottom: 0,
|
||||||
|
width: "100%",
|
||||||
|
paddingBottom: 50,
|
||||||
|
}}
|
||||||
|
onPress={() => SheetManager.show("TrainMenuLineSelector")}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
color: "white",
|
||||||
|
fontWeight: "bold",
|
||||||
|
fontSize: 10,
|
||||||
|
textAlign: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
▲ ここを押して路線をフィルタリングできます ▲
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
color: "white",
|
||||||
|
fontWeight: "bold",
|
||||||
|
fontSize: 20,
|
||||||
|
textAlign: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{selectedLine
|
||||||
|
? lineListPair[stationIDPair[selectedLine]]
|
||||||
|
: "JR四国 対象全駅"}
|
||||||
|
</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
<Text style={{ position: "absolute", bottom: 40 }}>
|
<Text style={{ position: "absolute", bottom: 40 }}>
|
||||||
路線記号からフィルタリング
|
路線記号からフィルタリング
|
||||||
</Text>
|
</Text>
|
||||||
@ -116,8 +143,12 @@ export default function TrainMenu({ stationData, style }) {
|
|||||||
padding: 5,
|
padding: 5,
|
||||||
margin: 2,
|
margin: 2,
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
|
borderColor: "white",
|
||||||
|
borderWidth: 1,
|
||||||
|
borderStyle: "solid",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
opacity: selectedLine == d ? 1 : !selectedLine ? 1 : 0.5,
|
opacity: selectedLine == d ? 1 : !selectedLine ? 1 : 0.5,
|
||||||
|
zIndex: 10,
|
||||||
}}
|
}}
|
||||||
onPress={() => setSelectedLine(selectedLine == d ? undefined : d)}
|
onPress={() => setSelectedLine(selectedLine == d ? undefined : d)}
|
||||||
>
|
>
|
||||||
@ -166,26 +197,14 @@ export default function TrainMenu({ stationData, style }) {
|
|||||||
</UsefulBox>
|
</UsefulBox>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
{navigate && (
|
<MapsButton
|
||||||
<TouchableOpacity
|
onPress={() => {
|
||||||
style={{
|
navigate("Apps");
|
||||||
padding: 10,
|
webview.current?.injectJavaScript(injectJavaScript);
|
||||||
flexDirection: "row",
|
}}
|
||||||
borderColor: "white",
|
top={0}
|
||||||
borderWidth: 1,
|
mapSwitch={"flex"}
|
||||||
margin: 10,
|
/>
|
||||||
borderRadius: 5,
|
|
||||||
alignItems: "center",
|
|
||||||
}}
|
|
||||||
onPress={() => navigate("Apps")}
|
|
||||||
>
|
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
|
||||||
閉じる
|
|
||||||
</Text>
|
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
</TouchableOpacity>
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -221,10 +240,47 @@ const MapPin = ({ index, indexBase, latlng, D, d, navigate, webview }) => {
|
|||||||
onPress={() => {
|
onPress={() => {
|
||||||
webview.current?.injectJavaScript(
|
webview.current?.injectJavaScript(
|
||||||
`MoveDisplayStation('${d}_${D.MyStation}_${D.Station_JP}');
|
`MoveDisplayStation('${d}_${D.MyStation}_${D.Station_JP}');
|
||||||
setStrings();`
|
document.getElementById("disp").insertAdjacentHTML("afterbegin", "<div />");`
|
||||||
);
|
);
|
||||||
if (navigate) navigate("Apps");
|
if (navigate) navigate("Apps");
|
||||||
}}
|
}}
|
||||||
|
image={require("../assets/reccha-small.png")}
|
||||||
></Marker>
|
></Marker>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const MapsButton = ({ onPress, top, mapSwitch }) => {
|
||||||
|
const styles = {
|
||||||
|
touch: {
|
||||||
|
position: "absolute",
|
||||||
|
top,
|
||||||
|
left: 10,
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
backgroundColor: "#0099CC",
|
||||||
|
borderColor: "white",
|
||||||
|
borderStyle: "solid",
|
||||||
|
borderWidth: 1,
|
||||||
|
borderRadius: 50,
|
||||||
|
alignContent: "center",
|
||||||
|
alignSelf: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
display: mapSwitch,
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
textAlign: "center",
|
||||||
|
width: "auto",
|
||||||
|
height: "auto",
|
||||||
|
textAlignVertical: "center",
|
||||||
|
fontWeight: "bold",
|
||||||
|
color: "white",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<TouchableOpacity onPress={onPress} style={styles.touch}>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
<Ionicons name="close" color="white" size={30} />
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
@ -13,6 +13,7 @@ import { checkDuplicateTrainData } from "../../lib/checkDuplicateTrainData";
|
|||||||
import { useCurrentTrain } from "../../stateBox/useCurrentTrain";
|
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";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -59,6 +60,31 @@ export default function LED_vision(props) {
|
|||||||
const [trainDescriptionSwitch, setTrainDescriptionSwitch] = useState(false);
|
const [trainDescriptionSwitch, setTrainDescriptionSwitch] = useState(false);
|
||||||
const { areaInfo } = useAreaInfo();
|
const { areaInfo } = useAreaInfo();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
AS.getItem("LEDSettings/trainIDSwitch").then((data) => {
|
||||||
|
console.log(data);
|
||||||
|
if (data == "true") {
|
||||||
|
setTrainIDSwitch(true);
|
||||||
|
} else {
|
||||||
|
setTrainIDSwitch(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AS.getItem("LEDSettings/trainDescriptionSwitch").then((data) => {
|
||||||
|
if (data == "true") {
|
||||||
|
setTrainDescriptionSwitch(true);
|
||||||
|
} else {
|
||||||
|
setTrainDescriptionSwitch(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AS.getItem("LEDSettings/finalSwitch").then((data) => {
|
||||||
|
if (data == "true") {
|
||||||
|
setFinalSwitch(true);
|
||||||
|
} else {
|
||||||
|
setFinalSwitch(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 現在の駅に停車するダイヤを作成する副作用[列車ダイヤと現在駅情報]
|
// 現在の駅に停車するダイヤを作成する副作用[列車ダイヤと現在駅情報]
|
||||||
if (!trainDiagram) {
|
if (!trainDiagram) {
|
||||||
@ -164,14 +190,20 @@ export default function LED_vision(props) {
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!areaInfo) return () => {};
|
if (!areaInfo) {
|
||||||
|
setAreaString("");
|
||||||
|
return () => {};
|
||||||
|
}
|
||||||
setAreaString(
|
setAreaString(
|
||||||
areaInfo.substring(move, areaInfo.length) + areaInfo.substring(0, move)
|
areaInfo.substring(move, areaInfo.length) + areaInfo.substring(0, move)
|
||||||
);
|
);
|
||||||
}, [move]);
|
}, [move]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!areaInfo) return () => {};
|
if (!areaInfo) {
|
||||||
|
setAreaStringLength(0);
|
||||||
|
return () => {};
|
||||||
|
}
|
||||||
setAreaStringLength(areaInfo.length);
|
setAreaStringLength(areaInfo.length);
|
||||||
}, [areaInfo]);
|
}, [areaInfo]);
|
||||||
|
|
||||||
@ -282,16 +314,31 @@ const Footer = (props) => {
|
|||||||
return (
|
return (
|
||||||
<View style={{ flexDirection: "row", padding: 10, alignItems: "center" }}>
|
<View style={{ flexDirection: "row", padding: 10, alignItems: "center" }}>
|
||||||
<Text style={textStyle}>種別名 / 列番</Text>
|
<Text style={textStyle}>種別名 / 列番</Text>
|
||||||
<Switch value={trainIDSwitch} onValueChange={setTrainIDSwitch} />
|
<Switch
|
||||||
|
value={trainIDSwitch}
|
||||||
|
onValueChange={(value) => {
|
||||||
|
AS.setItem("LEDSettings/trainIDSwitch", value.toString());
|
||||||
|
setTrainIDSwitch(value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Text style={textStyle}>列車情報</Text>
|
<Text style={textStyle}>列車情報</Text>
|
||||||
<Switch
|
<Switch
|
||||||
value={trainDescriptionSwitch}
|
value={trainDescriptionSwitch}
|
||||||
onValueChange={setTrainDescriptionSwitch}
|
onValueChange={(value) => {
|
||||||
|
AS.setItem("LEDSettings/trainDescriptionSwitch", value.toString());
|
||||||
|
setTrainDescriptionSwitch(value);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Text style={textStyle}>当駅止表示</Text>
|
<Text style={textStyle}>当駅止表示</Text>
|
||||||
<Switch value={finalSwitch} onValueChange={setFinalSwitch} />
|
<Switch
|
||||||
|
value={finalSwitch}
|
||||||
|
onValueChange={(value) => {
|
||||||
|
AS.setItem("LEDSettings/finalSwitch", value.toString());
|
||||||
|
setFinalSwitch(value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -336,10 +383,24 @@ const EachData = ({
|
|||||||
setTrain(customTrainDataDetector(d.train));
|
setTrain(customTrainDataDetector(d.train));
|
||||||
}, [currentTrain, d.train, trainDescriptionSwitch]);
|
}, [currentTrain, d.train, trainDescriptionSwitch]);
|
||||||
// 土讃線複数存在対策
|
// 土讃線複数存在対策
|
||||||
|
const currentTrainData = checkDuplicateTrainData(
|
||||||
|
currentTrain.filter((a) => a.num == d.train)
|
||||||
|
);
|
||||||
const trainDelayStatus = getTrainDelayStatus(
|
const trainDelayStatus = getTrainDelayStatus(
|
||||||
checkDuplicateTrainData(currentTrain.filter((a) => a.num == d.train)),
|
currentTrainData,
|
||||||
station.Station_JP
|
station.Station_JP
|
||||||
);
|
);
|
||||||
|
const trainPositionText = currentTrainData?.Pos.match("~")
|
||||||
|
? `現在地:${
|
||||||
|
currentTrainData?.Pos.replace("(下り)", "")
|
||||||
|
.replace("(上り)", "")
|
||||||
|
.split("~")[currentTrainData?.Direction == 1 ? 0 : 1]
|
||||||
|
}→${
|
||||||
|
currentTrainData?.Pos.replace("(下り)", "")
|
||||||
|
.replace("(上り)", "")
|
||||||
|
.split("~")[currentTrainData?.Direction == 1 ? 1 : 0]
|
||||||
|
}間を走行中`
|
||||||
|
: `現在地:${currentTrainData?.Pos}`;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
@ -365,6 +426,7 @@ const EachData = ({
|
|||||||
<DependTime time={d.time} />
|
<DependTime time={d.time} />
|
||||||
<StatusAndDelay trainDelayStatus={trainDelayStatus} />
|
<StatusAndDelay trainDelayStatus={trainDelayStatus} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
{trainDescriptionSwitch && <Description info={`${trainPositionText}`} />}
|
||||||
{trainDescriptionSwitch && !!train.info && (
|
{trainDescriptionSwitch && !!train.info && (
|
||||||
<Description info={train.info} />
|
<Description info={train.info} />
|
||||||
)}
|
)}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import React, { useRef, useState, useEffect, useLayoutEffect } from "react";
|
import React, { useRef, useState, useEffect, useLayoutEffect } from "react";
|
||||||
import { View, Text, TouchableOpacity } from "react-native";
|
import { View, Text, TouchableOpacity } from "react-native";
|
||||||
import { widthPercentageToDP as wp } from "react-native-responsive-screen";
|
import { widthPercentageToDP as wp } from "react-native-responsive-screen";
|
||||||
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import LottieView from "lottie-react-native";
|
import LottieView from "lottie-react-native";
|
||||||
import { useInterval } from "../../lib/useInterval";
|
import { useInterval } from "../../lib/useInterval";
|
||||||
import { AS } from "../../storageControl";
|
import { AS } from "../../storageControl";
|
||||||
@ -9,7 +10,13 @@ import { useFavoriteStation } from "../../stateBox/useFavoriteStation";
|
|||||||
import lineColorList from "../../assets/originData/lineColorList";
|
import lineColorList from "../../assets/originData/lineColorList";
|
||||||
|
|
||||||
export default function Sign(props) {
|
export default function Sign(props) {
|
||||||
const { currentStation, originalStationList, oP, oLP } = props;
|
const {
|
||||||
|
currentStation,
|
||||||
|
originalStationList,
|
||||||
|
oP,
|
||||||
|
oLP,
|
||||||
|
isCurrentStation = false,
|
||||||
|
} = props;
|
||||||
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
||||||
const [nexPrePosition, setNexPrePosition] = useState(0);
|
const [nexPrePosition, setNexPrePosition] = useState(0);
|
||||||
|
|
||||||
@ -68,9 +75,9 @@ export default function Sign(props) {
|
|||||||
"土讃線(多度津-高知間)[D]",
|
"土讃線(多度津-高知間)[D]",
|
||||||
"土讃線(高知-窪川間)[K]",
|
"土讃線(高知-窪川間)[K]",
|
||||||
"高徳線(高松-徳島間)[T]",
|
"高徳線(高松-徳島間)[T]",
|
||||||
"徳島線(徳島-阿波池田)[B]",
|
"徳島線(徳島-阿波池田間)[B]",
|
||||||
"鳴門線(池谷-鳴門間)[N]",
|
"鳴門線(池谷-鳴門間)[N]",
|
||||||
"瀬戸大橋線(宇多津-児島間)[M]",
|
"瀬戸大橋線(児島-宇多津間)[M]",
|
||||||
];
|
];
|
||||||
let returnData;
|
let returnData;
|
||||||
lineList.forEach((d) => {
|
lineList.forEach((d) => {
|
||||||
@ -92,39 +99,50 @@ export default function Sign(props) {
|
|||||||
<TouchableOpacity style={styleSheet.外枠} onPress={oP} onLongPress={oLP}>
|
<TouchableOpacity style={styleSheet.外枠} onPress={oP} onLongPress={oLP}>
|
||||||
<StationNumberMaker currentStation={currentStation} />
|
<StationNumberMaker currentStation={currentStation} />
|
||||||
<StationNameArea currentStation={currentStation} />
|
<StationNameArea currentStation={currentStation} />
|
||||||
<TouchableOpacity
|
{isCurrentStation ? (
|
||||||
style={{ position: "absolute", right: -15, top: -20 }}
|
<TouchableOpacity style={{ position: "absolute", right: 0, top: 0 }}>
|
||||||
onPress={() => {
|
<MaterialCommunityIcons
|
||||||
if (testButtonStatus) {
|
name="crosshairs-gps"
|
||||||
const otherData = favoriteStation.filter((d) => {
|
style={{ padding: 5 }}
|
||||||
const compare = JSON.stringify(d);
|
color="#2E94BB"
|
||||||
const current = JSON.stringify(currentStation);
|
size={30}
|
||||||
if (compare !== current) {
|
/>
|
||||||
return true;
|
</TouchableOpacity>
|
||||||
} else {
|
) : (
|
||||||
return false;
|
<TouchableOpacity
|
||||||
}
|
style={{ position: "absolute", right: -15, top: -20 }}
|
||||||
});
|
onPress={() => {
|
||||||
AS.setItem("favoriteStation", JSON.stringify(otherData));
|
if (testButtonStatus) {
|
||||||
setFavoriteStation(otherData);
|
const otherData = favoriteStation.filter((d) => {
|
||||||
} else {
|
const compare = JSON.stringify(d);
|
||||||
let ret = favoriteStation;
|
const current = JSON.stringify(currentStation);
|
||||||
ret.push(currentStation);
|
if (compare !== current) {
|
||||||
AS.setItem("favoriteStation", JSON.stringify(ret));
|
return true;
|
||||||
setFavoriteStation(ret);
|
} else {
|
||||||
}
|
return false;
|
||||||
setTestButtonStatus(!testButtonStatus);
|
}
|
||||||
}}
|
});
|
||||||
>
|
AS.setItem("favoriteStation", JSON.stringify(otherData));
|
||||||
<LottieDelayView
|
setFavoriteStation(otherData);
|
||||||
progress={testButtonStatus ? 1 : 0}
|
} else {
|
||||||
speed={1.4}
|
let ret = favoriteStation;
|
||||||
style={{ width: 80, height: 80 }}
|
ret.push(currentStation);
|
||||||
source={require("../../assets/939-star.json")}
|
AS.setItem("favoriteStation", JSON.stringify(ret));
|
||||||
lottieRef={lottieRef}
|
setFavoriteStation(ret);
|
||||||
loop={false}
|
}
|
||||||
/>
|
setTestButtonStatus(!testButtonStatus);
|
||||||
</TouchableOpacity>
|
}}
|
||||||
|
>
|
||||||
|
<LottieDelayView
|
||||||
|
progress={testButtonStatus ? 1 : 0}
|
||||||
|
speed={1.4}
|
||||||
|
style={{ width: 80, height: 80 }}
|
||||||
|
source={require("../../assets/939-star.json")}
|
||||||
|
lottieRef={lottieRef}
|
||||||
|
loop={false}
|
||||||
|
/>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
|
||||||
<Text style={styleSheet.JRStyle}>JR</Text>
|
<Text style={styleSheet.JRStyle}>JR</Text>
|
||||||
<View style={styleSheet.下帯} />
|
<View style={styleSheet.下帯} />
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// 駅名から駅情報を取得する
|
// 駅名から駅情報を取得する
|
||||||
//stationName: 駅名
|
//stationName: 駅名
|
||||||
//stationList: 駅情報リスト
|
//stationList: 駅情報リスト
|
||||||
export const getStationData = (stationName, stationList) => {
|
export const getStationID = (stationName, stationList) => {
|
||||||
const Stations = stationList.map((a) =>
|
const Stations = stationList.map((a) =>
|
||||||
a.filter((d) => d.StationName == stationName)
|
a.filter((d) => d.StationName == stationName)
|
||||||
);
|
);
|
||||||
@ -13,3 +13,15 @@ export const getStationData = (stationName, stationList) => {
|
|||||||
if (!Station[0]) return [];
|
if (!Station[0]) return [];
|
||||||
return Station.map((d) => d.StationNumber)[0];
|
return Station.map((d) => d.StationNumber)[0];
|
||||||
};
|
};
|
||||||
|
export const getStationName = (stationId, stationList) => {
|
||||||
|
const Stations = stationList.map((a) =>
|
||||||
|
a.filter((d) => d.StationNumber == stationId)
|
||||||
|
);
|
||||||
|
const Station =
|
||||||
|
Stations &&
|
||||||
|
Stations.reduce((newArray, e) => {
|
||||||
|
return newArray.concat(e);
|
||||||
|
}, []);
|
||||||
|
if (!Station[0]) return [];
|
||||||
|
return Station.map((d) => d.StaitonName)[0];
|
||||||
|
};
|
||||||
|
@ -25,9 +25,9 @@ export const lineList = [
|
|||||||
"土讃線(多度津-高知間)[D]",
|
"土讃線(多度津-高知間)[D]",
|
||||||
"土讃線(高知-窪川間)[K]",
|
"土讃線(高知-窪川間)[K]",
|
||||||
"高徳線(高松-徳島間)[T]",
|
"高徳線(高松-徳島間)[T]",
|
||||||
"徳島線(徳島-阿波池田)[B]",
|
"徳島線(徳島-阿波池田間)[B]",
|
||||||
"鳴門線(池谷-鳴門間)[N]",
|
"鳴門線(池谷-鳴門間)[N]",
|
||||||
"瀬戸大橋線(宇多津-児島間)[M]",
|
"瀬戸大橋線(児島-宇多津間)[M]",
|
||||||
];
|
];
|
||||||
export const lineListPair = {
|
export const lineListPair = {
|
||||||
Y: "予讃線(高松-松山間)[Y]",
|
Y: "予讃線(高松-松山間)[Y]",
|
||||||
@ -36,9 +36,9 @@ export const lineListPair = {
|
|||||||
D: "土讃線(多度津-高知間)[D]",
|
D: "土讃線(多度津-高知間)[D]",
|
||||||
K: "土讃線(高知-窪川間)[K]",
|
K: "土讃線(高知-窪川間)[K]",
|
||||||
T: "高徳線(高松-徳島間)[T]",
|
T: "高徳線(高松-徳島間)[T]",
|
||||||
B: "徳島線(徳島-阿波池田)[B]",
|
B: "徳島線(徳島-阿波池田間)[B]",
|
||||||
N: "鳴門線(池谷-鳴門間)[N]",
|
N: "鳴門線(池谷-鳴門間)[N]",
|
||||||
M: "瀬戸大橋線(宇多津-児島間)[M]",
|
M: "瀬戸大橋線(児島-宇多津間)[M]",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getStationList = async (props) => {
|
export const getStationList = async (props) => {
|
||||||
@ -65,9 +65,9 @@ export const getStationList = async (props) => {
|
|||||||
stationList["土讃線(多度津-高知間)[D]"],
|
stationList["土讃線(多度津-高知間)[D]"],
|
||||||
stationList["土讃線(高知-窪川間)[K]"],
|
stationList["土讃線(高知-窪川間)[K]"],
|
||||||
stationList["高徳線(高松-徳島間)[T]"],
|
stationList["高徳線(高松-徳島間)[T]"],
|
||||||
stationList["徳島線(徳島-阿波池田)[B]"],
|
stationList["徳島線(徳島-阿波池田間)[B]"],
|
||||||
stationList["鳴門線(池谷-鳴門間)[N]"],
|
stationList["鳴門線(池谷-鳴門間)[N]"],
|
||||||
stationList["瀬戸大橋線(宇多津-児島間)[M]"],
|
stationList["瀬戸大橋線(児島-宇多津間)[M]"],
|
||||||
stationList.駅間リスト,
|
stationList.駅間リスト,
|
||||||
stationList.日英対応表,
|
stationList.日英対応表,
|
||||||
] = values;
|
] = values;
|
||||||
@ -160,16 +160,16 @@ export const getStationList = async (props) => {
|
|||||||
stationList.日英対応表
|
stationList.日英対応表
|
||||||
);
|
);
|
||||||
const tokushimaCurrent = addStationPosition(
|
const tokushimaCurrent = addStationPosition(
|
||||||
concatBetweenStations(stationList["徳島線(徳島-阿波池田)[B]"]),
|
concatBetweenStations(stationList["徳島線(徳島-阿波池田間)[B]"]),
|
||||||
徳島線,
|
徳島線,
|
||||||
stationList.日英対応表
|
stationList.日英対応表
|
||||||
);
|
);
|
||||||
stationList["徳島線(徳島-阿波池田)[B]"] = [
|
stationList["徳島線(徳島-阿波池田間)[B]"] = [
|
||||||
tokushimaCurrent[tokushimaCurrent.length - 1],
|
tokushimaCurrent[tokushimaCurrent.length - 1],
|
||||||
...tokushimaCurrent,
|
...tokushimaCurrent,
|
||||||
];
|
];
|
||||||
stationList["徳島線(徳島-阿波池田)[B]"].pop();
|
stationList["徳島線(徳島-阿波池田間)[B]"].pop();
|
||||||
stationList["瀬戸大橋線(宇多津-児島間)[M]"] = [
|
stationList["瀬戸大橋線(児島-宇多津間)[M]"] = [
|
||||||
{
|
{
|
||||||
Station_JP: "坂出",
|
Station_JP: "坂出",
|
||||||
Station_EN: "Sakaide",
|
Station_EN: "Sakaide",
|
||||||
|
@ -32,3 +32,15 @@ export const stationIDPair = {
|
|||||||
naruto: "N",
|
naruto: "N",
|
||||||
seto: "M",
|
seto: "M",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const stationNamePair = {
|
||||||
|
"予讃線(高松 - 松山)": "yosan",
|
||||||
|
"予讃線・内子線(松山 - 内子 - 宇和島)": "uwajima",
|
||||||
|
"予讃線・伊予灘線(向井原 - 伊予大洲)": "uwajima2",
|
||||||
|
"土讃線(多度津 - 高知)": "dosan",
|
||||||
|
"土讃線(高知 - 窪川)": "dosan2",
|
||||||
|
"高徳線(高松 - 徳島)": "koutoku",
|
||||||
|
"徳島線(徳島 - 阿波池田)": "tokushima",
|
||||||
|
"鳴門線(池谷 - 鳴門)": "naruto",
|
||||||
|
"瀬戸大橋線(児島 - 宇多津)": "seto",
|
||||||
|
};
|
||||||
|
@ -696,7 +696,11 @@ const setStrings = () =>{
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const textInsert = new MutationObserver( (mutations) => setStrings());
|
const textInsert = new MutationObserver( (mutations) =>{
|
||||||
|
setStrings();
|
||||||
|
const currentLines = document.querySelector('#topHeader div').innerText;
|
||||||
|
window.ReactNativeWebView.postMessage(JSON.stringify({type:"currentLines",currentLines}));
|
||||||
|
});
|
||||||
|
|
||||||
// 監視を開始
|
// 監視を開始
|
||||||
textInsert.observe(document.getElementById('disp'), {
|
textInsert.observe(document.getElementById('disp'), {
|
||||||
|
3
menu.js
3
menu.js
@ -52,7 +52,7 @@ export default function Menu({ getCurrentTrain }) {
|
|||||||
const makeCurrentStation = (location) => {
|
const makeCurrentStation = (location) => {
|
||||||
if (!originalStationList) return () => {};
|
if (!originalStationList) return () => {};
|
||||||
const findStationEachLine = (selectLine) => {
|
const findStationEachLine = (selectLine) => {
|
||||||
const searchArea = 0.0015;
|
const searchArea = 0.002;
|
||||||
const _calcDistance = (from, to) => {
|
const _calcDistance = (from, to) => {
|
||||||
let lat = Math.abs(from.lat - to.lat);
|
let lat = Math.abs(from.lat - to.lat);
|
||||||
let lng = Math.abs(from.lng - to.lng);
|
let lng = Math.abs(from.lng - to.lng);
|
||||||
@ -172,6 +172,7 @@ export default function Menu({ getCurrentTrain }) {
|
|||||||
<Sign
|
<Sign
|
||||||
currentStation={item}
|
currentStation={item}
|
||||||
originalStationList={originalStationList}
|
originalStationList={originalStationList}
|
||||||
|
isCurrentStation={item == currentStation}
|
||||||
oP={() => {
|
oP={() => {
|
||||||
const payload = {
|
const payload = {
|
||||||
currentStation:
|
currentStation:
|
||||||
|
@ -31,14 +31,23 @@ export const CurrentTrainProvider = ({ children }) => {
|
|||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((d) => d.data)
|
.then((d) => d.data)
|
||||||
.then((d) =>
|
.then((d) =>
|
||||||
d.map((x) => ({ num: x.TrainNum, delay: x.delay, Pos: x.Pos }))
|
d.map((x) => ({
|
||||||
|
Index: x.Index,
|
||||||
|
num: x.TrainNum,
|
||||||
|
delay: x.delay,
|
||||||
|
Pos: x.Pos,
|
||||||
|
PosNum: x.PosNum,
|
||||||
|
Direction: x.Direction,
|
||||||
|
Type: x.Type,
|
||||||
|
Line: x.Line,
|
||||||
|
}))
|
||||||
)
|
)
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
setCurrentTrain(d);
|
setCurrentTrain(d);
|
||||||
setCurrentTrainLoading("success");
|
setCurrentTrainLoading("success");
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
alert("現在の全在線列車取得エラー/再取得します");
|
//alert("現在の全在線列車取得エラー/再取得します");
|
||||||
fetch(
|
fetch(
|
||||||
"https://script.google.com/macros/s/AKfycby9Y2-Bm75J_WkbZimi7iS8v5r9wMa9wtzpdwES9sOGF4i6HIYEJOM60W6gM1gXzt1o/exec",
|
"https://script.google.com/macros/s/AKfycby9Y2-Bm75J_WkbZimi7iS8v5r9wMa9wtzpdwES9sOGF4i6HIYEJOM60W6gM1gXzt1o/exec",
|
||||||
HeaderConfig
|
HeaderConfig
|
||||||
@ -57,6 +66,9 @@ export const CurrentTrainProvider = ({ children }) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
const inject = (i) => {
|
||||||
|
webview.current?.injectJavaScript(i);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(getCurrentTrain, []); //初回だけ現在の全在線列車取得
|
useEffect(getCurrentTrain, []); //初回だけ現在の全在線列車取得
|
||||||
|
|
||||||
@ -72,6 +84,7 @@ export const CurrentTrainProvider = ({ children }) => {
|
|||||||
currentTrainLoading,
|
currentTrainLoading,
|
||||||
setCurrentTrainLoading,
|
setCurrentTrainLoading,
|
||||||
getCurrentTrain,
|
getCurrentTrain,
|
||||||
|
inject,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
36
stateBox/useTrainMenu.js
Normal file
36
stateBox/useTrainMenu.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import React, { createContext, useContext, useState } from "react";
|
||||||
|
const initialState = {
|
||||||
|
selectedLine: undefined,
|
||||||
|
setSelectedLine: () => {},
|
||||||
|
mapsStationData: undefined,
|
||||||
|
setMapsStationData: () => {},
|
||||||
|
injectJavaScript: "",
|
||||||
|
setInjectJavaScript: () => {},
|
||||||
|
};
|
||||||
|
|
||||||
|
const TrainMenuContext = createContext(initialState);
|
||||||
|
|
||||||
|
export const useTrainMenu = () => {
|
||||||
|
return useContext(TrainMenuContext);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const TrainMenuProvider = ({ children }) => {
|
||||||
|
const [selectedLine, setSelectedLine] = useState(undefined);
|
||||||
|
const [mapsStationData, setMapsStationData] = useState(undefined);
|
||||||
|
const [injectJavaScript, setInjectJavaScript] = useState();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TrainMenuContext.Provider
|
||||||
|
value={{
|
||||||
|
selectedLine,
|
||||||
|
setSelectedLine,
|
||||||
|
mapsStationData,
|
||||||
|
setMapsStationData,
|
||||||
|
injectJavaScript,
|
||||||
|
setInjectJavaScript,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</TrainMenuContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user