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] =?UTF-8?q?=E5=8D=98=E7=99=BA=E3=81=AE=E5=A4=89=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: () => {}, };