import React from 'react'; import { View, Text, TextInput, StyleSheet, ScrollView } from 'react-native'; import { Task, RobotAction } from '../types/task'; interface TaskFormProps { task: Task; onTaskChange: (updatedTask: Task) => void; } const TaskForm: React.FC = ({ task, onTaskChange }) => { const handleParamChange = (field: string, value: string) => { const updatedTask = { ...task, parameters: { ...task.parameters, [field]: value, }, }; onTaskChange(updatedTask); }; return ( 任务名称 onTaskChange({ ...task, name: text })} /> 起点 handleParamChange('startLocation', text)} /> 终点 handleParamChange('endLocation', text)} /> 途经点 handleParamChange('waypoint', text)} placeholder="可选" /> 机器人动作 {/* 在实际应用中,这里最好是一个下拉选择器 */} handleParamChange('robotAction', text as RobotAction)} /> 载荷 handleParamChange('payload', text)} /> ); }; const styles = StyleSheet.create({ container: { flex: 1, padding: 16, }, fieldContainer: { marginBottom: 16, }, label: { fontSize: 16, marginBottom: 8, fontWeight: 'bold', }, input: { borderWidth: 1, borderColor: '#ccc', borderRadius: 4, padding: 12, fontSize: 16, }, }); export default TaskForm;