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