小整理
This commit is contained in:
parent
d627617ca0
commit
e9fd753a8f
@ -34,7 +34,6 @@ export default function FavoriteList({
|
|||||||
{favoriteStation
|
{favoriteStation
|
||||||
.filter((d) => d[0].StationMap)
|
.filter((d) => d[0].StationMap)
|
||||||
.map((currentStation) => {
|
.map((currentStation) => {
|
||||||
console.log(currentStation);
|
|
||||||
return (
|
return (
|
||||||
<ListItem
|
<ListItem
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
@ -138,7 +138,6 @@ export default function LED_vision(props) {
|
|||||||
});
|
});
|
||||||
return { train: d, time: a.time, lastStation: a.lastStation };
|
return { train: d, time: a.time, lastStation: a.lastStation };
|
||||||
});
|
});
|
||||||
console.log(returnData);
|
|
||||||
return returnData.sort((a, b) => {
|
return returnData.sort((a, b) => {
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case parseInt(a.time.split(":")[0]) < parseInt(b.time.split(":")[0]):
|
case parseInt(a.time.split(":")[0]) < parseInt(b.time.split(":")[0]):
|
||||||
|
@ -111,7 +111,6 @@ export default function Sign(props) {
|
|||||||
setFavoriteStation(otherData);
|
setFavoriteStation(otherData);
|
||||||
} else {
|
} else {
|
||||||
let ret = favoriteStation;
|
let ret = favoriteStation;
|
||||||
console.log(currentStation);
|
|
||||||
ret.push(currentStation);
|
ret.push(currentStation);
|
||||||
AS.setItem("favoriteStation", JSON.stringify(ret));
|
AS.setItem("favoriteStation", JSON.stringify(ret));
|
||||||
setFavoriteStation(ret);
|
setFavoriteStation(ret);
|
||||||
|
185
menu.js
185
menu.js
@ -48,59 +48,20 @@ export default function Menu(props) {
|
|||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
|
|
||||||
//位置情報
|
//位置情報
|
||||||
const [location, setLocation] = useState(null);
|
|
||||||
const [locationStatus, setLocationStatus] = useState(null);
|
const [locationStatus, setLocationStatus] = useState(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Location.requestForegroundPermissionsAsync().then((data) => {
|
Location.requestForegroundPermissionsAsync().then((data) => {
|
||||||
setLocationStatus(data.status);
|
setLocationStatus(data.status);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
useEffect(() => {
|
|
||||||
if (locationStatus !== "granted") return () => {};
|
|
||||||
getCurrentPosition();
|
|
||||||
}, [locationStatus]);
|
|
||||||
|
|
||||||
const getCurrentPosition = () => {
|
const getCurrentPosition = () => {
|
||||||
|
if (locationStatus !== "granted") return () => {};
|
||||||
Location.getCurrentPositionAsync({}).then((location) =>
|
Location.getCurrentPositionAsync({}).then((location) =>
|
||||||
setLocation(location)
|
makeCurrentStation(location)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
const makeCurrentStation = (location) => {
|
||||||
useInterval(() => {
|
|
||||||
if (locationStatus !== "granted") return () => {};
|
|
||||||
getCurrentPosition();
|
|
||||||
}, 5000);
|
|
||||||
|
|
||||||
const [originalStationList, setOriginalStationList] = useState();
|
|
||||||
useEffect(() => {
|
|
||||||
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]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!(selectedCurrentStation < favoriteStation.length)) {
|
|
||||||
if (favoriteStation.length == 0) {
|
|
||||||
setSelectedCurrentStation(0);
|
|
||||||
carouselRef.current.snapToItem(0);
|
|
||||||
} else {
|
|
||||||
setSelectedCurrentStation(favoriteStation.length - 1);
|
|
||||||
carouselRef.current.snapToItem(favoriteStation.length - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [favoriteStation]);
|
|
||||||
|
|
||||||
const [stationName, setStationName] = useState(undefined);
|
|
||||||
const [currentStation, setCurrentStation] = useState(undefined);
|
|
||||||
useEffect(() => {
|
|
||||||
if (!location) return () => {};
|
|
||||||
if (!originalStationList) return () => {};
|
if (!originalStationList) return () => {};
|
||||||
const findStationEachLine = (selectLine) => {
|
const findStationEachLine = (selectLine) => {
|
||||||
const searchArea = 0.0015;
|
const searchArea = 0.0015;
|
||||||
@ -134,7 +95,15 @@ export default function Menu(props) {
|
|||||||
} else {
|
} else {
|
||||||
setCurrentStation(undefined);
|
setCurrentStation(undefined);
|
||||||
}
|
}
|
||||||
}, [location, originalStationList]);
|
};
|
||||||
|
|
||||||
|
useEffect(getCurrentPosition, [locationStatus]);
|
||||||
|
useInterval(getCurrentPosition, 5000);
|
||||||
|
|
||||||
|
const [currentStation, setCurrentStation] = useState(undefined); //第三要素
|
||||||
|
|
||||||
|
const [originalStationList, setOriginalStationList] = useState(); // 第一要素
|
||||||
|
useEffect(() => getStationList().then(setOriginalStationList), []);
|
||||||
|
|
||||||
const [count, setCount] = useState(0);
|
const [count, setCount] = useState(0);
|
||||||
const [delayData, setDelayData] = useState(undefined);
|
const [delayData, setDelayData] = useState(undefined);
|
||||||
@ -152,7 +121,29 @@ export default function Menu(props) {
|
|||||||
.then(() => setGetTime(new Date()))
|
.then(() => setGetTime(new Date()))
|
||||||
.finally(() => setLoadingDelayData(false));
|
.finally(() => setLoadingDelayData(false));
|
||||||
}, [loadingDelayData]);
|
}, [loadingDelayData]);
|
||||||
|
const allStationData = [currentStation, ...favoriteStation].filter(
|
||||||
|
(d) => d != undefined
|
||||||
|
);
|
||||||
|
console.log(allStationData);
|
||||||
|
useEffect(() => {
|
||||||
|
if (allStationData.length == 0) {
|
||||||
|
setSelectedCurrentStation(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(allStationData[selectedCurrentStation]);
|
||||||
|
if (allStationData[selectedCurrentStation] == undefined) {
|
||||||
|
const count = selectedCurrentStation - 1;
|
||||||
|
setSelectedCurrentStation(count);
|
||||||
|
}
|
||||||
|
}, [selectedCurrentStation, currentStation, favoriteStation]);
|
||||||
|
useEffect(() => {
|
||||||
|
if (!carouselRef.current) return;
|
||||||
|
console.log(carouselRef.current);
|
||||||
|
if (carouselRef.current?._itemToSnapTo != selectedCurrentStation) {
|
||||||
|
carouselRef.current.snapToItem(0);
|
||||||
|
carouselRef.current.snapToItem(selectedCurrentStation);
|
||||||
|
}
|
||||||
|
}, [selectedCurrentStation]);
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
@ -165,48 +156,47 @@ export default function Menu(props) {
|
|||||||
<TitleBar />
|
<TitleBar />
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
<FixedContentTop navigate={navigate} />
|
<FixedContentTop navigate={navigate} />
|
||||||
<Carousel
|
{originalStationList && allStationData.length != 0 && (
|
||||||
ref={carouselRef}
|
<Carousel
|
||||||
layout={"default"}
|
ref={carouselRef}
|
||||||
data={
|
layout={"default"}
|
||||||
originalStationList &&
|
data={originalStationList && allStationData}
|
||||||
(currentStation
|
sliderWidth={wp("100%")}
|
||||||
? [currentStation, ...locationAndFavorite]
|
itemWidth={wp("80%")}
|
||||||
: locationAndFavorite)
|
enableMomentum
|
||||||
}
|
callbackOffsetMargin={1000}
|
||||||
sliderWidth={wp("100%")}
|
activeAnimationOptions={0.3}
|
||||||
itemWidth={wp("80%")}
|
onSnapToItem={(d) => {
|
||||||
enableMomentum
|
setSelectedCurrentStation(d);
|
||||||
callbackOffsetMargin={1000}
|
}}
|
||||||
activeAnimationOptions={0.3}
|
renderItem={({ item, index }) => {
|
||||||
onSnapToItem={(d) => {
|
return (
|
||||||
setSelectedCurrentStation(d);
|
<View
|
||||||
}}
|
style={{ marginVertical: 10 }}
|
||||||
renderItem={({ item, index }) => {
|
key={item[0].StationNumber}
|
||||||
return (
|
>
|
||||||
<View style={{ marginVertical: 10 }} key={item[0].StationNumber}>
|
<Sign
|
||||||
<Sign
|
currentStation={item}
|
||||||
currentStation={item}
|
originalStationList={originalStationList}
|
||||||
originalStationList={originalStationList}
|
favoriteStation={favoriteStation}
|
||||||
favoriteStation={favoriteStation}
|
setFavoriteStation={setFavoriteStation}
|
||||||
setFavoriteStation={setFavoriteStation}
|
oP={StationBoardAcSR.current?.setModalVisible}
|
||||||
oP={StationBoardAcSR.current?.setModalVisible}
|
/>
|
||||||
/>
|
</View>
|
||||||
</View>
|
);
|
||||||
);
|
}}
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{locationAndFavorite.length != 0 && originalStationList && (
|
|
||||||
<LED_vision
|
|
||||||
station={
|
|
||||||
originalStationList &&
|
|
||||||
(currentStation
|
|
||||||
? [currentStation, ...locationAndFavorite]
|
|
||||||
: locationAndFavorite)[selectedCurrentStation][0]
|
|
||||||
}
|
|
||||||
navigate={navigate}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{allStationData.length != 0 &&
|
||||||
|
originalStationList &&
|
||||||
|
allStationData[selectedCurrentStation] && (
|
||||||
|
<LED_vision
|
||||||
|
station={
|
||||||
|
originalStationList && allStationData[selectedCurrentStation][0]
|
||||||
|
}
|
||||||
|
navigate={navigate}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<JRSTraInfoBox
|
<JRSTraInfoBox
|
||||||
JRSTraInfoEXAcSR={JRSTraInfoEXAcSR}
|
JRSTraInfoEXAcSR={JRSTraInfoEXAcSR}
|
||||||
getTime={getTime}
|
getTime={getTime}
|
||||||
@ -217,19 +207,20 @@ export default function Menu(props) {
|
|||||||
<FixedContentBottom navigate={navigate} />
|
<FixedContentBottom navigate={navigate} />
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<StationDeteilView
|
{allStationData.length != 0 &&
|
||||||
StationBoardAcSR={StationBoardAcSR}
|
originalStationList &&
|
||||||
currentStation={
|
allStationData[selectedCurrentStation] && (
|
||||||
originalStationList &&
|
<StationDeteilView
|
||||||
(currentStation
|
StationBoardAcSR={StationBoardAcSR}
|
||||||
? [currentStation, ...locationAndFavorite]
|
currentStation={
|
||||||
: locationAndFavorite)[selectedCurrentStation]
|
originalStationList && allStationData[selectedCurrentStation]
|
||||||
}
|
}
|
||||||
originalStationList={originalStationList}
|
originalStationList={originalStationList}
|
||||||
favoriteStation={favoriteStation}
|
favoriteStation={favoriteStation}
|
||||||
setFavoriteStation={setFavoriteStation}
|
setFavoriteStation={setFavoriteStation}
|
||||||
busAndTrainData={busAndTrainData}
|
busAndTrainData={busAndTrainData}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
<JRSTraInfo
|
<JRSTraInfo
|
||||||
JRSTraInfoEXAcSR={JRSTraInfoEXAcSR}
|
JRSTraInfoEXAcSR={JRSTraInfoEXAcSR}
|
||||||
getTime={getTime}
|
getTime={getTime}
|
||||||
|
@ -12,7 +12,6 @@ import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
|||||||
export default function TrainBase({ route, navigation }) {
|
export default function TrainBase({ route, navigation }) {
|
||||||
const { info, from } = route.params;
|
const { info, from } = route.params;
|
||||||
const { navigate } = navigation;
|
const { navigate } = navigation;
|
||||||
console.log(info);
|
|
||||||
const webview = useRef();
|
const webview = useRef();
|
||||||
const jss = `document.getElementById('Footer').style.display = 'none';
|
const jss = `document.getElementById('Footer').style.display = 'none';
|
||||||
${
|
${
|
||||||
|
Loading…
Reference in New Issue
Block a user