Files
jrshikoku/components/Menu/Carousel/GridMiniSign.tsx
harukin-expo-dev-env 5202f35702 feat: 与島(観光スポット)をトップメニューに追加
- assets/originData/spots.ts: 与島PAデータを新規作成(isSpot: true, StationNumber: null)
- lib/CommonTypes.ts: StationProps に isSpot フラグを追加
- lib/getStationList.ts: 観光スポットキーとして stationList に追加
- stateBox/useStationList.tsx: StationNumber: null でも名前検索が通るよう修正、getInjectJavascriptAddress で路線外エントリをスキップ
- menu.tsx: 位置情報検索に観光スポットを追加
- components/観光スポット看板/SpotSign.tsx: テーマパーク風の観光スポット看板コンポーネントを新規作成
- components/Menu/Carousel/CarouselBox.tsx: isSpot フラグで SpotSign に切り替え
- components/Menu/Carousel/GridMiniSign.tsx: isSpot 対応・ドット除去表示
- components/StationDiagram/SearchBox/SearchInputSuggestBox.tsx: ドット除去表示
- components/StationDiagram/StationDiagramView.tsx: スポットの「駅」表記を除去

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-24 01:58:16 +00:00

126 lines
3.4 KiB
TypeScript

import React, { FC } from "react";
import { Text, TouchableOpacity, View } from "react-native";
import lineColorList from "@/assets/originData/lineColorList";
import { lightColors, useThemeColors } from "@/lib/theme";
type Props = {
item: any[]; // StationProps[] (路線をまたぐ同名駅の配列)
width: number;
height: number;
onPress?: () => void;
};
/**
* グリッド表示専用の軽量駅カード。
* Sign コンポーネントを使わず、駅番号・駅名をシンプルに描画するだけで
* hooks・Lottie・前後駅計算などを一切持たない純粋な表示コンポーネント。
*/
export const GridMiniSign: FC<Props> = React.memo(({ item, width, height, onPress }) => {
const { fixed } = useThemeColors();
const station = item[0];
const isSpot = !!station.isSpot;
const lineId = isSpot ? "" : (station.StationNumber?.slice(0, 1) ?? "Y");
const lineNum = isSpot ? "" : (station.StationNumber?.slice(1) ?? "");
const lineColor = lineColorList[lineId] ?? fixed.primary;
const rawName = station.Station_JP ?? "";
const displayName = rawName.startsWith(".") ? rawName.slice(1) : rawName;
const nameLen = displayName.length;
const nameFontSize = nameLen <= 3 ? 22 : nameLen <= 5 ? 16 : 12;
return (
<TouchableOpacity
onPress={onPress}
activeOpacity={0.85}
style={{
width,
height,
borderColor: fixed.primary,
borderWidth: 1,
backgroundColor: lightColors.background,
overflow: "hidden",
}}
>
{/* 駅番号バッジ */}
<View
style={{
position: "absolute",
top: "8%",
right: "8%",
width: height * 0.28,
height: height * 0.28,
borderRadius: height * 0.14,
borderColor: lineColor,
borderWidth: 2,
backgroundColor: lightColors.background,
alignItems: "center",
justifyContent: "center",
}}
>
<Text
style={{
fontSize: height * 0.1,
fontWeight: "bold",
color: lightColors.text,
textAlign: "center",
lineHeight: height * 0.12,
}}
numberOfLines={2}
adjustsFontSizeToFit
>
{lineId + "\n" + lineNum}
</Text>
</View>
{/* 駅名(日本語・英語) */}
<View
style={{
position: "absolute",
top: "10%",
left: 0,
right: 0,
bottom: "28%",
alignItems: "center",
justifyContent: "center",
}}
>
<Text
style={{
fontSize: nameFontSize,
fontWeight: "bold",
color: lightColors.textStationName,
textAlign: "center",
}}
adjustsFontSizeToFit
numberOfLines={1}
>
{displayName}
</Text>
<Text
style={{
fontSize: 8,
color: lightColors.textStationName,
textAlign: "center",
marginTop: 2,
}}
numberOfLines={1}
adjustsFontSizeToFit
>
{station.Station_EN}
</Text>
</View>
{/* 下帯 */}
<View
style={{
position: "absolute",
bottom: 0,
left: 0,
right: 0,
height: "26%",
backgroundColor: fixed.primary,
}}
/>
</TouchableOpacity>
);
});