From 12dd0ec6d3c945129101d3211a5a4765c2bbaf1d Mon Sep 17 00:00:00 2001 From: Tsubasa SEKIGUCHI Date: Sat, 12 Oct 2024 17:02:35 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AA=E3=83=BC=E3=83=88=E3=83=A2=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=83=9C=E3=82=BF=E3=83=B3=E3=81=AE=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/screens/SelectBound.tsx | 13 ------------- src/screens/SelectLine.tsx | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/screens/SelectBound.tsx b/src/screens/SelectBound.tsx index 223903d70..a54cb7819 100644 --- a/src/screens/SelectBound.tsx +++ b/src/screens/SelectBound.tsx @@ -22,7 +22,6 @@ import Heading from '../components/Heading' import Typography from '../components/Typography' import { TOEI_OEDO_LINE_ID } from '../constants' import { TOEI_OEDO_LINE_TOCHOMAE_STATION_ID } from '../constants/station' -import { useApplicationFlagStore } from '../hooks/useApplicationFlagStore' import useBounds from '../hooks/useBounds' import { useLoopLine } from '../hooks/useLoopLine' import { useStationList } from '../hooks/useStationList' @@ -84,13 +83,6 @@ const SelectBoundScreen: React.FC = () => { bounds: [inboundStations, outboundStations], } = useBounds() - const autoModeEnabled = useApplicationFlagStore( - (state) => state.autoModeEnabled - ) - const toggleAutoModeEnabled = useApplicationFlagStore( - (state) => state.toggleAutoModeEnabled - ) - // 種別選択ボタンを表示するかのフラグ const withTrainTypes = useMemo( (): boolean => fetchedTrainTypes.length > 1, @@ -314,10 +306,6 @@ const SelectBoundScreen: React.FC = () => { return subscription.remove }, [handleSelectBoundBackButtonPress]) - const autoModeButtonText = `${translate('autoModeSettings')}: ${ - autoModeEnabled ? 'ON' : 'OFF' - }` - if (error) { return ( { {translate('selectBoundSettings')} ) : null} - diff --git a/src/screens/SelectLine.tsx b/src/screens/SelectLine.tsx index e3252e4eb..1a86fd423 100644 --- a/src/screens/SelectLine.tsx +++ b/src/screens/SelectLine.tsx @@ -1,6 +1,6 @@ import AsyncStorage from '@react-native-async-storage/async-storage' import { useNavigation } from '@react-navigation/native' -import React, { useCallback, useEffect } from 'react' +import React, { useCallback, useEffect, useMemo } from 'react' import { Alert, ScrollView, StyleSheet, View } from 'react-native' import { useSetRecoilState } from 'recoil' import { Line } from '../../gen/proto/stationapi_pb' @@ -10,6 +10,7 @@ import FAB from '../components/FAB' import Heading from '../components/Heading' import Loading from '../components/Loading' import { ASYNC_STORAGE_KEYS, parenthesisRegexp } from '../constants' +import { useApplicationFlagStore } from '../hooks/useApplicationFlagStore' import useConnectivity from '../hooks/useConnectivity' import { useCurrentStation } from '../hooks/useCurrentStation' import { useFetchCurrentLocationOnce } from '../hooks/useFetchCurrentLocationOnce' @@ -50,6 +51,14 @@ const SelectLineScreen: React.FC = () => { const setStationState = useSetRecoilState(stationState) const setNavigationState = useSetRecoilState(navigationState) const setLineState = useSetRecoilState(lineState) + + const autoModeEnabled = useApplicationFlagStore( + (state) => state.autoModeEnabled + ) + const toggleAutoModeEnabled = useApplicationFlagStore( + (state) => state.toggleAutoModeEnabled + ) + const { fetchByCoords, isLoading: nearbyStationLoading, @@ -219,6 +228,11 @@ const SelectLineScreen: React.FC = () => { navigation.navigate('RouteSearch') }, [navigation]) + const autoModeButtonText = useMemo( + () => `${translate('autoModeSettings')}: ${autoModeEnabled ? 'ON' : 'OFF'}`, + [autoModeEnabled] + ) + if (nearbyStationFetchError) { return ( { ) : null} + +