diff --git a/components/Menu/Carousel/CarouselBox.tsx b/components/Menu/Carousel/CarouselBox.tsx
index 0b048fc..240c215 100644
--- a/components/Menu/Carousel/CarouselBox.tsx
+++ b/components/Menu/Carousel/CarouselBox.tsx
@@ -104,7 +104,7 @@ export const CarouselBox = ({
}}
>
- {!!isSearchMode ? "路線検索モードです。上に並んでいる路線を選んでみましょう!" :stationListMode == "position"
+ {!!isSearchMode ? "路線検索モードです。入力欄に駅名やナンバリングを入力したり、上に並んでいる路線を選んでみましょう!" :stationListMode == "position"
? "現在地の近くに駅がありません。"
: "お気に入りリストがありません。お気に入りの駅を追加しよう!"}
diff --git a/components/Menu/Carousel/CarouselTypeChanger.tsx b/components/Menu/Carousel/CarouselTypeChanger.tsx
index 8517190..5b28d3f 100644
--- a/components/Menu/Carousel/CarouselTypeChanger.tsx
+++ b/components/Menu/Carousel/CarouselTypeChanger.tsx
@@ -25,6 +25,10 @@ export const CarouselTypeChanger = ({
setMapMode,
isSearchMode,
setisSearchMode,
+ listUpStation,
+ setListUpStation,
+ input,
+ setInput
}) => {
const tabBarHeight = useBottomTabBarHeight();
const { height, width } = useWindowDimensions();
@@ -62,6 +66,8 @@ export const CarouselTypeChanger = ({
{
+export const SearchUnitBox = ({
+ isSearchMode,
+ setisSearchMode,
+ input,
+ setInput,
+}) => {
const { height, width } = useWindowDimensions();
- const [input, setInput] = React.useState("");
return (
<>
{
>
{!isSearchMode && }
{!!isSearchMode && (
-
-
- {}}
- onChange={(ret) => setInput(ret.nativeEvent.text)}
- value={input}
- style={{ flex: 1 }}
- />
-
+
+
+ {}}
+ onChange={(ret) => setInput(ret.nativeEvent.text)}
+ value={input}
+ style={{ flex: 1 }}
+ />
+
{
diff --git a/menu.js b/menu.js
index f8e7843..1c4b9d8 100644
--- a/menu.js
+++ b/menu.js
@@ -42,7 +42,7 @@ export default function Menu(props) {
const { scrollRef, mapHeight, MapFullHeight, mapMode, setMapMode } = props;
const { navigate, addListener, isFocused } = useNavigation();
const { favoriteStation } = useFavoriteStation();
- const { originalStationList } = useStationList();
+ const { originalStationList,getStationDataFromNameBase } = useStationList();
const { height, width } = useWindowDimensions();
const { bottom, left, right, top } = useSafeAreaInsets();
const tabBarHeight = useBottomTabBarHeight();
@@ -172,25 +172,31 @@ export default function Menu(props) {
const [listUpStation, setListUpStation] = useState([]);
const [isSearchMode, setisSearchMode] = useState(false);
+ const [input, setInput] = React.useState("");
useLayoutEffect(() => {
if (!!isSearchMode) {
const returnData = [];
- Object.keys(lineList_LineWebID).forEach((d, indexBase) => {
- originalStationList[d].forEach((D, index) => {
- if (
- isSearchMode &&
- isSearchMode != stationIDPair[lineList_LineWebID[d]]
- )
- return;
- const latlng = [D.lat, D.lng];
- if (latlng.length == 0) return null;
- if (D.StationNumber == undefined) {
- return null;
- }
- returnData.push([D]);
+ if (!input || input == "") {
+ Object.keys(lineList_LineWebID).forEach((d, indexBase) => {
+ originalStationList[d].forEach((D, index) => {
+ if (
+ isSearchMode &&
+ isSearchMode != stationIDPair[lineList_LineWebID[d]]
+ )
+ return;
+ const latlng = [D.lat, D.lng];
+ if (latlng.length == 0) return null;
+ if (D.StationNumber == undefined) {
+ return null;
+ }
+ returnData.push([D]);
+ });
});
- });
- if (JSON.stringify(returnData) == JSON.stringify(listUpStation)) return;
+ if (JSON.stringify(returnData) == JSON.stringify(listUpStation)) return;
+ }else{
+ const hoge = getStationDataFromNameBase(input);
+ hoge.forEach(d=>returnData.push([d]));
+ }
setListUpStation(returnData);
} else if (stationListMode == "position") {
const returnData = nearPositionStation.filter((d) => d != undefined);
@@ -290,7 +296,7 @@ export default function Menu(props) {
>
)}
@@ -386,7 +396,7 @@ export default function Menu(props) {
listIndex,
navigate,
stationListMode,
- isSearchMode
+ isSearchMode,
}}
/>
{listUpStation[listIndex] && (
@@ -416,6 +426,10 @@ export default function Menu(props) {
setMapMode,
isSearchMode,
setisSearchMode,
+ listUpStation,
+ setListUpStation,
+ input,
+ setInput,
}}
/>
)}
diff --git a/stateBox/useStationList.tsx b/stateBox/useStationList.tsx
index 7073735..73219b2 100644
--- a/stateBox/useStationList.tsx
+++ b/stateBox/useStationList.tsx
@@ -16,6 +16,7 @@ type initialStateType = {
setOriginalStationList: React.Dispatch>;
getStationDataFromName: (id: string) => any[];
getStationDataFromId: (id: string) => any[];
+ getStationDataFromNameBase: (name: string) => any[];
stationList: any[];
getInjectJavascriptAddress: (StationNumber: string) => string;
};
@@ -24,6 +25,7 @@ const initialState = {
setOriginalStationList: () => {},
getStationDataFromName: () => [],
getStationDataFromId: () => [],
+ getStationDataFromNameBase: () => [],
stationList: [],
getInjectJavascriptAddress: (StationNumber: string) => "",
};
@@ -66,6 +68,23 @@ export const StationListProvider: FC = ({ children }) => {
});
return returnArray;
};
+
+ const getStationDataFromNameBase: (name: string) => any[] = (name) => {
+ const returnArray = [];
+ Object.keys(originalStationList).forEach((key) => {
+ originalStationList[key].forEach((station) => {
+ if (!station.StationNumber) return;
+ if (typeof station.StationNumber === "string" && station.StationNumber.includes(name)) {
+ if (!!station.jslodApi) returnArray.push(station);
+ }
+ else if (typeof station.Station_JP === "string" && station.Station_JP.includes(name)) {
+ if (!!station.jslodApi) returnArray.push(station);
+ }
+ });
+ });
+ return returnArray;
+ };
+
const [stationList, setStationList] = useState([[]]);
useEffect(() => {
if (originalStationList.length === 0) return;
@@ -113,6 +132,7 @@ export const StationListProvider: FC = ({ children }) => {
setOriginalStationList,
getStationDataFromName,
getStationDataFromId,
+ getStationDataFromNameBase,
stationList,
getInjectJavascriptAddress,
}}