From 369ae557c762da992601a62bcf439baf9f2c413f Mon Sep 17 00:00:00 2001 From: harukin-DeskMini Date: Sun, 5 Feb 2023 17:07:57 +0900 Subject: [PATCH] =?UTF-8?q?=E9=A7=85=E3=83=AA=E3=82=B9=E3=83=88=E3=81=AE?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E3=81=AB=E6=83=85=E5=A0=B1=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0/DetailView=E5=81=B4=E3=81=AB=E8=B7=AF=E7=B7=9A?= =?UTF-8?q?=E6=A6=82=E8=A6=81=E8=A1=A8=E7=A4=BA=E6=A9=9F=E8=83=BD=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StationDeteilView.js | 240 +++++++++++++++++- components/駅名表/Sign.js | 18 +- lib/getStationList.js | 81 +++--- 3 files changed, 289 insertions(+), 50 deletions(-) diff --git a/components/ActionSheetComponents/StationDeteilView.js b/components/ActionSheetComponents/StationDeteilView.js index 3b1b05c..ec03f35 100644 --- a/components/ActionSheetComponents/StationDeteilView.js +++ b/components/ActionSheetComponents/StationDeteilView.js @@ -1,8 +1,17 @@ -import React from "react"; -import { View, Linking } from "react-native"; +import React, { useState, useEffect } from "react"; +import { + StatusBar, + View, + LayoutAnimation, + ScrollView, + Linking, + Text, + TouchableOpacity, +} from "react-native"; import { FontAwesome, Foundation, Ionicons } from "@expo/vector-icons"; import ActionSheet from "react-native-actions-sheet"; import Sign from "../../components/駅名表/Sign"; +import { useInterval } from "../../lib/useInterval"; import { TicketBox } from "../atom/TicketBox"; import { @@ -63,6 +72,15 @@ export const StationDeteilView = (props) => { /> )} + {currentStation && + currentStation.map((d) => ( + + ))} {currentStation && ( {!currentStation[0].JrHpUrl || ( @@ -108,3 +126,221 @@ export const StationDeteilView = (props) => { ); }; + +const StationName = (props) => { + const { stringData, ss } = props; + return ( + + {stringData.Station_JP} + {stringData.Station_EN} + + ); +}; + +const NexPreStationLine = ({ + currentStation, + originalStationList, + oP, + favoriteStation, + setFavoriteStation, +}) => { + const [preStation, setPreStation] = useState(); + const [nexStation, setNexStation] = useState(); + const [lineName, setLineName] = useState(); + + useEffect(() => { + getPreNextStation(currentStation); + }, [currentStation]); + + useEffect(() => { + if (!currentStation) return () => {}; + getPreNextStation(currentStation); + }, []); + const getPreNextStation = (now) => { + const lineList = [ + "予讃線(高松-松山間)[Y]", + "予讃線(松山-宇和島間)[U]", + "予讃線/愛ある伊予灘線(向井原-伊予大洲間)[S]", + "土讃線(多度津-高知間)[D]", + "土讃線(高知-窪川間)[K]", + "高徳線(高松-徳島間)[T]", + "徳島線(徳島-阿波池田)[B]", + "鳴門線(池谷-鳴門間)[N]", + "瀬戸大橋線(宇多津-児島間)[M]", + ]; + let returnData; + lineList.forEach((d) => { + let cache = originalStationList[d].findIndex( + (data) => data.StationNumber == now.StationNumber + ); + if (cache != -1) { + returnData = [ + originalStationList[d][cache - 1], + originalStationList[d][cache + 1], + d, + ]; + } + }); + setPreStation(returnData[0]); + setNexStation(returnData[1]); + setLineName(returnData[2]); + }; + return ( + + + {preStation ? ( + <> + + {preStation.StationNumber ? ( + + + + {preStation.StationNumber} + + + + ) : ( + <> + )} + + + ) : ( + <> + )} + + + + {lineName && + lineName + .split("(") + .map((d, index) => (index == 1 ? "(" + d : d)) + .join("\n")} + + + {nexStation ? ( + <> + + {nexStation.StationNumber ? ( + + + + {nexStation.StationNumber} + + + + ) : ( + <> + )} + + + ) : ( + <> + )} + + + ); +}; + +const styleSheet = { + 外枠: { + width: wp("80%"), + height: (wp("80%") / 20) * 9, + borderColor: "#2E94BB", + borderWidth: 1, + backgroundColor: "white", + }, + 下帯: { + position: "absolute", + bottom: "0%", + left: "0%", + width: "100%", + height: "30%", + backgroundColor: "#2E94BB", + }, + JRStyle: { + position: "absolute", + top: "2%", + left: "2%", + fontWeight: "bold", + fontSize: parseInt("30%"), + color: "#2E94BB", + }, + stationNameAreaOverWrap: { + position: "absolute", + top: "10%", + alignContent: "center", + flexDirection: "row", + }, + Station_JP: { + fontWeight: "bold", + fontSize: parseInt("40%"), + color: "#005170", + }, + Station_EN: { + fontWeight: "bold", + fontSize: parseInt("15%"), + color: "#005170", + }, + 下帯内容: { + position: "absolute", + bottom: "0%", + height: "30%", + width: "100%", + alignItems: "center", + flexDirection: "column", + }, + 下枠フレーム: { + flex: 1, + flexDirection: "row", + alignContent: "center", + }, + 下枠左右マーク: { + fontWeight: "bold", + fontSize: parseInt("20%"), + color: "white", + paddingHorizontal: 10, + textAlignVertical: "center", + }, + 下枠駅ナンバー: { + alignContent: "center", + alignItems: "center", + width: wp("8%"), + height: wp("8%"), + margin: wp("1%"), + borderColor: "white", + borderWidth: parseInt("2%"), + borderRadius: parseInt("100%"), + }, + 下枠駅名: { + fontWeight: "bold", + fontSize: parseInt("15%"), + color: "white", + flex: 1, + textAlignVertical: "center", + }, +}; diff --git a/components/駅名表/Sign.js b/components/駅名表/Sign.js index 71f7ae7..af44437 100644 --- a/components/駅名表/Sign.js +++ b/components/駅名表/Sign.js @@ -65,15 +65,15 @@ export default function Sign(props) { }, [nexPrePosition]); const getPreNextStation = (now) => { const lineList = [ - "予讃線", - "松宇線", - "伊予灘線", - "土讃線", - "窪川線", - "高徳線", - "徳島線", - "鳴門線", - "瀬戸大橋線", + "予讃線(高松-松山間)[Y]", + "予讃線(松山-宇和島間)[U]", + "予讃線/愛ある伊予灘線(向井原-伊予大洲間)[S]", + "土讃線(多度津-高知間)[D]", + "土讃線(高知-窪川間)[K]", + "高徳線(高松-徳島間)[T]", + "徳島線(徳島-阿波池田)[B]", + "鳴門線(池谷-鳴門間)[N]", + "瀬戸大橋線(宇多津-児島間)[M]", ]; let returnData; lineList.forEach((d) => { diff --git a/lib/getStationList.js b/lib/getStationList.js index d2a4280..077751b 100644 --- a/lib/getStationList.js +++ b/lib/getStationList.js @@ -19,15 +19,15 @@ import train_lang from "../assets/originData/train_lang"; let status = undefined; export const lineList = [ - "予讃線", - "松宇線", - "伊予灘線", - "土讃線", - "窪川線", - "高徳線", - "徳島線", - "鳴門線", - "瀬戸大橋線", + "予讃線(高松-松山間)[Y]", + "予讃線(松山-宇和島間)[U]", + "予讃線/愛ある伊予灘線(向井原-伊予大洲間)[S]", + "土讃線(多度津-高知間)[D]", + "土讃線(高知-窪川間)[K]", + "高徳線(高松-徳島間)[T]", + "徳島線(徳島-阿波池田)[B]", + "鳴門線(池谷-鳴門間)[N]", + "瀬戸大橋線(宇多津-児島間)[M]", ]; export const getStationList = async (props) => { @@ -53,15 +53,15 @@ export const getStationList = async (props) => { ]).then((values) => { let stationList = {}; [ - stationList.予讃線, - stationList.松宇線, - stationList.伊予灘線, - stationList.土讃線, - stationList.窪川線, - stationList.高徳線, - stationList.徳島線, - stationList.鳴門線, - stationList.瀬戸大橋線, + stationList["予讃線(高松-松山間)[Y]"], + stationList["予讃線(松山-宇和島間)[U]"], + stationList["予讃線/愛ある伊予灘線(向井原-伊予大洲間)[S]"], + stationList["土讃線(多度津-高知間)[D]"], + stationList["土讃線(高知-窪川間)[K]"], + stationList["高徳線(高松-徳島間)[T]"], + stationList["徳島線(徳島-阿波池田)[B]"], + stationList["鳴門線(池谷-鳴門間)[N]"], + stationList["瀬戸大橋線(宇多津-児島間)[M]"], stationList.駅間リスト, stationList.日英対応表, ] = values; @@ -115,52 +115,55 @@ export const getStationList = async (props) => { return data; }); }; - stationList.予讃線 = addStationPosition( - concatBetweenStations(stationList.予讃線), + stationList["予讃線(高松-松山間)[Y]"] = addStationPosition( + concatBetweenStations(stationList["予讃線(高松-松山間)[Y]"]), 予讃線, stationList.日英対応表 ); - stationList.松宇線 = addStationPosition( - concatBetweenStations(stationList.松宇線), + stationList["予讃線(松山-宇和島間)[U]"] = addStationPosition( + concatBetweenStations(stationList["予讃線(松山-宇和島間)[U]"]), 予讃線, stationList.日英対応表 ); - stationList.伊予灘線 = addStationPosition( - concatBetweenStations(stationList.伊予灘線), - 予讃線, - stationList.日英対応表 - ); - stationList.土讃線 = addStationPosition( - concatBetweenStations(stationList.土讃線), + stationList["予讃線/愛ある伊予灘線(向井原-伊予大洲間)[S]"] = + addStationPosition( + concatBetweenStations( + stationList["予讃線/愛ある伊予灘線(向井原-伊予大洲間)[S]"] + ), + 予讃線, + stationList.日英対応表 + ); + stationList["土讃線(多度津-高知間)[D]"] = addStationPosition( + concatBetweenStations(stationList["土讃線(多度津-高知間)[D]"]), 土讃線, stationList.日英対応表 ); - stationList.窪川線 = addStationPosition( - concatBetweenStations(stationList.窪川線), + stationList["土讃線(高知-窪川間)[K]"] = addStationPosition( + concatBetweenStations(stationList["土讃線(高知-窪川間)[K]"]), 土讃線, stationList.日英対応表 ); - stationList.高徳線 = addStationPosition( - concatBetweenStations(stationList.高徳線), + stationList["高徳線(高松-徳島間)[T]"] = addStationPosition( + concatBetweenStations(stationList["高徳線(高松-徳島間)[T]"]), 高徳線, stationList.日英対応表 ); - stationList.鳴門線 = addStationPosition( - concatBetweenStations(stationList.鳴門線), + stationList["鳴門線(池谷-鳴門間)[N]"] = addStationPosition( + concatBetweenStations(stationList["鳴門線(池谷-鳴門間)[N]"]), 鳴門線, stationList.日英対応表 ); const tokushimaCurrent = addStationPosition( - concatBetweenStations(stationList.徳島線), + concatBetweenStations(stationList["徳島線(徳島-阿波池田)[B]"]), 徳島線, stationList.日英対応表 ); - stationList.徳島線 = [ + stationList["徳島線(徳島-阿波池田)[B]"] = [ tokushimaCurrent[tokushimaCurrent.length - 1], ...tokushimaCurrent, ]; - stationList.徳島線.pop(); - stationList.瀬戸大橋線 = [ + stationList["徳島線(徳島-阿波池田)[B]"].pop(); + stationList["瀬戸大橋線(宇多津-児島間)[M]"] = [ { Station_JP: "坂出", Station_EN: "Sakaide",