回転判定の移動、コードの部分共通化

This commit is contained in:
harukin-expo-dev-env
2024-03-09 11:02:52 +00:00
parent d4c9bdae75
commit e1e35168d6
8 changed files with 139 additions and 132 deletions

View File

@@ -1,15 +1,7 @@
import React, { useEffect, useState } from "react";
import {
View,
Text,
TouchableOpacity,
useWindowDimensions,
} from "react-native";
import React from "react";
import { View, TouchableOpacity, useWindowDimensions } from "react-native";
import { StateBox } from "./StateBox";
import {
heightPercentageToDP,
widthPercentageToDP,
} from "react-native-responsive-screen";
import { useDeviceOrientationChange } from "../../../stateBox/useDeviceOrientationChange";
export const TrainDataView = ({
currentTrainData,
@@ -18,16 +10,8 @@ export const TrainDataView = ({
openTrainInfo,
mode = 0,
}) => {
const [isLandscape, setIsLandscape] = useState(false);
const { width, height } = useWindowDimensions();
useEffect(() => {
if (height / width > 1.5) {
setIsLandscape(false);
}
if (height / width < 1.5) {
setIsLandscape(true);
}
}, [width, height]);
const { isLandscape } = useDeviceOrientationChange();
return (
<View