Appsを横向き対応
This commit is contained in:
parent
acecd1a88b
commit
17602751d6
62
Apps.js
62
Apps.js
@ -1,8 +1,25 @@
|
|||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, {
|
||||||
import { View, Platform, Text, TouchableOpacity } from "react-native";
|
useEffect,
|
||||||
|
useLayoutEffect,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
useCallback,
|
||||||
|
} from "react";
|
||||||
|
import {
|
||||||
|
View,
|
||||||
|
Platform,
|
||||||
|
Text,
|
||||||
|
TouchableOpacity,
|
||||||
|
useWindowDimensions,
|
||||||
|
} from "react-native";
|
||||||
import { WebView } from "react-native-webview";
|
import { WebView } from "react-native-webview";
|
||||||
import Constants from "expo-constants";
|
import Constants from "expo-constants";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
|
||||||
|
import {
|
||||||
|
widthPercentageToDP as wp,
|
||||||
|
heightPercentageToDP as hp,
|
||||||
|
} from "react-native-responsive-screen";
|
||||||
import { AS } from "./storageControl";
|
import { AS } from "./storageControl";
|
||||||
import { news } from "./config/newsUpdate";
|
import { news } from "./config/newsUpdate";
|
||||||
import { getStationList, lineList } from "./lib/getStationList";
|
import { getStationList, lineList } from "./lib/getStationList";
|
||||||
@ -11,15 +28,30 @@ import { checkDuplicateTrainData } from "./lib/checkDuplicateTrainData";
|
|||||||
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
||||||
import { useCurrentTrain } from "./stateBox/useCurrentTrain";
|
import { useCurrentTrain } from "./stateBox/useCurrentTrain";
|
||||||
import { SheetManager } from "react-native-actions-sheet";
|
import { SheetManager } from "react-native-actions-sheet";
|
||||||
|
import TrainMenu from "./components/trainMenu";
|
||||||
/*
|
/*
|
||||||
import StatusbarDetect from './StatusbarDetect';
|
import StatusbarDetect from './StatusbarDetect';
|
||||||
var Status = StatusbarDetect(); */
|
var Status = StatusbarDetect(); */
|
||||||
|
|
||||||
export default function Apps({ navigation, webview, stationData }) {
|
export default function Apps({ navigation, webview, stationData }) {
|
||||||
const { currentTrain } = useCurrentTrain();
|
const { currentTrain } = useCurrentTrain();
|
||||||
|
const { height, width } = useWindowDimensions();
|
||||||
const { navigate } = navigation;
|
const { navigate } = navigation;
|
||||||
var urlcache = "";
|
var urlcache = "";
|
||||||
const { favoriteStation } = useFavoriteStation();
|
const { favoriteStation } = useFavoriteStation();
|
||||||
|
const [isLandscape, setIsLandscape] = useState(false); //画面が横向きかどうか
|
||||||
|
const handleLayout = () => {};
|
||||||
|
useEffect(() => {
|
||||||
|
console.log("レイアウト変更");
|
||||||
|
console.log(height, width);
|
||||||
|
console.log(height / width);
|
||||||
|
if (height / width > 1.5) {
|
||||||
|
setIsLandscape(false);
|
||||||
|
}
|
||||||
|
if (height / width < 1.5) {
|
||||||
|
setIsLandscape(true);
|
||||||
|
}
|
||||||
|
}, [height, width]);
|
||||||
|
|
||||||
//画面表示関連
|
//画面表示関連
|
||||||
const [iconSetting, setIconSetting] = useState(undefined);
|
const [iconSetting, setIconSetting] = useState(undefined);
|
||||||
@ -271,8 +303,22 @@ export default function Apps({ navigation, webview, stationData }) {
|
|||||||
style={{
|
style={{
|
||||||
height: "100%",
|
height: "100%",
|
||||||
paddingTop: Platform.OS == "ios" ? Constants.statusBarHeight : 0,
|
paddingTop: Platform.OS == "ios" ? Constants.statusBarHeight : 0,
|
||||||
|
flexDirection: isLandscape ? "row" : "column",
|
||||||
}}
|
}}
|
||||||
|
onLayout={handleLayout}
|
||||||
>
|
>
|
||||||
|
{isLandscape ? (
|
||||||
|
<TrainMenu
|
||||||
|
webview={webview}
|
||||||
|
stationData={stationData}
|
||||||
|
navigation={{ navigate: null }}
|
||||||
|
style={{
|
||||||
|
width: wp("40%"),
|
||||||
|
height: "100%",
|
||||||
|
flexDirection: "column-reverse",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
{/* {Status} */}
|
{/* {Status} */}
|
||||||
<WebView
|
<WebView
|
||||||
useWebKit
|
useWebKit
|
||||||
@ -310,11 +356,13 @@ export default function Apps({ navigation, webview, stationData }) {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<MapsButton
|
{isLandscape || (
|
||||||
onPress={() => navigate("trainMenu", { webview })}
|
<MapsButton
|
||||||
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
onPress={() => navigate("trainMenu", { webview })}
|
||||||
mapSwitch={mapSwitch == "true" ? "flex" : "none"}
|
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
||||||
/>
|
mapSwitch={mapSwitch == "true" ? "flex" : "none"}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<ReloadButton
|
<ReloadButton
|
||||||
onPress={() => webview.current.reload()}
|
onPress={() => webview.current.reload()}
|
||||||
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
||||||
|
2
app.json
2
app.json
@ -8,7 +8,7 @@
|
|||||||
"android"
|
"android"
|
||||||
],
|
],
|
||||||
"version": "4.6",
|
"version": "4.6",
|
||||||
"orientation": "portrait",
|
"orientation": "default",
|
||||||
"icon": "./assets/icon.png",
|
"icon": "./assets/icon.png",
|
||||||
"splash": {
|
"splash": {
|
||||||
"image": "./assets/splash.png",
|
"image": "./assets/splash.png",
|
||||||
|
@ -6,10 +6,11 @@ export default function TrainMenu({
|
|||||||
navigation: { navigate },
|
navigation: { navigate },
|
||||||
webview,
|
webview,
|
||||||
stationData,
|
stationData,
|
||||||
|
style,
|
||||||
}) {
|
}) {
|
||||||
const mapRef = useRef();
|
const mapRef = useRef();
|
||||||
return (
|
return (
|
||||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
<View style={{ height: "100%", backgroundColor: "#0099CC", ...style }}>
|
||||||
<MapView
|
<MapView
|
||||||
style={{ flex: 1, width: "100%", height: "100%" }}
|
style={{ flex: 1, width: "100%", height: "100%" }}
|
||||||
showsUserLocation={true}
|
showsUserLocation={true}
|
||||||
@ -46,65 +47,69 @@ export default function TrainMenu({
|
|||||||
webview.current?.injectJavaScript(
|
webview.current?.injectJavaScript(
|
||||||
`MoveDisplayStation('${d}_${D.MyStation}_${D.Station_JP}')`
|
`MoveDisplayStation('${d}_${D.MyStation}_${D.Station_JP}')`
|
||||||
);
|
);
|
||||||
navigate("Apps");
|
if (navigate) navigate("Apps");
|
||||||
}}
|
}}
|
||||||
></Marker>
|
></Marker>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
)}
|
)}
|
||||||
</MapView>
|
</MapView>
|
||||||
<View style={{ flexDirection: "row" }}>
|
{navigate && (
|
||||||
<UsefulBox
|
<View style={{ flexDirection: "row" }}>
|
||||||
backgroundColor={"#F89038"}
|
<UsefulBox
|
||||||
icon="train-car"
|
backgroundColor={"#F89038"}
|
||||||
flex={1}
|
icon="train-car"
|
||||||
onPressButton={() =>
|
flex={1}
|
||||||
navigate("howto", {
|
onPressButton={() =>
|
||||||
info: "https://train.jr-shikoku.co.jp/usage.htm",
|
navigate("howto", {
|
||||||
})
|
info: "https://train.jr-shikoku.co.jp/usage.htm",
|
||||||
}
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
使い方
|
||||||
|
</UsefulBox>
|
||||||
|
<UsefulBox
|
||||||
|
backgroundColor={"#EA4752"}
|
||||||
|
icon="star"
|
||||||
|
flex={1}
|
||||||
|
onPressButton={() => navigate("favoriteList")}
|
||||||
|
>
|
||||||
|
お気に入り
|
||||||
|
</UsefulBox>
|
||||||
|
<UsefulBox
|
||||||
|
backgroundColor={"#91C31F"}
|
||||||
|
icon="clipboard-list-outline"
|
||||||
|
flex={1}
|
||||||
|
onPressButton={() =>
|
||||||
|
Linking.openURL(
|
||||||
|
"https://nexcloud.haruk.in/apps/forms/ZRHjWFF7znr5Xjr2"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
フィードバック
|
||||||
|
</UsefulBox>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
{navigate && (
|
||||||
|
<TouchableOpacity
|
||||||
|
style={{
|
||||||
|
padding: 10,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderColor: "white",
|
||||||
|
borderWidth: 1,
|
||||||
|
margin: 10,
|
||||||
|
borderRadius: 5,
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
onPress={() => navigate("Apps")}
|
||||||
>
|
>
|
||||||
使い方
|
<View style={{ flex: 1 }} />
|
||||||
</UsefulBox>
|
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||||
<UsefulBox
|
閉じる
|
||||||
backgroundColor={"#EA4752"}
|
</Text>
|
||||||
icon="star"
|
<View style={{ flex: 1 }} />
|
||||||
flex={1}
|
</TouchableOpacity>
|
||||||
onPressButton={() => navigate("favoriteList")}
|
)}
|
||||||
>
|
|
||||||
お気に入り
|
|
||||||
</UsefulBox>
|
|
||||||
<UsefulBox
|
|
||||||
backgroundColor={"#91C31F"}
|
|
||||||
icon="clipboard-list-outline"
|
|
||||||
flex={1}
|
|
||||||
onPressButton={() =>
|
|
||||||
Linking.openURL(
|
|
||||||
"https://nexcloud.haruk.in/apps/forms/ZRHjWFF7znr5Xjr2"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
この機能のフィードバック
|
|
||||||
</UsefulBox>
|
|
||||||
</View>
|
|
||||||
<TouchableOpacity
|
|
||||||
style={{
|
|
||||||
padding: 10,
|
|
||||||
flexDirection: "row",
|
|
||||||
borderColor: "white",
|
|
||||||
borderWidth: 1,
|
|
||||||
margin: 10,
|
|
||||||
borderRadius: 5,
|
|
||||||
alignItems: "center",
|
|
||||||
}}
|
|
||||||
onPress={() => navigate("Apps")}
|
|
||||||
>
|
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
|
||||||
閉じる
|
|
||||||
</Text>
|
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -115,14 +120,14 @@ const UsefulBox = (props) => {
|
|||||||
style={{
|
style={{
|
||||||
flex: flex,
|
flex: flex,
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
padding: 10,
|
padding: 5,
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
margin: 2,
|
margin: 2,
|
||||||
}}
|
}}
|
||||||
onPress={onPressButton}
|
onPress={onPressButton}
|
||||||
>
|
>
|
||||||
<MaterialCommunityIcons name={icon} color="white" size={50} />
|
<MaterialCommunityIcons name={icon} color="white" size={50} />
|
||||||
<Text style={{ color: "white", fontWeight: "bold", fontSize: 18 }}>
|
<Text style={{ color: "white", fontWeight: "bold", fontSize: 16 }}>
|
||||||
{children}
|
{children}
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
Loading…
Reference in New Issue
Block a user