diff --git a/app/(tabs)/timeline.tsx b/app/(tabs)/timeline.tsx index f08fbf2..5d2fd47 100644 --- a/app/(tabs)/timeline.tsx +++ b/app/(tabs)/timeline.tsx @@ -25,7 +25,7 @@ import { useLocation } from "@/lib/location-store"; import type { LocationUpdate, MovingState } from "@/lib/types/location"; import { cn } from "@/lib/utils"; import { useColors } from "@/hooks/use-colors"; -import { useLineNames } from "@/hooks/use-line-names"; +import { useLineNames, useLineColors } from "@/hooks/use-line-names"; // 状態フィルターオプションの定義 const MOVING_STATES: { value: MovingState; label: string }[] = [ @@ -50,6 +50,7 @@ export default function TimelineScreen() { const [selectedRoutes, setSelectedRoutes] = useState>(new Set()); const [isFilterExpanded, setIsFilterExpanded] = useState(false); const lineNames = useLineNames(state.lineIds); + const lineColors = useLineColors(state.lineIds); // アニメーション用の共有値 const rotateValue = useSharedValue(0); @@ -451,33 +452,42 @@ export default function TimelineScreen() { - {state.lineIds.map((lineId) => ( - handleRouteSelect(lineId)} - activeOpacity={0.7} - style={styles.filterButton} - > - { + const lineColor = lineColors[lineId]; + const isSelected = selectedRoutes.has(lineId); + return ( + handleRouteSelect(lineId)} + activeOpacity={0.7} + style={styles.filterButton} > - - {lineNames[lineId] ? <>{lineNames[lineId]}({lineId}) : lineId} - - - - ))} + + {lineNames[lineId] ? <>{lineNames[lineId]}({lineId}) : lineId} + + + + ); + })} )} @@ -506,6 +516,7 @@ export default function TimelineScreen() { state.deviceIds, state.lineIds, lineNames, + lineColors, state.updates.length, searchQuery, selectedStates,