From 72412e87e887a1cbcf3987927c16fc9cb9e36949 Mon Sep 17 00:00:00 2001 From: harukin-OneMix4 Date: Mon, 12 Feb 2024 00:51:47 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=A8=E3=82=8A=E3=81=82=E3=81=88=E3=81=9A?= =?UTF-8?q?=E3=81=93=E3=82=8C=E3=81=A7=E3=83=93=E3=83=AB=E3=83=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Apps.js | 3 - .../ActionSheetComponents/EachTrainInfo.js | 324 ++++++++++++------ .../EachTrainInfo/LandscapeTrainInfo.js | 47 +++ .../EachTrainInfo/TrainDataView.js | 14 +- 4 files changed, 282 insertions(+), 106 deletions(-) create mode 100644 components/ActionSheetComponents/EachTrainInfo/LandscapeTrainInfo.js diff --git a/Apps.js b/Apps.js index 1df2b4a..2e3e09d 100644 --- a/Apps.js +++ b/Apps.js @@ -32,9 +32,6 @@ export default function Apps({ navigation, webview, stationData }) { const [isLandscape, setIsLandscape] = useState(false); //画面が横向きかどうか const handleLayout = () => {}; useEffect(() => { - console.log("レイアウト変更"); - console.log(height, width); - console.log(height / width); if (height / width > 1.5) { setIsLandscape(false); } diff --git a/components/ActionSheetComponents/EachTrainInfo.js b/components/ActionSheetComponents/EachTrainInfo.js index c508f9c..d3f5368 100644 --- a/components/ActionSheetComponents/EachTrainInfo.js +++ b/components/ActionSheetComponents/EachTrainInfo.js @@ -6,9 +6,13 @@ import { TouchableOpacity, Platform, StyleSheet, + useWindowDimensions, } from "react-native"; import { Ionicons } from "@expo/vector-icons"; -import ActionSheet, { SheetManager } from "react-native-actions-sheet"; +import ActionSheet, { + SheetManager, + useScrollHandlers, +} from "react-native-actions-sheet"; import { AS } from "../../storageControl"; import trainList from "../../assets/originData/trainList"; import { lineList } from "../../lib/getStationList"; @@ -24,6 +28,7 @@ import { DynamicHeaderScrollView } from "../DynamicHeaderScrollView"; import { LongHeader } from "./EachTrainInfo/LongHeader"; import { ShortHeader } from "./EachTrainInfo/ShortHeader"; import { ScrollStickyContent } from "./EachTrainInfo/ScrollStickyContent"; +import { LandscapeTrainInfo } from "./EachTrainInfo/LandscapeTrainInfo"; export const EachTrainInfo = (props) => { if (!props.payload) return <>; @@ -47,6 +52,16 @@ export const EachTrainInfo = (props) => { const [isConcatNear, setIsConcatNear] = useState(false); const [tailStation, setTailStation] = useState(); const [headStation, setHeadStation] = useState(); + const { height, width } = useWindowDimensions(); + const [isLandscape, setIsLandscape] = useState(false); + useEffect(() => { + if (height / width > 1.5) { + setIsLandscape(false); + } + if (height / width < 1.5) { + setIsLandscape(true); + } + }, [width, height]); // const [actionSheetHorizonalScroll, setActionSheetHorizonalScroll] = useState(false); //裏列車探索 @@ -376,6 +391,7 @@ export const EachTrainInfo = (props) => { .replace("ライナーライナー", "ライナー"); }; const actionSheetRef = useRef(null); + const scrollHandlers = useScrollHandlers("scrollview-1", actionSheetRef); return ( { ref={actionSheetRef} drawUnderStatusBar={false} isModal={Platform.OS == "ios"} + //useBottomSafeAreaPadding={Platform.OS == "android"} > { /> )} - - ) : ( - - ) - } - longHeader={ - from == "AllTrainDiagramView" ? ( - <> - ) : ( - - ) - } - topStickyContent={ - - } - > - {headStation && !isConcatNear && ( - openBackTrainInfo(headStation)} - style={{ - padding: 10, - flexDirection: "row", - borderColor: "blue", - borderWidth: 1, - margin: 10, - borderRadius: 5, - alignItems: "center", - }} - > - + ) : ( + + ) + } + topStickyContent={ + + } + > + {headStation && !isConcatNear && ( + openBackTrainInfo(headStation)} + style={{ + padding: 10, + flexDirection: "row", + borderColor: "blue", + borderWidth: 1, + margin: 10, + borderRadius: 5, + alignItems: "center", + }} > - 「本当の始発駅」を表示 - - - )} - {/* + 「本当の始発駅」を表示 + + + )} + {/* { /> ほげほげふがふが */} - {trainData.map((i, index) => - i.split(",")[1] == "提" ? ( - - ) : ( - - ) - )} - {tailStation && !isConcatNear && ( - openBackTrainInfo(tailStation)} - style={{ - padding: 10, - flexDirection: "row", - borderColor: "blue", - borderWidth: 1, - margin: 10, - borderRadius: 5, - alignItems: "center", - }} - > - + i.split(",")[1] == "提" ? ( + + ) : ( + + ) + )} + {tailStation && !isConcatNear && ( + openBackTrainInfo(tailStation)} + style={{ + padding: 10, + flexDirection: "row", + borderColor: "blue", + borderWidth: 1, + margin: 10, + borderRadius: 5, + alignItems: "center", + }} > - 「本当の終着駅」を表示 - - - )} + + 「本当の終着駅」を表示 + + + )} - - - - + + + + + - - + + ) : ( + + ) : ( + + ) + } + longHeader={ + from == "AllTrainDiagramView" ? ( + <> + ) : ( + + ) + } + topStickyContent={ + + } + > + {headStation && !isConcatNear && ( + openBackTrainInfo(headStation)} + style={{ + padding: 10, + flexDirection: "row", + borderColor: "blue", + borderWidth: 1, + margin: 10, + borderRadius: 5, + alignItems: "center", + }} + > + + 「本当の始発駅」を表示 + + + )} + {/* + ほげほげふがふが */} + + {trainData.map((i, index) => + i.split(",")[1] == "提" ? ( + + ) : ( + + ) + )} + {tailStation && !isConcatNear && ( + openBackTrainInfo(tailStation)} + style={{ + padding: 10, + flexDirection: "row", + borderColor: "blue", + borderWidth: 1, + margin: 10, + borderRadius: 5, + alignItems: "center", + }} + > + + 「本当の終着駅」を表示 + + + )} + + + + + + + + + )} ); diff --git a/components/ActionSheetComponents/EachTrainInfo/LandscapeTrainInfo.js b/components/ActionSheetComponents/EachTrainInfo/LandscapeTrainInfo.js new file mode 100644 index 0000000..8538b65 --- /dev/null +++ b/components/ActionSheetComponents/EachTrainInfo/LandscapeTrainInfo.js @@ -0,0 +1,47 @@ +import React from "react"; +import { View, Text, ScrollView, useWindowDimensions } from "react-native"; + +export const LandscapeTrainInfo = (props) => { + const { leftContent, topStickyContent, children, scrollHandlers } = props; + const { height, width } = useWindowDimensions(); + return ( + + + {width / 2} + {leftContent} + + { + console.log(d.nativeEvent.contentOffset.y); + }} + > + + + {topStickyContent} + + {children} + + + ); +}; diff --git a/components/ActionSheetComponents/EachTrainInfo/TrainDataView.js b/components/ActionSheetComponents/EachTrainInfo/TrainDataView.js index 449786c..6ac2eb7 100644 --- a/components/ActionSheetComponents/EachTrainInfo/TrainDataView.js +++ b/components/ActionSheetComponents/EachTrainInfo/TrainDataView.js @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect, useState } from "react"; import { View, Text, @@ -18,14 +18,24 @@ export const TrainDataView = ({ openTrainInfo, mode = 0, }) => { + const [isLandscape, setIsLandscape] = useState(false); const { width, height } = useWindowDimensions(); + useEffect(() => { + if (height / width > 1.5) { + setIsLandscape(false); + } + if (height / width < 1.5) { + setIsLandscape(true); + } + }, [width, height]); + return (