From 48e1ab7b26395e0f22e15cac42476559274052c7 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sat, 9 Mar 2024 13:48:53 +0000 Subject: [PATCH] =?UTF-8?q?=E7=94=BB=E9=9D=A2=E5=9B=9E=E8=BB=A2=E3=82=92?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E7=B5=84=E3=81=BF=E8=BE=BC=E3=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 12 +++++++++--- package.json | 1 + stateBox/useDeviceOrientationChange.js | 12 +++++++++++- yarn.lock | 5 +++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app.json b/app.json index 8ee7df3..75c0078 100644 --- a/app.json +++ b/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": { diff --git a/package.json b/package.json index 361f45a..3f7db2d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/stateBox/useDeviceOrientationChange.js b/stateBox/useDeviceOrientationChange.js index e79e5c0..79c305f 100644 --- a/stateBox/useDeviceOrientationChange.js +++ b/stateBox/useDeviceOrientationChange.js @@ -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 ( diff --git a/yarn.lock b/yarn.lock index 33bd9f0..9f0453d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"