横方向のアニメーションや要素の被りを修正

This commit is contained in:
harukin-OneMix4 2024-02-12 21:51:35 +09:00
parent bf2b4d356c
commit c45c58cc64
3 changed files with 108 additions and 20 deletions

85
Apps.js
View File

@ -5,6 +5,7 @@ import {
Text, Text,
TouchableOpacity, TouchableOpacity,
useWindowDimensions, useWindowDimensions,
LayoutAnimation,
} from "react-native"; } 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";
@ -19,6 +20,7 @@ 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 TrainMenu from "./components/trainMenu";
import { EachTrainInfoCore } from "./components/ActionSheetComponents/EachTrainInfoCore";
/* /*
import StatusbarDetect from './StatusbarDetect'; import StatusbarDetect from './StatusbarDetect';
var Status = StatusbarDetect(); */ var Status = StatusbarDetect(); */
@ -186,6 +188,7 @@ export default function Apps({ navigation, webview, stationData }) {
case "ShowTrainTimeInfo": { case "ShowTrainTimeInfo": {
const { trainNum, limited } = dataSet; const { trainNum, limited } = dataSet;
//alert(trainNum, limited); //alert(trainNum, limited);
LayoutAnimation.easeInEaseOut();
setTrainInfo({ setTrainInfo({
trainNum, trainNum,
limited, limited,
@ -193,6 +196,7 @@ export default function Apps({ navigation, webview, stationData }) {
currentTrain.filter((a) => a.num == trainNum) currentTrain.filter((a) => a.num == trainNum)
), ),
}); //遅延情報は未実装 }); //遅延情報は未実装
if (isLandscape) return;
const payload = { const payload = {
data: { data: {
trainNum, trainNum,
@ -294,7 +298,7 @@ export default function Apps({ navigation, webview, stationData }) {
}} }}
onLayout={handleLayout} onLayout={handleLayout}
> >
{isLandscape ? ( {!trainInfo.trainData && isLandscape ? (
<TrainMenu <TrainMenu
webview={webview} webview={webview}
stationData={stationData} stationData={stationData}
@ -343,6 +347,25 @@ export default function Apps({ navigation, webview, stationData }) {
} }
}} }}
/> />
{isLandscape && trainInfo.trainData && (
<View
style={{
width: (width / 100) * 40,
height: height,
flexDirection: "column",
}}
>
<EachTrainInfoCore
{...{
data: trainInfo.trainData ? trainInfo : undefined,
navigate,
originalStationList,
openStationACFromEachTrainInfo,
from: "Train",
}}
/>
</View>
)}
{isLandscape || ( {isLandscape || (
<MapsButton <MapsButton
onPress={() => navigate("trainMenu", { webview })} onPress={() => navigate("trainMenu", { webview })}
@ -350,9 +373,23 @@ export default function Apps({ navigation, webview, stationData }) {
mapSwitch={mapSwitch == "true" ? "flex" : "none"} mapSwitch={mapSwitch == "true" ? "flex" : "none"}
/> />
)} )}
{isLandscape && trainInfo.trainData && (
<LandscapeBackButton
onPress={() => {
LayoutAnimation.easeInEaseOut();
setTrainInfo({
trainNum: undefined,
limited: undefined,
trainData: undefined,
});
}}
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
/>
)}
<ReloadButton <ReloadButton
onPress={() => webview.current.reload()} onPress={() => webview.current.reload()}
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0} top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
right={isLandscape && trainInfo.trainData ? (width / 100) * 40 : 0}
LoadError={LoadError} LoadError={LoadError}
/> />
</View> </View>
@ -395,12 +432,54 @@ const MapsButton = ({ onPress, top, mapSwitch }) => {
); );
}; };
const ReloadButton = ({ onPress, top, mapSwitch, LoadError = false }) => { const LandscapeBackButton = ({ onPress, top }) => {
const styles = { const styles = {
touch: { touch: {
position: "absolute", position: "absolute",
top, top,
right: 10, left: 10,
width: 50,
height: 50,
backgroundColor: "#0099CC",
borderColor: "white",
borderStyle: "solid",
borderWidth: 1,
borderRadius: 50,
alignContent: "center",
alignSelf: "center",
alignItems: "center",
display: "flex",
},
text: {
textAlign: "center",
width: "auto",
height: "auto",
textAlignVertical: "center",
fontWeight: "bold",
color: "white",
},
};
return (
<TouchableOpacity onPress={onPress} style={styles.touch}>
<View style={{ flex: 1 }} />
<Ionicons name="arrow-back" color="white" size={30} />
<View style={{ flex: 1 }} />
</TouchableOpacity>
);
};
const ReloadButton = ({
onPress,
top,
mapSwitch,
LoadError = false,
right,
}) => {
const styles = {
touch: {
position: "absolute",
top,
right: 10 + right,
width: 50, width: 50,
height: 50, height: 50,
backgroundColor: LoadError ? "red" : "#0099CC", backgroundColor: LoadError ? "red" : "#0099CC",

View File

@ -35,7 +35,7 @@ export const TrainDataView = ({
flexDirection: "row", flexDirection: "row",
//minHeight: 200, //minHeight: 200,
//height: heightPercentageToDP("20%"), //height: heightPercentageToDP("20%"),
width: isLandscape ? width / 2 : width, width: isLandscape ? (width / 100) * 40 : width,
flex: 1, flex: 1,
}} }}
> >

View File

@ -52,7 +52,7 @@ export const EachTrainInfoCore = ({
currentTrain.filter((d) => d.num == data.trainNum) currentTrain.filter((d) => d.num == data.trainNum)
) )
); );
}, [currentTrain]); }, [currentTrain, data.trainNum]);
//bconst insets = useSafeAreaInsets(); //bconst insets = useSafeAreaInsets();
@ -232,7 +232,9 @@ export const EachTrainInfoCore = ({
setNearTrainIDList(returnArray); setNearTrainIDList(returnArray);
setShowNearTrain(TDArray); setShowNearTrain(TDArray);
}, [data]); }, [data]);
const scrollHandlers = useScrollHandlers("scrollview-1", actionSheetRef); const scrollHandlers = actionSheetRef
? useScrollHandlers("scrollview-1", actionSheetRef)
: null;
const migrateTrainName = (string) => { const migrateTrainName = (string) => {
return string return string
.replace("マリン", "マリンライナー") .replace("マリン", "マリンライナー")
@ -401,6 +403,7 @@ export const EachTrainInfoCore = ({
borderWidth: 1, borderWidth: 1,
}} }}
> >
{isLandscape || (
<View style={{ height: 26, width: "100%" }}> <View style={{ height: 26, width: "100%" }}>
<View <View
style={{ style={{
@ -413,6 +416,7 @@ export const EachTrainInfoCore = ({
}} }}
/> />
</View> </View>
)}
<View style={{ padding: 10, flexDirection: "row", alignItems: "center" }}> <View style={{ padding: 10, flexDirection: "row", alignItems: "center" }}>
<Text style={{ fontSize: 20, fontWeight: "bold", color: "white" }}> <Text style={{ fontSize: 20, fontWeight: "bold", color: "white" }}>
{data.limited {data.limited
@ -450,7 +454,8 @@ export const EachTrainInfoCore = ({
/> />
)} )}
</View> </View>
{isLandscape ? ( {/* {isLandscape */}
{false ? (
<LandscapeTrainInfo <LandscapeTrainInfo
scrollHandlers={scrollHandlers} scrollHandlers={scrollHandlers}
leftContent={ leftContent={
@ -552,7 +557,11 @@ export const EachTrainInfoCore = ({
styles={styles} styles={styles}
scrollViewProps={scrollHandlers} scrollViewProps={scrollHandlers}
containerProps={{ containerProps={{
style: { maxHeight: heightPercentageToDP("70%") }, style: {
maxHeight: isLandscape
? height - 94
: heightPercentageToDP("70%"),
},
}} }}
Max_Header_Height={from == "AllTrainDiagramView" ? 0 : 200} Max_Header_Height={from == "AllTrainDiagramView" ? 0 : 200}
Min_Header_Height={from == "AllTrainDiagramView" ? 0 : 80} Min_Header_Height={from == "AllTrainDiagramView" ? 0 : 80}