From cf025d3add4c3306d4f0d68ce737fb8326261861 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Fri, 11 Apr 2025 15:35:25 +0000 Subject: [PATCH] =?UTF-8?q?=E7=8F=BE=E5=9C=A8=E5=9C=B0=E3=83=99=E3=83=BC?= =?UTF-8?q?=E3=82=B9=E3=81=AE=E3=83=9C=E3=82=BF=E3=83=B3=E3=81=A8=E3=81=8B?= =?UTF-8?q?=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) => (