LEDに運行情報を表示するように変更

This commit is contained in:
harukin-OneMix4 2023-12-14 21:05:51 +09:00
parent 171df01a0d
commit d6f727710f
3 changed files with 43 additions and 3 deletions

4
App.js
View File

@ -104,7 +104,6 @@ export default function App() {
return ( return (
<NavigationContainer name="Root" style={{ flex: 1 }}> <NavigationContainer name="Root" style={{ flex: 1 }}>
{areaInfo != "" && <Text onPress={() => alert(areaInfo)}>{areaInfo}</Text>}
<Tab.Navigator detachInactiveScreens={false}> <Tab.Navigator detachInactiveScreens={false}>
<Tab.Screen <Tab.Screen
name="login" name="login"
@ -151,6 +150,7 @@ export default function App() {
setCurrentTrainLoading, setCurrentTrainLoading,
}} }}
getCurrentTrain={getCurrentTrain} getCurrentTrain={getCurrentTrain}
areaInfo={areaInfo}
/> />
)} )}
</Tab.Screen> </Tab.Screen>
@ -293,6 +293,7 @@ function MenuPage({
currentTrainState, currentTrainState,
currentTrainLoadingState, currentTrainLoadingState,
getCurrentTrain, getCurrentTrain,
areaInfo,
}) { }) {
useEffect(() => { useEffect(() => {
const unsubscribe = navigation.addListener("tabPress", (e) => { const unsubscribe = navigation.addListener("tabPress", (e) => {
@ -327,6 +328,7 @@ function MenuPage({
currentTrainState={currentTrainState} currentTrainState={currentTrainState}
currentTrainLoadingState={currentTrainLoadingState} currentTrainLoadingState={currentTrainLoadingState}
getCurrentTrain={getCurrentTrain} getCurrentTrain={getCurrentTrain}
areaInfo={areaInfo}
/> />
)} )}
</Stack.Screen> </Stack.Screen>

View File

@ -52,6 +52,7 @@ export default function LED_vision(props) {
currentTrainState, currentTrainState,
currentTrainLoadingState, currentTrainLoadingState,
getCurrentTrain, getCurrentTrain,
areaInfo,
} = props; } = props;
const { currentTrain, setCurrentTrain } = currentTrainState; const { currentTrain, setCurrentTrain } = currentTrainState;
const { currentTrainLoading, setCurrentTrainLoading } = const { currentTrainLoading, setCurrentTrainLoading } =
@ -149,6 +150,33 @@ export default function LED_vision(props) {
return false; return false;
}; };
const [areaString, setAreaString] = useState("");
const [areaStringLength, setAreaStringLength] = useState(0);
const [move, setMove] = useState(0);
useInterval(
() => {
if (areaInfo != "") {
if (areaStringLength < move) {
setMove(0);
} else {
setMove(move + 1);
}
}
},
350,
true
);
useEffect(() => {
setAreaString(
areaInfo.substring(move, areaInfo.length) + areaInfo.substring(0, move)
);
}, [move]);
useEffect(() => {
if (!areaInfo) return () => {};
setAreaStringLength(areaInfo.length);
}, [areaInfo]);
return ( return (
<View <View
style={{ style={{
@ -176,6 +204,13 @@ export default function LED_vision(props) {
EachTrainInfoAsSR={EachTrainInfoAsSR} EachTrainInfoAsSR={EachTrainInfoAsSR}
/> />
))} ))}
{areaString != "" && (
<Description
numberOfLines={1}
info={areaString.replace("\n", "").replace("\r", "")}
/>
)}
<Footer <Footer
trainIDSwitch={trainIDSwitch} trainIDSwitch={trainIDSwitch}
setTrainIDSwitch={setTrainIDSwitch} setTrainIDSwitch={setTrainIDSwitch}
@ -413,7 +448,7 @@ const StatusAndDelay = ({ trainDelayStatus }) => {
); );
}; };
const Description = ({ info }) => ( const Description = ({ info, numberOfLines = 0 }) => (
<View <View
style={{ style={{
alignContent: "center", alignContent: "center",
@ -432,6 +467,7 @@ const Description = ({ info }) => (
color: "green", color: "green",
fontWeight: "bold", fontWeight: "bold",
}} }}
numberOfLines={numberOfLines}
> >
{" "} {" "}
&gt; {info} &gt; {info}

View File

@ -49,6 +49,7 @@ export default function Menu(props) {
currentTrainState, currentTrainState,
currentTrainLoadingState, currentTrainLoadingState,
getCurrentTrain, getCurrentTrain,
areaInfo,
} = props; } = props;
const JRSTraInfoEXAcSR = useRef(null); const JRSTraInfoEXAcSR = useRef(null);
const StationBoardAcSR = useRef(null); const StationBoardAcSR = useRef(null);
@ -255,6 +256,7 @@ export default function Menu(props) {
currentTrainState={currentTrainState} currentTrainState={currentTrainState}
currentTrainLoadingState={currentTrainLoadingState} currentTrainLoadingState={currentTrainLoadingState}
getCurrentTrain={getCurrentTrain} getCurrentTrain={getCurrentTrain}
areaInfo={areaInfo}
/> />
)} )}
<JRSTraInfoBox <JRSTraInfoBox