小規模なアニメーション調整

This commit is contained in:
harukin-expo-dev-env
2025-08-28 15:08:39 +00:00
parent b38d8fe39d
commit 8b74273fed
2 changed files with 78 additions and 39 deletions

View File

@@ -1,4 +1,4 @@
import { FC, useRef, useState, useCallback } from "react"; import { FC, useRef, useState, useCallback, useEffect } from "react";
import { import {
View, View,
Text, Text,
@@ -43,42 +43,68 @@ export const ExGridView: FC<{
time: string; time: string;
isOperating: boolean; isOperating: boolean;
}[]; }[];
} = {"4":[], } = {
"5":[], "4": [],
"6":[], "5": [],
"7":[], "6": [],
"8":[], "7": [],
"9":[], "8": [],
"10":[], "9": [],
"11":[], "10": [],
"12":[], "11": [],
"13":[], "12": [],
"14":[], "13": [],
"15":[], "14": [],
"16":[], "15": [],
"17":[], "16": [],
"18":[], "17": [],
"19":[], "18": [],
"20":[], "19": [],
"21":[], "20": [],
"22":[], "21": [],
"23":[], "22": [],
"0":[], "23": [],
"1":[], "0": [],
"2":[], "1": [],
"3":[] "2": [],
"3": [],
}; };
const groupKeys: string[] = ["4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","0","1","2","3"]; const groupKeys: string[] = [
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
"23",
"0",
"1",
"2",
"3",
];
const { width } = useWindowDimensions(); const { width } = useWindowDimensions();
const { currentTrain } = useCurrentTrain(); const { currentTrain } = useCurrentTrain();
data.forEach((item) => { data.forEach((item) => {
let isOperating = false; let isOperating = false;
let [hour, minute] = dayjs() let [hour, minute] = dayjs()
.hour(parseInt(item.time.split(":")[0])) .hour(parseInt(item.time.split(":")[0]))
.minute(parseInt(item.time.split(":")[1])) .minute(parseInt(item.time.split(":")[1]))
.format("H:m") .format("H:m")
.split(":"); .split(":");
if (currentTrain.findIndex((x) => x.num == item.trainNumber) != -1) { if (currentTrain.findIndex((x) => x.num == item.trainNumber) != -1) {
const currentTrainTime = currentTrain.find( const currentTrainTime = currentTrain.find(
(x) => x.num == item.trainNumber (x) => x.num == item.trainNumber
@@ -93,19 +119,15 @@ export const ExGridView: FC<{
} }
isOperating = true; isOperating = true;
} }
// if (!groupedData[hour]) {
// groupedData[hour] = [];
// groupKeys.push(hour);
// }
groupedData[hour].push({ ...item, time: `${hour}:${minute}`, isOperating }); groupedData[hour].push({ ...item, time: `${hour}:${minute}`, isOperating });
}); });
// ドラッグ位置を保持する共有値 // ドラッグ位置を保持する共有値
const widthX = useSharedValue(width); const widthX = useSharedValue(width);
const savedWidthX = useSharedValue(width); const savedWidthX = useSharedValue(width);
const isChanging = useSharedValue(false); const isChanging = useSharedValue(false);
const animationProgress = useSharedValue(0); // アニメーション進行度
const [scrollEnabled, setScrollEnabled] = useState(true); const [scrollEnabled, setScrollEnabled] = useState(true);
const scrollRef = useRef<Animated.ScrollView>(null); const scrollRef = useRef<Animated.ScrollView>(null);
const scrollRef2 = useRef<Animated.ScrollView>(null);
// ScrollViewの有効/無効を切り替える関数 // ScrollViewの有効/無効を切り替える関数
const toggleScrollEnabled = useCallback((enabled: boolean) => { const toggleScrollEnabled = useCallback((enabled: boolean) => {
@@ -175,6 +197,15 @@ export const ExGridView: FC<{
const animatedLongPressStyle = useAnimatedStyle(() => ({ const animatedLongPressStyle = useAnimatedStyle(() => ({
display: isChanging.value ? "flex" : "none", display: isChanging.value ? "flex" : "none",
})); }));
useEffect(() => {
const getCurrentTime = dayjs().hour();
setTimeout(() => {
const goTo = getCurrentTime * 60;
if (goTo > 400) {
scrollRef2.current?.scrollTo({ y: goTo - 300, animated: true });
}
}, 400);
}, [scrollRef2]);
return ( return (
<> <>
<Animated.View <Animated.View
@@ -184,11 +215,12 @@ export const ExGridView: FC<{
width, width,
backgroundColor: "#26d1baff", backgroundColor: "#26d1baff",
zIndex: 500, zIndex: 500,
top:0 top: 0,
}, },
animatedLongPressStyle, animatedLongPressStyle,
]} ]}
entering={FadeInUp} exiting={FadeOutUp} entering={FadeInUp}
exiting={FadeOutUp}
> >
<Text style={{ fontSize: 30, textAlign: "center", flex: 1 }}> <Text style={{ fontSize: 30, textAlign: "center", flex: 1 }}>
     
@@ -268,6 +300,7 @@ export const ExGridView: FC<{
stickyHeaderIndices={ stickyHeaderIndices={
groupKeys.at(0) ? groupKeys.map((_, i) => i * 2) : [] groupKeys.at(0) ? groupKeys.map((_, i) => i * 2) : []
} }
ref={scrollRef2}
> >
{groupKeys.map((hour) => [ {groupKeys.map((hour) => [
<View <View
@@ -293,7 +326,13 @@ export const ExGridView: FC<{
{hour} {hour}
</Animated.Text> </Animated.Text>
</View>, </View>,
<View style={{ flexDirection: "row", position: "relative", height: 50 }}> <View
style={{
flexDirection: "row",
position: "relative",
height: 50,
}}
>
{groupedData[hour].map((d, i, array) => ( {groupedData[hour].map((d, i, array) => (
<ExGridViewItem <ExGridViewItem
key={d.trainNumber + i} key={d.trainNumber + i}

View File

@@ -179,7 +179,7 @@ export const ExGridViewItem: FC<{
}, },
navigate, navigate,
openStationACFromEachTrainInfo, openStationACFromEachTrainInfo,
from: "AllTrainIDList", from: d.isOperating ? null :"AllTrainIDList",
}; };
SheetManager.show("EachTrainInfo", { SheetManager.show("EachTrainInfo", {
//@ts-ignore //@ts-ignore