コンテンツ分割、整理

This commit is contained in:
harukin-OneMix4 2024-02-11 20:38:28 +09:00
parent 62d7936425
commit 1fb471205c
5 changed files with 157 additions and 118 deletions

View File

@ -2,18 +2,13 @@ import React, { useEffect, useState, useRef } from "react";
import { import {
View, View,
LayoutAnimation, LayoutAnimation,
ScrollView,
Text, Text,
TouchableOpacity, TouchableOpacity,
Platform, Platform,
Animated,
StyleSheet, StyleSheet,
} from "react-native"; } from "react-native";
import { Ionicons } from "@expo/vector-icons"; import { Ionicons } from "@expo/vector-icons";
import ActionSheet, { import ActionSheet, { SheetManager } from "react-native-actions-sheet";
SheetManager,
useScrollHandlers,
} from "react-native-actions-sheet";
import { AS } from "../../storageControl"; import { AS } from "../../storageControl";
import trainList from "../../assets/originData/trainList"; import trainList from "../../assets/originData/trainList";
import { lineList } from "../../lib/getStationList"; import { lineList } from "../../lib/getStationList";
@ -25,8 +20,10 @@ import { customTrainDataDetector } from "../custom-train-data";
import { useBusAndTrainData } from "../../stateBox/useBusAndTrainData"; import { useBusAndTrainData } from "../../stateBox/useBusAndTrainData";
import { EachStopList } from "./EachTrainInfo/EachStopList"; import { EachStopList } from "./EachTrainInfo/EachStopList";
import { DataFromButton } from "./EachTrainInfo/DataFromButton"; import { DataFromButton } from "./EachTrainInfo/DataFromButton";
import { TrainDataView } from "./EachTrainInfo/TrainDataView";
import { DynamicHeaderScrollView } from "../DynamicHeaderScrollView"; import { DynamicHeaderScrollView } from "../DynamicHeaderScrollView";
import { LongHeader } from "./EachTrainInfo/LongHeader";
import { ShortHeader } from "./EachTrainInfo/ShortHeader";
import { ScrollStickyContent } from "./EachTrainInfo/ScrollStickyContent";
export const EachTrainInfo = (props) => { export const EachTrainInfo = (props) => {
if (!props.payload) return <></>; if (!props.payload) return <></>;
@ -379,9 +376,6 @@ export const EachTrainInfo = (props) => {
.replace("ライナーライナー", "ライナー"); .replace("ライナーライナー", "ライナー");
}; };
const actionSheetRef = useRef(null); const actionSheetRef = useRef(null);
const scrollHandlers = useScrollHandlers("scrollview-1", actionSheetRef);
const scrollOffsetY = useRef(new Animated.Value(0)).current;
return ( return (
<ActionSheet <ActionSheet
gestureEnabled={true} gestureEnabled={true}
@ -460,108 +454,28 @@ export const EachTrainInfo = (props) => {
from == "AllTrainDiagramView" ? ( from == "AllTrainDiagramView" ? (
<></> <></>
) : ( ) : (
<ScrollView <ShortHeader
//onTouchStart={() => setActionSheetHorizonalScroll(true)} currentTrainData={currentTrainData}
//onScrollEndDrag={() => setActionSheetHorizonalScroll(false)} currentPosition={currentPosition}
//onScrollBeginDrag={() => console.log("onScrollBeginDrag")} nearTrainIDList={nearTrainIDList}
style={{ openTrainInfo={openTrainInfo}
flexDirection: "row", />
flex: 1,
//width: widthPercentageToDP("200%"),
// minHeight: 200,
//height: heightPercentageToDP("20%"),
}}
horizontal
pagingEnabled
>
<TrainDataView
mode={2}
currentTrainData={currentTrainData}
currentPosition={currentPosition}
nearTrainIDList={nearTrainIDList}
openTrainInfo={openTrainInfo}
/>
</ScrollView>
) )
} }
longHeader={ longHeader={
from == "AllTrainDiagramView" ? ( from == "AllTrainDiagramView" ? (
<></> <></>
) : ( ) : (
<ScrollView <LongHeader
//onTouchStart={() => setActionSheetHorizonalScroll(true)} currentTrainData={currentTrainData}
//onScrollEndDrag={() => setActionSheetHorizonalScroll(false)} currentPosition={currentPosition}
//onScrollBeginDrag={() => console.log("onScrollBeginDrag")} nearTrainIDList={nearTrainIDList}
style={{ openTrainInfo={openTrainInfo}
flexDirection: "row", />
//width: widthPercentageToDP("200%"),
// minHeight: 200,
//height: heightPercentageToDP("20%"),
}}
horizontal
pagingEnabled
>
<TrainDataView
currentTrainData={currentTrainData}
currentPosition={currentPosition}
nearTrainIDList={nearTrainIDList}
openTrainInfo={openTrainInfo}
/>
</ScrollView>
) )
} }
topStickyContent={ topStickyContent={
<View <ScrollStickyContent currentTrainData={currentTrainData} />
style={{
alignItems: "center",
backgroundColor: "white",
flexDirection: "row",
}}
>
<View
style={{
padding: 8,
flexDirection: "row",
borderBottomWidth: 1,
borderBottomColor: "#f0f0f0",
flex: 1,
}}
>
<Text style={{ fontSize: 20 }}>停車駅</Text>
<View style={{ flex: 1 }} />
<View style={{ flexDirection: "row" }}>
{!isNaN(currentTrainData?.delay) &&
currentTrainData?.delay != 0 && (
<Text
style={{
fontSize: 15,
color: "black",
position: "absolute",
right: 110,
textAlign: "right",
textDecorationLine: "line-through",
}}
>
(定刻)
</Text>
)}
<Text
style={{
fontSize: 20,
color: isNaN(currentTrainData?.delay)
? "black"
: currentTrainData?.delay == 0
? "black"
: "red",
width: 60,
}}
>
見込
</Text>
<Text style={{ fontSize: 20, width: 50 }}></Text>
</View>
</View>
</View>
} }
> >
{headStation && !isConcatNear && ( {headStation && !isConcatNear && (

View File

@ -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 (
<ScrollView
//onTouchStart={() => setActionSheetHorizonalScroll(true)}
//onScrollEndDrag={() => setActionSheetHorizonalScroll(false)}
//onScrollBeginDrag={() => console.log("onScrollBeginDrag")}
style={{
flexDirection: "row",
//width: widthPercentageToDP("200%"),
// minHeight: 200,
//height: heightPercentageToDP("20%"),
}}
horizontal
pagingEnabled
>
<TrainDataView
currentTrainData={currentTrainData}
currentPosition={currentPosition}
nearTrainIDList={nearTrainIDList}
openTrainInfo={openTrainInfo}
/>
</ScrollView>
);
};

View File

@ -0,0 +1,57 @@
import React from "react";
import { View, Text } from "react-native";
export const ScrollStickyContent = ({ currentTrainData }) => {
return (
<View
style={{
alignItems: "center",
backgroundColor: "white",
flexDirection: "row",
}}
>
<View
style={{
padding: 8,
flexDirection: "row",
borderBottomWidth: 1,
borderBottomColor: "#f0f0f0",
flex: 1,
}}
>
<Text style={{ fontSize: 20 }}>停車駅</Text>
<View style={{ flex: 1 }} />
<View style={{ flexDirection: "row" }}>
{!isNaN(currentTrainData?.delay) && currentTrainData?.delay != 0 && (
<Text
style={{
fontSize: 15,
color: "black",
position: "absolute",
right: 110,
textAlign: "right",
textDecorationLine: "line-through",
}}
>
(定刻)
</Text>
)}
<Text
style={{
fontSize: 20,
color: isNaN(currentTrainData?.delay)
? "black"
: currentTrainData?.delay == 0
? "black"
: "red",
width: 60,
}}
>
見込
</Text>
<Text style={{ fontSize: 20, width: 50 }}></Text>
</View>
</View>
</View>
);
};

View File

@ -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 (
<ScrollView
//onTouchStart={() => setActionSheetHorizonalScroll(true)}
//onScrollEndDrag={() => setActionSheetHorizonalScroll(false)}
//onScrollBeginDrag={() => console.log("onScrollBeginDrag")}
style={{
flexDirection: "row",
flex: 1,
//width: widthPercentageToDP("200%"),
// minHeight: 200,
//height: heightPercentageToDP("20%"),
}}
horizontal
pagingEnabled
>
<TrainDataView
mode={2}
currentTrainData={currentTrainData}
currentPosition={currentPosition}
nearTrainIDList={nearTrainIDList}
openTrainInfo={openTrainInfo}
/>
</ScrollView>
);
};

View File

@ -18,7 +18,7 @@ export const DynamicHeaderScrollView = (props) => {
const Scroll_Distance = Max_Header_Height - Min_Header_Height; const Scroll_Distance = Max_Header_Height - Min_Header_Height;
const animatedHeaderHeight = scrollOffsetY.interpolate({ const animatedHeaderHeight = scrollOffsetY.interpolate({
inputRange: [Min_Header_Height, Scroll_Distance], inputRange: [Scroll_Distance, Scroll_Distance + 10],
outputRange: [Max_Header_Height, 0], outputRange: [Max_Header_Height, 0],
extrapolate: "clamp", extrapolate: "clamp",
}); });
@ -40,20 +40,6 @@ export const DynamicHeaderScrollView = (props) => {
return ( return (
<View {...containerProps}> <View {...containerProps}>
<View style={{ position: "relative" }}> <View style={{ position: "relative" }}>
<Animated.View
style={[
styles.header,
{
height: Max_Header_Height,
backgroundColor: "#0099CC",
opacity: animatedHeaderVisible,
top: 0,
},
]}
>
{longHeader}
</Animated.View>
<Animated.View <Animated.View
style={[ style={[
styles.header, styles.header,
@ -68,6 +54,20 @@ export const DynamicHeaderScrollView = (props) => {
> >
{shortHeader} {shortHeader}
</Animated.View> </Animated.View>
<Animated.View
style={[
styles.header,
{
height: animatedHeaderHeight,
backgroundColor: "#0099CC",
opacity: animatedHeaderVisible,
top: 0,
},
]}
>
{longHeader}
</Animated.View>
</View> </View>
<ScrollView <ScrollView
{...scrollViewProps} {...scrollViewProps}