import React, { useEffect } from "react"; import { Image, Pressable, Text, View } from "react-native"; import { SafeAreaView } from "react-native-safe-area-context"; import { router } from "expo-router"; import * as Haptics from "expo-haptics"; import { useChat } from "../contexts/ChatContext"; interface NavButton { label: string; key: string; icon?: string; flex?: number; } const NAV_ROWS: NavButton[][] = [ // Row 1: Vi motion [ { label: "0", key: "0" }, { label: "k", key: "k", icon: "↑" }, { label: "G", key: "G" }, { label: "dd", key: "dd" }, ], // Row 2: Arrow keys [ { label: "h", key: "h", icon: "←" }, { label: "j", key: "j", icon: "↓" }, { label: "l", key: "l", icon: "→" }, { label: "Esc", key: "escape" }, ], // Row 3: Action keys [ { label: "Tab", key: "tab" }, { label: "Enter", key: "enter", flex: 2 }, { label: "^C", key: "ctrl-c" }, ], ]; export default function NavigateScreen() { const { latestScreenshot, requestScreenshot, sendNavKey } = useChat(); // Request a screenshot when entering navigation mode useEffect(() => { requestScreenshot(); }, [requestScreenshot]); function handleNavPress(key: string) { Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); sendNavKey(key); } return ( {/* Header */} router.back()} hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }} style={{ width: 36, height: 36, alignItems: "center", justifyContent: "center", borderRadius: 18, backgroundColor: "#1E1E2E", }} > Navigate requestScreenshot()} hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }} style={{ paddingHorizontal: 12, paddingVertical: 8, borderRadius: 12, backgroundColor: "#1E1E2E", }} > Refresh {/* Screenshot area */} {latestScreenshot ? ( ) : ( Loading screenshot... )} {/* Navigation buttons */} {NAV_ROWS.map((row, rowIdx) => ( {row.map((btn) => ( handleNavPress(btn.key)} style={({ pressed }) => ({ flex: btn.flex ?? 1, height: 56, borderRadius: 14, alignItems: "center", justifyContent: "center", backgroundColor: pressed ? "#4A9EFF" : "#1E1E2E", borderWidth: 1.5, borderColor: pressed ? "#4A9EFF" : "#2E2E45", })} > {btn.icon ? ( {btn.icon} {btn.label} ) : ( {btn.label} )} ))} ))} ); }