From fdacc00f93f95f4d07c119585cde2a8cf7b26e45 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Fri, 11 Apr 2025 11:18:51 +0000 Subject: [PATCH 01/36] =?UTF-8?q?menu=E3=81=AB=E6=96=B0=E3=81=97=E3=81=84?= =?UTF-8?q?=E6=A6=82=E5=BF=B5=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu.js | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/menu.js b/menu.js index 42a8592..644953e 100644 --- a/menu.js +++ b/menu.js @@ -8,7 +8,7 @@ import { Text, TouchableOpacity, LayoutAnimation, - Dimensions, + useWindowDimensions, } from "react-native"; import Constants from "expo-constants"; import * as Location from "expo-location"; @@ -42,6 +42,16 @@ export default function Menu({ getCurrentTrain }) { const { navigate } = useNavigation(); const { favoriteStation } = useFavoriteStation(); const { originalStationList } = useStationList(); + const { height, width } = useWindowDimensions(); + const scrollRef = useRef(null); + useEffect(() => { + if (scrollRef.current) { + scrollRef.current.scrollTo({ + y: (height / 100) * 60 - (((width / 100) * 80) / 20) * 9 + 30, + animated: false, + }); + } + }, []); //位置情報 const [locationStatus, setLocationStatus] = useState(null); @@ -131,7 +141,7 @@ export default function Menu({ getCurrentTrain }) { }, [selectedCurrentStation]); //全列車ダイヤリストを作成するuseEffect - const { allTrainDiagram:trainDiagram} = useAllTrainDiagram(); + const { allTrainDiagram: trainDiagram } = useAllTrainDiagram(); const oPSign = () => { const payload = { @@ -165,7 +175,6 @@ export default function Menu({ getCurrentTrain }) { ); setDotButton(!dotButton); }; - const width = Dimensions.get("window").width; return ( - + + + <> {originalStationList.length != 0 && allStationData.length != 0 && ( Date: Fri, 11 Apr 2025 13:52:48 +0000 Subject: [PATCH 02/36] =?UTF-8?q?=E5=9C=B0=E5=9B=B3=E3=81=AE=E6=A9=9F?= =?UTF-8?q?=E8=83=BD=E3=81=8C=E4=B8=80=E9=80=9A=E3=82=8A=E5=8B=95=E3=81=8F?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu.js | 74 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 15 deletions(-) diff --git a/menu.js b/menu.js index 644953e..6f712b2 100644 --- a/menu.js +++ b/menu.js @@ -37,6 +37,7 @@ import lineColorList from "./assets/originData/lineColorList"; import { AS } from "./storageControl"; import { SimpleDot } from "./components/Menu/SimpleDot"; import { useAllTrainDiagram } from "./stateBox/useAllTrainDiagram"; +import MapView from "react-native-maps"; export default function Menu({ getCurrentTrain }) { const { navigate } = useNavigation(); @@ -44,13 +45,28 @@ export default function Menu({ getCurrentTrain }) { const { originalStationList } = useStationList(); const { height, width } = useWindowDimensions(); const scrollRef = useRef(null); + const [mapsOpacity, setMapsOpacity] = useState(1); + const mapsSizeOffset = + (height / 100) * 60 - (((width / 100) * 80) / 20) * 9 + 60 - (Platform.OS == "ios" ? Constants.statusBarHeight : 0); useEffect(() => { - if (scrollRef.current) { - scrollRef.current.scrollTo({ - y: (height / 100) * 60 - (((width / 100) * 80) / 20) * 9 + 30, - animated: false, - }); - } + setTimeout(() => { + if (scrollRef.current) { + scrollRef.current.scrollTo({ + y: mapsSizeOffset, + animated: false, + }); + } + }, 10); + }, []); + useEffect(() => { + setTimeout(() => { + if (scrollRef.current) { + scrollRef.current.scrollTo({ + y: mapsSizeOffset, + animated: false, + }); + } + }, 10); }, []); //位置情報 @@ -186,21 +202,49 @@ export default function Menu({ getCurrentTrain }) { { + console.log(Object.keys(scrollRef.current)); + const scrollY = d.nativeEvent.contentOffset.y; + if (scrollY < mapsSizeOffset) { + setMapsOpacity(scrollY / mapsSizeOffset); + } + }} + snapToOffsets={[mapsSizeOffset]} > + + { + alert("地図をタップ"); + }} + > + - + <> {originalStationList.length != 0 && allStationData.length != 0 && ( From 190be0fa676afdb2b811edecab46bd75e5217db0 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Fri, 11 Apr 2025 14:12:10 +0000 Subject: [PATCH 03/36] =?UTF-8?q?=E5=9C=B0=E5=9B=B3=E3=81=8C=E7=A7=BB?= =?UTF-8?q?=E5=8B=95=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu.js | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/menu.js b/menu.js index 6f712b2..76bb345 100644 --- a/menu.js +++ b/menu.js @@ -12,6 +12,10 @@ import { } from "react-native"; import Constants from "expo-constants"; import * as Location from "expo-location"; +import { + configureReanimatedLogger, + ReanimatedLogLevel, +} from 'react-native-reanimated'; import StatusbarDetect from "./StatusbarDetect"; import { widthPercentageToDP as wp } from "react-native-responsive-screen"; import { Ionicons } from "@expo/vector-icons"; @@ -38,7 +42,10 @@ import { AS } from "./storageControl"; import { SimpleDot } from "./components/Menu/SimpleDot"; import { useAllTrainDiagram } from "./stateBox/useAllTrainDiagram"; import MapView from "react-native-maps"; - +configureReanimatedLogger({ + level: ReanimatedLogLevel.error, // Set the log level to error + strict: true, // Reanimated runs in strict mode by default +}); export default function Menu({ getCurrentTrain }) { const { navigate } = useNavigation(); const { favoriteStation } = useFavoriteStation(); @@ -46,8 +53,12 @@ export default function Menu({ getCurrentTrain }) { const { height, width } = useWindowDimensions(); const scrollRef = useRef(null); const [mapsOpacity, setMapsOpacity] = useState(1); + const mapsRef = useRef(null); const mapsSizeOffset = - (height / 100) * 60 - (((width / 100) * 80) / 20) * 9 + 60 - (Platform.OS == "ios" ? Constants.statusBarHeight : 0); + (height / 100) * 60 - + (((width / 100) * 80) / 20) * 9 + + 60 - + (Platform.OS == "ios" ? Constants.statusBarHeight : 0); useEffect(() => { setTimeout(() => { if (scrollRef.current) { @@ -58,17 +69,6 @@ export default function Menu({ getCurrentTrain }) { } }, 10); }, []); - useEffect(() => { - setTimeout(() => { - if (scrollRef.current) { - scrollRef.current.scrollTo({ - y: mapsSizeOffset, - animated: false, - }); - } - }, 10); - }, []); - //位置情報 const [locationStatus, setLocationStatus] = useState(null); useEffect(() => { @@ -175,6 +175,25 @@ export default function Menu({ getCurrentTrain }) { const [dotButton, setDotButton] = useState(false); + useEffect(() => { + console.log(selectedCurrentStation); + if(allStationData.length == 0) return; + const currentStationData = + originalStationList && + allStationData[selectedCurrentStation] && + allStationData[selectedCurrentStation][0]; + console.log(currentStationData); + const {lat, lng} = currentStationData; + const mapRegion = { + latitude: lat, + longitude: lng, + latitudeDelta: 0.05, + longitudeDelta: 0.05, + }; + mapsRef.current.animateToRegion(mapRegion, 1000); + + }, [selectedCurrentStation, currentStation, allStationData,mapsRef]); + useEffect(() => { AS.getItem("CarouselSettings/activeDotSettings").then((data) => { setDotButton(data === "true"); @@ -218,6 +237,7 @@ export default function Menu({ getCurrentTrain }) { > Date: Fri, 11 Apr 2025 15:35:25 +0000 Subject: [PATCH 04/36] =?UTF-8?q?=E7=8F=BE=E5=9C=A8=E5=9C=B0=E3=83=99?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E3=81=AE=E3=83=9C=E3=82=BF=E3=83=B3=E3=81=A8?= =?UTF-8?q?=E3=81=8B=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/atom/UsefulBox.js | 3 +- components/発車時刻表/LED_vidion.js | 55 ++++---- menu.js | 161 ++++++++++++++++++----- 3 files changed, 153 insertions(+), 66 deletions(-) diff --git a/components/atom/UsefulBox.js b/components/atom/UsefulBox.js index afab4cd..d6adf3c 100644 --- a/components/atom/UsefulBox.js +++ b/components/atom/UsefulBox.js @@ -1,7 +1,7 @@ import { TouchableOpacity, Text } from "react-native"; import { MaterialCommunityIcons } from "@expo/vector-icons"; export const UsefulBox = (props) => { - const { icon, backgroundColor, flex, onPressButton, children } = props; + const { icon, backgroundColor, flex, onPressButton, children, disable = false } = props; return ( { alignItems: "center", margin: 2, }} + disabled={disable} onPress={onPressButton} > diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index 6eefb49..3b4e86f 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -10,8 +10,7 @@ import { Footer } from "./LED_Vision_Component/Footer"; import { Header } from "./LED_Vision_Component/Header"; import { Description } from "./LED_inside_Component/Description"; import { EachData } from "./EachData"; - - +import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram"; /** * @@ -43,13 +42,8 @@ import { EachData } from "./EachData"; * 9062D 四国まんなか千年ものがたり(臨時?) */ export default function LED_vision(props) { - const { - station, - trainDiagram, - getCurrentTrain, - navigate, - openStationACFromEachTrainInfo, - } = props; + const { station, getCurrentTrain, navigate, openStationACFromEachTrainInfo } = + props; const { currentTrain } = useCurrentTrain(); const [stationDiagram, setStationDiagram] = useState({}); //当該駅の全時刻表 const [finalSwitch, setFinalSwitch] = useState(false); @@ -57,6 +51,7 @@ export default function LED_vision(props) { const [trainDescriptionSwitch, setTrainDescriptionSwitch] = useState(false); const [isInfoArea, setIsInfoArea] = useState(false); const { areaInfo, areaStationID } = useAreaInfo(); + const { allTrainDiagram: trainDiagram } = useAllTrainDiagram(); useEffect(() => { AS.getItem("LEDSettings/trainIDSwitch").then((data) => { @@ -107,27 +102,29 @@ export default function LED_vision(props) { }, [trainTimeAndNumber, currentTrain, finalSwitch]); const getTime = (stationDiagram, station) => { - const returnData = Object.keys(stationDiagram).map((trainNum) => { - let trainData = {}; - stationDiagram[trainNum].split("#").forEach((data) => { - if (data.match("着")) { - trainData.lastStation = data.split(",着,")[0]; - } - if (data.split(",")[0] === station.Station_JP) { - if (data.match(",発,")) { - trainData.time = data.split(",発,")[1]; - } else if(data.match(",着,")){ - trainData.time = data.split(",着,")[1]; - trainData.lastStation = "当駅止"; + const returnData = Object.keys(stationDiagram) + .map((trainNum) => { + let trainData = {}; + stationDiagram[trainNum].split("#").forEach((data) => { + if (data.match("着")) { + trainData.lastStation = data.split(",着,")[0]; } - } - }); - return { - train: trainNum, - time: trainData.time, - lastStation: trainData.lastStation, - }; - }).filter((d) => d.time); + if (data.split(",")[0] === station.Station_JP) { + if (data.match(",発,")) { + trainData.time = data.split(",発,")[1]; + } else if (data.match(",着,")) { + trainData.time = data.split(",着,")[1]; + trainData.lastStation = "当駅止"; + } + } + }); + return { + train: trainNum, + time: trainData.time, + lastStation: trainData.lastStation, + }; + }) + .filter((d) => d.time); return returnData.sort((a, b) => { switch (true) { case parseInt(a.time.split(":")[0]) < parseInt(b.time.split(":")[0]): diff --git a/menu.js b/menu.js index 76bb345..54f71e7 100644 --- a/menu.js +++ b/menu.js @@ -15,12 +15,10 @@ import * as Location from "expo-location"; import { configureReanimatedLogger, ReanimatedLogLevel, -} from 'react-native-reanimated'; +} from "react-native-reanimated"; import StatusbarDetect from "./StatusbarDetect"; -import { widthPercentageToDP as wp } from "react-native-responsive-screen"; import { Ionicons } from "@expo/vector-icons"; import LottieView from "lottie-react-native"; -import { parseAllTrainDiagram } from "./lib/parseAllTrainDiagram"; import LED_vision from "./components/発車時刻表/LED_vidion"; import Sign from "./components/駅名表/Sign"; @@ -52,7 +50,7 @@ export default function Menu({ getCurrentTrain }) { const { originalStationList } = useStationList(); const { height, width } = useWindowDimensions(); const scrollRef = useRef(null); - const [mapsOpacity, setMapsOpacity] = useState(1); + const [mapsOpacity, setMapsOpacity] = useState(false); const mapsRef = useRef(null); const mapsSizeOffset = (height / 100) * 60 - @@ -81,13 +79,17 @@ export default function Menu({ getCurrentTrain }) { ); }); }, []); - + const [position, setPosition] = useState(undefined); const getCurrentPosition = () => { if (!locationStatus) return () => {}; - Location.getCurrentPositionAsync({}).then((location) => - makeCurrentStation(location) - ); + Location.getCurrentPositionAsync({}).then((location) => { + setPosition(location); + }); }; + useEffect(() => { + if (!position) return () => {}; + makeCurrentStation(position); + }, [position]); const makeCurrentStation = (location) => { if (!originalStationList) return () => {}; const findStationEachLine = (selectLine) => { @@ -157,8 +159,6 @@ export default function Menu({ getCurrentTrain }) { }, [selectedCurrentStation]); //全列車ダイヤリストを作成するuseEffect - const { allTrainDiagram: trainDiagram } = useAllTrainDiagram(); - const oPSign = () => { const payload = { currentStation: @@ -177,22 +177,20 @@ export default function Menu({ getCurrentTrain }) { useEffect(() => { console.log(selectedCurrentStation); - if(allStationData.length == 0) return; - const currentStationData = + if (allStationData.length == 0) return; + if (allStationData[selectedCurrentStation] == undefined) return; + const { lat, lng } = originalStationList && allStationData[selectedCurrentStation] && allStationData[selectedCurrentStation][0]; - console.log(currentStationData); - const {lat, lng} = currentStationData; - const mapRegion = { - latitude: lat, - longitude: lng, - latitudeDelta: 0.05, - longitudeDelta: 0.05, - }; - mapsRef.current.animateToRegion(mapRegion, 1000); - - }, [selectedCurrentStation, currentStation, allStationData,mapsRef]); + const mapRegion = { + latitude: lat, + longitude: lng, + latitudeDelta: 0.05, + longitudeDelta: 0.05, + }; + mapsRef.current.animateToRegion(mapRegion, 1000); + }, [selectedCurrentStation, currentStation, allStationData, mapsRef]); useEffect(() => { AS.getItem("CarouselSettings/activeDotSettings").then((data) => { @@ -228,10 +226,8 @@ export default function Menu({ getCurrentTrain }) { decelerationRate={"normal"} onScroll={(d) => { console.log(Object.keys(scrollRef.current)); - const scrollY = d.nativeEvent.contentOffset.y; - if (scrollY < mapsSizeOffset) { - setMapsOpacity(scrollY / mapsSizeOffset); - } + const scrollY = d.nativeEvent.contentOffset.y + 100; + setMapsOpacity(scrollY < mapsSizeOffset); }} snapToOffsets={[mapsSizeOffset]} > @@ -244,7 +240,7 @@ export default function Menu({ getCurrentTrain }) { position: "absolute", height: (height / 100) * 60 + (((width / 100) * 80) / 20) * 9 + 60, - opacity: 1 - mapsOpacity, + opacity: mapsOpacity ? 1 : 0, }} showsUserLocation={true} loadingEnabled={true} @@ -263,8 +259,103 @@ export default function Menu({ getCurrentTrain }) { }} > - - + + + + { + if(!position) return; + const { latitude, longitude } = position.coords; + mapsRef.current.animateToRegion( + { + latitude, + longitude, + latitudeDelta: 0.05, + longitudeDelta: 0.05, + }, + 1000 + ); + }} + > + + + 現在地基準 + + + { + // お気に入りリスト更新 + }} + > + + + お気に入りリスト + + + + + <> {originalStationList.length != 0 && allStationData.length != 0 && ( @@ -346,10 +437,7 @@ export default function Menu({ getCurrentTrain }) { originalStationList.length != 0 && allStationData[selectedCurrentStation] && ( {}} @@ -362,7 +450,7 @@ export default function Menu({ getCurrentTrain }) { ); } -const TopMenuButton = () => { +const TopMenuButton = ({ show }) => { const buttonList = [ { backgroundColor: "#F89038", @@ -388,12 +476,13 @@ const TopMenuButton = () => { }, ]; return ( - + {buttonList.map((d, index) => ( From 44f8be994e1e45a752d1edc27c44185d20e1264b Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 13 Apr 2025 10:32:30 +0000 Subject: [PATCH 05/36] =?UTF-8?q?=E5=8D=98=E7=99=BA=E3=81=AE=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Menu/JRSTraInfoBox.tsx | 111 ++++++++++++++++++++++++++++++ components/Menu/TitleBar.js | 25 ++++--- components/Menu/TopMenuButton.tsx | 52 ++++++++++++++ components/atom/UsefulBox.js | 23 ------- stateBox/useTrainDelayData.js | 2 +- 5 files changed, 180 insertions(+), 33 deletions(-) create mode 100644 components/Menu/JRSTraInfoBox.tsx create mode 100644 components/Menu/TopMenuButton.tsx delete mode 100644 components/atom/UsefulBox.js diff --git a/components/Menu/JRSTraInfoBox.tsx b/components/Menu/JRSTraInfoBox.tsx new file mode 100644 index 0000000..b740f31 --- /dev/null +++ b/components/Menu/JRSTraInfoBox.tsx @@ -0,0 +1,111 @@ +import React from "react"; +import { + View, + Text, + TouchableOpacity, + ScrollView, + StyleProp, + ViewStyle, +} from "react-native"; +import { Ionicons } from "@expo/vector-icons"; +import { SheetManager } from "react-native-actions-sheet"; +import LottieView from "lottie-react-native"; +import { useTrainDelayData } from "@/stateBox/useTrainDelayData"; +import dayjs from "dayjs"; +export const JRSTraInfoBox = () => { + const { getTime, delayData, loadingDelayData, setLoadingDelayData } = + useTrainDelayData(); + const styles: { [key: string]: StyleProp } = { + touch: { + backgroundColor: "#0099CC", + borderRadius: 5, + margin: 10, + borderColor: "black", + borderWidth: 2, + overflow: "hidden", + }, + scroll: { + backgroundColor: "#0099CC", + borderRadius: 5, + maxHeight: 300, + }, + bottom: { + position: "absolute", + top: 250, + alignItems: "center", + width: "100%", + height: 50, + backgroundColor: "#007FCC88", + }, + box: { + padding: 10, + backgroundColor: "white", + borderBottomLeftRadius: 5, + borderBottomRightRadius: 5, + }, + }; + return ( + SheetManager.show("JRSTraInfo")} + style={styles.touch} + > + + + + 列車遅延速報EX + + + + {getTime ? dayjs(getTime).format("HH:mm") : NaN} + + setLoadingDelayData(true)} + /> + + + {loadingDelayData ? ( + + + + ) : delayData ? ( + delayData.map((d, index, array) => { + let data = d.split(" "); + return ( + + + {data[0].replace("\n", "")} + + {data[1]} + {data[3]} + + ); + }) + ) : ( + 現在、5分以上の遅れはありません。 + )} + + + + + + 詳細を見る + + + + + ); +}; diff --git a/components/Menu/TitleBar.js b/components/Menu/TitleBar.js index e8672a6..ad05cb5 100644 --- a/components/Menu/TitleBar.js +++ b/components/Menu/TitleBar.js @@ -1,18 +1,25 @@ -import { View, TouchableOpacity, Linking } from "react-native"; -import AutoHeightImage from "react-native-auto-height-image"; -import { widthPercentageToDP as wp } from "react-native-responsive-screen"; +import { View, TouchableOpacity, Linking,Platform, Image, useWindowDimensions } from "react-native"; +import Constants from "expo-constants"; + export const TitleBar = () => { + const { width } = useWindowDimensions(); return ( - + Linking.openURL("https://www.jr-shikoku.co.jp")} > - + ); diff --git a/components/Menu/TopMenuButton.tsx b/components/Menu/TopMenuButton.tsx new file mode 100644 index 0000000..d4950db --- /dev/null +++ b/components/Menu/TopMenuButton.tsx @@ -0,0 +1,52 @@ +import React from "react"; +import { Linking, View } from "react-native"; +import { UsefulBox } from "@/components/TrainMenu/UsefulBox"; +import MaterialCommunityIcons from "@expo/vector-icons/build/MaterialCommunityIcons"; +export const TopMenuButton = () => { + const buttonList:{ + backgroundColor: string; + icon: keyof typeof MaterialCommunityIcons.glyphMap; + onPress: () => void; + title: string; + }[] = [ + { + backgroundColor: "#F89038", + icon: "train-car", + onPress: () => + Linking.openURL("https://www.jr-shikoku.co.jp/01_trainbus/sp/"), + title: "駅・鉄道情報", + }, + { + backgroundColor: "#EA4752", + icon: "google-spreadsheet", + onPress: () => + Linking.openURL( + "https://www.jr-shikoku.co.jp/01_trainbus/jikoku/sp/#mainprice-box" + ), + title: "運賃表", + }, + { + backgroundColor: "#91C31F", + icon: "clipboard-list-outline", + onPress: () => Linking.openURL("https://www.jr-shikoku.co.jp/e5489/"), + title: "予約", + }, + ]; + + + return ( + + {buttonList.map((d, index) => ( + + {d.title} + + ))} + + ); +}; \ No newline at end of file diff --git a/components/atom/UsefulBox.js b/components/atom/UsefulBox.js deleted file mode 100644 index d6adf3c..0000000 --- a/components/atom/UsefulBox.js +++ /dev/null @@ -1,23 +0,0 @@ -import { TouchableOpacity, Text } from "react-native"; -import { MaterialCommunityIcons } from "@expo/vector-icons"; -export const UsefulBox = (props) => { - const { icon, backgroundColor, flex, onPressButton, children, disable = false } = props; - return ( - - - - {children} - - - ); -}; diff --git a/stateBox/useTrainDelayData.js b/stateBox/useTrainDelayData.js index ead6cb3..7c90660 100644 --- a/stateBox/useTrainDelayData.js +++ b/stateBox/useTrainDelayData.js @@ -3,7 +3,7 @@ const initialState = { getTime: new Date(), setGetTime: () => {}, loadingDelayData: true, - setLoadingDelayData: () => {}, + setLoadingDelayData: (loading) => {}, delayData: undefined, setDelayData: () => {}, }; From 934938287d11416cdb4cc09eb64b26d51244ce13 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 13 Apr 2025 10:35:08 +0000 Subject: [PATCH 06/36] =?UTF-8?q?=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=81=AE=E5=9C=B0=E5=9B=B3=E6=A9=9F=E8=83=BD=E3=81=AE=E4=BB=AE?= =?UTF-8?q?=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MenuPage.js | 26 ++- menu.js | 548 ++++++++++++++++++---------------------------------- 2 files changed, 208 insertions(+), 366 deletions(-) diff --git a/MenuPage.js b/MenuPage.js index dc198b5..8c11bda 100644 --- a/MenuPage.js +++ b/MenuPage.js @@ -1,5 +1,10 @@ -import React, { useEffect } from "react"; +import React, { useEffect, useRef } from "react"; import { createStackNavigator } from "@react-navigation/stack"; +import { useWindowDimensions, Platform } from "react-native"; +import Constants from "expo-constants"; + +import { Dimensions, StatusBar } from "react-native"; + import { SheetManager } from "react-native-actions-sheet"; import { AS } from "./storageControl"; import TrainBase from "./components/trainbaseview"; @@ -13,10 +18,13 @@ import AllTrainDiagramView from "./components/AllTrainDiagramView"; import { useCurrentTrain } from "./stateBox/useCurrentTrain"; import { useNavigation } from "@react-navigation/native"; import { news } from "./config/newsUpdate"; +import { useBottomTabBarHeight } from "@react-navigation/bottom-tabs"; const Stack = createStackNavigator(); export function MenuPage() { const { favoriteStation, setFavoriteStation } = useFavoriteStation(); + const { height, width } = useWindowDimensions(); + const tabBarHeight = useBottomTabBarHeight(); const { getCurrentTrain } = useCurrentTrain(); const navigation = useNavigation(); const { addListener } = navigation; @@ -42,8 +50,20 @@ export function MenuPage() { }) .catch((error) => console.error("Error fetching icon setting:", error)); }, []); + + const scrollRef = useRef(null); + const MapHeight = + height - + tabBarHeight + + (Platform.OS == "android" ? Constants.statusBarHeight : 0) - + 100 - + ((((width / 100) * 80) / 20) * 9 + 10 + 30); useEffect(() => { const unsubscribe = addListener("tabPress", (e) => { + scrollRef.current.scrollTo({ + y: MapHeight - 80, + animated: true, + }); AS.getItem("favoriteStation") .then((d) => { const returnData = JSON.parse(d); @@ -65,7 +85,9 @@ export function MenuPage() { gestureEnabled: true, headerTransparent: true, }} - children={() => } + children={() => ( + + )} /> { setTimeout(() => { if (scrollRef.current) { scrollRef.current.scrollTo({ - y: mapsSizeOffset, + y: MapHeight - 80, animated: false, }); } @@ -82,9 +81,9 @@ export default function Menu({ getCurrentTrain }) { const [position, setPosition] = useState(undefined); const getCurrentPosition = () => { if (!locationStatus) return () => {}; - Location.getCurrentPositionAsync({}).then((location) => { - setPosition(location); - }); + Location.getCurrentPositionAsync({}).then((location) => + setPosition(location) + ); }; useEffect(() => { if (!position) return () => {}; @@ -219,380 +218,201 @@ export default function Menu({ getCurrentTrain }) { { - console.log(Object.keys(scrollRef.current)); const scrollY = d.nativeEvent.contentOffset.y + 100; - setMapsOpacity(scrollY < mapsSizeOffset); + setMapsOpacity(scrollY < MapHeight); }} - snapToOffsets={[mapsSizeOffset]} + snapToOffsets={[MapHeight - 80]} > - - alert("地図をタップ")} + /> + + { - alert("地図をタップ"); - }} - > - - - - { + if (!position) return; + const { latitude, longitude } = position.coords; + mapsRef.current.animateToRegion( + { + latitude, + longitude, + latitudeDelta: 0.05, + longitudeDelta: 0.05, + }, + 1000 + ); }} > - + { - if(!position) return; - const { latitude, longitude } = position.coords; - mapsRef.current.animateToRegion( - { - latitude, - longitude, - latitudeDelta: 0.05, - longitudeDelta: 0.05, - }, - 1000 - ); + textAlign: "center", }} > - - - 現在地基準 - - - { - // お気に入りリスト更新 - }} - > - - - お気に入りリスト - - - - + + - - <> - {originalStationList.length != 0 && allStationData.length != 0 && ( - - { - return ( - - - - - - ); - }} + onPress={() => { + // お気に入りリスト更新 + }} + > + - - {originalStationList && - allStationData.map((d, index) => { - const active = index == selectedCurrentStation; - const numberIndex = d[0].StationNumber; - if (dotButton) { - return ( - setSelectedCurrentStation(index)} - currentStation={d} - active={active} - index={numberIndex} + お気に入りリスト + + + + {allStationData.length != 0 && originalStationList.length != 0 && ( + <> + + { + return ( + + + - ); - } else { - return ( - setSelectedCurrentStation(index)} - active={active} - index={numberIndex} - /> - ); - } - })} + + + ); + }} + /> + + {originalStationList && + allStationData.map((d, index) => { + const active = index == selectedCurrentStation; + const numberIndex = d[0].StationNumber; + if (dotButton) { + return ( + setSelectedCurrentStation(index)} + currentStation={d} + active={active} + index={numberIndex} + /> + ); + } else { + return ( + setSelectedCurrentStation(index)} + active={active} + index={numberIndex} + /> + ); + } + })} + - + {allStationData[selectedCurrentStation] && ( + {}} + /> + )} + )} - {allStationData.length != 0 && - originalStationList.length != 0 && - allStationData[selectedCurrentStation] && ( - {}} - /> - )} + + ); } - -const TopMenuButton = ({ show }) => { - const buttonList = [ - { - backgroundColor: "#F89038", - icon: "train-car", - onPress: () => - Linking.openURL("https://www.jr-shikoku.co.jp/01_trainbus/sp/"), - title: "駅・鉄道情報", - }, - { - backgroundColor: "#EA4752", - icon: "google-spreadsheet", - onPress: () => - Linking.openURL( - "https://www.jr-shikoku.co.jp/01_trainbus/jikoku/sp/#mainprice-box" - ), - title: "運賃表", - }, - { - backgroundColor: "#91C31F", - icon: "clipboard-list-outline", - onPress: () => Linking.openURL("https://www.jr-shikoku.co.jp/e5489/"), - title: "予約", - }, - ]; - return ( - - {buttonList.map((d, index) => ( - - {d.title} - - ))} - - ); -}; - -const JRSTraInfoBox = () => { - const { getTime, delayData, loadingDelayData, setLoadingDelayData } = - useTrainDelayData(); - const styles = { - touch: { - backgroundColor: "#0099CC", - borderRadius: 5, - margin: 10, - borderColor: "black", - borderWidth: 2, - overflow: "hidden", - }, - scroll: { - backgroundColor: "#0099CC", - borderRadius: 5, - maxHeight: 300, - }, - bottom: { - position: "absolute", - top: 250, - alignItems: "center", - width: "100%", - height: 50, - backgroundColor: "#007FCC88", - }, - box: { - padding: 10, - backgroundColor: "white", - borderBottomLeftRadius: 5, - borderBottomRightRadius: 5, - }, - }; - return ( - SheetManager.show("JRSTraInfo")} - style={styles.touch} - > - - - - 列車遅延速報EX - - - - {getTime - ? getTime.toLocaleTimeString("ja-JP").split(":")[0] + - ":" + - getTime.toLocaleTimeString("ja-JP").split(":")[1] - : NaN} - - { - setLoadingDelayData(true); - }} - /> - - - {loadingDelayData ? ( - - - - ) : delayData ? ( - delayData.map((d, index, array) => { - let data = d.split(" "); - return ( - - - {data[0].replace("\n", "")} - - {data[1]} - {data[3]} - - ); - }) - ) : ( - 現在、5分以上の遅れはありません。 - )} - - - - - - 詳細を見る - - - - - ); -}; From 97a6bbc619c8ebdf486b90a50b408dc7bcd80f17 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 13 Apr 2025 12:41:33 +0000 Subject: [PATCH 07/36] =?UTF-8?q?Carousel=E3=81=A8=E5=88=87=E3=82=8A?= =?UTF-8?q?=E6=9B=BF=E3=81=88=E3=83=9C=E3=82=BF=E3=83=B3=E3=82=92=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Menu/Carousel/CarouselBox.tsx | 125 ++++++++++ .../Menu/Carousel/CarouselTypeChanger.tsx | 80 +++++++ menu.js | 216 ++---------------- stateBox/useStationList.tsx | 3 +- 4 files changed, 221 insertions(+), 203 deletions(-) create mode 100644 components/Menu/Carousel/CarouselBox.tsx create mode 100644 components/Menu/Carousel/CarouselTypeChanger.tsx diff --git a/components/Menu/Carousel/CarouselBox.tsx b/components/Menu/Carousel/CarouselBox.tsx new file mode 100644 index 0000000..6f595a6 --- /dev/null +++ b/components/Menu/Carousel/CarouselBox.tsx @@ -0,0 +1,125 @@ +import Sign from "@/components/駅名表/Sign"; +import React, { useEffect, useState } from "react"; +import { AS } from "@/storageControl"; +import { useWindowDimensions, View, LayoutAnimation } from "react-native"; +import Carousel from "react-native-reanimated-carousel"; +import { SheetManager } from "react-native-actions-sheet"; +import { StationNumber } from "../StationPagination"; +import { SimpleDot } from "../SimpleDot"; +export const CarouselBox = ({ + originalStationList, + allStationData, + currentStation, + setSelectedCurrentStation, + carouselRef, + selectedCurrentStation, + navigate, +}) => { + const { height, width } = useWindowDimensions(); + const [dotButton, setDotButton] = useState(false); + const oPSign = () => { + const payload = { + currentStation: allStationData[selectedCurrentStation], + navigate, + goTo: "menu", + //@ts-ignore + useShow: () => SheetManager.show("StationDetailView", { payload }), + onExit: () => SheetManager.hide("StationDetailView"), + }; + //@ts-ignore + SheetManager.show("StationDetailView", { payload }); + }; + const oLPSign = () => { + LayoutAnimation.configureNext({ + duration: 600, + update: { type: "spring", springDamping: 0.5 }, + }); + AS.setItem( + "CarouselSettings/activeDotSettings", + !dotButton ? "true" : "false" + ); + setDotButton(!dotButton); + }; + + useEffect(() => { + AS.getItem("CarouselSettings/activeDotSettings").then((data) => { + setDotButton(data === "true"); + }); + }, []); + return ( + + { + return ( + + + + + + ); + }} + /> + + {originalStationList && + allStationData.map((d, index) => { + const active = index == selectedCurrentStation; + const numberIndex = d[0].StationNumber; + if (dotButton) { + return ( + setSelectedCurrentStation(index)} + currentStation={d} + active={active} + key={numberIndex} + /> + ); + } else { + return ( + setSelectedCurrentStation(index)} + active={active} + key={numberIndex} + /> + ); + } + })} + + + ); +}; diff --git a/components/Menu/Carousel/CarouselTypeChanger.tsx b/components/Menu/Carousel/CarouselTypeChanger.tsx new file mode 100644 index 0000000..776f4d9 --- /dev/null +++ b/components/Menu/Carousel/CarouselTypeChanger.tsx @@ -0,0 +1,80 @@ +import React, { useRef } from "react"; +import { View, TouchableOpacity, Text } from "react-native"; +import Ionicons from "react-native-vector-icons/Ionicons"; + +export const CarouselTypeChanger = ({ locationStatus, position, mapsRef }) => { + return ( + + { + if (!position) return; + const { latitude, longitude } = position.coords; + mapsRef.current.animateToRegion( + { + latitude, + longitude, + latitudeDelta: 0.05, + longitudeDelta: 0.05, + }, + 1000 + ); + }} + > + + + 現在地基準 + + + { + // お気に入りリスト更新 + }} + > + + + お気に入りリスト + + + + ); +}; diff --git a/menu.js b/menu.js index 5cb79d4..48f86a9 100644 --- a/menu.js +++ b/menu.js @@ -1,14 +1,5 @@ import React, { useRef, useState, useEffect } from "react"; -import Carousel from "react-native-reanimated-carousel"; -import { - Platform, - View, - ScrollView, - Text, - TouchableOpacity, - LayoutAnimation, - useWindowDimensions, -} from "react-native"; +import { Platform, View, ScrollView, useWindowDimensions } from "react-native"; import Constants from "expo-constants"; import * as Location from "expo-location"; import { @@ -16,27 +7,23 @@ import { ReanimatedLogLevel, } from "react-native-reanimated"; import StatusbarDetect from "./StatusbarDetect"; -import { Ionicons } from "@expo/vector-icons"; import LED_vision from "./components/発車時刻表/LED_vidion"; -import Sign from "./components/駅名表/Sign"; import { TitleBar } from "./components/Menu/TitleBar"; import { FixedContentBottom } from "./components/Menu/FixedContentBottom"; import { lineList } from "./lib/getStationList"; import useInterval from "./lib/useInterval"; import { useFavoriteStation } from "./stateBox/useFavoriteStation"; -import { SheetManager } from "react-native-actions-sheet"; import { useNavigation } from "@react-navigation/native"; import { useStationList } from "./stateBox/useStationList"; -import { StationNumber } from "./components/Menu/StationPagination"; -import { AS } from "./storageControl"; -import { SimpleDot } from "./components/Menu/SimpleDot"; import { TopMenuButton } from "@/components/Menu/TopMenuButton"; import { JRSTraInfoBox } from "@/components/Menu/JRSTraInfoBox"; import MapView from "react-native-maps"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useBottomTabBarHeight } from "@react-navigation/bottom-tabs"; +import { CarouselBox } from "./components/Menu/Carousel/CarouselBox"; +import { CarouselTypeChanger } from "./components/Menu/Carousel/CarouselTypeChanger"; configureReanimatedLogger({ level: ReanimatedLogLevel.error, // Set the log level to error strict: true, // Reanimated runs in strict mode by default @@ -157,23 +144,6 @@ export default function Menu({ getCurrentTrain, scrollRef }) { }); }, [selectedCurrentStation]); - //全列車ダイヤリストを作成するuseEffect - const oPSign = () => { - const payload = { - currentStation: - originalStationList && - allStationData.length != 0 && - allStationData[selectedCurrentStation], - navigate: navigate, - goTo: "menu", - useShow: () => SheetManager.show("StationDetailView", { payload }), - onExit: () => SheetManager.hide("StationDetailView"), - }; - SheetManager.show("StationDetailView", { payload }); - }; - - const [dotButton, setDotButton] = useState(false); - useEffect(() => { console.log(selectedCurrentStation); if (allStationData.length == 0) return; @@ -190,23 +160,6 @@ export default function Menu({ getCurrentTrain, scrollRef }) { }; mapsRef.current.animateToRegion(mapRegion, 1000); }, [selectedCurrentStation, currentStation, allStationData, mapsRef]); - - useEffect(() => { - AS.getItem("CarouselSettings/activeDotSettings").then((data) => { - setDotButton(data === "true"); - }); - }, []); - const oLPSign = () => { - LayoutAnimation.configureNext({ - duration: 600, - update: { type: "spring", springDamping: 0.5 }, - }); - AS.setItem( - "CarouselSettings/activeDotSettings", - !dotButton ? "true" : "false" - ); - setDotButton(!dotButton); - }; return ( alert("地図をタップ")} /> - - { - if (!position) return; - const { latitude, longitude } = position.coords; - mapsRef.current.animateToRegion( - { - latitude, - longitude, - latitudeDelta: 0.05, - longitudeDelta: 0.05, - }, - 1000 - ); - }} - > - - - 現在地基準 - - - { - // お気に入りリスト更新 - }} - > - - - お気に入りリスト - - - + {allStationData.length != 0 && originalStationList.length != 0 && ( <> - - { - return ( - - - - - - ); - }} - /> - - {originalStationList && - allStationData.map((d, index) => { - const active = index == selectedCurrentStation; - const numberIndex = d[0].StationNumber; - if (dotButton) { - return ( - setSelectedCurrentStation(index)} - currentStation={d} - active={active} - index={numberIndex} - /> - ); - } else { - return ( - setSelectedCurrentStation(index)} - active={active} - index={numberIndex} - /> - ); - } - })} - - + {allStationData[selectedCurrentStation] && ( = ({ children }) => { useEffect(()=>{ if(originalStationList.length === 0) return; const stationList = - originalStationList && lineList.map((d) => originalStationList[d].map((a) => ({ StationNumber: a.StationNumber, StationName: a.Station_JP, })) ); - setStationList(stationList) + setStationList(stationList); },[originalStationList]) return ( From f922edb973bdee883eee6c2a3969dbf2287bc38b Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 13 Apr 2025 13:21:09 +0000 Subject: [PATCH 08/36] =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E6=83=85=E5=A0=B1?= =?UTF-8?q?=E6=A8=A9=E9=99=90=E3=81=AE=E5=8F=96=E5=BE=97=E5=A0=B4=E6=89=80?= =?UTF-8?q?=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.js | 2 + menu.js | 26 ++---------- stateBox/useTopMenu.tsx | 68 ++++++++++++++++++++++++++++++++ stateBox/useUserPosition.tsx | 76 ++++++++++++++++++++++++++++++++++++ 4 files changed, 149 insertions(+), 23 deletions(-) create mode 100644 stateBox/useTopMenu.tsx create mode 100644 stateBox/useUserPosition.tsx diff --git a/App.js b/App.js index ded91f4..4fec0f5 100644 --- a/App.js +++ b/App.js @@ -18,6 +18,7 @@ import { TrainMenuProvider } from "./stateBox/useTrainMenu"; import { buildProvidersTree } from "./lib/providerTreeProvider"; import { StationListProvider } from "./stateBox/useStationList"; import { NotificationProvider } from "./stateBox/useNotifications"; +import { UserPositionProvider } from "./stateBox/useUserPosition"; LogBox.ignoreLogs([ "ViewPropTypes will be removed", @@ -36,6 +37,7 @@ export default function App() { const ProviderTree = buildProvidersTree([ AllTrainDiagramProvider, NotificationProvider, + UserPositionProvider, StationListProvider, FavoriteStationProvider, TrainDelayDataProvider, diff --git a/menu.js b/menu.js index 48f86a9..faf0d84 100644 --- a/menu.js +++ b/menu.js @@ -1,7 +1,6 @@ import React, { useRef, useState, useEffect } from "react"; import { Platform, View, ScrollView, useWindowDimensions } from "react-native"; import Constants from "expo-constants"; -import * as Location from "expo-location"; import { configureReanimatedLogger, ReanimatedLogLevel, @@ -13,7 +12,6 @@ import { TitleBar } from "./components/Menu/TitleBar"; import { FixedContentBottom } from "./components/Menu/FixedContentBottom"; import { lineList } from "./lib/getStationList"; -import useInterval from "./lib/useInterval"; import { useFavoriteStation } from "./stateBox/useFavoriteStation"; import { useNavigation } from "@react-navigation/native"; import { useStationList } from "./stateBox/useStationList"; @@ -24,6 +22,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useBottomTabBarHeight } from "@react-navigation/bottom-tabs"; import { CarouselBox } from "./components/Menu/Carousel/CarouselBox"; import { CarouselTypeChanger } from "./components/Menu/Carousel/CarouselTypeChanger"; +import { useUserPosition } from "./stateBox/useUserPosition"; configureReanimatedLogger({ level: ReanimatedLogLevel.error, // Set the log level to error strict: true, // Reanimated runs in strict mode by default @@ -54,24 +53,8 @@ export default function Menu({ getCurrentTrain, scrollRef }) { }, 10); }, []); //位置情報 - const [locationStatus, setLocationStatus] = useState(null); - useEffect(() => { - if (Platform.OS == "web") return; - Location.requestForegroundPermissionsAsync().then((data) => { - setLocationStatus( - Platform.OS == "ios" - ? data.status == "granted" - : data.android.accuracy == "fine" - ); - }); - }, []); - const [position, setPosition] = useState(undefined); - const getCurrentPosition = () => { - if (!locationStatus) return () => {}; - Location.getCurrentPositionAsync({}).then((location) => - setPosition(location) - ); - }; + const { position, locationStatus } = useUserPosition(); + useEffect(() => { if (!position) return () => {}; makeCurrentStation(position); @@ -112,9 +95,6 @@ export default function Menu({ getCurrentTrain, scrollRef }) { } }; - useEffect(getCurrentPosition, [locationStatus]); - useInterval(getCurrentPosition, 5000); - const [currentStation, setCurrentStation] = useState(undefined); //第三要素 const carouselRef = useRef(); diff --git a/stateBox/useTopMenu.tsx b/stateBox/useTopMenu.tsx new file mode 100644 index 0000000..b5b35c0 --- /dev/null +++ b/stateBox/useTopMenu.tsx @@ -0,0 +1,68 @@ +import React, { + createContext, + useContext, + useState, + useEffect, + FC, +} from "react"; +import { lineList, getStationList } from "../lib/getStationList"; + +type initialStateType = { + originalStationList: any[][]; + setOriginalStationList: React.Dispatch>; + getStationData: (id: string) => void; + stationList: any[]; +}; +const initialState = { + originalStationList: [[]], + setOriginalStationList: () => {}, + getStationData: () => {}, + stationList: [], +}; + +const TopMenuContext = createContext(initialState); +type Props = { + children: React.ReactNode; +}; +export const useTopMenu = () => { + return useContext(TopMenuContext); +}; + +export const TopMenuProvider: FC = ({ children }) => { + const [originalStationList, setOriginalStationList] = useState([]); + useEffect(() => { + getStationList().then(setOriginalStationList); + }, []); + const getStationData: (name: string) => void = (name) => { + const returnArray = []; + Object.keys(originalStationList).forEach((key) => { + originalStationList[key].forEach((station) => { + if (station.Station_JP === name) { + if (!!station.jslodApi) returnArray.push(station); + } + }); + }); + return returnArray; + }; + const [stationList, setStationList] = useState([[]]); + useEffect(()=>{ + if(originalStationList.length === 0) return; + const stationList = + originalStationList && + lineList.map((d) => + originalStationList[d].map((a) => ({ + StationNumber: a.StationNumber, + StationName: a.Station_JP, + })) + ); + setStationList(stationList) + },[originalStationList]) + + return ( + + {children} + + ); +}; diff --git a/stateBox/useUserPosition.tsx b/stateBox/useUserPosition.tsx new file mode 100644 index 0000000..2b4cb83 --- /dev/null +++ b/stateBox/useUserPosition.tsx @@ -0,0 +1,76 @@ +import React, { + createContext, + useContext, + useState, + useEffect, + FC, +} from "react"; +import { + LocationObject, + requestForegroundPermissionsAsync, + getCurrentPositionAsync, +} from "expo-location"; +import { Platform } from "react-native"; +import useInterval from "@/lib/useInterval"; + +type initialStateType = { + position: LocationObject | undefined; + getCurrentPosition: () => void; + locationStatus: boolean | null; + getLocationPermission: () => void; +}; +const initialState = { + position: undefined, + getCurrentPosition: () => {}, + locationStatus: null, + getLocationPermission: () => {}, +}; + +const UserPositionContext = createContext(initialState); +type Props = { + children: React.ReactNode; +}; +export const useUserPosition = () => { + return useContext(UserPositionContext); +}; + +export const UserPositionProvider: FC = ({ children }) => { + //位置情報 + const [locationStatus, setLocationStatus] = useState(null); + const [position, setPosition] = useState( + undefined + ); + + const getLocationPermission = async () => { + return requestForegroundPermissionsAsync().then((data) => { + setLocationStatus( + Platform.OS == "ios" + ? data.status == "granted" + : data.android.accuracy == "fine" + ); + }); + }; + const getCurrentPosition = () => { + if (!locationStatus) return () => {}; + getCurrentPositionAsync({}).then((location) => setPosition(location)); + }; + useEffect(() => { + if (Platform.OS == "web") return; + getLocationPermission(); + }, []); + useEffect(getCurrentPosition, [locationStatus]); + useInterval(getCurrentPosition, 5000); + + return ( + + {children} + + ); +}; From 3b98882d809bc03e8ef32274b016ba228742946f Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 13 Apr 2025 14:42:59 +0000 Subject: [PATCH 09/36] =?UTF-8?q?=E3=81=8A=E6=B0=97=E3=81=AB=E5=85=A5?= =?UTF-8?q?=E3=82=8A/=E7=8F=BE=E5=9C=A8=E5=9C=B0=E5=88=87=E3=82=8A?= =?UTF-8?q?=E6=9B=BF=E3=81=88=E6=A9=9F=E8=83=BD=E3=82=92=E4=BB=AE=E4=BD=9C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Menu/Carousel/CarouselTypeChanger.tsx | 51 +++++++++++++++++-- menu.js | 18 +++++-- 2 files changed, 62 insertions(+), 7 deletions(-) diff --git a/components/Menu/Carousel/CarouselTypeChanger.tsx b/components/Menu/Carousel/CarouselTypeChanger.tsx index 776f4d9..4f5b3ac 100644 --- a/components/Menu/Carousel/CarouselTypeChanger.tsx +++ b/components/Menu/Carousel/CarouselTypeChanger.tsx @@ -2,7 +2,13 @@ import React, { useRef } from "react"; import { View, TouchableOpacity, Text } from "react-native"; import Ionicons from "react-native-vector-icons/Ionicons"; -export const CarouselTypeChanger = ({ locationStatus, position, mapsRef }) => { +export const CarouselTypeChanger = ({ + locationStatus, + position, + mapsRef, + stationListMode, + setStationListMode,setSelectedCurrentStation +}) => { return ( { alignItems: "center", flexDirection: "row", marginHorizontal: 5, - borderRadius: 30, + borderTopLeftRadius: 20, + borderTopRightRadius: 20, + borderBottomLeftRadius: stationListMode == "position" ? 0 : 20, + borderBottomRightRadius: stationListMode == "position" ? 0 : 20, }} disabled={!locationStatus} onPress={() => { @@ -28,6 +37,7 @@ export const CarouselTypeChanger = ({ locationStatus, position, mapsRef }) => { }, 1000 ); + setStationListMode("position"); }} > { 現在地基準 + { + if (!position) return; + const { latitude, longitude } = position.coords; + mapsRef.current.animateToRegion( + { + latitude, + longitude, + latitudeDelta: 0.05, + longitudeDelta: 0.05, + }, + 1000 + ); + }} + > + + { alignItems: "center", flexDirection: "row", marginHorizontal: 5, - borderRadius: 30, + borderTopLeftRadius: 20, + borderTopRightRadius: 20, + borderBottomLeftRadius: stationListMode == "favorite" ? 0 : 20, + borderBottomRightRadius: stationListMode == "favorite" ? 0 : 20, }} onPress={() => { // お気に入りリスト更新 + setStationListMode("favorite"); + setSelectedCurrentStation(0); }} > diff --git a/menu.js b/menu.js index faf0d84..8778e8c 100644 --- a/menu.js +++ b/menu.js @@ -35,6 +35,7 @@ export default function Menu({ getCurrentTrain, scrollRef }) { const { bottom, left, right, top } = useSafeAreaInsets(); const tabBarHeight = useBottomTabBarHeight(); const [mapsOpacity, setMapsOpacity] = useState(false); + const [stationListMode, setStationListMode] = useState/*<"position"|"favorite">*/("position"); const mapsRef = useRef(null); const MapHeight = height - @@ -62,7 +63,7 @@ export default function Menu({ getCurrentTrain, scrollRef }) { const makeCurrentStation = (location) => { if (!originalStationList) return () => {}; const findStationEachLine = (selectLine) => { - const searchArea = 0.002; + const searchArea = stationListMode == "position" ? 0.1 : 0.002; const _calcDistance = (from, to) => { let lat = Math.abs(from.lat - to.lat); let lng = Math.abs(from.lng - to.lng); @@ -80,7 +81,9 @@ export default function Menu({ getCurrentTrain, scrollRef }) { let returnDataBase = lineList .map((d) => findStationEachLine(originalStationList[d])) - .filter((d) => d.length > 0) + .filter((d) => { + console.log(d); + return d.length > 0}) .reduce((pre, current) => { pre.push(...current); return pre; @@ -102,10 +105,17 @@ export default function Menu({ getCurrentTrain, scrollRef }) { const [allStationData, setAllStationData] = useState([]); useEffect(() => { + if(stationListMode == "position"){ + setAllStationData( + [currentStation].filter((d) => d != undefined) + ); + }else{ setAllStationData( [currentStation, ...favoriteStation].filter((d) => d != undefined) ); - }, [currentStation, favoriteStation]); + + } + }, [currentStation, favoriteStation,stationListMode]); useEffect(() => { if (allStationData.length == 0) { setSelectedCurrentStation(0); @@ -178,7 +188,7 @@ export default function Menu({ getCurrentTrain, scrollRef }) { }} onPress={() => alert("地図をタップ")} /> - + {allStationData.length != 0 && originalStationList.length != 0 && ( <> Date: Sun, 13 Apr 2025 15:43:10 +0000 Subject: [PATCH 10/36] =?UTF-8?q?Sign=E3=82=92ID=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E3=83=99=E3=83=BC=E3=82=B9=E3=81=AB=E7=BD=AE=E3=81=8D=E6=8F=9B?= =?UTF-8?q?=E3=81=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StationDeteilView.js | 2 +- components/Menu/Carousel/CarouselBox.tsx | 2 +- components/駅名表/Sign.js | 59 ++++++++++--------- menu.js | 2 - stateBox/useFavoriteStation.tsx | 4 +- stateBox/useStationList.tsx | 22 +++++-- 6 files changed, 52 insertions(+), 39 deletions(-) diff --git a/components/ActionSheetComponents/StationDeteilView.js b/components/ActionSheetComponents/StationDeteilView.js index 48d67a3..aa8189c 100644 --- a/components/ActionSheetComponents/StationDeteilView.js +++ b/components/ActionSheetComponents/StationDeteilView.js @@ -91,7 +91,7 @@ export const StationDeteilView = (props) => { {currentStation && ( { usePDFView == "true" ? Linking.openURL(currentStation[0].StationTimeTable) diff --git a/components/Menu/Carousel/CarouselBox.tsx b/components/Menu/Carousel/CarouselBox.tsx index 6f595a6..110e66e 100644 --- a/components/Menu/Carousel/CarouselBox.tsx +++ b/components/Menu/Carousel/CarouselBox.tsx @@ -78,7 +78,7 @@ export const CarouselBox = ({ > ; + } + const [currentStationData] = useState(getStationDataFromId(stationID)); const { favoriteStation, setFavoriteStation } = useFavoriteStation(); const [nexPrePosition, setNexPrePosition] = useState(0); const { originalStationList } = useStationList(); @@ -26,48 +31,40 @@ export default function Sign(props) { useLayoutEffect(() => { const isFavorite = favoriteStation.filter((d) => { const compare = JSON.stringify(d); - const current = JSON.stringify(currentStation); - if (compare === current) { - return true; - } else { - return false; - } + const current = JSON.stringify(currentStationData); + return compare === current; }); setTestButtonStatus(isFavorite.length == 0 ? false : true); - }, [favoriteStation, currentStation]); + }, [favoriteStation, currentStationData]); useEffect(() => { const isFavorite = favoriteStation.filter((d) => { const compare = JSON.stringify(d); - const current = JSON.stringify(currentStation); - if (compare === current) { - return true; - } else { - return false; - } + const current = JSON.stringify(currentStationData); + return compare === current; }); setTestButtonStatus(isFavorite.length == 0 ? false : true); - }, [favoriteStation, currentStation]); + }, [favoriteStation, currentStationData]); useInterval(() => { - if (currentStation.length == 1) { + if (currentStationData.length == 1) { setNexPrePosition(0); return () => {}; } setNexPrePosition( - nexPrePosition + 1 == currentStation.length ? 0 : nexPrePosition + 1 + nexPrePosition + 1 == currentStationData.length ? 0 : nexPrePosition + 1 ); }, 2000); useEffect(() => { setNexPrePosition(0); - getPreNextStation(currentStation[0]); - if (currentStation.length == 1) return () => {}; - getPreNextStation(currentStation[1]); - }, [currentStation]); + getPreNextStation(currentStationData[0]); + if (currentStationData.length == 1) return () => {}; + getPreNextStation(currentStationData[1]); + }, [currentStationData]); useEffect(() => { - if (!currentStation[nexPrePosition]) return () => {}; - getPreNextStation(currentStation[nexPrePosition]); + if (!currentStationData[nexPrePosition]) return () => {}; + getPreNextStation(currentStationData[nexPrePosition]); }, [nexPrePosition]); const getPreNextStation = (now) => { const lineList = [ @@ -101,20 +98,20 @@ export default function Sign(props) { if (returnData[1]) setNexStation(returnData[1]); } }; - const isMatsuyama = currentStation[0].StationNumber == "Y55"; + const isMatsuyama = currentStationData[0].StationNumber == "Y55"; //const isMatsuyama = true; const favoliteChanger = () => { if (testButtonStatus) { const otherData = favoriteStation.filter((d) => { const compare = JSON.stringify(d); - const current = JSON.stringify(currentStation); + const current = JSON.stringify(currentStationData); return compare !== current; }); AS.setItem("favoriteStation", JSON.stringify(otherData)); setFavoriteStation(otherData); } else { let ret = favoriteStation; - ret.push(currentStation); + ret.push(currentStationData); AS.setItem("favoriteStation", JSON.stringify(ret)); setFavoriteStation(ret); } @@ -138,8 +135,12 @@ export default function Sign(props) { source={require("../../assets/StationSign.json")} /> )} - - + + {isCurrentStation ? ( - + ); } diff --git a/menu.js b/menu.js index 8778e8c..c41aa4d 100644 --- a/menu.js +++ b/menu.js @@ -82,7 +82,6 @@ export default function Menu({ getCurrentTrain, scrollRef }) { let returnDataBase = lineList .map((d) => findStationEachLine(originalStationList[d])) .filter((d) => { - console.log(d); return d.length > 0}) .reduce((pre, current) => { pre.push(...current); @@ -135,7 +134,6 @@ export default function Menu({ getCurrentTrain, scrollRef }) { }, [selectedCurrentStation]); useEffect(() => { - console.log(selectedCurrentStation); if (allStationData.length == 0) return; if (allStationData[selectedCurrentStation] == undefined) return; const { lat, lng } = diff --git a/stateBox/useFavoriteStation.tsx b/stateBox/useFavoriteStation.tsx index dbc09d2..d4f5893 100644 --- a/stateBox/useFavoriteStation.tsx +++ b/stateBox/useFavoriteStation.tsx @@ -29,10 +29,10 @@ type Props = { }; export const FavoriteStationProvider:FC = ({ children }) => { const [favoriteStation, setFavoriteStation] = useState([]); - const { getStationData } = useStationList(); + const { getStationDataFromName } = useStationList(); const lodAddMigration = () => { const migration = favoriteStation.map((d) => { - return getStationData(d[0].Station_JP); + return getStationDataFromName(d[0].Station_JP); }); setFavoriteStation(migration); }; diff --git a/stateBox/useStationList.tsx b/stateBox/useStationList.tsx index f05d8d1..cc44ce4 100644 --- a/stateBox/useStationList.tsx +++ b/stateBox/useStationList.tsx @@ -10,13 +10,15 @@ import { lineList, getStationList } from "../lib/getStationList"; type initialStateType = { originalStationList: any[][]; setOriginalStationList: React.Dispatch>; - getStationData: (id: string) => void; + getStationDataFromName: (id: string) => any[]; + getStationDataFromId: (id: string) => any[]; stationList: any[]; }; const initialState = { originalStationList: [[]], setOriginalStationList: () => {}, - getStationData: () => {}, + getStationDataFromName: () => [], + getStationDataFromId: () => [], stationList: [], }; @@ -33,7 +35,19 @@ export const StationListProvider: FC = ({ children }) => { useEffect(() => { getStationList().then(setOriginalStationList); }, []); - const getStationData: (name: string) => void = (name) => { + const getStationDataFromId: (id: string) => any[] = (id) => { + console.log("id", id); + let returnArray = []; + Object.keys(originalStationList).forEach((key) => { + originalStationList[key].forEach((station) => { + if (station.StationNumber === id) { + returnArray = [...returnArray, ...getStationDataFromName(station.Station_JP)]; + } + }); + }); + return returnArray; + }; + const getStationDataFromName: (name: string) => any[] = (name) => { const returnArray = []; Object.keys(originalStationList).forEach((key) => { originalStationList[key].forEach((station) => { @@ -59,7 +73,7 @@ export const StationListProvider: FC = ({ children }) => { return ( {children} From 6d51db98fa39ae8ca178992f179d0bcadd850dc4 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 13 Apr 2025 15:48:25 +0000 Subject: [PATCH 11/36] =?UTF-8?q?=E5=BE=AE=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/駅名表/StationNumberMaker.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/駅名表/StationNumberMaker.tsx b/components/駅名表/StationNumberMaker.tsx index dbeef0e..bd38e40 100644 --- a/components/駅名表/StationNumberMaker.tsx +++ b/components/駅名表/StationNumberMaker.tsx @@ -1,10 +1,11 @@ import React from "react"; import { Text, View } from "react-native"; -import { widthPercentageToDP as wp } from "react-native-responsive-screen"; +import { useWindowDimensions } from "react-native"; import lineColorList from "../../assets/originData/lineColorList"; export const StationNumberMaker = (props) => { const { currentStation, isMatsuyama } = props; + const { width } = useWindowDimensions(); const getTop = (array: number[], index: number) => { if (array.length == 1) return 20; else if (index == 0) return 5; @@ -24,8 +25,8 @@ export const StationNumberMaker = (props) => { alignItems: "center", top: `${getTop(array, index)}%`, right: "10%", - width: wp("10%"), - height: wp("10%"), + width: (width / 100 * 10), + height: (width / 100 * 10), borderColor: lineColorList[lineID], backgroundColor: "white", borderWidth: parseInt("3%"), From 2c505c4b17b266cc39eb2de27e137f4f69abd25a Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 13 Apr 2025 16:17:15 +0000 Subject: [PATCH 12/36] =?UTF-8?q?=E8=BF=91=E3=81=8F=E3=81=AE=E9=A7=85?= =?UTF-8?q?=E3=81=AE=E6=83=85=E5=A0=B1=E3=81=8C=E3=81=A8=E3=82=8A=E3=81=82?= =?UTF-8?q?=E3=81=88=E3=81=9A=E5=87=BA=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu.js | 33 ++++++++++++++++++++++----------- stateBox/useStationList.tsx | 1 - 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/menu.js b/menu.js index c41aa4d..015f5cb 100644 --- a/menu.js +++ b/menu.js @@ -35,7 +35,9 @@ export default function Menu({ getCurrentTrain, scrollRef }) { const { bottom, left, right, top } = useSafeAreaInsets(); const tabBarHeight = useBottomTabBarHeight(); const [mapsOpacity, setMapsOpacity] = useState(false); - const [stationListMode, setStationListMode] = useState/*<"position"|"favorite">*/("position"); + const [stationListMode, setStationListMode] = useState( + /*<"position"|"favorite">*/ "position" + ); const mapsRef = useRef(null); const MapHeight = height - @@ -59,11 +61,11 @@ export default function Menu({ getCurrentTrain, scrollRef }) { useEffect(() => { if (!position) return () => {}; makeCurrentStation(position); - }, [position]); + }, [position, stationListMode]); const makeCurrentStation = (location) => { if (!originalStationList) return () => {}; const findStationEachLine = (selectLine) => { - const searchArea = stationListMode == "position" ? 0.1 : 0.002; + const searchArea = stationListMode == "position" ? 0.07 : 0.002; const _calcDistance = (from, to) => { let lat = Math.abs(from.lat - to.lat); let lng = Math.abs(from.lng - to.lng); @@ -104,17 +106,17 @@ export default function Menu({ getCurrentTrain, scrollRef }) { const [allStationData, setAllStationData] = useState([]); useEffect(() => { - if(stationListMode == "position"){ + if (stationListMode == "position") { + console.log(currentStation); setAllStationData( [currentStation].filter((d) => d != undefined) ); - }else{ - setAllStationData( - [currentStation, ...favoriteStation].filter((d) => d != undefined) - ); - + } else { + setAllStationData( + [currentStation, ...favoriteStation].filter((d) => d != undefined) + ); } - }, [currentStation, favoriteStation,stationListMode]); + }, [currentStation, favoriteStation, stationListMode]); useEffect(() => { if (allStationData.length == 0) { setSelectedCurrentStation(0); @@ -186,7 +188,16 @@ export default function Menu({ getCurrentTrain, scrollRef }) { }} onPress={() => alert("地図をタップ")} /> - + {allStationData.length != 0 && originalStationList.length != 0 && ( <> = ({ children }) => { getStationList().then(setOriginalStationList); }, []); const getStationDataFromId: (id: string) => any[] = (id) => { - console.log("id", id); let returnArray = []; Object.keys(originalStationList).forEach((key) => { originalStationList[key].forEach((station) => { From 748350178de46b25de3777caddaad06de663f28f Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 13 Apr 2025 16:31:11 +0000 Subject: [PATCH 13/36] =?UTF-8?q?=E5=B0=8F=E3=81=95=E3=81=AA=E3=83=9F?= =?UTF-8?q?=E3=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Menu/Carousel/CarouselBox.tsx | 4 ++-- menu.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/Menu/Carousel/CarouselBox.tsx b/components/Menu/Carousel/CarouselBox.tsx index 110e66e..3a54a9a 100644 --- a/components/Menu/Carousel/CarouselBox.tsx +++ b/components/Menu/Carousel/CarouselBox.tsx @@ -106,7 +106,7 @@ export const CarouselBox = ({ onPress={() => setSelectedCurrentStation(index)} currentStation={d} active={active} - key={numberIndex} + key={numberIndex + index} /> ); } else { @@ -114,7 +114,7 @@ export const CarouselBox = ({ setSelectedCurrentStation(index)} active={active} - key={numberIndex} + key={numberIndex + index} /> ); } diff --git a/menu.js b/menu.js index 015f5cb..09a7fdb 100644 --- a/menu.js +++ b/menu.js @@ -113,7 +113,7 @@ export default function Menu({ getCurrentTrain, scrollRef }) { ); } else { setAllStationData( - [currentStation, ...favoriteStation].filter((d) => d != undefined) + favoriteStation.filter((d) => d != undefined) ); } }, [currentStation, favoriteStation, stationListMode]); From 35bb460b54dd208075e67af5f9488b02dce1ac67 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 13 Apr 2025 16:54:02 +0000 Subject: [PATCH 14/36] =?UTF-8?q?CarouselBox=E3=82=B3=E3=83=B3=E3=83=9D?= =?UTF-8?q?=E3=83=BC=E3=83=8D=E3=83=B3=E3=83=88=E3=81=AErenderItem?= =?UTF-8?q?=E9=96=A2=E6=95=B0=E3=82=92=E5=88=86=E9=9B=A2=E3=81=97=E3=80=81?= =?UTF-8?q?Menu=E3=82=B3=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=8D=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=81=A7=E3=81=AEcurrentStation=E3=81=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E3=82=92nearPositionStation=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Menu/Carousel/CarouselBox.tsx | 81 ++++++++++++------------ menu.js | 33 ++++------ 2 files changed, 53 insertions(+), 61 deletions(-) diff --git a/components/Menu/Carousel/CarouselBox.tsx b/components/Menu/Carousel/CarouselBox.tsx index 3a54a9a..1315417 100644 --- a/components/Menu/Carousel/CarouselBox.tsx +++ b/components/Menu/Carousel/CarouselBox.tsx @@ -46,6 +46,29 @@ export const CarouselBox = ({ setDotButton(data === "true"); }); }, []); + const RenderItem = ({ item, index }) => { + return ( + + + + + + ); + }; return ( { - return ( - - - - - - ); - }} + renderItem={RenderItem} /> { const active = index == selectedCurrentStation; - const numberIndex = d[0].StationNumber; - if (dotButton) { - return ( - setSelectedCurrentStation(index)} - currentStation={d} - active={active} - key={numberIndex + index} - /> - ); - } else { - return ( - setSelectedCurrentStation(index)} - active={active} - key={numberIndex + index} - /> - ); - } + const numberKey = d[0].StationNumber + index; + return dotButton ? ( + setSelectedCurrentStation(index)} + currentStation={d} + active={active} + key={numberKey} + /> + ) : ( + setSelectedCurrentStation(index)} + active={active} + key={numberKey} + /> + ); })} diff --git a/menu.js b/menu.js index 09a7fdb..35460e5 100644 --- a/menu.js +++ b/menu.js @@ -84,7 +84,8 @@ export default function Menu({ getCurrentTrain, scrollRef }) { let returnDataBase = lineList .map((d) => findStationEachLine(originalStationList[d])) .filter((d) => { - return d.length > 0}) + return d.length > 0; + }) .reduce((pre, current) => { pre.push(...current); return pre; @@ -92,14 +93,14 @@ export default function Menu({ getCurrentTrain, scrollRef }) { if (returnDataBase.length) { let currentStation = currentStation == undefined ? [] : currentStation; if (currentStation.toString() != returnDataBase.toString()) { - setCurrentStation(returnDataBase); + setNearPositionStation(returnDataBase); } } else { - setCurrentStation(undefined); + setNearPositionStation(undefined); } }; - const [currentStation, setCurrentStation] = useState(undefined); //第三要素 + const [nearPositionStation, setNearPositionStation] = useState(undefined); //第三要素 const carouselRef = useRef(); const [selectedCurrentStation, setSelectedCurrentStation] = useState(0); @@ -107,16 +108,12 @@ export default function Menu({ getCurrentTrain, scrollRef }) { const [allStationData, setAllStationData] = useState([]); useEffect(() => { if (stationListMode == "position") { - console.log(currentStation); - setAllStationData( - [currentStation].filter((d) => d != undefined) - ); + console.log(nearPositionStation); + setAllStationData([nearPositionStation].filter((d) => d != undefined)); } else { - setAllStationData( - favoriteStation.filter((d) => d != undefined) - ); + setAllStationData(favoriteStation.filter((d) => d != undefined)); } - }, [currentStation, favoriteStation, stationListMode]); + }, [nearPositionStation, favoriteStation, stationListMode]); useEffect(() => { if (allStationData.length == 0) { setSelectedCurrentStation(0); @@ -126,7 +123,7 @@ export default function Menu({ getCurrentTrain, scrollRef }) { const count = selectedCurrentStation - 1; setSelectedCurrentStation(count); } - }, [selectedCurrentStation, currentStation, allStationData]); + }, [selectedCurrentStation, nearPositionStation, allStationData]); useEffect(() => { if (!carouselRef.current) return; carouselRef?.current.scrollTo({ @@ -136,12 +133,10 @@ export default function Menu({ getCurrentTrain, scrollRef }) { }, [selectedCurrentStation]); useEffect(() => { + if (originalStationList == undefined) return; if (allStationData.length == 0) return; if (allStationData[selectedCurrentStation] == undefined) return; - const { lat, lng } = - originalStationList && - allStationData[selectedCurrentStation] && - allStationData[selectedCurrentStation][0]; + const { lat, lng } = allStationData[selectedCurrentStation][0]; const mapRegion = { latitude: lat, longitude: lng, @@ -149,7 +144,7 @@ export default function Menu({ getCurrentTrain, scrollRef }) { longitudeDelta: 0.05, }; mapsRef.current.animateToRegion(mapRegion, 1000); - }, [selectedCurrentStation, currentStation, allStationData, mapsRef]); + }, [selectedCurrentStation, nearPositionStation, allStationData, mapsRef]); return ( Date: Sun, 13 Apr 2025 16:56:47 +0000 Subject: [PATCH 15/36] =?UTF-8?q?menu=E3=81=AE=E5=A4=89=E6=95=B0=E5=90=8D?= =?UTF-8?q?=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu.js | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/menu.js b/menu.js index 35460e5..1392e8c 100644 --- a/menu.js +++ b/menu.js @@ -103,40 +103,40 @@ export default function Menu({ getCurrentTrain, scrollRef }) { const [nearPositionStation, setNearPositionStation] = useState(undefined); //第三要素 const carouselRef = useRef(); - const [selectedCurrentStation, setSelectedCurrentStation] = useState(0); + const [listIndex, setListIndex] = useState(0); - const [allStationData, setAllStationData] = useState([]); + const [listUpStation, setListUpStation] = useState([]); useEffect(() => { if (stationListMode == "position") { console.log(nearPositionStation); - setAllStationData([nearPositionStation].filter((d) => d != undefined)); + setListUpStation([nearPositionStation].filter((d) => d != undefined)); } else { - setAllStationData(favoriteStation.filter((d) => d != undefined)); + setListUpStation(favoriteStation.filter((d) => d != undefined)); } }, [nearPositionStation, favoriteStation, stationListMode]); useEffect(() => { - if (allStationData.length == 0) { - setSelectedCurrentStation(0); + if (listUpStation.length == 0) { + setListIndex(0); return; } - if (allStationData[selectedCurrentStation] == undefined) { - const count = selectedCurrentStation - 1; - setSelectedCurrentStation(count); + if (listUpStation[listIndex] == undefined) { + const count = listIndex - 1; + setListIndex(count); } - }, [selectedCurrentStation, nearPositionStation, allStationData]); + }, [listIndex, nearPositionStation, listUpStation]); useEffect(() => { if (!carouselRef.current) return; carouselRef?.current.scrollTo({ - count: selectedCurrentStation - carouselRef.current.getCurrentIndex(), + count: listIndex - carouselRef.current.getCurrentIndex(), animated: true, }); - }, [selectedCurrentStation]); + }, [listIndex]); useEffect(() => { if (originalStationList == undefined) return; - if (allStationData.length == 0) return; - if (allStationData[selectedCurrentStation] == undefined) return; - const { lat, lng } = allStationData[selectedCurrentStation][0]; + if (listUpStation.length == 0) return; + if (listUpStation[listIndex] == undefined) return; + const { lat, lng } = listUpStation[listIndex][0]; const mapRegion = { latitude: lat, longitude: lng, @@ -144,7 +144,7 @@ export default function Menu({ getCurrentTrain, scrollRef }) { longitudeDelta: 0.05, }; mapsRef.current.animateToRegion(mapRegion, 1000); - }, [selectedCurrentStation, nearPositionStation, allStationData, mapsRef]); + }, [listIndex, nearPositionStation, listUpStation, mapsRef]); return ( - {allStationData.length != 0 && originalStationList.length != 0 && ( + {listUpStation.length != 0 && originalStationList.length != 0 && ( <> - {allStationData[selectedCurrentStation] && ( + {listUpStation[listIndex] && ( {}} From 015e4e54edde3c6be1f84508c594fab104aebe2b Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 13 Apr 2025 17:24:35 +0000 Subject: [PATCH 16/36] =?UTF-8?q?=E7=8F=BE=E5=9C=A8=E5=9C=B0=E5=9F=BA?= =?UTF-8?q?=E6=BA=96=E3=81=AE=E5=BD=93=E8=A9=B2=E9=A7=85=E3=82=92=E8=A4=87?= =?UTF-8?q?=E6=95=B0=E8=A1=A8=E7=A4=BA=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu.js | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/menu.js b/menu.js index 1392e8c..9732fa4 100644 --- a/menu.js +++ b/menu.js @@ -55,9 +55,9 @@ export default function Menu({ getCurrentTrain, scrollRef }) { } }, 10); }, []); - //位置情報 - const { position, locationStatus } = useUserPosition(); + //現在地基準の駅名標リストアップ機能 + const { position, locationStatus } = useUserPosition(); useEffect(() => { if (!position) return () => {}; makeCurrentStation(position); @@ -65,7 +65,7 @@ export default function Menu({ getCurrentTrain, scrollRef }) { const makeCurrentStation = (location) => { if (!originalStationList) return () => {}; const findStationEachLine = (selectLine) => { - const searchArea = stationListMode == "position" ? 0.07 : 0.002; + const searchArea = 0.12; const _calcDistance = (from, to) => { let lat = Math.abs(from.lat - to.lat); let lng = Math.abs(from.lng - to.lng); @@ -78,11 +78,26 @@ export default function Menu({ getCurrentTrain, scrollRef }) { lng: location.coords.longitude, }) < searchArea ); + //NearStationを距離の近い順にソート + NearStation.sort((a, b) => { + return ( + _calcDistance(a, { + lat: location.coords.latitude, + lng: location.coords.longitude, + }) - + _calcDistance(b, { + lat: location.coords.latitude, + lng: location.coords.longitude, + }) + ); + }); return NearStation; }; let returnDataBase = lineList - .map((d) => findStationEachLine(originalStationList[d])) + .map((d) => { + return findStationEachLine(originalStationList[d]); + }) .filter((d) => { return d.length > 0; }) @@ -90,17 +105,16 @@ export default function Menu({ getCurrentTrain, scrollRef }) { pre.push(...current); return pre; }, []); + if (returnDataBase.length) { - let currentStation = currentStation == undefined ? [] : currentStation; - if (currentStation.toString() != returnDataBase.toString()) { - setNearPositionStation(returnDataBase); - } + const returnData = returnDataBase.map((d) => [d]); + setNearPositionStation(returnData); } else { - setNearPositionStation(undefined); + setNearPositionStation([]); } }; - const [nearPositionStation, setNearPositionStation] = useState(undefined); //第三要素 + const [nearPositionStation, setNearPositionStation] = useState([]); //第三要素 const carouselRef = useRef(); const [listIndex, setListIndex] = useState(0); @@ -108,8 +122,7 @@ export default function Menu({ getCurrentTrain, scrollRef }) { const [listUpStation, setListUpStation] = useState([]); useEffect(() => { if (stationListMode == "position") { - console.log(nearPositionStation); - setListUpStation([nearPositionStation].filter((d) => d != undefined)); + setListUpStation(nearPositionStation.filter((d) => d != undefined)); } else { setListUpStation(favoriteStation.filter((d) => d != undefined)); } From f26da93193d122e96dc6663cdff620822c69cd7c Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 13 Apr 2025 18:06:22 +0000 Subject: [PATCH 17/36] =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AE?= =?UTF-8?q?=E6=95=B4=E7=90=86=E3=81=A8useCurrentTrain=E3=81=AE=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E3=83=AB=E3=83=BC=E3=83=88=E3=81=AE=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MenuPage.js | 4 +-- components/Menu/Carousel/CarouselBox.tsx | 37 +++++++++++++--------- components/発車時刻表/LED_vidion.js | 21 ++++++------- menu.js | 39 ++++++------------------ 4 files changed, 42 insertions(+), 59 deletions(-) diff --git a/MenuPage.js b/MenuPage.js index 8c11bda..b3a20e7 100644 --- a/MenuPage.js +++ b/MenuPage.js @@ -15,7 +15,6 @@ import Setting from "./components/Settings/settings"; import { useFavoriteStation } from "./stateBox/useFavoriteStation"; import { optionData } from "./lib/stackOption"; import AllTrainDiagramView from "./components/AllTrainDiagramView"; -import { useCurrentTrain } from "./stateBox/useCurrentTrain"; import { useNavigation } from "@react-navigation/native"; import { news } from "./config/newsUpdate"; import { useBottomTabBarHeight } from "@react-navigation/bottom-tabs"; @@ -25,7 +24,6 @@ export function MenuPage() { const { favoriteStation, setFavoriteStation } = useFavoriteStation(); const { height, width } = useWindowDimensions(); const tabBarHeight = useBottomTabBarHeight(); - const { getCurrentTrain } = useCurrentTrain(); const navigation = useNavigation(); const { addListener } = navigation; useEffect(() => { @@ -86,7 +84,7 @@ export function MenuPage() { headerTransparent: true, }} children={() => ( - + )} /> diff --git a/components/Menu/Carousel/CarouselBox.tsx b/components/Menu/Carousel/CarouselBox.tsx index 1315417..950acec 100644 --- a/components/Menu/Carousel/CarouselBox.tsx +++ b/components/Menu/Carousel/CarouselBox.tsx @@ -1,25 +1,25 @@ import Sign from "@/components/駅名表/Sign"; -import React, { useEffect, useState } from "react"; +import React, { useEffect, useRef, useState } from "react"; import { AS } from "@/storageControl"; import { useWindowDimensions, View, LayoutAnimation } from "react-native"; -import Carousel from "react-native-reanimated-carousel"; +import Carousel, { ICarouselInstance } from "react-native-reanimated-carousel"; import { SheetManager } from "react-native-actions-sheet"; import { StationNumber } from "../StationPagination"; import { SimpleDot } from "../SimpleDot"; export const CarouselBox = ({ originalStationList, - allStationData, - currentStation, - setSelectedCurrentStation, - carouselRef, - selectedCurrentStation, + listUpStation, + nearPositionStation, + setListIndex, + listIndex, navigate, }) => { + const carouselRef = useRef(null); const { height, width } = useWindowDimensions(); const [dotButton, setDotButton] = useState(false); const oPSign = () => { const payload = { - currentStation: allStationData[selectedCurrentStation], + currentStation: listUpStation[listIndex], navigate, goTo: "menu", //@ts-ignore @@ -46,6 +46,13 @@ export const CarouselBox = ({ setDotButton(data === "true"); }); }, []); + useEffect(() => { + if (!carouselRef.current) return; + carouselRef?.current.scrollTo({ + count: listIndex - carouselRef.current.getCurrentIndex(), + animated: true, + }); + }, [listIndex]); const RenderItem = ({ item, index }) => { return ( @@ -73,7 +80,7 @@ export const CarouselBox = ({ {originalStationList && - allStationData.map((d, index) => { - const active = index == selectedCurrentStation; + listUpStation.map((d, index) => { + const active = index == listIndex; const numberKey = d[0].StationNumber + index; return dotButton ? ( setSelectedCurrentStation(index)} + onPress={() => setListIndex(index)} currentStation={d} active={active} key={numberKey} /> ) : ( setSelectedCurrentStation(index)} + onPress={() => setListIndex(index)} active={active} key={numberKey} /> diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index 3b4e86f..2ebce12 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -42,44 +42,43 @@ import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram"; * 9062D 四国まんなか千年ものがたり(臨時?) */ export default function LED_vision(props) { - const { station, getCurrentTrain, navigate, openStationACFromEachTrainInfo } = - props; - const { currentTrain } = useCurrentTrain(); + const { station, navigate, openStationACFromEachTrainInfo } = props; + const { getCurrentTrain, currentTrain } = useCurrentTrain(); const [stationDiagram, setStationDiagram] = useState({}); //当該駅の全時刻表 const [finalSwitch, setFinalSwitch] = useState(false); const [trainIDSwitch, setTrainIDSwitch] = useState(false); const [trainDescriptionSwitch, setTrainDescriptionSwitch] = useState(false); const [isInfoArea, setIsInfoArea] = useState(false); const { areaInfo, areaStationID } = useAreaInfo(); - const { allTrainDiagram: trainDiagram } = useAllTrainDiagram(); + const { allTrainDiagram } = useAllTrainDiagram(); useEffect(() => { AS.getItem("LEDSettings/trainIDSwitch").then((data) => { setTrainIDSwitch(data === "true"); }); AS.getItem("LEDSettings/trainDescriptionSwitch").then((data) => { - setTrainDescriptionSwitch(data == "true"); + setTrainDescriptionSwitch(data === "true"); }); AS.getItem("LEDSettings/finalSwitch").then((data) => { - setFinalSwitch(data == "true"); + setFinalSwitch(data === "true"); }); }, []); useEffect(() => { // 現在の駅に停車するダイヤを作成する副作用[列車ダイヤと現在駅情報] - if (!trainDiagram) { + if (!allTrainDiagram) { setStationDiagram({}); return; } let returnData = {}; - Object.keys(trainDiagram).forEach((key) => { - if (trainDiagram[key].match(station[0].Station_JP + ",")) { - returnData[key] = trainDiagram[key]; + Object.keys(allTrainDiagram).forEach((key) => { + if (allTrainDiagram[key].match(station[0].Station_JP + ",")) { + returnData[key] = allTrainDiagram[key]; } }); setStationDiagram(returnData); setIsInfoArea(station.some((s) => areaStationID.includes(s.StationNumber))); - }, [trainDiagram, station]); + }, [allTrainDiagram, station]); const [trainTimeAndNumber, setTrainTimeAndNumber] = useState(null); diff --git a/menu.js b/menu.js index 9732fa4..393a305 100644 --- a/menu.js +++ b/menu.js @@ -27,7 +27,7 @@ configureReanimatedLogger({ level: ReanimatedLogLevel.error, // Set the log level to error strict: true, // Reanimated runs in strict mode by default }); -export default function Menu({ getCurrentTrain, scrollRef }) { +export default function Menu({scrollRef }) { const { navigate, addListener, isFocused } = useNavigation(); const { favoriteStation } = useFavoriteStation(); const { originalStationList } = useStationList(); @@ -95,28 +95,17 @@ export default function Menu({ getCurrentTrain, scrollRef }) { }; let returnDataBase = lineList - .map((d) => { - return findStationEachLine(originalStationList[d]); - }) - .filter((d) => { - return d.length > 0; - }) + .map((d) => findStationEachLine(originalStationList[d])) + .filter((d) => d.length > 0) .reduce((pre, current) => { pre.push(...current); return pre; - }, []); - - if (returnDataBase.length) { - const returnData = returnDataBase.map((d) => [d]); - setNearPositionStation(returnData); - } else { - setNearPositionStation([]); - } + }, []).map((d) => [d]); + setNearPositionStation(returnDataBase.length ? returnDataBase : []); }; const [nearPositionStation, setNearPositionStation] = useState([]); //第三要素 - const carouselRef = useRef(); const [listIndex, setListIndex] = useState(0); const [listUpStation, setListUpStation] = useState([]); @@ -137,14 +126,6 @@ export default function Menu({ getCurrentTrain, scrollRef }) { setListIndex(count); } }, [listIndex, nearPositionStation, listUpStation]); - useEffect(() => { - if (!carouselRef.current) return; - carouselRef?.current.scrollTo({ - count: listIndex - carouselRef.current.getCurrentIndex(), - animated: true, - }); - }, [listIndex]); - useEffect(() => { if (originalStationList == undefined) return; if (listUpStation.length == 0) return; @@ -211,18 +192,16 @@ export default function Menu({ getCurrentTrain, scrollRef }) { {listUpStation[listIndex] && ( {}} /> From 427e06967c8614e21c2a4531e292ed94ec9fb491 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 13 Apr 2025 19:16:58 +0000 Subject: [PATCH 18/36] =?UTF-8?q?LED=E3=81=ABkey=E3=82=92=E4=BB=98?= =?UTF-8?q?=E4=B8=8E=E3=81=97=E3=81=A6=E3=83=87=E3=83=BC=E3=82=BF=E3=81=AE?= =?UTF-8?q?=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/EachData.tsx | 25 ++++++++------- .../LED_Vision_Component/Header.js | 4 +-- components/発車時刻表/LED_vidion.js | 31 ++++++++++--------- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/components/発車時刻表/EachData.tsx b/components/発車時刻表/EachData.tsx index 84c47e4..c3dce10 100644 --- a/components/発車時刻表/EachData.tsx +++ b/components/発車時刻表/EachData.tsx @@ -122,21 +122,21 @@ export const EachData: FC = (props) => { = (props) => { flexDirection: "row", }} onPress={() => openTrainInfo(d)} + key={ d.train + "-eachData" } > = (props) => { /> )} {trainDescriptionSwitch && !!train.info && ( - + )} ); diff --git a/components/発車時刻表/LED_Vision_Component/Header.js b/components/発車時刻表/LED_Vision_Component/Header.js index 392ed13..274b9c8 100644 --- a/components/発車時刻表/LED_Vision_Component/Header.js +++ b/components/発車時刻表/LED_Vision_Component/Header.js @@ -3,8 +3,8 @@ import { useCurrentTrain } from "../../../stateBox/useCurrentTrain"; import LottieView from "lottie-react-native"; import { Ionicons } from "@expo/vector-icons"; -export const Header = ({ getCurrentTrain }) => { - const { currentTrainLoading, setCurrentTrainLoading } = useCurrentTrain(); +export const Header = () => { + const { currentTrainLoading, setCurrentTrainLoading,getCurrentTrain } = useCurrentTrain(); return ( areaStationID.includes(s.StationNumber))); }, [allTrainDiagram, station]); - const [trainTimeAndNumber, setTrainTimeAndNumber] = useState(null); + /* +{lastStation: "当駅止", time: "12:34", train: "1234M"} + */ + const [trainTimeAndNumber, setTrainTimeAndNumber] = useState([]); useEffect(() => { //現在の駅に停車する列車から時刻を切り出してLEDベースにフォーマット @@ -141,16 +144,15 @@ export default function LED_vision(props) { }; const timeFiltering = (d) => { - const date = new Date(); - const newDate = new Date(); - let data = d.time.split(":"); + const date = dayjs(); + const newDate = dayjs(); + let [h,m] = d.time.split(":"); let delay = isNaN(currentTrain.filter((t) => t.num == d.train)[0].delay) ? 0 : currentTrain.filter((t) => t.num == d.train)[0].delay; - date.setHours(parseInt(data[0])); - date.setMinutes(parseInt(data[1]) + parseInt(delay)); - return !(newDate > date); + date.hour(parseInt(h)).minute(parseInt(m) + parseInt(delay)); + return !(newDate.isAfter(date)); }; const [areaString, setAreaString] = useState(""); @@ -182,18 +184,19 @@ export default function LED_vision(props) { } setAreaStringLength(areaInfo.length); }, [areaInfo]); - + const { width } = useWindowDimensions(); + const adjustedWidth = width * 0.98; return ( -
+
{selectedTrain.map((d) => ( Date: Sun, 13 Apr 2025 19:46:15 +0000 Subject: [PATCH 19/36] =?UTF-8?q?=E3=83=9E=E3=83=83=E3=83=97=E3=81=AE?= =?UTF-8?q?=E7=A7=BB=E5=8B=95=E6=A9=9F=E8=83=BD=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Menu/Carousel/CarouselTypeChanger.tsx | 37 ++++++++------ menu.js | 51 ++++++++++++++----- 2 files changed, 58 insertions(+), 30 deletions(-) diff --git a/components/Menu/Carousel/CarouselTypeChanger.tsx b/components/Menu/Carousel/CarouselTypeChanger.tsx index 4f5b3ac..a41b8da 100644 --- a/components/Menu/Carousel/CarouselTypeChanger.tsx +++ b/components/Menu/Carousel/CarouselTypeChanger.tsx @@ -1,5 +1,5 @@ import React, { useRef } from "react"; -import { View, TouchableOpacity, Text } from "react-native"; +import { View, TouchableOpacity, Text, LayoutAnimation } from "react-native"; import Ionicons from "react-native-vector-icons/Ionicons"; export const CarouselTypeChanger = ({ @@ -7,8 +7,24 @@ export const CarouselTypeChanger = ({ position, mapsRef, stationListMode, - setStationListMode,setSelectedCurrentStation + setStationListMode, + setSelectedCurrentStation, + setMapMode, }) => { + const returnToDefaultMode = ()=>{ + LayoutAnimation.configureNext({ + duration: 300, + create: { + type: LayoutAnimation.Types.easeInEaseOut, + property: LayoutAnimation.Properties.opacity, + }, + update: { + type: LayoutAnimation.Types.easeInEaseOut, + property: LayoutAnimation.Properties.opacity, + }, + }); + setMapMode(false); + } return ( { if (!position) return; + returnToDefaultMode(); const { latitude, longitude } = position.coords; mapsRef.current.animateToRegion( { @@ -66,20 +83,7 @@ export const CarouselTypeChanger = ({ marginHorizontal: 5, borderRadius: 50, }} - disabled={true} - onPress={() => { - if (!position) return; - const { latitude, longitude } = position.coords; - mapsRef.current.animateToRegion( - { - latitude, - longitude, - latitudeDelta: 0.05, - longitudeDelta: 0.05, - }, - 1000 - ); - }} + onPress={() => returnToDefaultMode()} > { + returnToDefaultMode(); // お気に入りリスト更新 setStationListMode("favorite"); setSelectedCurrentStation(0); diff --git a/menu.js b/menu.js index 393a305..0214584 100644 --- a/menu.js +++ b/menu.js @@ -1,5 +1,5 @@ import React, { useRef, useState, useEffect } from "react"; -import { Platform, View, ScrollView, useWindowDimensions } from "react-native"; +import { Platform, View, ScrollView, useWindowDimensions, LayoutAnimation } from "react-native"; import Constants from "expo-constants"; import { configureReanimatedLogger, @@ -17,7 +17,7 @@ import { useNavigation } from "@react-navigation/native"; import { useStationList } from "./stateBox/useStationList"; import { TopMenuButton } from "@/components/Menu/TopMenuButton"; import { JRSTraInfoBox } from "@/components/Menu/JRSTraInfoBox"; -import MapView from "react-native-maps"; +import MapView, { Marker } from "react-native-maps"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useBottomTabBarHeight } from "@react-navigation/bottom-tabs"; import { CarouselBox } from "./components/Menu/Carousel/CarouselBox"; @@ -27,14 +27,14 @@ configureReanimatedLogger({ level: ReanimatedLogLevel.error, // Set the log level to error strict: true, // Reanimated runs in strict mode by default }); -export default function Menu({scrollRef }) { +export default function Menu({ scrollRef }) { const { navigate, addListener, isFocused } = useNavigation(); const { favoriteStation } = useFavoriteStation(); const { originalStationList } = useStationList(); const { height, width } = useWindowDimensions(); const { bottom, left, right, top } = useSafeAreaInsets(); + const [mapMode, setMapMode] = useState(false); const tabBarHeight = useBottomTabBarHeight(); - const [mapsOpacity, setMapsOpacity] = useState(false); const [stationListMode, setStationListMode] = useState( /*<"position"|"favorite">*/ "position" ); @@ -45,6 +45,7 @@ export default function Menu({scrollRef }) { (Platform.OS == "android" ? Constants.statusBarHeight : 0) - 100 - ((((width / 100) * 80) / 20) * 9 + 10 + 30); + const MapFullHeight = height - tabBarHeight + (Platform.OS == "android" ? Constants.statusBarHeight : 0) - 100; useEffect(() => { setTimeout(() => { if (scrollRef.current) { @@ -95,12 +96,13 @@ export default function Menu({scrollRef }) { }; let returnDataBase = lineList - .map((d) => findStationEachLine(originalStationList[d])) + .map((d) => findStationEachLine(originalStationList[d])) .filter((d) => d.length > 0) .reduce((pre, current) => { pre.push(...current); return pre; - }, []).map((d) => [d]); + }, []) + .map((d) => [d]); setNearPositionStation(returnDataBase.length ? returnDataBase : []); }; @@ -154,15 +156,11 @@ export default function Menu({scrollRef }) { snapToStart={false} snapToEnd={false} decelerationRate={"normal"} - onScroll={(d) => { - const scrollY = d.nativeEvent.contentOffset.y + 100; - setMapsOpacity(scrollY < MapHeight); - }} snapToOffsets={[MapHeight - 80]} > alert("地図をタップ")} - /> + onTouchStart={() => { + LayoutAnimation.configureNext({ + duration: 300, + create: { + type: LayoutAnimation.Types.easeInEaseOut, + property: LayoutAnimation.Properties.opacity, + }, + update: { + type: LayoutAnimation.Types.easeInEaseOut, + property: LayoutAnimation.Properties.opacity, + }, + }); + setMapMode(true); + }} + > + {listUpStation.map(([{ lat, lng, StationNumber }], index) => ( + + ))} + {listUpStation.length != 0 && originalStationList.length != 0 && ( @@ -194,7 +217,7 @@ export default function Menu({scrollRef }) { originalStationList, listUpStation, nearPositionStation, - setListIndex , + setListIndex, listIndex, navigate, }} From fa758c144f5558de7ec18c48fb76f84a79e296f0 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 14 Apr 2025 18:52:21 +0000 Subject: [PATCH 20/36] =?UTF-8?q?=E3=82=B9=E3=82=AF=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E6=8C=99=E5=8B=95=E3=81=8C=E3=81=8A=E3=81=8B?= =?UTF-8?q?=E3=81=97=E3=81=8B=E3=81=A3=E3=81=9F=E3=83=90=E3=82=B0=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MenuPage.js | 26 +++--- .../Menu/Carousel/CarouselTypeChanger.tsx | 14 +-- menu.js | 88 ++++++++++++++++--- 3 files changed, 91 insertions(+), 37 deletions(-) diff --git a/MenuPage.js b/MenuPage.js index b3a20e7..e9f16b4 100644 --- a/MenuPage.js +++ b/MenuPage.js @@ -1,4 +1,4 @@ -import React, { useEffect, useRef } from "react"; +import React, { useEffect, useRef,useState } from "react"; import { createStackNavigator } from "@react-navigation/stack"; import { useWindowDimensions, Platform } from "react-native"; import Constants from "expo-constants"; @@ -50,16 +50,20 @@ export function MenuPage() { }, []); const scrollRef = useRef(null); - const MapHeight = - height - - tabBarHeight + - (Platform.OS == "android" ? Constants.statusBarHeight : 0) - - 100 - - ((((width / 100) * 80) / 20) * 9 + 10 + 30); + const [mapHeight,setMapHeight] = useState(0); + useEffect(()=>{ + const MapHeight = + height - + tabBarHeight + + (Platform.OS == "android" ? Constants.statusBarHeight : 0) - + 100 - + ((((width / 100) * 80) / 20) * 9 + 10 + 30); + setMapHeight(MapHeight); + }, [height, tabBarHeight, width]); useEffect(() => { const unsubscribe = addListener("tabPress", (e) => { scrollRef.current.scrollTo({ - y: MapHeight - 80, + y: mapHeight - 80, animated: true, }); AS.getItem("favoriteStation") @@ -73,7 +77,7 @@ export function MenuPage() { }); return unsubscribe; - }, [navigation]); + }, [navigation, mapHeight]); return ( ( - - )} + children={() => } /> { if (!position) return; returnToDefaultMode(); - const { latitude, longitude } = position.coords; - mapsRef.current.animateToRegion( - { - latitude, - longitude, - latitudeDelta: 0.05, - longitudeDelta: 0.05, - }, - 1000 - ); setStationListMode("position"); }} > @@ -83,7 +73,7 @@ export const CarouselTypeChanger = ({ marginHorizontal: 5, borderRadius: 50, }} - onPress={() => returnToDefaultMode()} + onPressIn={() => returnToDefaultMode()} > { + scrollRef.current.scrollTo({ + y: mapHeight > 80 ?mapHeight - 80 :0, + animated: bool, + }); + }; + const goToMap = () => { + scrollRef.current.scrollTo({ + y: 0, + animated: true, + }); + }; useEffect(() => { - setTimeout(() => { - if (scrollRef.current) { - scrollRef.current.scrollTo({ - y: MapHeight - 80, - animated: false, - }); - } + setTimeout(()=>{ + returnToTop(false); }, 10); - }, []); - + }, [mapHeight]); + const returnToDefaultMode = () => { + LayoutAnimation.configureNext({ + duration: 300, + create: { + type: LayoutAnimation.Types.easeInEaseOut, + property: LayoutAnimation.Properties.opacity, + }, + update: { + type: LayoutAnimation.Types.easeInEaseOut, + property: LayoutAnimation.Properties.opacity, + }, + }); + setMapMode(false); + }; //現在地基準の駅名標リストアップ機能 const { position, locationStatus } = useUserPosition(); useEffect(() => { @@ -125,6 +155,7 @@ export default function Menu({ scrollRef }) { } if (listUpStation[listIndex] == undefined) { const count = listIndex - 1; + setMapMode(false); setListIndex(count); } }, [listIndex, nearPositionStation, listUpStation]); @@ -139,8 +170,10 @@ export default function Menu({ scrollRef }) { latitudeDelta: 0.05, longitudeDelta: 0.05, }; + if (mapMode) return; mapsRef.current.animateToRegion(mapRegion, 1000); }, [listIndex, nearPositionStation, listUpStation, mapsRef]); + return ( returnToDefaultMode()} > {listUpStation.map(([{ lat, lng, StationNumber }], index) => ( @@ -196,6 +231,33 @@ export default function Menu({ scrollRef }) { longitude: parseFloat(lng), }} image={require("@/assets/reccha-small.png")} + onPress={() => { + setMapMode(false); + setListIndex(index); + if (mapsRef.current) { + mapsRef.current.animateToRegion( + { + latitude: parseFloat(lat), + longitude: parseFloat(lng), + latitudeDelta: 0.05, + longitudeDelta: 0.05, + }, + 1000 + ); + } + LayoutAnimation.configureNext({ + duration: 300, + create: { + type: LayoutAnimation.Types.easeInEaseOut, + property: LayoutAnimation.Properties.opacity, + }, + update: { + type: LayoutAnimation.Types.easeInEaseOut, + property: LayoutAnimation.Properties.opacity, + }, + }); + returnToTop(); + }} /> ))} @@ -238,4 +300,4 @@ export default function Menu({ scrollRef }) { ); -} +} \ No newline at end of file From 85de99e32df45bd8db9a5134dd61371680f0b401 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Tue, 15 Apr 2025 07:37:14 +0000 Subject: [PATCH 21/36] =?UTF-8?q?LED=E7=99=BA=E8=BB=8A=E6=A8=99=E3=81=8C?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E3=81=AB=E5=8B=95=E3=81=84=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E5=95=8F=E9=A1=8C=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/LED_vidion.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index ae2c906..420a9e6 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -145,14 +145,12 @@ export default function LED_vision(props) { const timeFiltering = (d) => { const date = dayjs(); - const newDate = dayjs(); let [h,m] = d.time.split(":"); let delay = isNaN(currentTrain.filter((t) => t.num == d.train)[0].delay) ? 0 : currentTrain.filter((t) => t.num == d.train)[0].delay; - - date.hour(parseInt(h)).minute(parseInt(m) + parseInt(delay)); - return !(newDate.isAfter(date)); + const db = date.hour(parseInt(h)).minute(parseInt(m) + parseInt(delay)); + return !(date.isAfter(db)); }; const [areaString, setAreaString] = useState(""); From b3cc5b6ede1611c775e341bdd0a10ef98437e0dd Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Fri, 18 Apr 2025 09:51:36 +0000 Subject: [PATCH 22/36] =?UTF-8?q?=E5=9C=B0=E5=9B=B3=E3=81=AE=E4=B8=8B?= =?UTF-8?q?=E9=83=A8=E5=86=85=E5=AE=B9=E3=82=92absolute=E3=81=AB=E3=81=97?= =?UTF-8?q?=E3=81=A6=E6=A9=9F=E8=83=BD=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88?= =?UTF-8?q?=E3=82=92=E3=82=B9=E3=82=AF=E3=83=AD=E3=83=BC=E3=83=AB=E3=81=A7?= =?UTF-8?q?=E7=99=BA=E5=8B=95=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MenuPage.js | 26 +++++- .../Menu/Carousel/CarouselTypeChanger.tsx | 19 ++++- menu.js | 80 ++++++++++++------- 3 files changed, 88 insertions(+), 37 deletions(-) diff --git a/MenuPage.js b/MenuPage.js index e9f16b4..a815a2e 100644 --- a/MenuPage.js +++ b/MenuPage.js @@ -1,4 +1,4 @@ -import React, { useEffect, useRef,useState } from "react"; +import React, { useEffect, useRef, useState } from "react"; import { createStackNavigator } from "@react-navigation/stack"; import { useWindowDimensions, Platform } from "react-native"; import Constants from "expo-constants"; @@ -50,8 +50,9 @@ export function MenuPage() { }, []); const scrollRef = useRef(null); - const [mapHeight,setMapHeight] = useState(0); - useEffect(()=>{ + const [mapMode, setMapMode] = useState(false); + const [mapHeight, setMapHeight] = useState(0); + useEffect(() => { const MapHeight = height - tabBarHeight + @@ -60,12 +61,21 @@ export function MenuPage() { ((((width / 100) * 80) / 20) * 9 + 10 + 30); setMapHeight(MapHeight); }, [height, tabBarHeight, width]); + const [MapFullHeight, setMapFullHeight] = useState(0); + useEffect(() => { + const MapFullHeight = + height - + tabBarHeight + + (Platform.OS == "android" ? Constants.statusBarHeight : 0); + setMapFullHeight(MapFullHeight); + }, [height, tabBarHeight, width]); useEffect(() => { const unsubscribe = addListener("tabPress", (e) => { scrollRef.current.scrollTo({ y: mapHeight - 80, animated: true, }); + setMapMode(false); AS.getItem("favoriteStation") .then((d) => { const returnData = JSON.parse(d); @@ -87,7 +97,15 @@ export function MenuPage() { gestureEnabled: true, headerTransparent: true, }} - children={() => } + children={() => ( + + )} /> { + const tabBarHeight = useBottomTabBarHeight(); const returnToDefaultMode = ()=>{ LayoutAnimation.configureNext({ duration: 300, @@ -26,7 +29,7 @@ export const CarouselTypeChanger = ({ setMapMode(false); } return ( - + { + if (!position) return; + returnToDefaultMode(); + setStationListMode("position"); + }} onPress={() => { if (!position) return; returnToDefaultMode(); @@ -76,7 +85,7 @@ export const CarouselTypeChanger = ({ onPressIn={() => returnToDefaultMode()} > { + returnToDefaultMode(); + // お気に入りリスト更新 + setStationListMode("favorite"); + setSelectedCurrentStation(0); + }} onPress={() => { returnToDefaultMode(); // お気に入りリスト更新 diff --git a/menu.js b/menu.js index 50a1e3e..b02d605 100644 --- a/menu.js +++ b/menu.js @@ -33,32 +33,20 @@ configureReanimatedLogger({ level: ReanimatedLogLevel.error, // Set the log level to error strict: true, // Reanimated runs in strict mode by default }); -export default function Menu({ scrollRef, mapHeight }) { +export default function Menu({ scrollRef, mapHeight, MapFullHeight, mapMode, setMapMode }) { const { navigate, addListener, isFocused } = useNavigation(); const { favoriteStation } = useFavoriteStation(); const { originalStationList } = useStationList(); const { height, width } = useWindowDimensions(); const { bottom, left, right, top } = useSafeAreaInsets(); - const [mapMode, setMapMode] = useState(false); const tabBarHeight = useBottomTabBarHeight(); const [stationListMode, setStationListMode] = useState( /*<"position"|"favorite">*/ "position" ); const mapsRef = useRef(null); - const MapHeight = - height - - tabBarHeight + - (Platform.OS == "android" ? Constants.statusBarHeight : 0) - - 100 - - ((((width / 100) * 80) / 20) * 9 + 10 + 30); - const MapFullHeight = - height - - tabBarHeight + - (Platform.OS == "android" ? Constants.statusBarHeight : 0) - - 100; const returnToTop = (bool = true) => { scrollRef.current.scrollTo({ - y: mapHeight > 80 ?mapHeight - 80 :0, + y: mapHeight > 80 ? mapHeight - 80 : 0, animated: bool, }); }; @@ -69,11 +57,12 @@ export default function Menu({ scrollRef, mapHeight }) { }); }; useEffect(() => { - setTimeout(()=>{ + setTimeout(() => { returnToTop(false); }, 10); }, [mapHeight]); - const returnToDefaultMode = () => { + const [scrollStartPosition, setScrollStartPosition] = useState(0); + const onScrollBeginDrag = (e) => { LayoutAnimation.configureNext({ duration: 300, create: { @@ -85,6 +74,7 @@ export default function Menu({ scrollRef, mapHeight }) { property: LayoutAnimation.Properties.opacity, }, }); + setScrollStartPosition(e.nativeEvent.contentOffset.y); setMapMode(false); }; //現在地基準の駅名標リストアップ機能 @@ -189,12 +179,22 @@ export default function Menu({ scrollRef, mapHeight }) { snapToStart={false} snapToEnd={false} decelerationRate={"normal"} - snapToOffsets={[MapHeight - 80]} - onScrollBeginDrag={() => returnToDefaultMode()} + snapToOffsets={[mapHeight - 80]} + onScrollBeginDrag={onScrollBeginDrag} + onScrollEndDrag={(e) => { + console.log(e.nativeEvent.velocity); + if (e.nativeEvent.contentOffset.y < mapHeight - 80) { + if (scrollStartPosition > e.nativeEvent.contentOffset.y) { + goToMap(); + } else { + returnToTop(); + } + } + }} > ))} - + {!mapMode && ( + + )} + {listUpStation.length != 0 && originalStationList.length != 0 && ( <> + {mapMode && ( + + )} ); -} \ No newline at end of file +} From fbcded3d23685ec9988b595ff6eb35b1bf72ea9d Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Fri, 18 Apr 2025 15:39:58 +0000 Subject: [PATCH 23/36] =?UTF-8?q?=E5=88=97=E8=BB=8A=E3=81=8C=E5=87=BA?= =?UTF-8?q?=E7=99=BA=E3=81=97=E3=81=A6=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E3=82=89LED=E3=81=8B=E3=82=89=E6=B6=88=E3=81=88=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3=E3=80=81?= =?UTF-8?q?=E5=87=BA=E7=99=BA=E3=81=97=E3=81=A6=E3=81=9F=E3=82=89=E7=8E=87?= =?UTF-8?q?=E5=85=88=E3=81=97=E3=81=A6=E6=B6=88=E3=81=88=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/LED_vidion.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index 420a9e6..085b4f2 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -11,6 +11,7 @@ import { Header } from "./LED_Vision_Component/Header"; import { Description } from "./LED_inside_Component/Description"; import { EachData } from "./EachData"; import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram"; +import { trainPosition } from "@/lib/trainPositionTextArray"; /** * @@ -144,6 +145,15 @@ export default function LED_vision(props) { }; const timeFiltering = (d) => { + const Pos = trainPosition(currentTrain.filter((t) => t.num == d.train)[0]) + const nextPos = Pos.isBetween ? Pos.Pos.to : Pos.Pos.Pos; + const PrePos = Pos.isBetween ? Pos.Pos.from : ""; + if(station[0].Station_JP == nextPos){ + return true; + } + else if(station[0].Station_JP == PrePos){ + return false; + } const date = dayjs(); let [h,m] = d.time.split(":"); let delay = isNaN(currentTrain.filter((t) => t.num == d.train)[0].delay) From 8c17a5b3daa104b9b8f066454437dcfcede86709 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 20 Apr 2025 05:31:30 +0000 Subject: [PATCH 24/36] =?UTF-8?q?=E5=88=97=E8=BB=8A=E3=81=AE=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E6=9D=A1=E4=BB=B6=E3=81=AE=E5=8E=B3=E5=AF=86=E5=8C=96?= =?UTF-8?q?=E3=80=81=E3=81=8A=E3=82=88=E3=81=B3=E5=87=BA=E7=99=BA=E4=BF=83?= =?UTF-8?q?=E9=80=B2=E8=A1=A8=E7=A4=BA=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/EachData.tsx | 22 +++++++++++ components/発車時刻表/LED_vidion.js | 50 ++++++++++++++++-------- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/components/発車時刻表/EachData.tsx b/components/発車時刻表/EachData.tsx index c3dce10..f636d48 100644 --- a/components/発車時刻表/EachData.tsx +++ b/components/発車時刻表/EachData.tsx @@ -16,6 +16,8 @@ import { TrainPosition } from "./LED_inside_Component/TrainPosition"; import { TrainPositionDataPush } from "./LED_inside_Component/TrainPositionDataPush"; import { TrainPositionDataDelete } from "./LED_inside_Component/TrainPositionDataDelete"; import { useStationList } from "../../stateBox/useStationList"; +import useInterval from "@/lib/useInterval"; +import dayjs from "dayjs"; type Props = { d: { @@ -117,6 +119,22 @@ export const EachData: FC = (props) => { const [descInput, setDescInput] = useState(""); const [stationInput, setStationInput] = useState(""); const [stationNumberInput, setStationNumberInput] = useState(""); + + const [isShow, setIsShow] = useState(true); + const [isDepartureNow, setIsDepartureNow] = useState(false); + useEffect(()=>{ + const currentTime = dayjs(); + const trainTime = currentTime.set("hour", parseInt(d.time.split(":")[0])).set("minute", parseInt(d.time.split(":")[1])); + const diff = trainTime.diff(currentTime, "minute"); + if (diff < 2) setIsDepartureNow(true); + else setIsDepartureNow(false); + }) + useInterval(()=>{ + if (isDepartureNow) { + setIsShow(!isShow); + + } + }, 800); return ( <> = (props) => { marginHorizontal: "3%", backgroundColor: "#000", flexDirection: "row", + opacity: isShow ? 1 : 0.5, }} onPress={() => openTrainInfo(d)} key={ d.train + "-eachData" } @@ -162,6 +181,9 @@ export const EachData: FC = (props) => { + {!!isDepartureNow && ( + + )} {trainDescriptionSwitch && ( {}; if (!currentTrain) return () => {}; const data = trainTimeAndNumber - .filter((d) => currentTrain.map((m) => m.num).includes(d.train)) + //.filter((d) => currentTrain.map((m) => m.num).includes(d.train)) .filter(timeFiltering) .filter((d) => !!finalSwitch || d.lastStation != "当駅止"); setSelectedTrain(data); @@ -145,22 +145,40 @@ export default function LED_vision(props) { }; const timeFiltering = (d) => { - const Pos = trainPosition(currentTrain.filter((t) => t.num == d.train)[0]) - const nextPos = Pos.isBetween ? Pos.Pos.to : Pos.Pos.Pos; - const PrePos = Pos.isBetween ? Pos.Pos.from : ""; - if(station[0].Station_JP == nextPos){ - return true; - } - else if(station[0].Station_JP == PrePos){ + + const baseTime = 2; + + if (currentTrain.filter((t) => t.num == d.train).length == 0) { + const date = dayjs(); + const trainTime = date + .hour(parseInt(d.time.split(":")[0])) + .minute(parseInt(d.time.split(":")[1])); + + if (date.isAfter(trainTime)) { + return false; + } else if (trainTime.diff(date) < baseTime * 60 * 60 * 1000) { + return true; + } return false; + } else { + const Pos = trainPosition( + currentTrain.filter((t) => t.num == d.train)[0] + ); + const nextPos = Pos.isBetween ? Pos.Pos.to : Pos.Pos.Pos; + const PrePos = Pos.isBetween ? Pos.Pos.from : ""; + if (station[0].Station_JP == nextPos) { + if(d.lastStation != "当駅止") return true; + } else if (station[0].Station_JP == PrePos) { + return false; + } + const date = dayjs(); + let [h, m] = d.time.split(":"); + let delay = isNaN(currentTrain.filter((t) => t.num == d.train)[0].delay) + ? 0 + : currentTrain.filter((t) => t.num == d.train)[0].delay; + const db = date.hour(parseInt(h)).minute(parseInt(m) + parseInt(delay)); + return !date.isAfter(db); } - const date = dayjs(); - let [h,m] = d.time.split(":"); - let delay = isNaN(currentTrain.filter((t) => t.num == d.train)[0].delay) - ? 0 - : currentTrain.filter((t) => t.num == d.train)[0].delay; - const db = date.hour(parseInt(h)).minute(parseInt(m) + parseInt(delay)); - return !(date.isAfter(db)); }; const [areaString, setAreaString] = useState(""); From c41c61bba792ccf6ac48c7abef5fd0bfc8274019 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Tue, 6 May 2025 11:53:45 +0000 Subject: [PATCH 25/36] =?UTF-8?q?=E5=AE=87=E5=A4=9A=E6=B4=A5=E3=81=AB?= =?UTF-8?q?=E8=BF=91=E3=81=A5=E3=81=84=E3=81=9F=E3=82=89=E3=82=AF=E3=83=A9?= =?UTF-8?q?=E3=83=83=E3=82=B7=E3=83=A5=E3=81=99=E3=82=8B=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=80=81=E7=8F=BE=E5=9C=A8=E5=9C=B0=E3=81=AE=E3=83=AA=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=82=A2=E3=83=83=E3=83=97=E6=A9=9F=E8=83=BD=E3=81=8C?= =?UTF-8?q?=E3=81=A1=E3=82=83=E3=82=93=E3=81=A8=E6=95=B4=E7=90=86=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/EachData.tsx | 7 +++++-- menu.js | 25 ++++++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/components/発車時刻表/EachData.tsx b/components/発車時刻表/EachData.tsx index f636d48..2fb5686 100644 --- a/components/発車時刻表/EachData.tsx +++ b/components/発車時刻表/EachData.tsx @@ -128,7 +128,10 @@ export const EachData: FC = (props) => { const diff = trainTime.diff(currentTime, "minute"); if (diff < 2) setIsDepartureNow(true); else setIsDepartureNow(false); - }) + return()=>{ + setIsDepartureNow(false); + } + }, [d.time]); useInterval(()=>{ if (isDepartureNow) { setIsShow(!isShow); @@ -182,7 +185,7 @@ export const EachData: FC = (props) => { {!!isDepartureNow && ( - + )} {trainDescriptionSwitch && ( findStationEachLine(originalStationList[d])) .filter((d) => d.length > 0) .reduce((pre, current) => { pre.push(...current); return pre; - }, []) - .map((d) => [d]); - setNearPositionStation(returnDataBase.length ? returnDataBase : []); + }, []); + if (_stList.length == 0) setNearPositionStation([]); + else { + let returnData = []; + _stList.forEach((d, index, array) => { + const stationName = d.Station_JP; + if (returnData.findIndex((d) => d[0].Station_JP == stationName) != -1) return; + returnData.push(array.filter((d2) => d2.Station_JP == stationName)); + }); + returnData.forEach((d) => console.log(d)); + setNearPositionStation(returnData); + } }; const [nearPositionStation, setNearPositionStation] = useState([]); //第三要素 From 7ca4cf95e6b6b3b75b767f0c0735b867bc916d5e Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Tue, 6 May 2025 13:59:13 +0000 Subject: [PATCH 26/36] =?UTF-8?q?=E3=83=86=E3=82=AD=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=81=AE=E7=82=B9=E6=BB=85=E3=82=92=E7=A7=BB=E5=8B=95=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AB=E3=82=AD=E3=83=A3=E3=83=B3?= =?UTF-8?q?=E3=82=BB=E3=83=AB=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/EachData.tsx | 1 + menu.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/components/発車時刻表/EachData.tsx b/components/発車時刻表/EachData.tsx index 2fb5686..eadce46 100644 --- a/components/発車時刻表/EachData.tsx +++ b/components/発車時刻表/EachData.tsx @@ -130,6 +130,7 @@ export const EachData: FC = (props) => { else setIsDepartureNow(false); return()=>{ setIsDepartureNow(false); + setIsShow(true); } }, [d.time]); useInterval(()=>{ diff --git a/menu.js b/menu.js index a714611..b07ec58 100644 --- a/menu.js +++ b/menu.js @@ -136,7 +136,6 @@ export default function Menu({ if (returnData.findIndex((d) => d[0].Station_JP == stationName) != -1) return; returnData.push(array.filter((d2) => d2.Station_JP == stationName)); }); - returnData.forEach((d) => console.log(d)); setNearPositionStation(returnData); } }; From 6a58263e9422e8077959fcc7a030276c35d8257b Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Tue, 6 May 2025 16:27:42 +0000 Subject: [PATCH 27/36] =?UTF-8?q?=E6=9C=80=E5=BE=8C=E3=81=AE=E9=A7=85?= =?UTF-8?q?=E3=83=AA=E3=82=B9=E3=83=88=E9=81=B8=E6=8A=9E=E3=82=92=E7=B6=AD?= =?UTF-8?q?=E6=8C=81=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Menu/Carousel/CarouselTypeChanger.tsx | 7 +++++++ menu.js | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/components/Menu/Carousel/CarouselTypeChanger.tsx b/components/Menu/Carousel/CarouselTypeChanger.tsx index 6c9cecf..c2a0850 100644 --- a/components/Menu/Carousel/CarouselTypeChanger.tsx +++ b/components/Menu/Carousel/CarouselTypeChanger.tsx @@ -1,3 +1,4 @@ +import { AS } from "@/storageControl"; import { useBottomTabBarHeight } from "@react-navigation/bottom-tabs"; import React, { useEffect, useRef } from "react"; import { View, TouchableOpacity, Text, LayoutAnimation } from "react-native"; @@ -49,11 +50,15 @@ export const CarouselTypeChanger = ({ if (!position) return; returnToDefaultMode(); setStationListMode("position"); + AS.setItem("stationListMode", "position"); + setSelectedCurrentStation(0); }} onPress={() => { if (!position) return; returnToDefaultMode(); setStationListMode("position"); + AS.setItem("stationListMode", "position"); + setSelectedCurrentStation(0); }} > { returnToDefaultMode(); // お気に入りリスト更新 setStationListMode("favorite"); + AS.setItem("stationListMode", "favorite"); setSelectedCurrentStation(0); }} > diff --git a/menu.js b/menu.js index b07ec58..3a222f1 100644 --- a/menu.js +++ b/menu.js @@ -29,6 +29,7 @@ import { useBottomTabBarHeight } from "@react-navigation/bottom-tabs"; import { CarouselBox } from "./components/Menu/Carousel/CarouselBox"; import { CarouselTypeChanger } from "./components/Menu/Carousel/CarouselTypeChanger"; import { useUserPosition } from "./stateBox/useUserPosition"; +import { AS } from "./storageControl"; configureReanimatedLogger({ level: ReanimatedLogLevel.error, // Set the log level to error strict: true, // Reanimated runs in strict mode by default @@ -49,6 +50,13 @@ export default function Menu({ const [stationListMode, setStationListMode] = useState( /*<"position"|"favorite">*/ "position" ); + useEffect(()=>{ + AS.getItem("stationListMode").then((res) => { + setStationListMode(res); + }).catch((e) => { + // AS.setItem("stationListMode", "position"); + }); + }, []); const mapsRef = useRef(null); const returnToTop = (bool = true) => { scrollRef.current.scrollTo({ From 73ed5480c1b515137c560de1b22e4365d1856618 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sat, 17 May 2025 10:16:35 +0000 Subject: [PATCH 28/36] =?UTF-8?q?wp=E3=82=92=E5=89=8A=E9=99=A4=E3=81=97?= =?UTF-8?q?=E3=81=A6=E9=85=8D=E7=BD=AE=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StationDeteilView.js | 8 +- components/駅名表/NextPreStationLine.tsx | 79 ++++++----- components/駅名表/Sign.js | 125 +++++++++--------- menu.js | 3 + 4 files changed, 116 insertions(+), 99 deletions(-) diff --git a/components/ActionSheetComponents/StationDeteilView.js b/components/ActionSheetComponents/StationDeteilView.js index aa8189c..17ce175 100644 --- a/components/ActionSheetComponents/StationDeteilView.js +++ b/components/ActionSheetComponents/StationDeteilView.js @@ -14,7 +14,6 @@ import ActionSheet, { SheetManager } from "react-native-actions-sheet"; import Sign from "../../components/駅名表/Sign"; import { TicketBox } from "../atom/TicketBox"; -import { widthPercentageToDP as wp } from "react-native-responsive-screen"; import { getPDFViewURL } from "../../lib/getPdfViewURL"; import { useBusAndTrainData } from "../../stateBox/useBusAndTrainData"; import { AS } from "../../storageControl"; @@ -27,13 +26,14 @@ import { StationTimeTableButton } from "./StationDeteilView/StationTimeTableButt export const StationDeteilView = (props) => { if (!props.payload) return <>; const { currentStation, navigate, onExit, goTo, useShow } = props.payload; + const { width } = useWindowDimensions(); const { busAndTrainData } = useBusAndTrainData(); const [trainBus, setTrainBus] = useState(); useEffect(() => { if (!currentStation) return () => {}; - const data = busAndTrainData.filter((d) => - d.name === currentStation[0].Station_JP + const data = busAndTrainData.filter( + (d) => d.name === currentStation[0].Station_JP ); if (data.length == 0) { setTrainBus(); @@ -89,7 +89,7 @@ export const StationDeteilView = (props) => { {currentStation && ( - + { diff --git a/components/駅名表/NextPreStationLine.tsx b/components/駅名表/NextPreStationLine.tsx index 27843c3..269c79d 100644 --- a/components/駅名表/NextPreStationLine.tsx +++ b/components/駅名表/NextPreStationLine.tsx @@ -1,9 +1,22 @@ import React, { CSSProperties, FC } from "react"; -import { widthPercentageToDP as wp } from "react-native-responsive-screen"; -import { Platform, Text, TextStyle, View, ViewStyle } from "react-native"; +import { + Platform, + Text, + TextStyle, + useWindowDimensions, + View, + ViewStyle, +} from "react-native"; import { StationName } from "./StationName"; import lineColorList from "../../assets/originData/lineColorList"; export const NextPreStationLine = ({ nexStation, preStation, isMatsuyama }) => { + const 下枠フレーム: ViewStyle = { + flex: 1, + flexDirection: "row", + alignContent: "center", + alignItems: "center", + }; + return ( @@ -49,12 +62,40 @@ type FCimport = { children: string; }; const BottomSideArrow: FC = ({ isMatsuyama, children }) => { + const 下枠左右マーク: TextStyle = { + fontWeight: "bold", + fontSize: parseInt("20%"), + color: "white", + paddingHorizontal: 5, + textAlignVertical: "center", + }; return !isMatsuyama && {children}; }; const BottomStationNumberView: FC = ({ isMatsuyama, children }) => { + const { width } = useWindowDimensions(); const lineID = children.slice(0, 1); const lineName = children.slice(1); + const 下枠駅ナンバー: ViewStyle = { + alignContent: "center", + alignItems: "center", + width: width * 0.08, + height: width * 0.08, + margin: width * 0.01, + backgroundColor: "white", + borderWidth: parseInt("3%"), + borderRadius: parseInt("100%"), + }; + const 下枠駅ナンバーB: ViewStyle = { + alignContent: "center", + alignItems: "center", + width: width * 0.07, + height: width * 0.07, + margin: width * 0.02, + backgroundColor: "white", + borderWidth: parseInt("3%"), + borderRadius: parseInt("100%"), + }; return ( = ({ isMatsuyama, children }) => { ); }; - -const 下枠フレーム: ViewStyle = { - flex: 1, - flexDirection: "row", - alignContent: "center", - alignItems: "center", -}; -const 下枠左右マーク: TextStyle = { - fontWeight: "bold", - fontSize: parseInt("20%"), - color: "white", - paddingHorizontal: 5, - textAlignVertical: "center", -}; -const 下枠駅ナンバー: ViewStyle = { - alignContent: "center", - alignItems: "center", - width: wp("8%"), - height: wp("8%"), - margin: wp("1%"), - backgroundColor: "white", - borderWidth: parseInt("3%"), - borderRadius: parseInt("100%"), -}; -const 下枠駅ナンバーB: ViewStyle = { - alignContent: "center", - alignItems: "center", - width: wp("7%"), - height: wp("7%"), - margin: wp("2%"), - backgroundColor: "white", - borderWidth: parseInt("3%"), - borderRadius: parseInt("100%"), -}; diff --git a/components/駅名表/Sign.js b/components/駅名表/Sign.js index eb1b182..f7a3929 100644 --- a/components/駅名表/Sign.js +++ b/components/駅名表/Sign.js @@ -1,6 +1,10 @@ import React, { useRef, useState, useEffect, useLayoutEffect } from "react"; -import { View, Text, TouchableOpacity } from "react-native"; -import { widthPercentageToDP as wp } from "react-native-responsive-screen"; +import { + View, + Text, + TouchableOpacity, + useWindowDimensions, +} from "react-native"; import { MaterialCommunityIcons } from "@expo/vector-icons"; import LottieView from "lottie-react-native"; import { useInterval } from "../../lib/useInterval"; @@ -16,6 +20,8 @@ import { useStationList } from "../../stateBox/useStationList"; export default function Sign(props) { const { oP, oLP, isCurrentStation = false, stationID } = props; + + const { width, height } = useWindowDimensions(); const { getStationDataFromId } = useStationList(); if (!stationID) { return <>; @@ -117,6 +123,62 @@ export default function Sign(props) { } setTestButtonStatus(!testButtonStatus); }; + + const styleSheet = { + 外枠: { + width: width * 0.8, + height: ((width * 0.8) / 20) * 9, + borderColor: "#0099CC", + borderWidth: 1, + backgroundColor: "white", + }, + 外枠B: { + width: width * 0.8, + height: ((width * 0.8) / 20) * 9, + borderWidth: 0, + }, + 下帯: { + position: "absolute", + bottom: "8%", + left: "0%", + width: "100%", + height: "27%", + backgroundColor: "#0099CC", + }, + 下帯B: { + position: "absolute", + bottom: "0%", + left: "0%", + width: "100%", + height: "26%", + backgroundColor: "#454545", + }, + JRStyle: { + position: "absolute", + top: "2%", + left: "2%", + fontWeight: "bold", + fontSize: parseInt("25%"), + color: "#0099CC", + }, + 下帯内容: { + position: "absolute", + bottom: "8%", + height: "27%", + width: "100%", + alignItems: "center", + flexDirection: "column", + }, + 下帯内容B: { + position: "absolute", + bottom: "0%", + height: "26%", + width: "100%", + alignItems: "center", + flexDirection: "column", + }, + }; + return ( ); } - -const styleSheet = { - 外枠: { - width: wp("80%"), - height: (wp("80%") / 20) * 9, - borderColor: "#0099CC", - borderWidth: 1, - backgroundColor: "white", - }, - 外枠B: { - width: wp("80%"), - height: (wp("80%") / 20) * 9, - borderWidth: 0, - }, - 下帯: { - position: "absolute", - bottom: "8%", - left: "0%", - width: "100%", - height: "27%", - backgroundColor: "#0099CC", - }, - 下帯B: { - position: "absolute", - bottom: "0%", - left: "0%", - width: "100%", - height: "26%", - backgroundColor: "#454545", - }, - JRStyle: { - position: "absolute", - top: "2%", - left: "2%", - fontWeight: "bold", - fontSize: parseInt("25%"), - color: "#0099CC", - }, - 下帯内容: { - position: "absolute", - bottom: "8%", - height: "27%", - width: "100%", - alignItems: "center", - flexDirection: "column", - }, - 下帯内容B: { - position: "absolute", - bottom: "0%", - height: "26%", - width: "100%", - alignItems: "center", - flexDirection: "column", - }, -}; diff --git a/menu.js b/menu.js index 3a222f1..1e9bd93 100644 --- a/menu.js +++ b/menu.js @@ -57,6 +57,9 @@ export default function Menu({ // AS.setItem("stationListMode", "position"); }); }, []); + useEffect(()=>{ + alert(`height:${height}, width:${width}, bottom:${bottom}, left:${left}, right:${right}, top:${top}, tabBarHeight:${tabBarHeight}`); + }, [height, width, bottom, left, right, top, tabBarHeight]) const mapsRef = useRef(null); const returnToTop = (bool = true) => { scrollRef.current.scrollTo({ From 2f65cd6a6f2a358826684ba53043be56b3e321d6 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 19 May 2025 06:21:08 +0000 Subject: [PATCH 29/36] =?UTF-8?q?=E5=AE=9A=E7=BE=A9=E5=BF=98=E3=82=8C?= =?UTF-8?q?=E3=83=90=E3=82=B0=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ActionSheetComponents/StationDeteilView.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/ActionSheetComponents/StationDeteilView.js b/components/ActionSheetComponents/StationDeteilView.js index 17ce175..1423b5b 100644 --- a/components/ActionSheetComponents/StationDeteilView.js +++ b/components/ActionSheetComponents/StationDeteilView.js @@ -2,18 +2,14 @@ import React, { useState, useEffect } from "react"; import { View, Linking, - Text, - TouchableOpacity, BackHandler, Platform, + useWindowDimensions, } from "react-native"; -import AutoHeightImage from "react-native-auto-height-image"; -import { FontAwesome, Foundation, Ionicons } from "@expo/vector-icons"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import ActionSheet, { SheetManager } from "react-native-actions-sheet"; import Sign from "../../components/駅名表/Sign"; -import { TicketBox } from "../atom/TicketBox"; import { getPDFViewURL } from "../../lib/getPdfViewURL"; import { useBusAndTrainData } from "../../stateBox/useBusAndTrainData"; import { AS } from "../../storageControl"; From 59082c78735905889a95da37adb5d73a9f94310c Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sat, 24 May 2025 06:29:17 +0000 Subject: [PATCH 30/36] =?UTF-8?q?=E5=B0=8F=E3=81=95=E3=81=AA=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StationDeteilView.js | 129 +++++++++--------- 1 file changed, 65 insertions(+), 64 deletions(-) diff --git a/components/ActionSheetComponents/StationDeteilView.js b/components/ActionSheetComponents/StationDeteilView.js index 1423b5b..a75c2e2 100644 --- a/components/ActionSheetComponents/StationDeteilView.js +++ b/components/ActionSheetComponents/StationDeteilView.js @@ -85,73 +85,74 @@ export const StationDeteilView = (props) => { {currentStation && ( - - { - usePDFView == "true" - ? Linking.openURL(currentStation[0].StationTimeTable) - : navigate("howto", { - info, + <> + + { + usePDFView == "true" + ? Linking.openURL(currentStation[0].StationTimeTable) + : navigate("howto", { + info, + goTo, + useShow, + }); + onExit(); + }} + oLP={() => + Linking.openURL(currentStation[0].StationTimeTable) + } + /> + + {currentStation[0].JrHpUrl && + currentStation[0].StationNumber != "M12" && ( + <駅構内図 //児島例外/ + navigate={navigate} + goTo={goTo} + useShow={useShow} + address={currentStation[0].JrHpUrl} + onExit={onExit} + /> + )} + + {!currentStation[0].JrHpUrl || ( + + )} + {!currentStation[0].StationTimeTable || ( + + )} + {!currentStation[0].StationMap || ( + + )} + {!trainBus || ( + { + navigate("howto", { + info: trainBus.address, goTo, useShow, }); - onExit(); - }} - oLP={() => Linking.openURL(currentStation[0].StationTimeTable)} - /> - - )} - {currentStation && - currentStation[0].JrHpUrl && - currentStation[0].StationNumber != "M12" && ( - <駅構内図 //児島例外/ - navigate={navigate} - goTo={goTo} - useShow={useShow} - address={currentStation[0].JrHpUrl} - onExit={onExit} - /> - )} - {currentStation && ( - - {!currentStation[0].JrHpUrl || ( - - )} - {!currentStation[0].StationTimeTable || ( - - )} - {!currentStation[0].StationMap || ( - - )} - {!trainBus || ( - { - navigate("howto", { - info: trainBus.address, - goTo, - useShow, - }); - onExit(); - }} - /> - )} - + onExit(); + }} + /> + )} + + )} From d6b701bdb13c5398520a0cfa2b5e2668aa6bb264 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Tue, 3 Jun 2025 13:37:04 +0000 Subject: [PATCH 31/36] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E8=A6=81?= =?UTF-8?q?=E7=B4=A0=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/menu.js b/menu.js index 1e9bd93..3a222f1 100644 --- a/menu.js +++ b/menu.js @@ -57,9 +57,6 @@ export default function Menu({ // AS.setItem("stationListMode", "position"); }); }, []); - useEffect(()=>{ - alert(`height:${height}, width:${width}, bottom:${bottom}, left:${left}, right:${right}, top:${top}, tabBarHeight:${tabBarHeight}`); - }, [height, width, bottom, left, right, top, tabBarHeight]) const mapsRef = useRef(null); const returnToTop = (bool = true) => { scrollRef.current.scrollTo({ From 0d595c7f67b194fa4184d6856ba3401f9fc79a13 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Tue, 10 Jun 2025 13:18:52 +0000 Subject: [PATCH 32/36] =?UTF-8?q?=E5=B0=8F=E4=BF=AE=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MenuPage.js | 2 +- components/発車時刻表/EachData.tsx | 2 +- menu.js | 24 ++++++++++-------------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/MenuPage.js b/MenuPage.js index a815a2e..de4f199 100644 --- a/MenuPage.js +++ b/MenuPage.js @@ -50,7 +50,7 @@ export function MenuPage() { }, []); const scrollRef = useRef(null); - const [mapMode, setMapMode] = useState(false); + const [mapMode, setMapMode] = useState(false); const [mapHeight, setMapHeight] = useState(0); useEffect(() => { const MapHeight = diff --git a/components/発車時刻表/EachData.tsx b/components/発車時刻表/EachData.tsx index eadce46..664fd8e 100644 --- a/components/発車時刻表/EachData.tsx +++ b/components/発車時刻表/EachData.tsx @@ -132,7 +132,7 @@ export const EachData: FC = (props) => { setIsDepartureNow(false); setIsShow(true); } - }, [d.time]); + }, [d.time,currentTrainData]); useInterval(()=>{ if (isDepartureNow) { setIsShow(!isShow); diff --git a/menu.js b/menu.js index 3a222f1..ffff6f5 100644 --- a/menu.js +++ b/menu.js @@ -34,13 +34,8 @@ configureReanimatedLogger({ level: ReanimatedLogLevel.error, // Set the log level to error strict: true, // Reanimated runs in strict mode by default }); -export default function Menu({ - scrollRef, - mapHeight, - MapFullHeight, - mapMode, - setMapMode, -}) { +export default function Menu(props) { + const { scrollRef, mapHeight, MapFullHeight, mapMode, setMapMode } = props; const { navigate, addListener, isFocused } = useNavigation(); const { favoriteStation } = useFavoriteStation(); const { originalStationList } = useStationList(); @@ -50,12 +45,12 @@ export default function Menu({ const [stationListMode, setStationListMode] = useState( /*<"position"|"favorite">*/ "position" ); - useEffect(()=>{ - AS.getItem("stationListMode").then((res) => { - setStationListMode(res); - }).catch((e) => { - // AS.setItem("stationListMode", "position"); - }); + useEffect(() => { + AS.getItem("stationListMode") + .then((res) => setStationListMode(res)) + .catch((e) => { + // AS.setItem("stationListMode", "position"); + }); }, []); const mapsRef = useRef(null); const returnToTop = (bool = true) => { @@ -141,7 +136,8 @@ export default function Menu({ let returnData = []; _stList.forEach((d, index, array) => { const stationName = d.Station_JP; - if (returnData.findIndex((d) => d[0].Station_JP == stationName) != -1) return; + if (returnData.findIndex((d) => d[0].Station_JP == stationName) != -1) + return; returnData.push(array.filter((d2) => d2.Station_JP == stationName)); }); setNearPositionStation(returnData); From 52ca9d03a82ea1ac7e95b20f648a8cdf3365b0ab Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Tue, 10 Jun 2025 13:59:38 +0000 Subject: [PATCH 33/36] =?UTF-8?q?=E8=B7=AF=E7=B7=9A=E3=82=92=E8=B7=A8?= =?UTF-8?q?=E3=81=90=E4=BD=8D=E7=BD=AE=E3=81=AB=E5=B1=85=E3=82=8B=E3=81=A8?= =?UTF-8?q?=E8=B7=AF=E7=B7=9A=E9=A0=86=E3=81=AB=E5=80=99=E8=A3=9C=E3=81=8C?= =?UTF-8?q?=E4=B8=A6=E3=82=93=E3=81=A7=E3=81=97=E3=81=BE=E3=81=86=E5=95=8F?= =?UTF-8?q?=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/menu.js b/menu.js index ffff6f5..2413050 100644 --- a/menu.js +++ b/menu.js @@ -140,6 +140,24 @@ export default function Menu(props) { return; returnData.push(array.filter((d2) => d2.Station_JP == stationName)); }); + //returnDataを距離の近い順にソート + returnData.sort((a, b) => { + const _calcDistance = (from, to) => { + let lat = Math.abs(from.lat - to.lat); + let lng = Math.abs(from.lng - to.lng); + return Math.sqrt(lat * lat + lng * lng); + }; + return ( + _calcDistance(a[0], { + lat: location.coords.latitude, + lng: location.coords.longitude, + }) - + _calcDistance(b[0], { + lat: location.coords.latitude, + lng: location.coords.longitude, + }) + ); + }); setNearPositionStation(returnData); } }; From c52cb1c91fc0b816278f31ea0d56d5d794a9ec7c Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Tue, 10 Jun 2025 14:08:41 +0000 Subject: [PATCH 34/36] =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E7=AF=84=E5=9B=B2?= =?UTF-8?q?=E3=82=92=E7=B8=AE=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu.js b/menu.js index 2413050..73a2ade 100644 --- a/menu.js +++ b/menu.js @@ -95,7 +95,7 @@ export default function Menu(props) { const makeCurrentStation = (location) => { if (!originalStationList) return () => {}; const findStationEachLine = (selectLine) => { - const searchArea = 0.12; + const searchArea = 0.055; //検索範囲 const _calcDistance = (from, to) => { let lat = Math.abs(from.lat - to.lat); let lng = Math.abs(from.lng - to.lng); From aefbf68401c271f1dcf79233b1d5a2484d776071 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Tue, 10 Jun 2025 14:17:23 +0000 Subject: [PATCH 35/36] =?UTF-8?q?LED=E3=82=92=E4=BB=A5=E5=89=8D=E3=81=AE?= =?UTF-8?q?=E4=BB=95=E6=A7=98=E3=81=AB=E6=88=BB=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/LED_vidion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index bc351d2..14502fd 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -98,7 +98,7 @@ export default function LED_vision(props) { if (!trainTimeAndNumber) return () => {}; if (!currentTrain) return () => {}; const data = trainTimeAndNumber - //.filter((d) => currentTrain.map((m) => m.num).includes(d.train)) + .filter((d) => currentTrain.map((m) => m.num).includes(d.train)) //現在の列車に絞る[ToDo] .filter(timeFiltering) .filter((d) => !!finalSwitch || d.lastStation != "当駅止"); setSelectedTrain(data); From af30d1cbb0ffac53805f28107b3564535219e541 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Tue, 10 Jun 2025 14:26:15 +0000 Subject: [PATCH 36/36] =?UTF-8?q?css=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Menu/Carousel/CarouselTypeChanger.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/Menu/Carousel/CarouselTypeChanger.tsx b/components/Menu/Carousel/CarouselTypeChanger.tsx index c2a0850..11f13af 100644 --- a/components/Menu/Carousel/CarouselTypeChanger.tsx +++ b/components/Menu/Carousel/CarouselTypeChanger.tsx @@ -34,15 +34,15 @@ export const CarouselTypeChanger = ({ { returnToDefaultMode();