Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 35 additions & 24 deletions app/(tabs)/timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }[] = [
Expand All @@ -50,6 +50,7 @@ export default function TimelineScreen() {
const [selectedRoutes, setSelectedRoutes] = useState<Set<string>>(new Set());
const [isFilterExpanded, setIsFilterExpanded] = useState(false);
const lineNames = useLineNames(state.lineIds);
const lineColors = useLineColors(state.lineIds);

// アニメーション用の共有値
const rotateValue = useSharedValue(0);
Expand Down Expand Up @@ -451,33 +452,42 @@ export default function TimelineScreen() {
</Text>
</View>
</TouchableOpacity>
{state.lineIds.map((lineId) => (
<TouchableOpacity
key={lineId}
onPress={() => handleRouteSelect(lineId)}
activeOpacity={0.7}
style={styles.filterButton}
>
<View
className={cn(
"px-3 py-2 rounded-full border",
selectedRoutes.has(lineId)
? "bg-primary border-primary"
: "bg-background border-border"
)}
{state.lineIds.map((lineId) => {
const lineColor = lineColors[lineId];
const isSelected = selectedRoutes.has(lineId);
return (
<TouchableOpacity
key={lineId}
onPress={() => handleRouteSelect(lineId)}
activeOpacity={0.7}
style={styles.filterButton}
>
<Text
<View
className={cn(
"text-sm font-medium",
selectedRoutes.has(lineId) ? "text-white" : "text-foreground"
"px-3 py-2 rounded-full",
!lineColor && "border",
!lineColor && (isSelected ? "bg-primary border-primary" : "bg-background border-border")
)}
numberOfLines={1}
style={lineColor ? {
backgroundColor: isSelected ? lineColor : "transparent",
borderWidth: 1,
borderColor: lineColor,
} : undefined}
>
{lineNames[lineId] ? <><Text style={{ fontWeight: "bold" }}>{lineNames[lineId]}</Text>({lineId})</> : lineId}
</Text>
</View>
</TouchableOpacity>
))}
<Text
className={cn(
"text-sm font-medium",
!lineColor && (isSelected ? "text-white" : "text-foreground")
)}
style={lineColor ? { color: isSelected ? "#FFFFFF" : lineColor } : undefined}
Comment thread
TinyKitten marked this conversation as resolved.
numberOfLines={1}
>
{lineNames[lineId] ? <><Text style={{ fontWeight: "bold" }}>{lineNames[lineId]}</Text>({lineId})</> : lineId}
</Text>
</View>
</TouchableOpacity>
);
})}
</ScrollView>
</View>
)}
Expand Down Expand Up @@ -506,6 +516,7 @@ export default function TimelineScreen() {
state.deviceIds,
state.lineIds,
lineNames,
lineColors,
state.updates.length,
searchQuery,
selectedStates,
Expand Down