画面回転を固定するように組み込み
This commit is contained in:
parent
e1e35168d6
commit
48e1ab7b26
12
app.json
12
app.json
@ -22,7 +22,13 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"expo-font"
|
||||
"expo-font",
|
||||
[
|
||||
"expo-screen-orientation",
|
||||
{
|
||||
"initialOrientation": "DEFAULT"
|
||||
}
|
||||
]
|
||||
],
|
||||
"version": "5.0",
|
||||
"orientation": "default",
|
||||
@ -38,7 +44,7 @@
|
||||
},
|
||||
"assetBundlePatterns": ["**/*"],
|
||||
"ios": {
|
||||
"buildNumber": "31",
|
||||
"buildNumber": "32",
|
||||
"supportsTablet": true,
|
||||
"bundleIdentifier": "jrshikokuinfo.xprocess.hrkn",
|
||||
"config": {
|
||||
@ -57,7 +63,7 @@
|
||||
},
|
||||
"android": {
|
||||
"package": "jrshikokuinfo.xprocess.hrkn",
|
||||
"versionCode": 20,
|
||||
"versionCode": 21,
|
||||
"permissions": ["ACCESS_FINE_LOCATION", "NFC"],
|
||||
"googleServicesFile": "./google-services.json",
|
||||
"config": {
|
||||
|
@ -22,6 +22,7 @@
|
||||
"expo-font": "~11.10.3",
|
||||
"expo-location": "~16.5.5",
|
||||
"expo-notifications": "~0.27.6",
|
||||
"expo-screen-orientation": "~6.4.1",
|
||||
"expo-sharing": "~11.10.0",
|
||||
"expo-updates": "~0.24.11",
|
||||
"expo-web-browser": "~12.8.2",
|
||||
|
@ -1,5 +1,6 @@
|
||||
import React, { createContext, useContext, useState, useEffect } from "react";
|
||||
import { useWindowDimensions } from "react-native";
|
||||
import * as ScreenOrientation from "expo-screen-orientation";
|
||||
const initialState = { isLandscape: false, setIsLandscape: () => {} };
|
||||
|
||||
const DeviceOrientationChange = createContext(initialState);
|
||||
@ -11,13 +12,22 @@ export const useDeviceOrientationChange = () => {
|
||||
export const DeviceOrientationChangeProvider = ({ children }) => {
|
||||
const [isLandscape, setIsLandscape] = useState(false);
|
||||
const { height, width } = useWindowDimensions();
|
||||
const data = async () => {
|
||||
await ScreenOrientation.lockAsync(
|
||||
ScreenOrientation.OrientationLock.PORTRAIT_UP
|
||||
);
|
||||
};
|
||||
useEffect(() => {
|
||||
data();
|
||||
//ScreenOrientation.unlockAsync();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (height / width > 1.5) {
|
||||
setIsLandscape(false);
|
||||
}
|
||||
if (height / width < 1.5) {
|
||||
setIsLandscape(true);
|
||||
//setIsLandscape(true);
|
||||
}
|
||||
}, [height, width]);
|
||||
return (
|
||||
|
@ -5474,6 +5474,11 @@ expo-notifications@~0.27.6:
|
||||
expo-constants "~15.4.0"
|
||||
fs-extra "^9.1.0"
|
||||
|
||||
expo-screen-orientation@~6.4.1:
|
||||
version "6.4.1"
|
||||
resolved "https://registry.yarnpkg.com/expo-screen-orientation/-/expo-screen-orientation-6.4.1.tgz#1c4428a058921e48b5caa45367e626b8bec10e24"
|
||||
integrity sha512-VM0C9ORNL1aT6Dr2OUeryzV519n0FjtXI2m+HlijOMi1QT2bPg4tBkCd7HLgywU4dZ1Esa46ewUudmk+fOqmMQ==
|
||||
|
||||
expo-sharing@~11.10.0:
|
||||
version "11.10.0"
|
||||
resolved "https://registry.yarnpkg.com/expo-sharing/-/expo-sharing-11.10.0.tgz#0e85197ee4d2634b00fe201e571fbdc64cf83eef"
|
||||
|
Loading…
Reference in New Issue
Block a user