通過表示のオンオフを実装

This commit is contained in:
harukin-expo-dev-env 2024-10-19 12:54:32 +00:00
parent 86655f5632
commit a9dddfca2c
3 changed files with 57 additions and 20 deletions

View File

@ -10,7 +10,9 @@ export const EachStopList = ({
points, points,
currentTrainData, currentTrainData,
openStationACFromEachTrainInfo, openStationACFromEachTrainInfo,
showThrew,
}) => { }) => {
if (!showThrew && i.split(",")[1] == "通過") return null;
const [station, se, time] = i.split(","); // 阿波池田,発,6:21 const [station, se, time] = i.split(","); // 阿波池田,発,6:21
const Stations = stationList const Stations = stationList
.map((a) => a.filter((d) => d.StationName == station)) .map((a) => a.filter((d) => d.StationName == station))
@ -66,7 +68,9 @@ export const EachStopList = ({
{lineIDs.map((lineID, index) => ( {lineIDs.map((lineID, index) => (
<View <View
style={{ style={{
backgroundColor: lineColorList[lineID], backgroundColor: `${lineColorList[lineID]}${
se == "通過" ? "80" : ""
}`,
flex: 1, flex: 1,
}} }}
key={lineID} key={lineID}
@ -97,7 +101,11 @@ export const EachStopList = ({
flex: 1, flex: 1,
}} }}
> >
<Text style={{ fontSize: 20 }}>{station}</Text> <Text
style={{ fontSize: 20, color: `#000${se == "通過" ? "5" : ""}` }}
>
{station}
</Text>
<View style={{ flex: 1 }} /> <View style={{ flex: 1 }} />
{points && points.findIndex((d) => d == index) >= 0 ? ( {points && points.findIndex((d) => d == index) >= 0 ? (
<Text style={{ fontSize: 20, marginRight: 70 }}>🚊</Text> <Text style={{ fontSize: 20, marginRight: 70 }}>🚊</Text>

View File

@ -1,7 +1,8 @@
import React from "react"; import React from "react";
import { View, Text } from "react-native"; import { View, Text, LayoutAnimation } from "react-native";
export const ScrollStickyContent = ({ currentTrainData }) => { export const ScrollStickyContent = (props) => {
const { currentTrainData, showThrew, setShowThrew, haveThrough } = props;
return ( return (
<View <View
style={{ style={{
@ -49,7 +50,27 @@ export const ScrollStickyContent = ({ currentTrainData }) => {
> >
見込 見込
</Text> </Text>
<Text style={{ fontSize: 20, width: 50 }}></Text> <Text
style={{
fontSize: 15,
width: 50,
paddingBottom: 0,
margin: 0,
textAlign: "center",
textAlignVertical: "center",
opacity: haveThrough ? 1 : 0,
}}
onPress={() => {
if (!haveThrough) return;
LayoutAnimation.configureNext({
duration: 200,
update: { type: "easeInEaseOut", springDamping: 0.6 },
});
setShowThrew(!showThrew);
}}
>
(通過{showThrew ? "▼" : "▶"})
</Text>
</View> </View>
</View> </View>
</View> </View>

View File

@ -82,6 +82,8 @@ export const EachTrainInfoCore = ({
const [currentPosition, setCurrentPosition] = useState([]); const [currentPosition, setCurrentPosition] = useState([]);
const [trainData, setTrainData] = useState([]); const [trainData, setTrainData] = useState([]);
const [trainDataWidhThrough, setTrainDataWithThrough] = useState([]); const [trainDataWidhThrough, setTrainDataWithThrough] = useState([]);
const [showThrew, setShowThrew] = useState(false);
const [haveThrough, setHaveThrough] = useState(false);
const stationList = const stationList =
originalStationList && originalStationList &&
@ -136,13 +138,13 @@ export const EachTrainInfoCore = ({
originalStationList[ originalStationList[
lineListPair[stationIDPair[betweenStationLine]] lineListPair[stationIDPair[betweenStationLine]]
].forEach((d) => { ].forEach((d) => {
console.log(d.StationNumber, baseStationNumberFirst, baseStationNumberSecond);
if ( if (
d.StationNumber > baseStationNumberFirst && d.StationNumber > baseStationNumberFirst &&
d.StationNumber < baseStationNumberSecond d.StationNumber < baseStationNumberSecond
) { ) {
console.log(d.Station_JP); console.log(d.Station_JP);
allThroughStation.push(`${d.Station_JP},通過,`); allThroughStation.push(`${d.Station_JP},通過,`);
setHaveThrough(true);
reverse = false; reverse = false;
} else { } else {
if ( if (
@ -151,6 +153,7 @@ export const EachTrainInfoCore = ({
) { ) {
console.log(d.Station_JP); console.log(d.Station_JP);
allThroughStation.push(`${d.Station_JP},通過,`); allThroughStation.push(`${d.Station_JP},通過,`);
setHaveThrough(true);
reverse = true; reverse = true;
} }
} }
@ -366,7 +369,9 @@ export const EachTrainInfoCore = ({
shortHeader={<ShortHeader {...headerItem} />} shortHeader={<ShortHeader {...headerItem} />}
longHeader={<LongHeader {...headerItem} />} longHeader={<LongHeader {...headerItem} />}
topStickyContent={ topStickyContent={
<ScrollStickyContent currentTrainData={currentTrainData} /> <ScrollStickyContent
{...{ currentTrainData, showThrew, setShowThrew, haveThrough }}
/>
} }
> >
{headStation.length != 0 && {headStation.length != 0 &&
@ -430,12 +435,15 @@ export const EachTrainInfoCore = ({
<DataFromButton i={i} /> <DataFromButton i={i} />
) : ( ) : (
<EachStopList <EachStopList
i={i} {...{
index={index} i,
stationList={stationList} index,
points={points} stationList,
currentTrainData={currentTrainData} points,
openStationACFromEachTrainInfo={openStationACFromEachTrainInfo} currentTrainData,
openStationACFromEachTrainInfo,
showThrew,
}}
/> />
) )
)} )}