選択された駅名板を利用したLED表示と選択画面の整備
This commit is contained in:
parent
12f23bef16
commit
bb89149876
39
menu.js
39
menu.js
@ -74,6 +74,14 @@ export default function Menu(props) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getStationList().then(setOriginalStationList);
|
getStationList().then(setOriginalStationList);
|
||||||
}, []);
|
}, []);
|
||||||
|
const [locationAndFavorite, setLocationAndFavorite] = useState([]);
|
||||||
|
useEffect(() => {
|
||||||
|
if (!favoriteStation) return () => {};
|
||||||
|
const data = favoriteStation.filter((d) =>
|
||||||
|
JSON.stringify(d) === JSON.stringify(currentStation) ? false : true
|
||||||
|
);
|
||||||
|
setLocationAndFavorite(data);
|
||||||
|
}, [currentStation, favoriteStation]);
|
||||||
|
|
||||||
const [stationName, setStationName] = useState(undefined);
|
const [stationName, setStationName] = useState(undefined);
|
||||||
const [currentStation, setCurrentStation] = useState(undefined);
|
const [currentStation, setCurrentStation] = useState(undefined);
|
||||||
@ -123,6 +131,7 @@ export default function Menu(props) {
|
|||||||
const carouselRef = useRef();
|
const carouselRef = useRef();
|
||||||
const scrollRef = useRef();
|
const scrollRef = useRef();
|
||||||
const [isScroll, setIsScroll] = useState(true);
|
const [isScroll, setIsScroll] = useState(true);
|
||||||
|
const [selectedCurrentStation, setSelectedCurrentStation] = useState(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch(
|
fetch(
|
||||||
@ -166,11 +175,20 @@ export default function Menu(props) {
|
|||||||
<Carousel
|
<Carousel
|
||||||
ref={carouselRef}
|
ref={carouselRef}
|
||||||
layout={"default"}
|
layout={"default"}
|
||||||
data={originalStationList && favoriteStation}
|
data={
|
||||||
|
originalStationList &&
|
||||||
|
(currentStation
|
||||||
|
? [currentStation, ...locationAndFavorite]
|
||||||
|
: locationAndFavorite)
|
||||||
|
}
|
||||||
sliderWidth={wp("100%")}
|
sliderWidth={wp("100%")}
|
||||||
itemWidth={wp("80%")}
|
itemWidth={wp("80%")}
|
||||||
enableMomentum
|
enableMomentum
|
||||||
callbackOffsetMargin={1000}
|
callbackOffsetMargin={1000}
|
||||||
|
activeAnimationOptions={0.3}
|
||||||
|
onSnapToItem={(d) => {
|
||||||
|
setSelectedCurrentStation(d);
|
||||||
|
}}
|
||||||
renderItem={({ item, index }) => {
|
renderItem={({ item, index }) => {
|
||||||
return (
|
return (
|
||||||
<View style={{ marginVertical: 10 }} key={item[0].StationNumber}>
|
<View style={{ marginVertical: 10 }} key={item[0].StationNumber}>
|
||||||
@ -185,8 +203,16 @@ export default function Menu(props) {
|
|||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{currentStation && (
|
{(currentStation || originalStationList) && (
|
||||||
<LED_vision station={currentStation[0]} navigate={navigate} />
|
<LED_vision
|
||||||
|
station={
|
||||||
|
originalStationList &&
|
||||||
|
(currentStation
|
||||||
|
? [currentStation, ...locationAndFavorite]
|
||||||
|
: locationAndFavorite)[selectedCurrentStation][0]
|
||||||
|
}
|
||||||
|
navigate={navigate}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
<JRSTraInfoBox
|
<JRSTraInfoBox
|
||||||
JRSTraInfoEXAcSR={JRSTraInfoEXAcSR}
|
JRSTraInfoEXAcSR={JRSTraInfoEXAcSR}
|
||||||
@ -477,7 +503,12 @@ export default function Menu(props) {
|
|||||||
</ScrollView>
|
</ScrollView>
|
||||||
<StationDeteilView
|
<StationDeteilView
|
||||||
StationBoardAcSR={StationBoardAcSR}
|
StationBoardAcSR={StationBoardAcSR}
|
||||||
currentStation={currentStation}
|
currentStation={
|
||||||
|
originalStationList &&
|
||||||
|
(currentStation
|
||||||
|
? [currentStation, ...locationAndFavorite]
|
||||||
|
: locationAndFavorite)[selectedCurrentStation]
|
||||||
|
}
|
||||||
originalStationList={originalStationList}
|
originalStationList={originalStationList}
|
||||||
favoriteStation={favoriteStation}
|
favoriteStation={favoriteStation}
|
||||||
setFavoriteStation={setFavoriteStation}
|
setFavoriteStation={setFavoriteStation}
|
||||||
|
Loading…
Reference in New Issue
Block a user