topとobject

This commit is contained in:
harukin-expo-dev-env 2024-06-07 08:01:26 +00:00
parent 0528ec6c2d
commit 801b3dc3b0
2 changed files with 40 additions and 64 deletions

View File

@ -28,6 +28,8 @@ import { AppsWebView } from "./Apps/WebView";
import StatusbarDetect from '../StatusbarDetect'; import StatusbarDetect from '../StatusbarDetect';
var Status = StatusbarDetect(); */ var Status = StatusbarDetect(); */
const top = Platform.OS == "ios" ? Constants.statusBarHeight : 0;
export default function Apps() { export default function Apps() {
const { webview } = useCurrentTrain(); const { webview } = useCurrentTrain();
const { height, width } = useWindowDimensions(); const { height, width } = useWindowDimensions();
@ -52,9 +54,7 @@ export default function Apps() {
//駅情報画面用 //駅情報画面用
const [originalStationList, setOriginalStationList] = useState(); const [originalStationList, setOriginalStationList] = useState();
const [trainMenu, setTrainMenu] = useState("true"); const [trainMenu, setTrainMenu] = useState("true");
useEffect(() => { useEffect(() => getStationList().then(setOriginalStationList), []);
getStationList().then(setOriginalStationList);
}, []);
//地図表示テキスト //地図表示テキスト
const injectJavascript = injectJavascriptData( const injectJavascript = injectJavascriptData(
@ -119,7 +119,7 @@ export default function Apps() {
<View <View
style={{ style={{
height: "100%", height: "100%",
paddingTop: Platform.OS == "ios" ? Constants.statusBarHeight : 0, paddingTop: top,
flexDirection: isLandscape ? "row" : "column", flexDirection: isLandscape ? "row" : "column",
}} }}
onLayout={handleLayout} onLayout={handleLayout}
@ -172,7 +172,6 @@ export default function Apps() {
setInjectJavaScript(""); setInjectJavaScript("");
navigate("trainMenu", { webview }); navigate("trainMenu", { webview });
}} }}
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
mapSwitch={mapSwitch == "true" ? "flex" : "none"} mapSwitch={mapSwitch == "true" ? "flex" : "none"}
/> />
)} )}
@ -186,13 +185,11 @@ export default function Apps() {
trainData: undefined, trainData: undefined,
}); });
}} }}
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
/> />
)} )}
{mapSwitch == "true" ? ( {mapSwitch == "true" ? (
<ReloadButton <ReloadButton
onPress={() => Updates.reloadAsync()} onPress={() => Updates.reloadAsync()}
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
right={isLandscape && trainInfo.trainNum ? (width / 100) * 40 : 0} right={isLandscape && trainInfo.trainNum ? (width / 100) * 40 : 0}
LoadError={LoadError} LoadError={LoadError}
/> />
@ -207,15 +204,14 @@ export default function Apps() {
</View> </View>
); );
} }
const NewMenu = ({ webview, LoadError }) => { const NewMenu = ({ webview, LoadError }) => {
const { width } = useWindowDimensions(); const { width } = useWindowDimensions();
return ( return (
<View <View
style={{ style={{
position: "absolute", position: "absolute",
top: Platform.OS == "ios" ? Constants.statusBarHeight : 0, top,
width: width, width,
height: 54, height: 54,
backgroundColor: "#0099CC", backgroundColor: "#0099CC",
borderColor: "white", borderColor: "white",
@ -291,7 +287,7 @@ const NewMenu = ({ webview, LoadError }) => {
</View> </View>
); );
}; };
const MapsButton = ({ onPress, top, mapSwitch }) => { const MapsButton = ({ onPress, mapSwitch }) => {
const styles = { const styles = {
touch: { touch: {
position: "absolute", position: "absolute",
@ -328,11 +324,10 @@ const MapsButton = ({ onPress, top, mapSwitch }) => {
); );
}; };
const LandscapeBackButton = ({ onPress, top }) => { const LandscapeBackButton = ({ onPress }) => {
const styles = { const styles = {
touch: { touch: {
position: "absolute", position: "absolute",
top,
left: 10, left: 10,
width: 50, width: 50,
height: 50, height: 50,
@ -364,13 +359,7 @@ const LandscapeBackButton = ({ onPress, top }) => {
); );
}; };
const ReloadButton = ({ const ReloadButton = ({ onPress, mapSwitch, LoadError = false, right }) => {
onPress,
top,
mapSwitch,
LoadError = false,
right,
}) => {
const styles = { const styles = {
touch: { touch: {
position: "absolute", position: "absolute",

View File

@ -27,23 +27,21 @@ export const AppsWebView = ({
var urlcache = ""; var urlcache = "";
let once = false; let once = false;
const onNavigationStateChange = (event) => { const onNavigationStateChange = ({ url }) => {
if (event.url != urlcache) { if (url == urlcache) return;
//URL //URL
urlcache = event.url; urlcache = url;
switch (true) {
if (event.url.includes("https://train.jr-shikoku.co.jp/usage.htm")) { case url.includes("https://train.jr-shikoku.co.jp/usage.htm"):
if (Platform.OS === "android") navigate("howto", { info: event.url }); if (Platform.OS === "android") navigate("howto", { info: url });
webview?.current.goBack(); webview?.current.goBack();
//Actions.howto(); //Actions.howto();
} else if ( break;
event.url.includes("https://train.jr-shikoku.co.jp/train.html") case url.includes("https://train.jr-shikoku.co.jp/train.html"):
) { //Actions.trainbase({info: url});
//Actions.trainbase({info: event.url}); if (Platform.OS === "android") navigate("trainbase", { info: url });
if (Platform.OS === "android")
navigate("trainbase", { info: event.url });
webview?.current.goBack(); webview?.current.goBack();
} break;
} }
}; };
@ -65,11 +63,8 @@ export const AppsWebView = ({
} }
case "PopUpMenu": case "PopUpMenu":
{ {
const selectedStationPDFAddress = dataSet.pdf;
const findStationEachLine = (selectLine) => const findStationEachLine = (selectLine) =>
selectLine.filter( selectLine.filter((d) => d.StationTimeTable == dataSet.pdf);
(d) => d.StationTimeTable == selectedStationPDFAddress
);
let returnDataBase = lineList let returnDataBase = lineList
.map((d) => findStationEachLine(originalStationList[d])) .map((d) => findStationEachLine(originalStationList[d]))
.filter((d) => d.length > 0) .filter((d) => d.length > 0)
@ -85,9 +80,7 @@ export const AppsWebView = ({
navigate: navigate, navigate: navigate,
goTo: "Apps", goTo: "Apps",
useShow: () => useShow: () =>
SheetManager.show("StationDetailView", { SheetManager.show("StationDetailView", { payload }),
payload,
}),
onExit: () => SheetManager.hide("StationDetailView"), onExit: () => SheetManager.hide("StationDetailView"),
}; };
SheetManager.show("StationDetailView", { payload }); SheetManager.show("StationDetailView", { payload });
@ -107,17 +100,12 @@ export const AppsWebView = ({
}); // }); //
if (isLandscape) return; if (isLandscape) return;
const payload = { const payload = {
data: { data: { trainNum, limited },
trainNum,
limited,
},
navigate, navigate,
originalStationList, originalStationList,
openStationACFromEachTrainInfo, openStationACFromEachTrainInfo,
}; };
SheetManager.show("EachTrainInfo", { SheetManager.show("EachTrainInfo", { payload });
payload,
});
return; return;
} }
case "currentLines": { case "currentLines": {
@ -136,22 +124,21 @@ export const AppsWebView = ({
const onLoadEnd = () => { const onLoadEnd = () => {
if (once) return () => {}; if (once) return () => {};
if (!stationData) return () => {}; if (!stationData) return () => {};
if (favoriteStation.length > 0) { if (favoriteStation.length < 1) return () => {};
const getStationLine = (now) => { const getStationLine = (now) => {
const returnData = Object.keys(stationData).filter((d) => { const returnData = Object.keys(stationData).filter((d) => {
const cache = stationData[d].findIndex( const cache = stationData[d].findIndex(
(data) => data.Station_JP == now.Station_JP (data) => data.Station_JP == now.Station_JP
); );
return cache != -1; return cache != -1;
}); });
return returnData[0]; return returnData[0];
}; };
const lineName = getStationLine(favoriteStation[0][0]); const lineName = getStationLine(favoriteStation[0][0]);
webview.current?.injectJavaScript( webview.current?.injectJavaScript(
`MoveDisplayStation('${lineName}_${favoriteStation[0][0].MyStation}_${favoriteStation[0][0].Station_JP}')` `MoveDisplayStation('${lineName}_${favoriteStation[0][0].MyStation}_${favoriteStation[0][0].Station_JP}')`
); );
once = true; once = true;
}
}; };
return ( return (