From 1a2d678ef3011f913df66f364b00f95140213ae6 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Thu, 3 Apr 2025 09:15:42 +0000 Subject: [PATCH 1/2] =?UTF-8?q?StationDeteilView=E3=81=AE=E9=A0=85?= =?UTF-8?q?=E7=9B=AE=E5=88=86=E9=9B=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StationDeteilView.js | 188 ++++-------------- .../StationInsideMapButton.tsx | 43 ++++ .../StationDeteilView/StationMapButton.tsx | 16 ++ .../StationTimeTableButton.tsx | 32 +++ .../StationDeteilView/TrainBusButton.tsx | 21 ++ .../StationDeteilView/WebSiteButton.tsx | 28 +++ 6 files changed, 175 insertions(+), 153 deletions(-) create mode 100644 components/ActionSheetComponents/StationDeteilView/StationInsideMapButton.tsx create mode 100644 components/ActionSheetComponents/StationDeteilView/StationMapButton.tsx create mode 100644 components/ActionSheetComponents/StationDeteilView/StationTimeTableButton.tsx create mode 100644 components/ActionSheetComponents/StationDeteilView/TrainBusButton.tsx create mode 100644 components/ActionSheetComponents/StationDeteilView/WebSiteButton.tsx diff --git a/components/ActionSheetComponents/StationDeteilView.js b/components/ActionSheetComponents/StationDeteilView.js index baa6610..fea49f6 100644 --- a/components/ActionSheetComponents/StationDeteilView.js +++ b/components/ActionSheetComponents/StationDeteilView.js @@ -18,16 +18,15 @@ import { widthPercentageToDP as wp } from "react-native-responsive-screen"; import { getPDFViewURL } from "../../lib/getPdfViewURL"; import { useBusAndTrainData } from "../../stateBox/useBusAndTrainData"; import { AS } from "../../storageControl"; +import { StationMapButton } from "./StationDeteilView/StationMapButton"; +import { TrainBusButton } from "./StationDeteilView/TrainBusButton"; +import { 駅構内図 } from "./StationDeteilView/StationInsideMapButton"; +import { WebSiteButton } from "./StationDeteilView/WebSiteButton"; +import { StationTimeTableButton } from "./StationDeteilView/StationTimeTableButton"; export const StationDeteilView = (props) => { if (!props.payload) return <>; - const { - currentStation, - navigate, - onExit, - goTo, - useShow, - } = props.payload; + const { currentStation, navigate, onExit, goTo, useShow } = props.payload; const { busAndTrainData } = useBusAndTrainData(); const [trainBus, setTrainBus] = useState(); @@ -90,12 +89,7 @@ export const StationDeteilView = (props) => { {currentStation && ( - + { @@ -115,102 +109,51 @@ export const StationDeteilView = (props) => { {currentStation && currentStation[0].JrHpUrl && currentStation[0].StationNumber != "M12" && ( - <駅構内図 //高松/阿波池田&後免&須崎kounai.png児島例外/ - oP={() => { - navigate("howto", { - info: - currentStation[0].JrHpUrl.replace("/index.html", "/") + - "/kounai_map.html", - goTo, - useShow, - }); - onExit(); - }} - oLP={() => { - Linking.openURL( - currentStation[0].JrHpUrl.replace("/index.html", "/") + - "/kounai_map.html" - ); - }} - uri={currentStation[0].JrHpUrl.replace("/index.html", "/")} + <駅構内図 //児島例外/ + navigate={navigate} + goTo={goTo} + useShow={useShow} + address={currentStation[0].JrHpUrl} + onExit={onExit} /> )} {currentStation && ( {!currentStation[0].JrHpUrl || ( - } - flex={1} - onPressButton={() => { - navigate("howto", { - info: currentStation[0].JrHpUrl, - - goTo, - useShow, - }); - onExit(); - }} - onLongPressButton={() => - Linking.openURL(currentStation[0].JrHpUrl) - } - > - web - + )} {!currentStation[0].StationTimeTable || ( - } - flex={1} - onPressButton={() => { - usePDFView == "true" - ? Linking.openURL(currentStation[0].StationTimeTable) - : navigate("howto", { - info, - - goTo, - useShow, - }); - onExit(); - }} - onLongPressButton={() => - Linking.openURL(currentStation[0].StationTimeTable) - } - > - 時刻表 - + )} {!currentStation[0].StationMap || ( - } - flex={1} - onPressButton={() => - Linking.openURL(currentStation[0].StationMap) - } - > - Map - + )} {!trainBus || ( - } - flex={1} - onPressButton={() => { + { navigate("howto", { info: trainBus.address, - goTo, useShow, }); onExit(); }} - onLongPressButton={() => Linking.openURL(trainBus.address)} - > - 並行バス - + /> )} )} @@ -220,67 +163,6 @@ export const StationDeteilView = (props) => { ); }; - -const 駅構内図 = (props) => { - const [open, setOpen] = useState(false); - return ( - <> - setOpen(!open)} - > - - - {open ? "駅構内図を非表示" : "駅構内図を表示"} - - - - - {open && ( - <> - - - - - - )} - - - ); -}; - const Handler = () => { useEffect(() => { const backAction = () => { @@ -294,4 +176,4 @@ const Handler = () => { return () => backHandler.remove(); }, []); return <>; -}; \ No newline at end of file +}; diff --git a/components/ActionSheetComponents/StationDeteilView/StationInsideMapButton.tsx b/components/ActionSheetComponents/StationDeteilView/StationInsideMapButton.tsx new file mode 100644 index 0000000..19cc47a --- /dev/null +++ b/components/ActionSheetComponents/StationDeteilView/StationInsideMapButton.tsx @@ -0,0 +1,43 @@ +import { FC } from "react"; +import { TouchableOpacity, View, Text, Linking } from "react-native"; +type Props = { + navigate: (screen: string, params: { info: string; goTo: string; useShow: boolean }) => void; + address: string; + goTo: string; + useShow: boolean; + onExit: () => void; +}; +export const 駅構内図:FC = (props) => { + const { navigate, address, goTo, useShow, onExit } = props; + const info = address.replace("/index.html", "/") + "/kounai_map.html"; + return ( + { + navigate("howto", { info, goTo, useShow }); + onExit(); + }} + onLongPress={() => Linking.openURL(info)} + > + + + 駅構内図を表示 + + + + ); +}; diff --git a/components/ActionSheetComponents/StationDeteilView/StationMapButton.tsx b/components/ActionSheetComponents/StationDeteilView/StationMapButton.tsx new file mode 100644 index 0000000..09c6c33 --- /dev/null +++ b/components/ActionSheetComponents/StationDeteilView/StationMapButton.tsx @@ -0,0 +1,16 @@ +import React from "react"; +import { Linking } from "react-native"; +import { Ionicons } from "@expo/vector-icons"; +import { TicketBox } from "@/components/atom/TicketBox"; +export const StationMapButton = ({stationMap}) => { + return ( + } + flex={1} + onPressButton={() => Linking.openURL(stationMap)} + > + Map + + ); +}; diff --git a/components/ActionSheetComponents/StationDeteilView/StationTimeTableButton.tsx b/components/ActionSheetComponents/StationDeteilView/StationTimeTableButton.tsx new file mode 100644 index 0000000..6eae7f3 --- /dev/null +++ b/components/ActionSheetComponents/StationDeteilView/StationTimeTableButton.tsx @@ -0,0 +1,32 @@ +import React, { FC } from "react"; +import { Linking } from "react-native"; +import { FontAwesome } from "@expo/vector-icons"; +import { TicketBox } from "@/components/atom/TicketBox"; +type Props = { + info: string; + address: string; + usePDFView: string; + navigate: (screen: string, params?: object) => void; + onExit: () => void; + goTo: string; + useShow: string; +}; +export const StationTimeTableButton: FC = (props) => { + const { info, address, usePDFView, navigate, onExit, goTo, useShow } = props; + return ( + } + flex={1} + onPressButton={() => { + usePDFView == "true" + ? Linking.openURL(address) + : navigate("howto", { info, goTo, useShow }); + onExit(); + }} + onLongPressButton={() => Linking.openURL(address)} + > + 時刻表 + + ); +}; diff --git a/components/ActionSheetComponents/StationDeteilView/TrainBusButton.tsx b/components/ActionSheetComponents/StationDeteilView/TrainBusButton.tsx new file mode 100644 index 0000000..eb1851d --- /dev/null +++ b/components/ActionSheetComponents/StationDeteilView/TrainBusButton.tsx @@ -0,0 +1,21 @@ +import React, { FC } from "react"; +import { Linking } from "react-native"; +import { Ionicons } from "@expo/vector-icons"; +import { TicketBox } from "@/components/atom/TicketBox"; +type Props = { + address: string; + press: () => void; +}; +export const TrainBusButton: FC = ({ address, press }) => { + return ( + } + flex={1} + onPressButton={press} + onLongPressButton={() => Linking.openURL(address)} + > + 並行バス + + ); +}; diff --git a/components/ActionSheetComponents/StationDeteilView/WebSiteButton.tsx b/components/ActionSheetComponents/StationDeteilView/WebSiteButton.tsx new file mode 100644 index 0000000..73b715c --- /dev/null +++ b/components/ActionSheetComponents/StationDeteilView/WebSiteButton.tsx @@ -0,0 +1,28 @@ +import React, { FC } from "react"; +import { Linking } from "react-native"; +import { Foundation } from "@expo/vector-icons"; +import { TicketBox } from "@/components/atom/TicketBox"; +type Props = { + navigate: (screen: string, params: any) => void; + info: string; + goTo: string; + useShow: string; + onExit: () => void; +}; +export const WebSiteButton: FC = (Props) => { + const { navigate, info, goTo, useShow, onExit } = Props; + return ( + } + flex={1} + onPressButton={() => { + navigate("howto", { info, goTo, useShow }); + onExit(); + }} + onLongPressButton={() => Linking.openURL(info)} + > + web + + ); +}; From c9af861e714d94168dc99850b5e95c48127303ca Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Fri, 4 Apr 2025 14:41:03 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EachTrainInfoCore.js | 33 ++----------------- .../StationDeteilView.js | 6 ++-- 2 files changed, 5 insertions(+), 34 deletions(-) diff --git a/components/ActionSheetComponents/EachTrainInfoCore.js b/components/ActionSheetComponents/EachTrainInfoCore.js index 0933429..d837113 100644 --- a/components/ActionSheetComponents/EachTrainInfoCore.js +++ b/components/ActionSheetComponents/EachTrainInfoCore.js @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo, useRef, useState } from "react"; +import React, { useEffect, useState } from "react"; import { View, Text, @@ -28,8 +28,6 @@ import { ShortHeader } from "./EachTrainInfo/ShortHeader"; import { ScrollStickyContent } from "./EachTrainInfo/ScrollStickyContent"; import { getStationID } from "../../lib/eachTrainInfoCoreLib/getStationData"; import { findReversalPoints } from "../../lib/eachTrainInfoCoreLib/findReversalPoints"; -import { migrateTrainName } from "../../lib/eachTrainInfoCoreLib/migrateTrainName"; -import { getType } from "../../lib/eachTrainInfoCoreLib/getType"; import { searchSpecialTrain } from "../../lib/eachTrainInfoCoreLib/searchSpecialTrain"; import { openBackTrainInfo } from "../../lib/eachTrainInfoCoreLib/openBackTrainInfo"; import { ShowSpecialTrain } from "./EachTrainInfo/ShowSpecialTrain"; @@ -45,14 +43,11 @@ export const EachTrainInfoCore = ({ from, navigate, }) => { - // const [actionSheetHorizonalScroll, setActionSheetHorizonalScroll] = useState(false); const { currentTrain } = useCurrentTrain(); const { originalStationList, stationList } = useStationList(); const { setTrainInfo } = useTrainMenu(); const [currentTrainData, setCurrentTrainData] = useState(); - // const [actionSheetHorizonalScroll, setActionSheetHorizonalScroll] = useState(false); - useEffect(() => { if (!currentTrain.length) return; setCurrentTrainData( @@ -196,29 +191,6 @@ export const EachTrainInfoCore = ({ } setIsJumped(true); }, [points]); - const trainName = useMemo(() => { - if (!data.limited) return ""; - const limitedArray = data.limited.split(":"); - const type = getType(limitedArray[0]); - - switch (true) { - case !!limitedArray[1]: - // 特急の場合は、列車名を取得 - return type + migrateTrainName(limitedArray[1]); - case trainData.length == 0: - // 特急以外の場合は、列車番号を取得 - return type; - default: - // 行先がある場合は、行先を取得 - return ( - type + - migrateTrainName( - trainData[trainData.length - 1].split(",")[0] + "行き" - ) - ); - } - }, [data.limited, trainData]); - const { height } = useWindowDimensions(); const { isLandscape } = useDeviceOrientationChange(); const scrollHandlers = actionSheetRef @@ -326,8 +298,7 @@ export const EachTrainInfoCore = ({ }); const currentPos = currentPosID.filter((d) => d != false)[0]; if (currentPos) { - if (direction == 0) setCurrentPosition(currentPos.reverse()); - else setCurrentPosition(currentPos); + setCurrentPosition(direction == 0 ? currentPos.reverse() : currentPos); } else if (direction == 0) { setCurrentPosition([ getStationID(pos[1], stationList), diff --git a/components/ActionSheetComponents/StationDeteilView.js b/components/ActionSheetComponents/StationDeteilView.js index fea49f6..48d67a3 100644 --- a/components/ActionSheetComponents/StationDeteilView.js +++ b/components/ActionSheetComponents/StationDeteilView.js @@ -32,9 +32,9 @@ export const StationDeteilView = (props) => { useEffect(() => { if (!currentStation) return () => {}; - const data = busAndTrainData.filter((d) => { - return d.name === currentStation[0].Station_JP; - }); + const data = busAndTrainData.filter((d) => + d.name === currentStation[0].Station_JP + ); if (data.length == 0) { setTrainBus(); }