LEDの枠に位置情報ジャンプボタンを追加
This commit is contained in:
parent
19db27a378
commit
67d2bf6c98
@ -8,11 +8,13 @@ import { useNavigation } from "@react-navigation/native";
|
|||||||
import { useTrainMenu } from "../stateBox/useTrainMenu";
|
import { useTrainMenu } from "../stateBox/useTrainMenu";
|
||||||
import { FavoriteListItem } from "./atom/FavoriteListItem";
|
import { FavoriteListItem } from "./atom/FavoriteListItem";
|
||||||
import { BigButton } from "./atom/BigButton";
|
import { BigButton } from "./atom/BigButton";
|
||||||
|
import { useStationList } from "@/stateBox/useStationList";
|
||||||
export const FavoriteList: FC = () => {
|
export const FavoriteList: FC = () => {
|
||||||
const { favoriteStation } = useFavoriteStation();
|
const { favoriteStation } = useFavoriteStation();
|
||||||
const { webview } = useCurrentTrain();
|
const { webview } = useCurrentTrain();
|
||||||
const { navigate, addListener, goBack, canGoBack } = useNavigation();
|
const { navigate, addListener, goBack, canGoBack } = useNavigation();
|
||||||
const { mapsStationData: stationData } = useTrainMenu();
|
const { mapsStationData: stationData } = useTrainMenu();
|
||||||
|
const { getInjectJavascriptAddress } = useStationList();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unsubscribe = addListener("tabPress", goToTrainMenu);
|
const unsubscribe = addListener("tabPress", goToTrainMenu);
|
||||||
@ -38,27 +40,16 @@ export const FavoriteList: FC = () => {
|
|||||||
</Text>
|
</Text>
|
||||||
<ScrollView style={{ height: "100%", backgroundColor: "white" }}>
|
<ScrollView style={{ height: "100%", backgroundColor: "white" }}>
|
||||||
{favoriteStation
|
{favoriteStation
|
||||||
.filter((d) => d[0].StationMap)
|
|
||||||
.map((currentStation) => {
|
.map((currentStation) => {
|
||||||
return (
|
return (
|
||||||
<FavoriteListItem
|
<FavoriteListItem
|
||||||
currentStation={currentStation}
|
currentStation={currentStation}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
const getStationLine = (now) => {
|
const scriptString = getInjectJavascriptAddress(
|
||||||
const returnData = Object.keys(stationData).filter((d) => {
|
currentStation[0].StationNumber
|
||||||
const cache = stationData[d].findIndex(
|
|
||||||
(data) => data.Station_JP == now.Station_JP
|
|
||||||
);
|
|
||||||
return cache != -1;
|
|
||||||
});
|
|
||||||
return returnData[0];
|
|
||||||
};
|
|
||||||
const lineName = getStationLine(currentStation[0]);
|
|
||||||
|
|
||||||
webview.current?.injectJavaScript(
|
|
||||||
`MoveDisplayStation('${lineName}_${currentStation[0].MyStation}_${currentStation[0].Station_JP}');
|
|
||||||
document.getElementById("disp").insertAdjacentHTML("afterbegin", "<div />");`
|
|
||||||
);
|
);
|
||||||
|
if (!scriptString) return;
|
||||||
|
webview.current?.injectJavaScript(scriptString);
|
||||||
goBack();
|
goBack();
|
||||||
if (canGoBack()) goBack();
|
if (canGoBack()) goBack();
|
||||||
}}
|
}}
|
||||||
|
@ -1,48 +1,74 @@
|
|||||||
import { View, Text } from "react-native";
|
import { View, Text } from "react-native";
|
||||||
import { useCurrentTrain } from "../../../stateBox/useCurrentTrain";
|
import { useCurrentTrain } from "../../../stateBox/useCurrentTrain";
|
||||||
import LottieView from "lottie-react-native";
|
import LottieView from "lottie-react-native";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons, AntDesign } from "@expo/vector-icons";
|
||||||
|
import { useStationList } from "@/stateBox/useStationList";
|
||||||
|
import { useNavigation } from "@react-navigation/native";
|
||||||
|
|
||||||
export const Header = () => {
|
export const Header = ({ station }) => {
|
||||||
const { currentTrainLoading, setCurrentTrainLoading,getCurrentTrain } = useCurrentTrain();
|
const {
|
||||||
return (
|
currentTrainLoading,
|
||||||
<View
|
setCurrentTrainLoading,
|
||||||
style={{
|
getCurrentTrain,
|
||||||
alignContent: "center",
|
inject,
|
||||||
alignItems: "center",
|
} = useCurrentTrain();
|
||||||
width: "100%",
|
const { getInjectJavascriptAddress } = useStationList();
|
||||||
marginVertical: 10,
|
const { navigate } = useNavigation();
|
||||||
flexDirection: "row",
|
return (
|
||||||
}}
|
<View
|
||||||
>
|
style={{
|
||||||
<View style={{ flex: 1 }}></View>
|
alignContent: "center",
|
||||||
<View style={{}}>
|
alignItems: "center",
|
||||||
<Text style={{ fontSize: 25, color: "white", fontWeight: "bold" }}>
|
width: "100%",
|
||||||
次の列車
|
marginVertical: 10,
|
||||||
</Text>
|
flexDirection: "row",
|
||||||
<Text style={{ fontSize: 15, color: "white" }}>Next Train</Text>
|
}}
|
||||||
</View>
|
>
|
||||||
<View style={{ flex: 1, flexDirection: "row-reverse" }}>
|
<View style={{ flex: 1, flexDirection: "column", alignItems: "center" }}>
|
||||||
{currentTrainLoading == "loading" ? (
|
<AntDesign
|
||||||
<LottieView
|
name={"barchart"}
|
||||||
autoPlay
|
size={20}
|
||||||
loop
|
color={"white"}
|
||||||
style={{ width: 40, height: 40, marginRight: 30 }}
|
style={{
|
||||||
source={require("../../../assets/51690-loading-diamonds.json")}
|
borderWidth: 1,
|
||||||
/>
|
borderColor: "white",
|
||||||
) : currentTrainLoading == "error" ? (
|
padding: 10,
|
||||||
<Ionicons
|
borderRadius: 10,
|
||||||
name="reload"
|
}}
|
||||||
color="white"
|
onPress={() => {
|
||||||
size={30}
|
navigate("positions", { screen: "Apps" });
|
||||||
style={{ marginRight: 30 }}
|
const script = getInjectJavascriptAddress(station.StationNumber);
|
||||||
onPress={() => {
|
inject(script);
|
||||||
setCurrentTrainLoading("loading");
|
}}
|
||||||
getCurrentTrain();
|
/>
|
||||||
}}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
<View style={{}}>
|
||||||
};
|
<Text style={{ fontSize: 25, color: "white", fontWeight: "bold" }}>
|
||||||
|
次の列車
|
||||||
|
</Text>
|
||||||
|
<Text style={{ fontSize: 15, color: "white" }}>Next Train</Text>
|
||||||
|
</View>
|
||||||
|
<View style={{ flex: 1, flexDirection: "row-reverse" }}>
|
||||||
|
{currentTrainLoading == "loading" ? (
|
||||||
|
<LottieView
|
||||||
|
autoPlay
|
||||||
|
loop
|
||||||
|
style={{ width: 40, height: 40, marginRight: 30 }}
|
||||||
|
source={require("../../../assets/51690-loading-diamonds.json")}
|
||||||
|
/>
|
||||||
|
) : currentTrainLoading == "error" ? (
|
||||||
|
<Ionicons
|
||||||
|
name="reload"
|
||||||
|
color="white"
|
||||||
|
size={30}
|
||||||
|
style={{ marginRight: 30 }}
|
||||||
|
onPress={() => {
|
||||||
|
setCurrentTrainLoading("loading");
|
||||||
|
getCurrentTrain();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
@ -222,7 +222,7 @@ export default function LED_vision(props) {
|
|||||||
marginHorizontal: width * 0.01,
|
marginHorizontal: width * 0.01,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Header />
|
<Header station={station[0]} />
|
||||||
{selectedTrain.map((d) => (
|
{selectedTrain.map((d) => (
|
||||||
<EachData
|
<EachData
|
||||||
{...{
|
{...{
|
||||||
|
@ -15,6 +15,7 @@ const initialState = {
|
|||||||
currentTrainLoading: "loading",
|
currentTrainLoading: "loading",
|
||||||
setCurrentTrainLoading: () => {},
|
setCurrentTrainLoading: () => {},
|
||||||
getCurrentTrain: () => {},
|
getCurrentTrain: () => {},
|
||||||
|
inject: () => {},
|
||||||
};
|
};
|
||||||
|
|
||||||
const CurrentTrainContext = createContext(initialState);
|
const CurrentTrainContext = createContext(initialState);
|
||||||
|
Loading…
Reference in New Issue
Block a user