From 1fb471205c30dc71e59506f01afc002ee81bcef4 Mon Sep 17 00:00:00 2001 From: harukin-OneMix4 Date: Sun, 11 Feb 2024 20:38:28 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=83=86=E3=83=B3=E3=83=84?= =?UTF-8?q?=E5=88=86=E5=89=B2=E3=80=81=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ActionSheetComponents/EachTrainInfo.js | 120 +++--------------- .../EachTrainInfo/LongHeader.js | 33 +++++ .../EachTrainInfo/ScrollStickyContent.js | 57 +++++++++ .../EachTrainInfo/ShortHeader.js | 35 +++++ components/DynamicHeaderScrollView.js | 30 ++--- 5 files changed, 157 insertions(+), 118 deletions(-) create mode 100644 components/ActionSheetComponents/EachTrainInfo/LongHeader.js create mode 100644 components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js create mode 100644 components/ActionSheetComponents/EachTrainInfo/ShortHeader.js diff --git a/components/ActionSheetComponents/EachTrainInfo.js b/components/ActionSheetComponents/EachTrainInfo.js index 8e4aea4..c508f9c 100644 --- a/components/ActionSheetComponents/EachTrainInfo.js +++ b/components/ActionSheetComponents/EachTrainInfo.js @@ -2,18 +2,13 @@ import React, { useEffect, useState, useRef } from "react"; import { View, LayoutAnimation, - ScrollView, Text, TouchableOpacity, Platform, - Animated, StyleSheet, } from "react-native"; import { Ionicons } from "@expo/vector-icons"; -import ActionSheet, { - SheetManager, - useScrollHandlers, -} from "react-native-actions-sheet"; +import ActionSheet, { SheetManager } from "react-native-actions-sheet"; import { AS } from "../../storageControl"; import trainList from "../../assets/originData/trainList"; import { lineList } from "../../lib/getStationList"; @@ -25,8 +20,10 @@ import { customTrainDataDetector } from "../custom-train-data"; import { useBusAndTrainData } from "../../stateBox/useBusAndTrainData"; import { EachStopList } from "./EachTrainInfo/EachStopList"; import { DataFromButton } from "./EachTrainInfo/DataFromButton"; -import { TrainDataView } from "./EachTrainInfo/TrainDataView"; import { DynamicHeaderScrollView } from "../DynamicHeaderScrollView"; +import { LongHeader } from "./EachTrainInfo/LongHeader"; +import { ShortHeader } from "./EachTrainInfo/ShortHeader"; +import { ScrollStickyContent } from "./EachTrainInfo/ScrollStickyContent"; export const EachTrainInfo = (props) => { if (!props.payload) return <>; @@ -379,9 +376,6 @@ export const EachTrainInfo = (props) => { .replace("ライナーライナー", "ライナー"); }; const actionSheetRef = useRef(null); - const scrollHandlers = useScrollHandlers("scrollview-1", actionSheetRef); - - const scrollOffsetY = useRef(new Animated.Value(0)).current; return ( { from == "AllTrainDiagramView" ? ( <> ) : ( - setActionSheetHorizonalScroll(true)} - //onScrollEndDrag={() => setActionSheetHorizonalScroll(false)} - //onScrollBeginDrag={() => console.log("onScrollBeginDrag")} - style={{ - flexDirection: "row", - flex: 1, - //width: widthPercentageToDP("200%"), - // minHeight: 200, - //height: heightPercentageToDP("20%"), - }} - horizontal - pagingEnabled - > - - + ) } longHeader={ from == "AllTrainDiagramView" ? ( <> ) : ( - setActionSheetHorizonalScroll(true)} - //onScrollEndDrag={() => setActionSheetHorizonalScroll(false)} - //onScrollBeginDrag={() => console.log("onScrollBeginDrag")} - style={{ - flexDirection: "row", - //width: widthPercentageToDP("200%"), - // minHeight: 200, - //height: heightPercentageToDP("20%"), - }} - horizontal - pagingEnabled - > - - + ) } topStickyContent={ - - - 停車駅 - - - {!isNaN(currentTrainData?.delay) && - currentTrainData?.delay != 0 && ( - - (定刻) - - )} - - 見込 - - - - - + } > {headStation && !isConcatNear && ( diff --git a/components/ActionSheetComponents/EachTrainInfo/LongHeader.js b/components/ActionSheetComponents/EachTrainInfo/LongHeader.js new file mode 100644 index 0000000..95f23f9 --- /dev/null +++ b/components/ActionSheetComponents/EachTrainInfo/LongHeader.js @@ -0,0 +1,33 @@ +import React from "react"; +import { ScrollView } from "react-native"; +import { TrainDataView } from "./TrainDataView"; + +export const LongHeader = ({ + currentTrainData, + currentPosition, + nearTrainIDList, + openTrainInfo, +}) => { + return ( + setActionSheetHorizonalScroll(true)} + //onScrollEndDrag={() => setActionSheetHorizonalScroll(false)} + //onScrollBeginDrag={() => console.log("onScrollBeginDrag")} + style={{ + flexDirection: "row", + //width: widthPercentageToDP("200%"), + // minHeight: 200, + //height: heightPercentageToDP("20%"), + }} + horizontal + pagingEnabled + > + + + ); +}; diff --git a/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js b/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js new file mode 100644 index 0000000..3881b36 --- /dev/null +++ b/components/ActionSheetComponents/EachTrainInfo/ScrollStickyContent.js @@ -0,0 +1,57 @@ +import React from "react"; +import { View, Text } from "react-native"; + +export const ScrollStickyContent = ({ currentTrainData }) => { + return ( + + + 停車駅 + + + {!isNaN(currentTrainData?.delay) && currentTrainData?.delay != 0 && ( + + (定刻) + + )} + + 見込 + + + + + + ); +}; diff --git a/components/ActionSheetComponents/EachTrainInfo/ShortHeader.js b/components/ActionSheetComponents/EachTrainInfo/ShortHeader.js new file mode 100644 index 0000000..a289e24 --- /dev/null +++ b/components/ActionSheetComponents/EachTrainInfo/ShortHeader.js @@ -0,0 +1,35 @@ +import React from "react"; +import { ScrollView } from "react-native"; +import { TrainDataView } from "./TrainDataView"; + +export const ShortHeader = ({ + currentTrainData, + currentPosition, + nearTrainIDList, + openTrainInfo, +}) => { + return ( + setActionSheetHorizonalScroll(true)} + //onScrollEndDrag={() => setActionSheetHorizonalScroll(false)} + //onScrollBeginDrag={() => console.log("onScrollBeginDrag")} + style={{ + flexDirection: "row", + flex: 1, + //width: widthPercentageToDP("200%"), + // minHeight: 200, + //height: heightPercentageToDP("20%"), + }} + horizontal + pagingEnabled + > + + + ); +}; diff --git a/components/DynamicHeaderScrollView.js b/components/DynamicHeaderScrollView.js index e804856..8254937 100644 --- a/components/DynamicHeaderScrollView.js +++ b/components/DynamicHeaderScrollView.js @@ -18,7 +18,7 @@ export const DynamicHeaderScrollView = (props) => { const Scroll_Distance = Max_Header_Height - Min_Header_Height; const animatedHeaderHeight = scrollOffsetY.interpolate({ - inputRange: [Min_Header_Height, Scroll_Distance], + inputRange: [Scroll_Distance, Scroll_Distance + 10], outputRange: [Max_Header_Height, 0], extrapolate: "clamp", }); @@ -40,20 +40,6 @@ export const DynamicHeaderScrollView = (props) => { return ( - - {longHeader} - { > {shortHeader} + + {longHeader} +