diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index e20e4c5e..6d518113 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -17,7 +17,7 @@ diff --git a/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png index ccb74bb6..d2e6c844 100644 Binary files a/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png and b/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png index 752f3061..6e7740fd 100644 Binary files a/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png and b/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png index d50460a2..063d3239 100644 Binary files a/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png and b/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png index 359a7652..6ec08c5f 100644 Binary files a/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png and b/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png index b4737524..896919f3 100644 Binary files a/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png and b/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-hdpi/launcher_icon.png b/android/app/src/main/res/mipmap-hdpi/launcher_icon.png index 87750511..38e69ebd 100644 Binary files a/android/app/src/main/res/mipmap-hdpi/launcher_icon.png and b/android/app/src/main/res/mipmap-hdpi/launcher_icon.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/launcher_icon.png b/android/app/src/main/res/mipmap-mdpi/launcher_icon.png index 16a85bac..0d005234 100644 Binary files a/android/app/src/main/res/mipmap-mdpi/launcher_icon.png and b/android/app/src/main/res/mipmap-mdpi/launcher_icon.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/launcher_icon.png b/android/app/src/main/res/mipmap-xhdpi/launcher_icon.png index 29f84b66..1c0b6137 100644 Binary files a/android/app/src/main/res/mipmap-xhdpi/launcher_icon.png and b/android/app/src/main/res/mipmap-xhdpi/launcher_icon.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png b/android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png index 5dbd0cd4..e9e3d1fd 100644 Binary files a/android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png and b/android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png b/android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png index 3893e23a..c4bf2dbe 100644 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png and b/android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png differ diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml index d150a391..2531ca64 100644 --- a/android/app/src/main/res/values/colors.xml +++ b/android/app/src/main/res/values/colors.xml @@ -1,4 +1,4 @@ - #2e2e2e + #FF8500 \ No newline at end of file diff --git a/assets/images/img.png b/assets/images/img.png new file mode 100644 index 00000000..a383e388 Binary files /dev/null and b/assets/images/img.png differ diff --git a/assets/languages/en-US.json b/assets/languages/en-US.json index bd956505..c43f7da1 100644 --- a/assets/languages/en-US.json +++ b/assets/languages/en-US.json @@ -1,8 +1,38 @@ { - "app_name": "Maibu Mowing Robot", + + "device_task_control": { + "title": "Task control", + "pause": "Pause task", + "resume": "Resume task", + "pause_hint": "Pause current work", + "resume_hint": "Paused · Tap to resume", + "no_task": "No current task", + "not_running": "The task is waiting to start or is ending. It cannot be paused or resumed yet.", + "load_failed": "Could not load the task pool. Please try again.", + "choose_task": "Select a task to pause or resume", + "task_number": "Task {id}", + "paused": "Paused · Can resume", + "running": "Running · Can pause", + "task_changed": "The task status has changed. Please select again.", + "unavailable": "This operation is currently unavailable.", + "pause_failed": "Could not pause the task. Please try again.", + "resume_failed": "Could not resume the task. Please try again.", + "operation_failed": "The operation failed. Please try again later." + }, + "app_name": "飒沓·星枢", "device_control_mode": { + "cancel_to_preview": "Skip to preview", + "preview_status": "Video preview. Confirm the mode to enable control.", + "confirm_mode": "Confirm mode", "title": "Confirm control mode", + "switch_title": "Manual / autonomous mode", + "selection_target": "Select the target mode", + "switch_manual": "Manual (remote control)", + "switch_intelligent": "Intelligent (autonomous tasks)", + "selection_matched": "The live mode already matches your selection. Press OK without sending another request.", + "selection_hint": "Press OK to request %s.", + "switch_confirmed": "Operation successful. The live mode follows device reports.", "unknown_mode": "The current mode has not been reported. Press OK to request %s.", "current": "Current live mode", "target": "Mode required by this page", @@ -31,6 +61,9 @@ "login": { "title": "Login", + "welcome_title": "Welcome to SATA Robotics", + "welcome_subtitle": "Manage your robots in one place", + "hero_caption": "SMART ROBOTICS · CONNECTED", "username": "Username", "password": "Password", "login_button": "Login", @@ -644,12 +677,10 @@ "overview_title": "Device overview", "overview_desc": "Built for centralized multi-robot management", "stat_total": "Total devices", - "stat_alarm_offline": "Alarm/Offline", "device_distribution": "Device distribution", "total_devices_count": "%s devices in total", "th_device_info": "Device", "th_status": "Status", - "th_location_task": "Location / Task", "add_robot": "Add robot", "scan_action": "Scan", "add_device": "Add device", @@ -836,9 +867,12 @@ "rec_efficiency": "Efficiency", "fault_state": "Fault status", "fault_none": "No faults", - "fault_none_sub": "Device running normally, no anomaly detected", + "fault_none_sub": "No details available", "fn_title": "Quick actions", - "fn_edit_order": "Edit order", + "fn_edit_order": "Edit order (hold to drag)", + "fn_save_order": "Save", + "fn_drag_order": "Press and hold a tile, then drag to reorder", + "fn_save_failed": "Could not save the order. Please try again.", "fn_realtime_video": "Live video", "fn_remote": "Remote control", "fn_find": "Find robot", @@ -847,18 +881,19 @@ "fn_sensor": "Sensor monitoring", "all_functions": "View all functions", "set_group_device": "Device settings & upgrade", + "set_group_device_sub": "Device parameters and firmware", "set_param": "Device parameters", "set_param_sub": "Operation, chassis and blade parameters", "set_firmware": "Firmware & OTA upgrade", - "set_firmware_sub": "Current version V1.1.2 · Check for updates", - "set_firmware_sub_old": "Current version V0.9.7 · Requires downtime", - "set_check_update": "Check update", - "set_group_blade": "Operation & blade strategy", + "set_unavailable": "Unavailable", + "set_not_connected": "Not yet available", + "set_group_blade": "Blade safety", + "set_group_blade_sub": "Obstacle stop and blade auto-resume", "set_manage_perm": "Admin permission", "set_obstacle_stop": "Blade stop on obstacle", "set_obstacle_stop_sub": "Enabled · Stop blade by strategy on obstacle", "set_enabled": "Enabled", - "set_blade_resume": "Blade resume strategy", + "set_blade_resume": "Blade resume mode", "set_blade_resume_sub": "Manual confirmation (recommended)", "set_manual_confirm": "Manual confirm", "set_chassis": "Chassis lift parameters", @@ -876,7 +911,7 @@ "set_group_safety": "Safety settings", "set_auto_stop": "Auto blade stop on obstacle", "set_auto_stop_sub": "Stop the blade automatically when an obstacle is detected", - "set_auto_resume": "Auto blade resume after clearing", + "set_auto_resume": "Auto-resume blade after obstacle clears", "set_auto_resume_sub": "Resume mowing once the obstacle is removed", "set_alarm": "Alarm & light settings", "set_alarm_sub": "Volume, light prompts and alert methods", @@ -895,8 +930,9 @@ "set_remote_ctrl": "Remote control settings", "set_remote_ctrl_sub": "Preferences, layout and video latency", "set_group_maintain": "Network & system maintenance", - "set_net_loc": "Network & positioning", - "set_net_loc_sub": "4G/Wi-Fi and GNSS communication", + "set_group_network": "Network & location", + "set_net_loc": "Network & location status", + "set_net_loc_sub": "View device connectivity and location", "unbind": "Unbind device", "unbinding": "Unbinding…", "unbind_confirm_body": "After unbinding you can no longer monitor or control \"%s\". Rebinding is required. Unbind now?", @@ -1413,7 +1449,7 @@ "todo": "This feature is not available yet", "sec_profile": "Basic Profile", "sec_runtime": "Runtime & Control", - "footer": "Power type, last report, control session and fault count are demo values; they will be replaced once connected", + "footer": "Power type is a demo value", "model_suffix": "%s · STD", "tagline": "Dedicated video · Ultrasonic & light · Basic GNSS", "pill_online": "Online · %s", @@ -1663,15 +1699,18 @@ "maintenance": "Maintenance", "maintenance_desc": "Plans, reminders and records", "help_guide": "Help & Guide", - "help_guide_desc": "Manuals, tutorials and FAQ", + "help_guide_desc": "Device binding, route planning and remote control", "account_security": "Account & Security", "account_security_desc": "Email/phone, password and devices", "message_notice": "Notifications", "message_notice_desc": "Device, work, service and auth messages", "general_settings": "General Settings", - "general_settings_desc": "Language, units, region and app preferences", + "general_settings_desc": "Language, navigation, float bar and updates", + "general_settings_basic_desc": "Language and navigation", "about_legal": "About & Legal", "about_legal_desc": "App version, terms and privacy policy", + "privacy_and_terms": "Privacy Policy & User Agreement", + "legal_unavailable": "The official document is not available yet", "stat_processing_order": "Open Orders", "stat_maintenance_reminder": "Maintenance", "stat_tutorial": "Guides", @@ -1753,6 +1792,29 @@ "create_task": "New Route", "no_current_task": "No current work", "no_current_task_sub": "You can switch the site", + "all_work": { + "title": "All Work", + "plans": "Task Plans", + "pool": "Task Pool", + "consecutive": "Consecutive Tasks", + "consecutive_pending": "The consecutive task list is coming later.", + "refresh": "Refresh list", + "retry": "Reload", + "empty": "No task plans for this site", + "count": "%s plans", + "device": "Device", + "route": "Route", + "schedule": "Schedule", + "starts_at": "Starts", + "ends_at": "Ends", + "month_days": "Days %s", + "delete": "Delete", + "deleting": "Deleting", + "delete_title": "Delete task plan", + "delete_message": "Delete the task plan “%s”?", + "delete_success": "Task plan deleted" + }, + "task_pool": { "no_user": "Sign in to view work tasks", "no_site": "Select a site first", @@ -1776,7 +1838,9 @@ "title": "Zones", "new": "New", "page_title": "Work Zone Management", - "page_subtitle": "Draw work zones, no-go zones and obstacle zones in the map editor", + "page_subtitle": "View this site's work zones, or create and edit them on the map.", + "refresh": "Refresh zones", + "empty_site": "No work zones for this site yet", "filter_all": "All zones", "kind_work": "Work zone", "kind_forbidden": "No-go zone", @@ -1853,16 +1917,29 @@ "timing_scheduled": "Scheduled", "scheduled_hint": "Set a cycle and date range. The device will run at the scheduled time.", "immediate_hint": "Open the work center with the selected device and route, then tap Start Work to begin.", - "area_immediate_hint": "Select the device and area, then confirm the work details.", + "area_immediate_hint": "Select areas and routes, arrange their order, then choose a robot from this site to dispatch.", "selection_changed": "The station or device assignment changed. Reopen this page to select the device and route again.", "task_info": "Task Details", "schedule_settings": "Schedule Settings", + "area_load_hint": "Load the areas and routes for the current site.", + "area_reload": "Reload", + "area_select_title": "Select task areas", + "area_select_hint": "Select multiple areas. Each area's default route is selected automatically.", + "area_empty": "No available areas at this site. Create one in Area Management.", + "area_routes_title": "Select routes", + "area_routes_hint": "Choose from the selected areas' linked routes. Shared routes run once.", + "area_choose_first": "Select a task area first.", + "area_routes_empty": "No available routes. Link routes from this site in the area editor.", + "area_order_title": "Execution order", + "area_order_hint": "Drag the handle on the right to change the execution order.", + "area_order_empty": "Select routes to arrange their order.", + "area_remove_route": "Deselect route", + "area_success": "Area tasks dispatched successfully", "area_label": "Work Area", "area_pick": "Coming soon", - "area_pending": "Area dispatch is coming soon. Choose Routes to schedule a task or open the work center.", "immediate_pending": "Immediate dispatch is coming soon. Choose Scheduled to create a work plan.", - "coming_soon": "Coming soon", "submit_now": "Dispatch Now", + "submit_consecutive": "Dispatch consecutive tasks", "subtitle": "Pick device and route, set the cycle, work starts automatically on time", "name_label": "Plan Name", "name_hint": "e.g. Zone A daily morning mowing", @@ -1893,7 +1970,32 @@ "record": { "title": "Work Records", - "page_subtitle": "Every job archived by month; open one to see its report", + "page_subtitle": "View device execution history for this site. Tap a record for details.", + "history_scope": "Device execution history for this site", + "device_history_scope": "Work records for this device", + "device_page_subtitle": "View this device’s work history and execution details.", + "device_loaded_count": "%s records loaded for this device", + "loaded_count": "%s loaded · %s total", + "filter_canceled": "Canceled", + "retry": "Retry", + "load_hint": "No data to display. Select a site or retry.", + "task_id": "Task", + "device": "Device", + "status": "Status", + "unknown_status": "Unknown", + "created_at": "Created", + "started_at": "Started", + "finished_at": "Finished", + "updated_at": "Updated", + "route_id": "Route ID", + "plan_id": "Plan ID", + "task_type": "Task type", + "route_type": "Route type", + "accepted": "Device accepted", + "remark": "Remark", + "yes": "Yes", + "no": "No", + "details": "Details", "filter_all": "All", "filter_done": "Completed", "filter_aborted": "Aborted", @@ -1945,6 +2047,34 @@ "filter_all": "All routes", "kind_coverage": "Coverage", "kind_return": "Return", + "return_manage": "Return setup", + "return_subtitle": "Return points, linked devices and obstacles for this site", + "return_plan_title": "Site return plan", + "return_plan_id": "Plan ID", + "return_points": "Return points", + "return_obstacles": "Obstacles / restricted areas", + "return_bound_devices": "Linked devices", + "return_plan_hint": "Each site has one return plan. Edit its return points and obstacles together.", + "return_empty": "No return plan for this site", + "return_empty_hint": "Create a plan to place return points, link robots and configure obstacles on the map.", + "return_create": "Create return plan", + "return_edit": "Edit return plan", + "return_preview": "Plan map preview", + "return_expand": "Expand map", + "return_map_note": "Green numbers mark return points; red marks obstacles. These are not driven paths.", + "return_no_points": "No return points configured", + "return_no_obstacles": "No obstacles configured", + "return_point_index": "Return point %s", + "return_obstacle_index": "Obstacle %s", + "return_device": "Linked device", + "return_unbound": "No device linked", + "return_coordinates": "Coordinates (latitude, longitude)", + "return_size": "Size (width × height)", + "return_shape": "Shape", + "return_shape_rect": "Rectangle", + "return_shape_circle": "Circle", + "return_source": "Source", + "return_platform": "Platform", "kind_edge": "Edge", "kind_custom": "Custom", "loading": "Loading routes…", @@ -2124,5 +2254,435 @@ "municipal": "Municipal & Riverbank", "airport": "Airport Facilities" } + }, + "autonomous_work": { + "path_point_count": "{count} path points", + "boundary_point_count": "{count} boundary points", + "no_route": "No route selected", + "position_single_no_heading": "Single point (no heading)", + "position_diff_no_heading": "Differential (no heading)", + "work_completed": "Work completed", + "work_ended": "Work ended", + "restore_failed": "Could not restore the task", + "route_kept": "Work is running. The current route was kept.", + "route_selected": "Selected route: {route}", + "route_no_geometry": "No path data is available for “{route}”", + "pick_route_first": "Choose a route from the Route Library first.", + "dispatch_offline": "The device is offline. Work cannot be dispatched.", + "start_title": "Confirm start", + "start_description": "Route: {route}{details}{warning}. Confirm to start work.", + "no_path_warning": " (no path data, dispatch may fail)", + "check_power": "The device is powered on and control is authorized", + "check_location": "Position is valid and the route matches the geofence", + "check_site": "The work area is safe and blade and emergency-stop interlocks are active", + "start_confirm": "Start work", + "task_query_failed": "Could not load tasks", + "other_route_active": "The device has a task for another route ({route}). Handle it in the task queue first.", + "dispatch_failed": "Could not dispatch work", + "dispatched_route": "Work dispatched: {route}", + "no_pausing_task": "No task can be paused", + "pause_title": "Confirm pause", + "pause_description": "Pausing keeps the task ID, route and resume point. The robot must first stop safely.", + "check_pause_speed": "Driving speed drops to a safe level", + "check_pause_blade": "Blades stop under the task’s safe-pause policy", + "check_pause_progress": "Save the resume point and covered area", + "pause_confirm": "Pause work", + "pause_failed": "Could not pause work", + "pause_sent": "Pause command sent", + "no_stopping_task": "No task can be stopped", + "stop_title": "Confirm stop", + "stop_description": "This ends the task and disables automatic resumption. The covered area, track and stop time are saved to work history.", + "check_stop_hardware": "Stop the chassis and blades safely first", + "check_stop_record": "Record the manual stop reason and covered area", + "check_stop_final": "A terminated task cannot be resumed", + "stop_confirm": "Stop work", + "stop_failed": "Could not stop work", + "work_stopped": "Work stopped", + "no_resuming_task": "No task can be resumed", + "resume_title": "Confirm resume", + "resume_description": "Resume “{route}” using the same route and saved coverage.", + "check_resume_cause": "The reason for the pause or fault has been resolved", + "check_resume_task": "Task ID, map, route and resume point match", + "check_resume_safety": "Position quality, control access, blades and chassis meet requirements", + "resume_confirm": "Resume work", + "resume_failed": "Could not resume work", + "resume_sent": "Resume command sent", + "no_canceling_task": "No queued task can be canceled", + "cancel_title": "Confirm task cancellation", + "cancel_description": "Only tasks that have not started can be canceled. Running tasks must be stopped.", + "check_cancel_queued": "Verify the task has not started", + "check_cancel_route": "The route stays in the library after cancellation", + "cancel_confirm": "Cancel task", + "cancel_failed": "Could not cancel the task", + "task_canceled": "Queued task canceled", + "multiple_active_tasks": "Multiple active tasks on this device", + "task_number": "Task #{id}", + "unknown_route": "Unknown route", + "library_unavailable": "The route library is unavailable in this environment", + "online_edit_unavailable": "Online route editing is unavailable in this environment", + "pause_before_route_change": "Pause or stop work before changing routes.", + "queue_unavailable": "The task queue is unavailable in this environment", + "return_demo": "Return commands are unavailable on this device. This is a preview only.", + "more": "More", + "more_description": "Shortcuts to common device features.", + "manual_control": "Manual control", + "manual_control_description": "Open landscape remote control", + "find_description": "Make the robot beep and flash its lights", + "light_sound_description": "Light and alert sound preferences", + "sensors_status": "Sensors and live status", + "sensors_description": "View sensor data and live status", + "title": "Autonomous Work", + "robot_model": "{name} · {type} · PLUS Smart Edition", + "status_details": "Status details", + "route_change_requires_pause": "Pause the running task safely before editing the route.", + "cannot_plot_route": "No path data to display for “{route}”", + "device_status": "Device status", + "stopped": "Stopped", + "current_faults": "Current faults", + "no_fault_count": "0", + "view_sensors": "View sensors and live status ›", + "work_paused": "Work paused", + "waiting": "Queued", + "work_interrupted": "Work interrupted", + "no_running_task": "No active task", + "task_running": "Current task · Running", + "task_paused": "Current task · Paused", + "task_interrupted": "Current task · Interrupted", + "task_queued": "Current task · Queued", + "task_not_started": "Current task · Not started", + "task_ended": "Current task · Ended", + "dispatched_at": "Dispatched at", + "settings": "Work settings", + "queue": "Task queue", + "run_ended": "This job has ended", + "run_in_progress": "Task running", + "pick_route_to_start": "No task dispatched · Select a route to start", + "progress": "{percent}% complete", + "covered_area": "Covered {covered} / {total} mu", + "dispatched_time": "Dispatched {time}", + "ready": "Ready", + "paused_with_checkpoint": "Paused · Resume point saved", + "interrupted": "Interrupted", + "ended": "Ended", + "leave_setup": "Exit setup", + "preview_route": "Preview / Select route", + "cancel_queued": "Cancel queued task", + "view_queue": "View queue", + "stop": "Stop work", + "view_status": "View status", + "robot_status_opened": "Robot status expanded", + "resume": "Resume work", + "view_records": "View work history", + "new_task": "Choose a new task", + "camera_front": "Front", + "camera_demo_switched": "Switched to {camera} video (demo)", + "confirmation_demo_note": "Demo only. Wait for the robot’s acknowledgement. A timeout is not a success.", + "pending_device_check": "Pending device check", + "records_unavailable": "Work history is unavailable in this environment", + "records_title": "Autonomous Work History", + "records_description": "Shows finished tasks and notifications received by this device. Missing area and duration values are left blank.", + "records_load_failed": "Could not load records", + "records_empty": "No work history for this device", + "terminated": "Terminated", + "record_task_id": "Task ID: {id}", + "record_dispatched_at": "Dispatched at: {time}", + "record_completed_points": "Arrival points received: {count}", + "records_refresh": "Refresh history", + "back_to_map": "Back to map", + "route_library_title": "Route Library · Choose a route", + "route_library_description": "An area can have several routes. Preview anytime. To change routes, stop the current task safely and confirm again.", + "route_create_edit": "+ New / Edit", + "route_confirm": "Confirm route", + "route_required": "Select a route first", + "route_number": "Route #{id}", + "queue_task_canceled": "Task #{id} canceled", + "queue_switch_failed": "Could not switch tasks", + "queue_task_switched": "Switched to task #{id}", + "queue_title": "Multi-Area Task Queue", + "queue_description": "Cancel tasks that have not started here. Use Stop Work to end a running task safely.", + "queue_refresh": "Refresh queue", + "queue_empty": "No active tasks on this device", + "processing": "Processing…", + "schedule_title": "Scheduled Task", + "schedule_description": "Scheduled work still requires safety checks and supervision before the robot can start.", + "demo_route": "Area A · Route 01", + "schedule_date": "Date", + "schedule_time": "Time", + "schedule_repeat": "Repeat", + "schedule_once": "Once", + "schedule_enabled": "Enable schedule", + "schedule_safety": "Safety and authorization required", + "schedule_save": "Save schedule", + "schedule_demo": "Dispatch is unavailable. This is a preview only.", + "schedule_demo_options": "These options are demo data.", + "settings_coverage": "Coverage", + "settings_blades": "Blades", + "settings_obstacles": "Safety", + "settings_resume": "Resume", + "settings_return": "Return", + "settings_network": "Network", + "settings_title": "Autonomous Work Settings", + "settings_description": "You can use the defaults for this task. Pause safely and run the checks again before changing motion or blade settings.", + "settings_save": "Save settings (demo)", + "settings_saved": "Demo preferences saved locally. No parameters were sent to the device.", + "coverage_title": "Route and coverage settings", + "cut_width": "Cutting width", + "cut_width_detail": "Based on the model’s blade size", + "route_overlap": "Route overlap", + "route_overlap_detail": "Applies to new tasks only", + "planning_direction": "Planning direction", + "planning_direction_detail": "Prefer the solar array direction", + "along_array": "Along array", + "edge_handling": "Edge handling", + "edge_handling_detail": "Follow the boundary along edges", + "standard": "Standard", + "blade_section": "Execution and blades", + "autonomous_speed": "Autonomous work speed", + "autonomous_speed_detail": "Capped at the maximum safe speed", + "automatic_blade": "Automatic blade start and stop", + "automatic_blade_detail": "Based on task status and safety conditions", + "chassis_height": "Chassis height policy", + "chassis_height_detail": "Available on supported devices", + "configured_per_task": "Per task", + "blade_safety_note": "Verify safety interlocks before operating blades. Blade height is shown only when reliable feedback is available.", + "obstacle_section": "Obstacle avoidance and safety", + "obstacle_monitoring": "Obstacle monitoring", + "obstacle_monitoring_detail": "View forward sensors and ultrasonic status", + "obstacle_response": "Response to obstacles", + "obstacle_response_detail": "A safe stop takes priority", + "pause_wait": "Pause and wait", + "person_alert": "Person proximity warning", + "person_alert_detail": "Applicable warnings stay enabled", + "obstacle_safety_note": "Mandatory collision protection, emergency stop and safety interlocks cannot be disabled here.", + "resume_section": "Resume points", + "resume_checkpoint": "Resume from checkpoint", + "resume_checkpoint_detail": "Keep the resume point and coverage after a pause or interruption", + "resume_checks": "Pre-resume checks", + "resume_checks_detail": "Position quality and route version must match", + "strict_checks": "Strict validation", + "resume_note": "Resuming requires a reliable position and task acknowledgement. Select the task again if validation fails.", + "return_section": "Return and completion", + "completion_action": "After task completion", + "completion_action_detail": "Default device action after completion", + "standby_in_place": "Stand by in place", + "low_battery_threshold": "Low battery threshold", + "low_battery_threshold_detail": "Suggest returning when the battery falls below this level", + "return_channel": "Return command", + "return_channel_detail": "Automatic return is unavailable on this device", + "notify_only": "Notify only", + "network_section": "Weak signal and reconnection", + "network_reconnect": "Reconnect on weak signal", + "network_reconnect_detail": "Reconnect automatically when signal fluctuates", + "command_timeout": "Command timeout policy", + "command_timeout_detail": "Do not resend hazardous commands after a timeout", + "scheduled_safety": "Scheduled task safety", + "scheduled_safety_detail": "Verify safety before running a scheduled task", + "network_safety_note": "Hazardous commands are not queued when signal is weak. Confirm again after reconnecting before sending.", + "settings_demo": "Sending parameters to the device is unavailable. This is a preview only.", + "stage_setup": "Setup", + "stage_pause": "Paused / Interrupted", + "camera_left": "Left", + "camera_right": "Right", + "camera_rear": "Rear" + }, + "region_editor": { + "region_saving": "The region is being saved", + "region_readonly_saved": "Region saved. Tap New to draw another one.", + "invalid_coordinates": "The point coordinates are invalid", + "too_many_points": "A region needs 4 points. Undo or delete a point before adding another.", + "point_already_marked": "This location is already marked. Move to the next point.", + "editing_scope_changed": "The region or site changed. Reopen the editor.", + "four_points_required": "The region must have exactly 4 boundary points", + "invalid_boundary_points": "The boundary contains invalid coordinates", + "duplicate_boundary_points": "The 4 boundary points must be distinct", + "invalid_region_id": "Invalid region ID", + "invalid_region_site_id": "Invalid region or site ID", + "invalid_route": "Select a valid route", + "invalid_region": "Select a valid region", + "delete_retry": "The region was not deleted. Try again.", + "save_retry": "The region was not saved. Try again.", + "region_delete_failed": "Could not delete the region", + "region_save_failed": "Could not save the region", + "regions_invalid_response": "Invalid response while loading regions", + "regions_data_not_list": "Invalid region list data", + "region_delete_invalid_response": "Invalid response while deleting the region", + "region_save_invalid_response": "Invalid response while saving the region", + "mark_area": "Mark area", + "position_single_short": "Single", + "position_diff_short": "Diff.", + "position_ins_short": "INS", + "position_fixed_short": "Fixed", + "position_float_short": "Float", + "position_fixed": "Fixed", + "position_float": "Float", + "position_unknown": "Position unknown", + "map_not_ready": "The map is not ready. Try again shortly.", + "invalid_device_point": "The device position is invalid. A point could not be added.", + "work_point_added": "Added work area point {count}", + "add_work_points_first": "Add work area points first.", + "custom_route_generated": "Custom route generated ({count} points)", + "route_needs_three_points": "Add at least 3 work area points to generate a route.", + "coverage_route_generated": "Coverage route generated ({count} points)", + "work_point_undone": "Last work area point removed · {count} left", + "obstacle_undone": "Last no-go rectangle removed · {count} left", + "no_obstacle_to_undo": "No no-go zones to undo", + "no_point_to_delete": "No work area points to delete", + "no_obstacle_to_delete": "No no-go zones to delete", + "obstacles_cleared": "All no-go zones cleared", + "region_create_hint": "Move the map and mark 4 boundary points with the crosshair, then save.", + "region_edit_hint": "The region boundary is loaded. Edit its details or redraw it.", + "region_requires_scope": "Sign in and select a site. Reopen the editor after changing sites or accounts.", + "obstacle_mode_hint": "Obstacle mode: tap + to add a no-go rectangle separately from the region.", + "invalid_region_point": "The device position is invalid. A region point could not be added.", + "region_point_added": "Added region point {count}/4", + "region_already_saved": "Region saved. Tap New to draw another one.", + "region_saved": "Region “{name}” saved", + "region_point_count": "Region · {count}/4 points", + "redraw": "Redraw", + "saved": "Saved", + "edit": "Edit", + "work_point_deleted": "Deleted point {index} · {count} left", + "obstacle_deleted": "Deleted no-go rectangle {index} · {count} left", + "coverage_mode_hint": "Coverage mode: mark the boundary. The route closes the loop automatically.", + "custom_mode_hint": "Custom mode: the route follows points in the order marked.", + "select_site_first": "Choose a site from the site list first.", + "records_load_failed": "Could not load work history", + "geometry_load_failed": "Could not load route geometry", + "route_loaded": "Loaded “{name}”. You can edit it and save a copy.", + "centered_on_device": "Centered on the device", + "editor_reset": "Editor reset", + "return_mark_hint": "Marking with {mode} · Tap + to add a return point", + "crosshair": "Crosshair", + "device": "Device", + "return_point_summary": "{points} points · {devices} linked devices{saved}", + "saved_suffix": " · Saved", + "return_load_failed": "Could not load the return plan", + "return_new_hint": "New return plan: tap the green + to add a return point.", + "return_edit_hint": "Return plan loaded. Tap Edit to save changes.", + "return_mode_exited": "Exited return-point editing", + "invalid_return_point": "The device position is invalid. A return point could not be added.", + "return_point_added": "Added return point {count}", + "invalid_obstacle_point": "The device position is invalid. An obstacle could not be added.", + "return_obstacle_deleted": "Deleted return no-go zone {index} · {count} left", + "no_return_obstacle_to_undo": "No return no-go zones to undo", + "return_obstacle_undone": "Last return no-go zone removed · {count} left", + "return_point_canceled": "Return point removed · {count} left", + "no_return_point_to_undo": "No return points to undo", + "return_point_undone": "Last return point removed · {count} left", + "return_point_name": "Return point {index}", + "rename_return_point": "Name return point {index}", + "rename_return_point_hint": "Leave blank to use the default number", + "name": "Name", + "name_too_long": "Use no more than 20 characters", + "rename_obstacle": "Name obstacle {index}", + "rename_obstacle_hint": "Leave blank to use the dimensions", + "add_return_points_first": "Add return points on the map first.", + "select_site": "Select a site first.", + "site_changed": "The site changed. Reopen the editor before saving.", + "obstacle_point_name": "Obstacle point {index}", + "return_save_failed": "Could not save the return plan", + "return_saved": "Return plan saved: {points} return points{obstacles}", + "obstacles_suffix": " · {count} obstacles", + "return_execute_unavailable": "Return execution is unavailable. The return points were kept.", + "work_area_needs_three_points": "A work area needs at least 3 points.", + "save_area": "Save area", + "area_name_hint": "Enter an area name (max. 20 characters)", + "area_name": "Area name", + "area_name_required": "Enter an area name", + "area_name_too_long": "Use no more than 20 characters for the area name", + "saved_without_screenshot": "Saved “{name}”, but the map image could not be created", + "area_saved": "Saved “{name}”", + "area_summary": "{points} work points · {obstacles} no-go zones · {mode} mode", + "coverage": "Coverage", + "custom": "Custom", + "region_number": "Region #{id}", + "title": "Map and Region Editor", + "network_online": "4G online", + "battery_unknown": "Battery unknown", + "portrait": "Portrait", + "brightness_demo": "Map brightness controls are unavailable in this preview.", + "region": "Region", + "obstacle": "Obstacle", + "return_points_title": "Return to base · Points", + "new_area_at_site": "Current site · New area", + "new_area_steps": "Choose Mark Area and a work mode, add points, then finish and save.", + "region_four_point_title": "Region · 4-point boundary", + "mark_four_points": "Mark 4 boundary points in order", + "obstacle_mode": "Obstacle · No-go rectangle", + "resize_rectangle_hint": "Tap + to place a rectangle, then drag its sides or corners to resize.", + "return_obstacles_title": "Return to base · Obstacles", + "return_order": "Return in the order marked", + "mark_with_crosshair": "Crosshair", + "mark_with_device": "Device position", + "crosshair_return_hint": "Crosshair: add the return point at the map center", + "device_mark_hint": "Device position: use the device’s current coordinates", + "crosshair_mark_hint": "Crosshair: add the point at the map center", + "default_device": "Default device", + "obstacle_point": "Obstacle point", + "choose_device": "Select device", + "devices_empty": "No devices available", + "select_rectangle": "Select a rectangle on the map", + "return_obstacle_empty_hint": "Aim at the obstacle and tap the green + to add a rectangle. Tap its name to rename it.", + "obstacle_empty_hint": "Aim at the obstacle and tap the green + to add a rectangle.", + "region_points_empty": "Tap the green + to add 4 boundary points in order.", + "return_points_empty": "Tap the green + to add a point at the crosshair or device position.", + "return_obstacle_summary": "{count} obstacles{note}", + "independent_suffix": " · Separate from other regions and obstacles", + "saving": "Saving…", + "execute": "Run", + "row_spacing": "Row spacing", + "use_optimal_heading": "Use optimal heading", + "return_counts": "{points} return points · {obstacles} obstacles", + "return_plan": "Return plan", + "records_empty": "No work history for this site", + "unnamed_work": "Unnamed job", + "no_video": "No video stream available", + "rectangle_dimensions": "Rectangle dimensions", + "rectangle_width": "Width X (m)", + "rectangle_height": "Height Y (m)", + "rectangle_preview": "Name: {width} m × {height} m", + "rectangle_positive_dimensions": "Enter a width and height greater than 0", + "no_device_crosshair_hint": "No device selected. Move the map to align the crosshair with your target, then tap +.", + "dismiss_tip": "Dismiss tip", + "scope_changed_reopen": "The site or account changed. Reopen the editor before saving.", + "bind_routes": "Linked routes", + "no_routes_to_bind": "No routes to link at this site", + "new_region": "New region", + "edit_region": "Edit region", + "region_name_field": "Region name *", + "region_name_required": "Enter a region name", + "region_code": "Region code", + "route_load_failed": "Could not load routes", + "reload_routes": "Reload routes", + "default_route": "Default route", + "routes_loading": "Loading routes…", + "pick_default_route": "Select a default route (optional)", + "pick_linked_routes": "Select one or more routes to link", + "boundary_count": "Boundary points: {count}/4", + "save_confirm": "Save changes", + "delete_region": "Delete region", + "delete_region_message": "Delete “{region}”? This cannot be undone.", + "scope_changed_select_region": "The site or account changed. Select the region again.", + "region_deleted": "Region deleted", + "regions_count": "Regions ({count})", + "regions": "Regions", + "add_region": "Add", + "refresh_regions": "Refresh regions", + "close_regions": "Close list", + "sign_in_first": "Sign in first", + "select_site_for_regions": "Select a site to view its regions", + "regions_load_failed": "Could not load regions", + "reload_regions": "Reload regions", + "regions_empty": "No regions at this site. Tap Add to create one.", + "enabled": "Enabled", + "disabled": "Disabled", + "code_value": "Code: {code}", + "region_summary": "{points} boundary points · {routes} linked routes", + "redraw_required": "Redraw the boundary", + "route_type_title": "Select route type", + "route_type_mowing": "Mowing", + "route_type_inspection": "Inspection", + "route_type_predefined": "Predefined mode", + "route_type_other": "Other" } } diff --git a/assets/languages/zh-CN.json b/assets/languages/zh-CN.json index 19767bbd..6c6f239b 100644 --- a/assets/languages/zh-CN.json +++ b/assets/languages/zh-CN.json @@ -1,8 +1,38 @@ { - "app_name": "麦步割草机器人", + + "device_task_control": { + "title": "任务控制", + "pause": "任务暂停", + "resume": "恢复任务", + "pause_hint": "暂停当前作业", + "resume_hint": "已暂停 · 点击恢复", + "no_task": "当前没有任务", + "not_running": "当前任务尚未执行或正在结束,暂不能暂停或恢复。", + "load_failed": "任务池查询失败,请稍后重试。", + "choose_task": "选择要暂停或恢复的任务", + "task_number": "任务 {id}", + "paused": "已暂停 · 可恢复", + "running": "执行中 · 可暂停", + "task_changed": "任务状态已变化,请重新选择。", + "unavailable": "当前设备暂不支持此操作。", + "pause_failed": "暂停失败,请重试。", + "resume_failed": "恢复失败,请重试。", + "operation_failed": "操作失败,请稍后重试。" + }, + "app_name": "飒沓·星枢", "device_control_mode": { + "cancel_to_preview": "取消并预览", + "preview_status": "画面预览,确认模式后可遥控", + "confirm_mode": "确认模式", "title": "控制模式确认", + "switch_title": "手动/智能切换", + "selection_target": "选择目标控制模式", + "switch_manual": "手动(远程控制)", + "switch_intelligent": "智能(自主任务)", + "selection_matched": "当前实时模式与所选模式一致,点击确定即可,无需重复下发。", + "selection_hint": "点击确定将下发切换为%s。", + "switch_confirmed": "操作成功,当前模式以设备实时上报为准。", "unknown_mode": "暂未收到当前模式,点击确定将下发切换为%s。", "current": "当前实时模式", "target": "当前页面所需模式", @@ -31,6 +61,9 @@ "login": { "title": "登录", + "welcome_title": "欢迎使用飒沓机器人", + "welcome_subtitle": "统一管理您的机器人设备", + "hero_caption": "智能机器人 · 互联", "username": "用户名", "password": "密码", "login_button": "登录", @@ -643,12 +676,10 @@ "overview_title": "设备集中概览", "overview_desc": "适合企业多机器人集中管理", "stat_total": "设备总数", - "stat_alarm_offline": "告警/离线", "device_distribution": "设备分布", "total_devices_count": "共 %s 台设备", "th_device_info": "设备信息", "th_status": "状态", - "th_location_task": "位置/当前任务", "add_robot": "添加机器人", "scan_action": "扫一扫", "add_device": "添加设备", @@ -834,10 +865,13 @@ "rec_duration": "作业时长", "rec_efficiency": "作业效率", "fault_state": "故障状态", - "fault_none": "当前无故障", - "fault_none_sub": "设备运行正常,未检测到异常", + "fault_none": "暂无故障", + "fault_none_sub": "暂无详情", "fn_title": "常用功能", - "fn_edit_order": "编辑排序", + "fn_edit_order": "编辑排序(长按拖动)", + "fn_save_order": "保存", + "fn_drag_order": "长按磁贴,再拖动调整顺序", + "fn_save_failed": "排序保存失败,请重试", "fn_realtime_video": "实时图传", "fn_remote": "远程遥控", "fn_find": "一键寻车", @@ -846,18 +880,19 @@ "fn_sensor": "传感器监测", "all_functions": "查看全部功能", "set_group_device": "设备设置升级", + "set_group_device_sub": "设备参数、固件与 OTA", "set_param": "设备参数设置", - "set_param_sub": "作业参数、底盘参数、割刀参数等设置", - "set_firmware": "固件与OTA升级", - "set_firmware_sub": "当前版本 V1.1.2 · 可检查新版本", - "set_firmware_sub_old": "当前版本 V0.9.7 · 需停机检查", - "set_check_update": "检查升级", - "set_group_blade": "作业与割刀策略", + "set_param_sub": "作业、底盘和割刀参数", + "set_firmware": "固件与 OTA 升级", + "set_unavailable": "暂未开放", + "set_not_connected": "暂未接入", + "set_group_blade": "割刀安全", + "set_group_blade_sub": "遇障停刀、自动恢复割刀", "set_manage_perm": "管理权限", - "set_obstacle_stop": "障碍物联动停刀", + "set_obstacle_stop": "遇障停刀", "set_obstacle_stop_sub": "已启用 · 障碍触发时按策略停止割刀", "set_enabled": "已启用", - "set_blade_resume": "割刀恢复策略", + "set_blade_resume": "割刀恢复方式", "set_blade_resume_sub": "人工确认恢复(推荐)", "set_manual_confirm": "人工确认", "set_chassis": "底盘升降参数", @@ -875,7 +910,7 @@ "set_group_safety": "安全设置", "set_auto_stop": "遥障自动关闭割刀", "set_auto_stop_sub": "检测到障碍物时自动停止割刀,提升作业安全", - "set_auto_resume": "障碍清除后自动开启割刀", + "set_auto_resume": "障碍清除后自动恢复割刀", "set_auto_resume_sub": "障碍物移除后自动恢复割刀作业", "set_alarm": "声光报警设置", "set_alarm_sub": "报警音量、灯光提示、异常提醒方式", @@ -894,8 +929,9 @@ "set_remote_ctrl": "远程智控设置", "set_remote_ctrl_sub": "远程控制偏好、操作布局、图传延迟设置", "set_group_maintain": "网络与系统维护", - "set_net_loc": "网络与定位参数", - "set_net_loc_sub": "4G/Wi-Fi配置、GNSS通信配置", + "set_group_network": "网络与定位", + "set_net_loc": "网络与定位状态", + "set_net_loc_sub": "查看设备在线状态和定位", "unbind": "解绑设备", "unbinding": "解绑中…", "unbind_confirm_body": "解绑后将无法继续查看「%s」的监测与控制,需重新绑定才能使用。确定解绑?", @@ -1412,7 +1448,7 @@ "todo": "功能暂未开发", "sec_profile": "机器人基础资料", "sec_runtime": "运行与控制信息", - "footer": "动力类型、最近上报、控制会话、故障数为示例;接入后自动替换", + "footer": "动力类型目前为示例值", "model_suffix": "%s · STD标准版", "tagline": "独立图传 · 超声波声光 · 基础GNSS", "pill_online": "在线 · %s", @@ -1662,15 +1698,18 @@ "maintenance": "维修保养", "maintenance_desc": "保养计划、提醒与维护记录", "help_guide": "帮助与操作指南", - "help_guide_desc": "产品说明书、教程及常见问题", + "help_guide_desc": "设备绑定、路径规划与远程控制", "account_security": "账号与安全", "account_security_desc": "邮箱/手机、密码及登录设备", "message_notice": "消息通知", "message_notice_desc": "设备、作业、服务及授权消息", "general_settings": "通用设置", - "general_settings_desc": "语言、单位、地区及APP偏好", + "general_settings_desc": "语言、底部导航、悬浮条与版本更新", + "general_settings_basic_desc": "语言与底部导航", "about_legal": "关于与法律协议", "about_legal_desc": "APP版本、协议和隐私政策", + "privacy_and_terms": "隐私政策与用户协议", + "legal_unavailable": "正式文件暂未提供", "stat_processing_order": "处理中工单", "stat_maintenance_reminder": "保养提醒", "stat_tutorial": "教程", @@ -1752,6 +1791,29 @@ "create_task": "新建路线", "no_current_task": "暂无作业", "no_current_task_sub": "可以更换场站", + "all_work": { + "title": "全部作业", + "plans": "任务计划", + "pool": "任务池", + "consecutive": "连续任务", + "consecutive_pending": "连续任务列表暂未开放", + "refresh": "刷新列表", + "retry": "重新加载", + "empty": "当前场站暂无任务计划", + "count": "共 %s 条计划", + "device": "执行设备", + "route": "作业路线", + "schedule": "执行规则", + "starts_at": "生效时间", + "ends_at": "结束时间", + "month_days": "每月 %s 日", + "delete": "删除", + "deleting": "正在删除", + "delete_title": "删除任务计划", + "delete_message": "确定删除任务计划“%s”吗?", + "delete_success": "任务计划已删除" + }, + "task_pool": { "no_user": "请先登录后查看作业任务", "no_site": "请先选择场站", @@ -1775,7 +1837,9 @@ "title": "区域管理", "new": "新建", "page_title": "作业区域管理", - "page_subtitle": "在地图和区域编辑里画出作业区、禁行区与障碍区", + "page_subtitle": "查看当前场站的作业区域,或在地图上新建和编辑。", + "refresh": "刷新区域列表", + "empty_site": "当前场站暂无作业区域", "filter_all": "全部区域", "kind_work": "作业区", "kind_forbidden": "禁行区", @@ -1852,16 +1916,29 @@ "timing_scheduled": "定时任务", "scheduled_hint": "设置周期与生效日期,设备将在设定时间自动执行。", "immediate_hint": "先进入自主作业中心,核对所选设备和路线后,点击「开始作业」执行。", - "area_immediate_hint": "选择设备和作业区域,确认本次作业内容。", + "area_immediate_hint": "选择区域及路线,调整执行顺序,再选择当前场站的机器人下发任务。", "selection_changed": "场站或设备归属已变更,请重新进入页面选择设备和路线", "task_info": "任务信息", "schedule_settings": "定时设置", + "area_load_hint": "请加载当前场站的分区和路线", + "area_reload": "重新加载", + "area_select_title": "选择任务区域", + "area_select_hint": "可多选;新选区域会默认勾选它的默认路线。", + "area_empty": "当前场站暂无可用分区,请先在区域管理中新增。", + "area_routes_title": "选择执行路线", + "area_routes_hint": "显示所选区域的绑定路线,可多选;相同路线只执行一次。", + "area_choose_first": "请先选择任务区域", + "area_routes_empty": "所选区域暂无可用路线,请在区域编辑中绑定当前场站的路线。", + "area_order_title": "调整执行顺序", + "area_order_hint": "按住右侧拖拽柄调整,机器人将按下方顺序执行。", + "area_order_empty": "选择路线后显示执行顺序", + "area_remove_route": "取消选择路线", + "area_success": "区域作业任务下发成功", "area_label": "作业区域", - "area_pick": "区域选择即将开放", - "area_pending": "区域下发即将开放。当前可选择「路线下发」创建定时任务或进入自主作业中心。", + "area_pick": "请选择任务区域", "immediate_pending": "立即下发即将开放。当前可选择「定时任务」创建作业计划。", - "coming_soon": "即将开放", "submit_now": "立即下发", + "submit_consecutive": "连续任务下发", "subtitle": "选择设备与路线,设置循环规则,到点自动开始作业", "name_label": "方案名称", "name_hint": "例如:A区每日早晨修剪", @@ -1892,7 +1969,32 @@ "record": { "title": "作业记录", - "page_subtitle": "按月归档每一次作业,点开可查看单次作业报告", + "page_subtitle": "查看当前场站设备的真实执行历史,点击记录查看详情", + "history_scope": "当前场站设备执行历史", + "device_history_scope": "本设备作业记录", + "device_page_subtitle": "查看这台设备的作业历史和执行详情", + "device_loaded_count": "本设备已加载 %s 条记录", + "loaded_count": "已加载 %s 条 · 总计 %s 条", + "filter_canceled": "已取消", + "retry": "重试", + "load_hint": "暂无可显示的数据,请选择场站或点击重试", + "task_id": "任务", + "device": "执行设备", + "status": "任务状态", + "unknown_status": "未知状态", + "created_at": "创建时间", + "started_at": "开始时间", + "finished_at": "结束时间", + "updated_at": "更新时间", + "route_id": "路线 ID", + "plan_id": "计划 ID", + "task_type": "任务类型", + "route_type": "路线类型", + "accepted": "设备已接收", + "remark": "备注", + "yes": "是", + "no": "否", + "details": "详情", "filter_all": "全部", "filter_done": "已完成", "filter_aborted": "已中止", @@ -1944,6 +2046,34 @@ "filter_all": "全部路线", "kind_coverage": "覆盖路线", "kind_return": "返航路线", + "return_manage": "返航设置", + "return_subtitle": "查看当前场站的返航点、绑定设备与障碍物", + "return_plan_title": "场站返航方案", + "return_plan_id": "方案 ID", + "return_points": "返航点", + "return_obstacles": "障碍物/禁行区", + "return_bound_devices": "绑定设备", + "return_plan_hint": "每个场站维护一套返航方案,可统一编辑返航点和障碍物。", + "return_empty": "当前场站暂无返航方案", + "return_empty_hint": "新建方案后,可在地图上配置返航点、绑定机器人并设置障碍物。", + "return_create": "新建返航方案", + "return_edit": "编辑返航方案", + "return_preview": "方案地图预览", + "return_expand": "放大地图", + "return_map_note": "绿色编号为返航点,红色为障碍物/禁行区;不代表实际行驶轨迹。", + "return_no_points": "尚未配置返航点", + "return_no_obstacles": "尚未配置障碍物", + "return_point_index": "返航点 %s", + "return_obstacle_index": "障碍物 %s", + "return_device": "绑定设备", + "return_unbound": "未绑定设备", + "return_coordinates": "经纬度(纬度,经度)", + "return_size": "尺寸(宽 × 高)", + "return_shape": "形状", + "return_shape_rect": "矩形", + "return_shape_circle": "圆形", + "return_source": "来源", + "return_platform": "平台", "kind_edge": "沿边路线", "kind_custom": "自定义路线", "loading": "正在加载路线…", @@ -2123,5 +2253,435 @@ "municipal": "市政河堤", "airport": "机场场所" } + }, + "autonomous_work": { + "path_point_count": "{count} 个路径点", + "boundary_point_count": "{count} 个边界点", + "no_route": "未选择作业路线", + "position_single_no_heading": "单点(无航向)", + "position_diff_no_heading": "差分(无航向)", + "work_completed": "作业已完成", + "work_ended": "作业已结束", + "restore_failed": "任务恢复失败", + "route_kept": "作业执行中,已保留当前任务路线", + "route_selected": "已选择路线:{route}", + "route_no_geometry": "「{route}」没有可用的路径数据", + "pick_route_first": "请先在「路线库」选择作业路线", + "dispatch_offline": "设备离线,无法下发作业", + "start_title": "开始作业 · 二次确认", + "start_description": "路线:{route}{details}{warning}。确认后开始执行。", + "no_path_warning": "(无路径数据,可能下发失败)", + "check_power": "设备已上电、控制权符合要求", + "check_location": "定位有效,路线及电子围栏匹配", + "check_site": "作业区域安全,割刀与急停互锁有效", + "start_confirm": "确认开始作业", + "task_query_failed": "任务查询失败", + "other_route_active": "设备上已有其它路线的任务({route}),请先在「任务队列」处理", + "dispatch_failed": "作业下发失败", + "dispatched_route": "作业已下发:{route}", + "no_pausing_task": "当前没有可暂停的任务", + "pause_title": "暂停作业 · 确认", + "pause_description": "暂停后保留当前任务ID、路线及作业断点;机器人需要先完成安全停止。", + "check_pause_speed": "行驶速度降至安全状态", + "check_pause_blade": "割刀按任务安全暂停策略停转", + "check_pause_progress": "保存断点位置与已覆盖区域", + "pause_confirm": "确认暂停", + "pause_failed": "暂停失败", + "pause_sent": "已下发暂停指令", + "no_stopping_task": "当前没有可停止的任务", + "stop_title": "停止作业 · 二次确认", + "stop_description": "本次任务将被终止,不会自动续作。已完成区域、轨迹与停止时间会保存到作业记录。", + "check_stop_hardware": "先安全停止底盘与割刀", + "check_stop_record": "记录人工停止原因与实际完成区域", + "check_stop_final": "已终止任务不能用“继续”恢复", + "stop_confirm": "确认停止作业", + "stop_failed": "停止失败", + "work_stopped": "作业已停止", + "no_resuming_task": "没有可继续的任务", + "resume_title": "继续 / 断点续作 · 确认", + "resume_description": "继续原任务「{route}」,沿用原路线与已保存的覆盖区域。", + "check_resume_cause": "暂停或故障原因已消除", + "check_resume_task": "任务ID、地图、路线与断点匹配", + "check_resume_safety": "定位质量、控制权限、割刀与底盘状态合格", + "resume_confirm": "确认继续作业", + "resume_failed": "继续失败", + "resume_sent": "已下发继续指令", + "no_canceling_task": "没有待取消的任务", + "cancel_title": "取消待执行任务 · 确认", + "cancel_description": "取消只撤销尚未运行的任务,不会把运行中的任务当作取消处理。", + "check_cancel_queued": "确认目标任务尚未开始执行", + "check_cancel_route": "取消后路线仍保留在路线库", + "cancel_confirm": "确认取消任务", + "cancel_failed": "取消失败", + "task_canceled": "已取消待执行任务", + "multiple_active_tasks": "设备上存在多个活跃任务", + "task_number": "任务 #{id}", + "unknown_route": "未知路线", + "library_unavailable": "当前环境未启用路线库", + "online_edit_unavailable": "当前环境不支持在线编辑路线", + "pause_before_route_change": "作业执行中,请先暂停或停止后再更换路线", + "queue_unavailable": "当前环境未启用任务队列", + "return_demo": "返航指令通道未接入(设备端未开放),仅作界面演示", + "more": "更多功能", + "more_description": "以下为设备常用能力的快捷入口,点击后进入对应页面或面板。", + "manual_control": "手动遥控", + "manual_control_description": "进入遥控页(横屏)", + "find_description": "让机器人发出提示音并闪灯", + "light_sound_description": "灯光与提示音偏好", + "sensors_status": "传感器与运行状态", + "sensors_description": "查看传感器与实时状态详情", + "title": "自主作业中心", + "robot_model": "{name} · {type} · PLUS 智能版", + "status_details": "状态详情", + "route_change_requires_pause": "当前任务正在执行,修改路线前需要安全暂停", + "cannot_plot_route": "「{route}」无路径数据,地图上无法显示轨迹", + "device_status": "设备运行", + "stopped": "已停止", + "current_faults": "当前故障", + "no_fault_count": "0 项", + "view_sensors": "查看传感器与运行状态 ›", + "work_paused": "作业已暂停", + "waiting": "等待执行", + "work_interrupted": "作业异常中断", + "no_running_task": "暂无进行中", + "task_running": "当前任务 · 执行中", + "task_paused": "当前任务 · 已暂停", + "task_interrupted": "当前任务 · 异常中断", + "task_queued": "当前任务 · 待执行", + "task_not_started": "当前任务 · 未开始", + "task_ended": "当前任务 · 已结束", + "dispatched_at": "下发时间", + "settings": "作业设置", + "queue": "任务队列", + "run_ended": "本次作业已结束", + "run_in_progress": "任务执行中", + "pick_route_to_start": "尚未下发任务 · 选择路线后开始作业", + "progress": "已完成 {percent}%", + "covered_area": "已覆盖 {covered} / {total} 亩", + "dispatched_time": "下发 {time}", + "ready": "准备就绪", + "paused_with_checkpoint": "暂停 · 保留断点", + "interrupted": "异常中断", + "ended": "已结束", + "leave_setup": "放弃准备", + "preview_route": "预览 / 选择路线", + "cancel_queued": "取消待执行任务", + "view_queue": "查看任务队列", + "stop": "停止作业", + "view_status": "查看状态", + "robot_status_opened": "已展开「机器人信息」运行状态", + "resume": "继续 / 断点续作", + "view_records": "查看作业记录", + "new_task": "选择新任务", + "camera_front": "前置", + "camera_demo_switched": "已切换为「{camera}」视频(演示)", + "confirmation_demo_note": "这是视觉交互演示。实际确认结果必须等待机器人回执;超时不能直接显示成功。", + "pending_device_check": "待设备校验", + "records_unavailable": "当前环境尚未提供真实作业记录", + "records_title": "自主作业记录", + "records_description": "显示任务池中的结束任务及本机收到的完成通知;未提供的面积、耗时不作估算。", + "records_load_failed": "记录加载失败", + "records_empty": "该设备暂无可查询的作业记录", + "terminated": "已终止", + "record_task_id": "任务 ID:{id}", + "record_dispatched_at": "下发时间:{time}", + "record_completed_points": "已接收到达点:{count} 个", + "records_refresh": "刷新记录", + "back_to_map": "返回地图", + "route_library_title": "路线库 · 选择已有路线", + "route_library_description": "一个区域可保存多条路线。执行期间可预览,但更换执行路线前必须先安全停止原任务并重新确认。", + "route_create_edit": "+ 新建 / 编辑", + "route_confirm": "确认路线", + "route_required": "请先选择一条路线", + "route_number": "路线 #{id}", + "queue_task_canceled": "已取消任务 #{id}", + "queue_switch_failed": "切换任务失败", + "queue_task_switched": "已切换到任务 #{id}", + "queue_title": "多区域连续任务队列", + "queue_description": "尚未启动的任务可在此取消;正在执行的任务需要通过“停止作业”安全终止。", + "queue_refresh": "刷新队列", + "queue_empty": "该设备当前没有活跃任务", + "processing": "处理中…", + "schedule_title": "定时任务计划", + "schedule_description": "时间到达后需执行安全准入验证,不代表机器人可以无人监护地无条件启动。", + "demo_route": "A区 · 路线01", + "schedule_date": "执行日期", + "schedule_time": "时间", + "schedule_repeat": "重复规则", + "schedule_once": "仅一次", + "schedule_enabled": "启用计划", + "schedule_safety": "需满足安全策略与权限", + "schedule_save": "保存计划", + "schedule_demo": "计划下发通道未接入,仅作视觉演示", + "schedule_demo_options": "表单选项为演示数据", + "settings_coverage": "路线覆盖", + "settings_blades": "执行割刀", + "settings_obstacles": "避障安全", + "settings_resume": "断点恢复", + "settings_return": "返航策略", + "settings_network": "弱网策略", + "settings_title": "自主作业设置", + "settings_description": "本次任务可使用默认配置;任务执行中改变运动/割刀参数应先安全暂停并重新校验。", + "settings_save": "保存设置(演示)", + "settings_saved": "设置已保存为本地演示偏好,未向设备下发参数", + "coverage_title": "路径与覆盖规划参数", + "cut_width": "作业割幅", + "cut_width_detail": "依据机型割刀尺寸", + "route_overlap": "路线重叠率", + "route_overlap_detail": "仅影响新规划任务", + "planning_direction": "规划方向", + "planning_direction_detail": "沿光伏阵列方向优先", + "along_array": "沿阵列", + "edge_handling": "边缘处理", + "edge_handling_detail": "地块边界贴边作业策略", + "standard": "标准", + "blade_section": "作业执行与割刀", + "autonomous_speed": "自主作业速度", + "autonomous_speed_detail": "受最大安全速度限制", + "automatic_blade": "任务内割刀自动启停", + "automatic_blade_detail": "依据任务状态和必要的安全条件", + "chassis_height": "底盘高度策略", + "chassis_height_detail": "当前设备可用时开放", + "configured_per_task": "按任务配置", + "blade_safety_note": "割刀动作前必须核验安全互锁;没有可靠高度反馈的机器不展示虚假的刀盘状态。", + "obstacle_section": "避障与安全策略", + "obstacle_monitoring": "避障状态监测", + "obstacle_monitoring_detail": "查看前向感知和超声波状态", + "obstacle_response": "障碍触发的任务处理", + "obstacle_response_detail": "安全停车为优先策略", + "pause_wait": "暂停并等待", + "person_alert": "人员接近预警", + "person_alert_detail": "适用的警示机制保持启用", + "obstacle_safety_note": "不可通过此页面关闭不可绕过的碰撞保护、急停及必要的安全互锁。", + "resume_section": "断点与恢复", + "resume_checkpoint": "断点续作", + "resume_checkpoint_detail": "任务中断或暂停后保留断点位置与已覆盖区域", + "resume_checks": "恢复前校验", + "resume_checks_detail": "定位质量与路线版本必须匹配", + "strict_checks": "严格校验", + "resume_note": "断点恢复依赖可靠的定位与任务回执;校验不通过时应重新选择任务。", + "return_section": "返航与收尾", + "completion_action": "任务结束后动作", + "completion_action_detail": "任务完成后设备默认动作", + "standby_in_place": "原地待命", + "low_battery_threshold": "低电量返航阈值", + "low_battery_threshold_detail": "低于阈值触发返航提示", + "return_channel": "返航通道", + "return_channel_detail": "当前设备未开放自动返航指令位", + "notify_only": "仅提示", + "network_section": "弱网与重连", + "network_reconnect": "弱网重连", + "network_reconnect_detail": "信号波动时自动重建链路", + "command_timeout": "指令超时处理", + "command_timeout_detail": "超时后不重发危险指令", + "scheduled_safety": "定时任务准入", + "scheduled_safety_detail": "启用计划任务执行前的安全准入验证", + "network_safety_note": "弱网下不缓存危险指令;恢复后可先在界面重新确认再下发。", + "settings_demo": "参数下发通道未接入,本页仅作视觉演示", + "stage_setup": "准备", + "stage_pause": "暂停/中断", + "camera_left": "左视", + "camera_right": "右视", + "camera_rear": "后视" + }, + "region_editor": { + "region_saving": "分区正在保存", + "region_readonly_saved": "分区已保存,请点「新建」绘制下一个分区", + "invalid_coordinates": "打点经纬度无效", + "too_many_points": "分区只需要 4 个打点,请撤回或删除后重打", + "point_already_marked": "该位置已打点,请移动到下一个位置", + "editing_scope_changed": "分区或场站已切换,请重新打开编辑", + "four_points_required": "分区范围需要恰好 4 个打点", + "invalid_boundary_points": "分区范围包含无效经纬度", + "duplicate_boundary_points": "分区的 4 个打点不能重复", + "invalid_region_id": "分区 ID 无效", + "invalid_region_site_id": "分区 ID 或场站 ID 无效", + "invalid_route": "请选择有效路线", + "invalid_region": "请选择有效分区", + "delete_retry": "分区未删除,请重试", + "save_retry": "分区未保存,请重试", + "region_delete_failed": "分区删除失败", + "region_save_failed": "分区保存失败", + "regions_invalid_response": "分区列表响应格式错误", + "regions_data_not_list": "分区列表 data 必须为数组", + "region_delete_invalid_response": "分区删除响应格式错误", + "region_save_invalid_response": "分区保存响应格式错误", + "mark_area": "圈地", + "position_single_short": "单点", + "position_diff_short": "差分", + "position_ins_short": "惯导", + "position_fixed_short": "固定解", + "position_float_short": "浮点解", + "position_fixed": "固定", + "position_float": "浮点", + "position_unknown": "定位未知", + "map_not_ready": "地图中心尚未就绪,请稍后重试", + "invalid_device_point": "设备坐标无效,无法添加打点!", + "work_point_added": "已添加第 {count} 个作业区域打点", + "add_work_points_first": "请先添加作业区域打点!", + "custom_route_generated": "已生成路线(自定义模式,{count} 个点)", + "route_needs_three_points": "作业区域至少需要3个打点才能生成路径!", + "coverage_route_generated": "已生成路线(覆盖模式,{count} 个点)", + "work_point_undone": "已撤回作业区域最后一个点,剩余 {count} 个点", + "obstacle_undone": "已撤回上一个禁行区矩形,剩余 {count} 个", + "no_obstacle_to_undo": "暂无可撤回的禁行区", + "no_point_to_delete": "暂无作业区域点可删除", + "no_obstacle_to_delete": "暂无可删除的禁行区", + "obstacles_cleared": "已清空所有禁行区", + "region_create_hint": "移动地图,用准星依次打 4 个边界点后保存分区", + "region_edit_hint": "已回填分区范围,可修改信息或重画边界", + "region_requires_scope": "请先选择场站并登录;场站或账号切换后需重新进入编辑器", + "obstacle_mode_hint": "障碍物模式:点「+」独立添加禁行区矩形(与分区互不影响)", + "invalid_region_point": "设备坐标无效,无法添加分区点", + "region_point_added": "已添加分区第 {count}/4 个点", + "region_already_saved": "该分区已保存,请点「新建」绘制下一个分区", + "region_saved": "分区「{name}」已保存", + "region_point_count": "分区 {count}/4 个点", + "redraw": "重画", + "saved": "已保存", + "edit": "修改", + "work_point_deleted": "已删除第 {index} 个点,剩余 {count} 个", + "obstacle_deleted": "已删除第 {index} 个禁行区矩形,剩余 {count} 个", + "coverage_mode_hint": "覆盖模式:沿边界打点,生成时首尾闭合", + "custom_mode_hint": "自定义模式:按打点顺序生成路线", + "select_site_first": "请先在场站列表中选择一个场站!", + "records_load_failed": "作业记录加载失败", + "geometry_load_failed": "路线几何加载失败", + "route_loaded": "已载入「{name}」,可继续编辑并另存", + "centered_on_device": "已回到设备当前位置", + "editor_reset": "已重置页面状态", + "return_mark_hint": "打点方式:{mode} · 点「+」添加返航点", + "crosshair": "准星", + "device": "设备", + "return_point_summary": "共 {points} 点 · 已绑定设备 {devices} 台{saved}", + "saved_suffix": " · 已保存", + "return_load_failed": "返航方案加载失败", + "return_new_hint": "新建返航方案:点绿色「+」添加返航点", + "return_edit_hint": "已载入返航方案,修改后点「修改」保存", + "return_mode_exited": "已退出返航打点模式", + "invalid_return_point": "设备坐标无效,无法添加返航点!", + "return_point_added": "已添加第 {count} 个返航点", + "invalid_obstacle_point": "设备坐标无效,无法添加障碍!", + "return_obstacle_deleted": "已删除第 {index} 个返航禁行区,剩余 {count} 个", + "no_return_obstacle_to_undo": "暂无可撤回的返航禁行区", + "return_obstacle_undone": "已撤回上一个返航禁行区,剩余 {count} 个", + "return_point_canceled": "已取消该返航点,剩余 {count} 个", + "no_return_point_to_undo": "暂无可撤回的返航点", + "return_point_undone": "已撤回最后一个返航点,剩余 {count} 个", + "return_point_name": "返航点-{index}", + "rename_return_point": "命名返航点 {index}", + "rename_return_point_hint": "给这个返航点起个名字(留空用默认编号)", + "name": "名字", + "name_too_long": "名字不能超过 20 个字符", + "rename_obstacle": "命名障碍 {index}", + "rename_obstacle_hint": "给这个障碍起个名字(留空用尺寸)", + "add_return_points_first": "请先在地图上添加返航点", + "select_site": "请先选择一个场站!", + "site_changed": "场站已切换,请重新进入编辑器后保存", + "obstacle_point_name": "障碍物点-{index}", + "return_save_failed": "返航方案保存失败", + "return_saved": "返航方案已保存:{points} 个返航点{obstacles}", + "obstacles_suffix": " · {count} 个障碍", + "return_execute_unavailable": "返航执行接口尚未接入,返航点已保留", + "work_area_needs_three_points": "作业区域至少需要 3 个打点!", + "save_area": "保存区域", + "area_name_hint": "请输入区域名称(最多 20 字)", + "area_name": "区域名称", + "area_name_required": "区域名称不能为空", + "area_name_too_long": "区域名称不能超过 20 个字符", + "saved_without_screenshot": "「{name}」已保存,但地图截图生成失败", + "area_saved": "「{name}」已保存", + "area_summary": "作业区 {points} 点 · 禁行区 {obstacles} 处 · {mode}模式", + "coverage": "覆盖", + "custom": "自定义", + "region_number": "分区 #{id}", + "title": "地图与区域编辑", + "network_online": "4G在线", + "battery_unknown": "电量未知", + "portrait": "竖屏", + "brightness_demo": "地图亮度调节暂未开发(演示)", + "region": "分区", + "obstacle": "障碍物", + "return_points_title": "一键返航 · 返航点", + "new_area_at_site": "当前场站 · 新建区域", + "new_area_steps": "点「圈地」选择作业模式 → 打点 → 完成 → 保存区域", + "region_four_point_title": "分区 · 四点范围", + "mark_four_points": "依次打 4 个边界点", + "obstacle_mode": "障碍物 · 禁行区矩形", + "resize_rectangle_hint": "点「+」放置矩形,拖动边或角调尺寸", + "return_obstacles_title": "一键返航 · 障碍点", + "return_order": "按打点顺序返航", + "mark_with_crosshair": "准星打点", + "mark_with_device": "设备打点", + "crosshair_return_hint": "准星打点:地图中心即返航点", + "device_mark_hint": "设备打点:取设备实时坐标", + "crosshair_mark_hint": "准星打点:地图中心即打点位置", + "default_device": "默认设备", + "obstacle_point": "障碍点", + "choose_device": "选择设备", + "devices_empty": "暂无可用设备", + "select_rectangle": "在地图上选中矩形", + "return_obstacle_empty_hint": "对准障碍位置点绿色「+」在返航线上落一个矩形(点名字可改名)", + "obstacle_empty_hint": "对准障碍物位置点绿色「+」落一个矩形", + "region_points_empty": "尚未加分区点:点绿色「+」依次打 4 个边界点", + "return_points_empty": "尚未添加返航点:点绿色「+」在当前准星/设备位置打点", + "return_obstacle_summary": "障碍点 {count} 个{note}", + "independent_suffix": " · 与分区/障碍互不影响", + "saving": "保存中", + "execute": "执行", + "row_spacing": "作业行距", + "use_optimal_heading": "使用最优航向", + "return_counts": "{points} 个返航点 · {obstacles} 个障碍", + "return_plan": "返航方案", + "records_empty": "当前场站暂无作业记录", + "unnamed_work": "未命名作业", + "no_video": "未获取到视频流", + "rectangle_dimensions": "矩形尺寸", + "rectangle_width": "宽 X(米)", + "rectangle_height": "高 Y(米)", + "rectangle_preview": "名字:{width}m×{height}m", + "rectangle_positive_dimensions": "请输入大于 0 的宽高", + "no_device_crosshair_hint": "未选择设备,请使用「准星打点」:移动地图,将准星对准目标位置后点「+」。", + "dismiss_tip": "关闭提示", + "scope_changed_reopen": "场站或账号已切换,请重新进入编辑器后保存", + "bind_routes": "绑定路线", + "no_routes_to_bind": "当前场站暂无可绑定路线", + "new_region": "新建分区", + "edit_region": "编辑分区", + "region_name_field": "分区名称 *", + "region_name_required": "请填写分区名称", + "region_code": "分区编码", + "route_load_failed": "路线加载失败", + "reload_routes": "重新加载路线", + "default_route": "默认路线", + "routes_loading": "路线加载中", + "pick_default_route": "请选择默认路线(可选)", + "pick_linked_routes": "请选择绑定路线(可多选)", + "boundary_count": "当前区域范围点数:{count}/4", + "save_confirm": "确认保存", + "delete_region": "删除分区", + "delete_region_message": "确定删除「{region}」?删除后无法恢复。", + "scope_changed_select_region": "场站或账号已切换,请重新选择分区", + "region_deleted": "分区已删除", + "regions_count": "分区列表({count})", + "regions": "分区列表", + "add_region": "新增", + "refresh_regions": "刷新分区", + "close_regions": "关闭列表", + "sign_in_first": "请先登录", + "select_site_for_regions": "请选择场站后查看分区", + "regions_load_failed": "分区加载失败", + "reload_regions": "重新加载分区", + "regions_empty": "当前场站暂无分区,可点击「新增」", + "enabled": "启用", + "disabled": "停用", + "code_value": "编码:{code}", + "region_summary": "{points} 个范围点 · {routes} 条绑定路线", + "redraw_required": "范围需重新打点", + "route_type_title": "选择规划类型", + "route_type_mowing": "割草任务", + "route_type_inspection": "巡检任务", + "route_type_predefined": "预定义模式", + "route_type_other": "其他类型" } } diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png index dc9ada47..db1da6da 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png index 7353c41e..15de6704 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png index 797d452e..989c8115 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png index 6ed2d933..7fdca99c 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png index 4cd7b009..fc35f0d4 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png index fe730945..ada70882 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png index 321773cd..d948e411 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png index 797d452e..989c8115 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png index 502f463a..20b87aeb 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png index 0ec30343..2f8eac9c 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png index 0ec30343..2f8eac9c 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png index e9f5fea2..3ab68f03 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png index 84ac32ae..9e73d780 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png index 8953cba0..cc6f715a 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png index 0467bf12..a3e0afc0 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 14303516..23463170 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -7,7 +7,7 @@ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName - Maibu Satabot V2 + 飒沓·星枢 CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -15,7 +15,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - maibu_satabot_v2 + 飒沓·星枢 CFBundlePackageType APPL CFBundleShortVersionString diff --git a/lib/components/language_selection_dialog.dart b/lib/components/language_selection_dialog.dart index a171e439..87a6e6be 100644 --- a/lib/components/language_selection_dialog.dart +++ b/lib/components/language_selection_dialog.dart @@ -1,6 +1,9 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; import 'package:maibu_satabot_v2/core/localization/locale_cubit.dart'; /// 可选语言项:tag 对应 assets/languages/{tag}.json,nativeName 用该语言本地写法展示。 @@ -22,8 +25,8 @@ class AppLanguages { static final AppLanguages instance = AppLanguages._(); final List items = const [ - LanguageItem(Locale('zh', 'CN'), '简体中文'), - LanguageItem(Locale('en', 'US'), 'English'), + LanguageItem(AppLocalizations.chinese, '简体中文'), + LanguageItem(AppLocalizations.english, 'English'), ]; String nameOf(Locale locale) { @@ -44,56 +47,154 @@ class LanguageSelectionDialog extends StatelessWidget { final bool mandatory; const LanguageSelectionDialog({super.key, this.mandatory = true}); - Future _onSelect(BuildContext context, Locale locale) async { - await context.read().setLocale(locale); - if (context.mounted) Navigator.of(context).pop(); + void _onSelect(BuildContext context, Locale locale) { + if (ModalRoute.of(context)?.isCurrent != true) return; + unawaited(context.read().setLocale(locale)); + Navigator.of(context).pop(); } - /// “继续”:不改变当前(默认)语言,仅确认已选并关闭,后续启动不再弹。 - Future _onContinue(BuildContext context, Locale current) async { - await context.read().setLocale(current); - if (context.mounted) Navigator.of(context).pop(); - } + static const _navy = Color(0xFF1A2B4A); + static const _blue = Color(0xFF1C96F6); + static const _gray = Color(0xFF63758A); + static const _border = Color(0xFFE5EDF7); + static const _softBlue = Color(0xFFEAF3FE); @override Widget build(BuildContext context) { - final current = context.select( - (c) => c.state, + final current = context.select((c) => c.state); + final isChinese = current.languageCode == 'zh'; + final buttonShape = RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), ); return PopScope( - // 强制弹窗时拦截返回键,必须选一个才能继续使用 canPop: !mandatory, - child: AlertDialog( - title: const Text('选择语言 / Select Language'), - content: SizedBox( - width: 300, + child: Dialog( + backgroundColor: Colors.white, + surfaceTintColor: Colors.transparent, + insetPadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20), + constraints: const BoxConstraints(maxWidth: 360), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)), + child: SingleChildScrollView( + padding: const EdgeInsets.all(20), child: Column( mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - for (final item in AppLanguages.instance.items) - RadioListTile( - value: item.tag, - // 高亮当前语言:按 languageCode 匹配,兼容国家码为空的历史值 - groupValue: current.countryCode == null || - current.countryCode!.isEmpty - ? current.languageCode - : '${current.languageCode}-${current.countryCode}', - title: Text(item.nativeName), - onChanged: (_) => _onSelect(context, item.locale), + Row( + children: [ + Container( + width: 44, + height: 44, + decoration: BoxDecoration( + color: _softBlue, + borderRadius: BorderRadius.circular(12), + ), + child: const Icon(Icons.language_rounded, color: _blue), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + isChinese ? '选择语言' : 'Select language', + style: const TextStyle( + color: _navy, + fontSize: 18, + fontWeight: FontWeight.w800, + ), + ), + const SizedBox(height: 2), + Text( + isChinese ? 'Select language' : '选择语言', + style: const TextStyle(color: _gray, fontSize: 12), + ), + ], + ), + ), + ], + ), + const SizedBox(height: 18), + for (final item in AppLanguages.instance.items) ...[ + _languageOption(context, item, selected: item.locale == current), + const SizedBox(height: 8), + ], + const SizedBox(height: 8), + if (mandatory) + FilledButton( + style: FilledButton.styleFrom( + backgroundColor: const Color(0xFF0B6DCC), + foregroundColor: Colors.white, + minimumSize: const Size.fromHeight(44), + shape: buttonShape, + ), + onPressed: () => _onSelect(context, current), + child: Text(isChinese ? '继续 / Continue' : 'Continue / 继续'), + ) + else + OutlinedButton( + style: OutlinedButton.styleFrom( + foregroundColor: _navy, + side: const BorderSide(color: _border), + minimumSize: const Size.fromHeight(44), + shape: buttonShape, + ), + onPressed: () => Navigator.of(context).pop(), + child: Text( + AppLocalizations.of(context).translate('common.cancel'), + ), ), ], ), ), - actions: [ - // 强制弹窗:提供“继续”出口,保持当前默认语言并确认后关闭;非强制:取消 - TextButton( - onPressed: () => mandatory - ? _onContinue(context, current) - : Navigator.of(context).pop(), - child: Text(mandatory ? '继续 / Continue' : '取消'), + ), + ); + } + + Widget _languageOption( + BuildContext context, + LanguageItem item, { + required bool selected, + }) { + return Semantics( + selected: selected, + button: true, + child: Material( + color: selected ? _softBlue : const Color(0xFFF6FAFE), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + side: BorderSide(color: selected ? _blue : _border), + ), + clipBehavior: Clip.antiAlias, + child: InkWell( + onTap: () => _onSelect(context, item.locale), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 14), + child: Row( + children: [ + Expanded( + child: Text( + item.nativeName, + style: const TextStyle( + color: _navy, + fontSize: 15, + fontWeight: FontWeight.w600, + ), + ), + ), + const SizedBox(width: 10), + Icon( + selected + ? Icons.check_circle_rounded + : Icons.radio_button_unchecked_rounded, + size: 20, + color: selected ? _blue : const Color(0xFFABBBCD), + ), + ], + ), ), - ], + ), ), ); } diff --git a/lib/components/route_type_picker.dart b/lib/components/route_type_picker.dart index ae0669da..bc3e433e 100644 --- a/lib/components/route_type_picker.dart +++ b/lib/components/route_type_picker.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; import 'package:maibu_satabot_v2/features/home/presentation/widgets/common/enum.dart'; @@ -13,7 +14,7 @@ import 'package:maibu_satabot_v2/features/home/presentation/widgets/common/enum. /// [initial]:默认选中项,默认「割草任务」。 Future showRouteTypePicker( BuildContext context, { - String title = '选择规划类型', + String? title, RouteType? initial, double? maxWidth, EdgeInsets? insetPadding, @@ -21,7 +22,7 @@ Future showRouteTypePicker( return showDialog( context: context, builder: (dialogContext) => _RouteTypeDialog( - title: title, + title: title ?? AppLocalizations.of(dialogContext).translate('region_editor.route_type_title'), initial: initial ?? RouteType.mowingTask, maxWidth: maxWidth, insetPadding: insetPadding, @@ -47,6 +48,8 @@ class _RouteTypeDialog extends StatefulWidget { } class _RouteTypeDialogState extends State<_RouteTypeDialog> { + AppLocalizations get _l10n => AppLocalizations.of(context); + late RouteType _picked = widget.initial; @override @@ -77,12 +80,12 @@ class _RouteTypeDialogState extends State<_RouteTypeDialog> { actions: [ TextButton( onPressed: () => Navigator.of(context).pop(), - child: const Text('取消'), + child: Text(_l10n.translate('common.cancel')), ), TextButton( onPressed: () => Navigator.of(context).pop(_picked), child: Text( - '确定', + _l10n.translate('common.ok'), style: TextStyle( color: accent, fontWeight: FontWeight.w600, @@ -117,7 +120,12 @@ class _RouteTypeDialogState extends State<_RouteTypeDialog> { const SizedBox(width: 10), Expanded( child: Text( - type.label, + _l10n.translate(switch (type) { + RouteType.mowingTask => 'region_editor.route_type_mowing', + RouteType.inspectionTask => 'region_editor.route_type_inspection', + RouteType.predefinedPath => 'region_editor.route_type_predefined', + RouteType.other => 'region_editor.route_type_other', + }), style: TextStyle( fontSize: 15, color: selected ? accent : null, diff --git a/lib/core/consts/http_api_consts.dart b/lib/core/consts/http_api_consts.dart index 1c454354..920971ac 100644 --- a/lib/core/consts/http_api_consts.dart +++ b/lib/core/consts/http_api_consts.dart @@ -2,6 +2,12 @@ import '../env/env_config.dart'; class HttpApiConsts { static String get baseUrl => EnvConfig.baseUrl; + static String get siteDevicePlans => '$baseUrl/iot/deviceTask/getSiteDevicePlan'; + static String get deleteDevicePlan => '$baseUrl/iot/deviceTask/delete'; + static String get siteDeviceTaskHistory => + '$baseUrl/iot/deviceTask/getSiteDeviceTaskHistory'; + static String get createConsecutiveTask => + '$baseUrl/iot/deviceTask/createConsecutiveTask'; static String get saveRegion => '$baseUrl/system/region/save'; static String get regionsBySite => '$baseUrl/system/region/selectBySiteId'; static String get deleteRegions => '$baseUrl/system/region/delete'; diff --git a/lib/core/di/injection.dart b/lib/core/di/injection.dart index 23d3d8a0..57551fdd 100644 --- a/lib/core/di/injection.dart +++ b/lib/core/di/injection.dart @@ -1,3 +1,20 @@ +import '../../features/autonomous_work/domain/usecases/load_site_return_plan_usecase.dart'; +import '../../features/v2/work/presentation/cubit/return_plan_library_cubit.dart'; +import '../../features/site_task_plans/data/datasources/site_task_plan_remote_datasource.dart'; +import '../../features/site_task_plans/data/repositories/site_task_plan_repository_impl.dart'; +import '../../features/site_task_plans/domain/repositories/site_task_plan_repository.dart'; +import '../../features/site_task_plans/domain/usecases/site_task_plan_usecases.dart'; +import '../../features/site_task_plans/presentation/cubit/site_task_plans_cubit.dart'; +import '../../features/work_history/data/datasources/work_history_remote_datasource.dart'; +import '../../features/work_history/data/repositories/work_history_repository_impl.dart'; +import '../../features/work_history/domain/repositories/work_history_repository.dart'; +import '../../features/work_history/domain/usecases/load_site_work_history_usecase.dart'; +import '../../features/work_history/presentation/cubit/work_history_cubit.dart'; +import '../../features/consecutive_tasks/data/datasources/consecutive_task_remote_datasource.dart'; +import '../../features/consecutive_tasks/data/repositories/consecutive_task_repository_impl.dart'; +import '../../features/consecutive_tasks/domain/repositories/consecutive_task_repository.dart'; +import '../../features/consecutive_tasks/domain/usecases/create_consecutive_task_usecase.dart'; +import '../../features/consecutive_tasks/presentation/cubit/area_task_create_cubit.dart'; import 'package:dio/dio.dart'; import 'adapters/device_control_mode_realtime_adapter.dart'; import '../../features/device_control_mode/data/datasources/control_mode_remote_datasource.dart'; @@ -508,7 +525,7 @@ Future init() async { ); // 🔥 语言管理 Cubit (单例) - sl.registerLazySingleton(() => LocaleCubit()); + sl.registerLazySingleton(() => LocaleCubit(sl())); // 🔥 主题管理 Cubit (单例,管理亮/暗/跟随系统) sl.registerLazySingleton(() => ThemeCubit()); @@ -640,6 +657,24 @@ Future init() async { ); sl.registerLazySingleton(() => GetDeviceTaskPoolUseCase(sl())); sl.registerFactory(() => WorkHomeTaskCubit(sl())); + sl.registerLazySingleton( + () => SiteTaskPlanRemoteDatasource(sl(), sl()), + ); + sl.registerLazySingleton( + () => SiteTaskPlanRepositoryImpl(sl()), + ); + sl.registerLazySingleton( + () => LoadSiteTaskPlansUseCase(sl()), + ); + sl.registerLazySingleton( + () => DeleteSiteTaskPlanUseCase(sl()), + ); + sl.registerFactory( + () => SiteTaskPlansCubit( + sl(), + sl(), + ), + ); sl.registerLazySingleton(() => CancelTaskUseCase(sl())); sl.registerLazySingleton(() => PauseTaskUseCase(sl())); sl.registerLazySingleton(() => RecoveryTaskUseCase(sl())); @@ -688,7 +723,39 @@ Future init() async { () => LoadRegionRoutesUseCase(sl()), ); sl.registerLazySingleton(() => LoadRegionsUseCase(sl())); + sl.registerLazySingleton( + () => LoadSiteReturnPlanUseCase(sl()), + ); + sl.registerFactory( + () => ReturnPlanLibraryCubit(sl()), + ); sl.registerLazySingleton(() => DeleteRegionsUseCase(sl())); + sl.registerLazySingleton( + () => WorkHistoryRemoteDatasource(sl(), sl()), + ); + sl.registerLazySingleton( + () => WorkHistoryRepositoryImpl(sl()), + ); + sl.registerLazySingleton( + () => LoadSiteWorkHistoryUseCase(sl()), + ); + sl.registerFactory(() => WorkHistoryCubit(sl())); + sl.registerLazySingleton( + () => ConsecutiveTaskRemoteDatasource(sl(), sl()), + ); + sl.registerLazySingleton( + () => ConsecutiveTaskRepositoryImpl(sl()), + ); + sl.registerLazySingleton( + () => CreateConsecutiveTaskUseCase(sl()), + ); + sl.registerFactory( + () => AreaTaskCreateCubit( + sl(), + sl(), + sl(), + ), + ); sl.registerFactory( () => RegionListCubit(sl(), sl()), ); diff --git a/lib/core/domain/entities/user_entity.dart b/lib/core/domain/entities/user_entity.dart index 9a4cc452..b7ee0cfe 100644 --- a/lib/core/domain/entities/user_entity.dart +++ b/lib/core/domain/entities/user_entity.dart @@ -1,6 +1,8 @@ import 'package:equatable/equatable.dart'; class UserEntity extends Equatable { + static const adminRoleKey = 'admin'; + final String userId; final String username; final String nickname; @@ -25,6 +27,8 @@ class UserEntity extends Equatable { this.siteId, }); + bool get isAdmin => roleKey == adminRoleKey; + @override List get props => [ userId, diff --git a/lib/core/env/env_config.dart b/lib/core/env/env_config.dart index a0147362..74fa9ae4 100644 --- a/lib/core/env/env_config.dart +++ b/lib/core/env/env_config.dart @@ -12,7 +12,7 @@ class EnvConfig { return 'https://1a72051f8ac6c21cde96ded18a318217@o4510984107261952.ingest.de.sentry.io/4510984468824144'; } - static bool get isProduction => environment == 'prod'; + static const bool isProduction = environment == 'prod'; // ─── 服务器 IP(测试/生产共用同一台机器) ─── static const String serverHost = '1.95.137.212'; diff --git a/lib/core/infrastructure/logging/sentry_logger_impl.dart b/lib/core/infrastructure/logging/sentry_logger_impl.dart index a390bc90..23730daf 100644 --- a/lib/core/infrastructure/logging/sentry_logger_impl.dart +++ b/lib/core/infrastructure/logging/sentry_logger_impl.dart @@ -9,6 +9,12 @@ import '../../logging/i_logger_service.dart'; import 'package:intl/intl.dart'; class SentryLoggerImpl implements ILoggerService { + // 正式包默认关闭上报,重新启用时传入 --dart-define=ENABLE_SENTRY=true。 + static const bool _sentryEnabled = bool.fromEnvironment( + 'ENABLE_SENTRY', + defaultValue: !kReleaseMode && !EnvConfig.isProduction, + ); + File? _localLogFile; //调试模式开关 bool _isDebugModeEnabled = false; @@ -16,20 +22,17 @@ class SentryLoggerImpl implements ILoggerService { @override Future init() async { _isDebugModeEnabled = false; - await SentryFlutter.init((options) { - options.dsn = EnvConfig.sentryDsn; - options.environment = EnvConfig.environment; - // 生产环境只采样 20% 的性能数据,测试环境全开 - options.tracesSampleRate = EnvConfig.isProduction ? 0.2 : 1.0; + if (_sentryEnabled) { + await SentryFlutter.init((options) { + options.dsn = EnvConfig.sentryDsn; + options.environment = EnvConfig.environment; + // 生产环境只采样 20% 的性能数据,测试环境全开 + options.tracesSampleRate = EnvConfig.isProduction ? 0.2 : 1.0; + options.debug = _isDebugModeEnabled; + }); - // 动态设置 Sentry 接收的日志级别 - // 如果开启调试模式,接收 DEBUG;否则生产环境只接收 INFO 以上 - - options.debug = _isDebugModeEnabled; // 开启 SDK 内部调试 - - }); - - await _collectDeviceInfo(); + await _collectDeviceInfo(); + } await _prepareLocalFile(); } @@ -67,7 +70,9 @@ class SentryLoggerImpl implements ILoggerService { @override void captureException(dynamic exception, {dynamic stackTrace}) { - Sentry.captureException(exception, stackTrace: stackTrace); + if (_sentryEnabled) { + Sentry.captureException(exception, stackTrace: stackTrace); + } } @override @@ -80,13 +85,13 @@ class SentryLoggerImpl implements ILoggerService { final level = isWarning ? 'WARNING' : 'INFO'; final logEntry = "[$timestamp] [$level] $message ${data ?? ''}\n"; - // 1.发送日志到 Sentry - Sentry.captureMessage( - message, - level: isWarning ? SentryLevel.warning : SentryLevel.info, - ); + if (_sentryEnabled) { + Sentry.captureMessage( + message, + level: isWarning ? SentryLevel.warning : SentryLevel.info, + ); + } - // 2.写入本地文件 _writeToLocalFile(logEntry); if (kDebugMode) { @@ -127,10 +132,10 @@ class SentryLoggerImpl implements ILoggerService { _isDebugModeEnabled; if (shouldProcess) { - // 写入本地文件 _writeToLocalFile(logEntry); + } - // 上报 Sentry + if (_sentryEnabled && shouldProcess) { SentryLevel sentryLevel; switch (level) { case 'DEBUG': sentryLevel = SentryLevel.debug; break; @@ -164,11 +169,15 @@ class SentryLoggerImpl implements ILoggerService { @override void addBreadcrumb(String message, {String? category}) { - Sentry.addBreadcrumb(Breadcrumb(message: message, category: category)); + if (_sentryEnabled) { + Sentry.addBreadcrumb(Breadcrumb(message: message, category: category)); + } } @override void setUser(String userId) { - Sentry.configureScope((scope) => scope.setUser(SentryUser(id: userId))); + if (_sentryEnabled) { + Sentry.configureScope((scope) => scope.setUser(SentryUser(id: userId))); + } } } diff --git a/lib/core/localization/app_localizations.dart b/lib/core/localization/app_localizations.dart index e50d4ed7..5ed161a7 100644 --- a/lib/core/localization/app_localizations.dart +++ b/lib/core/localization/app_localizations.dart @@ -3,21 +3,32 @@ import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; class AppLocalizations { + static const chinese = Locale('zh', 'CN'); + static const english = Locale('en', 'US'); + static const supportedLocales = [chinese, english]; + + static Locale localeForLanguage(String? languageCode) => + languageCode == 'zh' ? chinese : english; + + static final _placeholderPattern = RegExp(r'\{(\w+)\}'); + final Locale locale; Map _localizedStrings = {}; - + AppLocalizations(this.locale); - + static AppLocalizations of(BuildContext context) { return Localizations.of(context, AppLocalizations)!; } - - static const LocalizationsDelegate delegate = _AppLocalizationsDelegate(); - + + static const LocalizationsDelegate delegate = + _AppLocalizationsDelegate(); + Future load() async { try { - String jsonString = await rootBundle.loadString( - 'assets/languages/${locale.languageCode}-${locale.countryCode}.json', + final assetLocale = localeForLanguage(locale.languageCode); + final jsonString = await rootBundle.loadString( + 'assets/languages/${assetLocale.toLanguageTag()}.json', ); Map jsonMap = json.decode(jsonString); _localizedStrings = jsonMap; @@ -27,11 +38,11 @@ class AppLocalizations { return false; } } - - String translate(String key) { + + String translate(String key, [Map values = const {}]) { final keys = key.split('.'); dynamic value = _localizedStrings; - + for (final k in keys) { if (value is Map) { value = value[k]; @@ -39,26 +50,34 @@ class AppLocalizations { return key; } } - - return value?.toString() ?? key; + + final text = value?.toString() ?? key; + if (values.isEmpty) return text; + return text.replaceAllMapped( + _placeholderPattern, + (match) => values[match[1]]?.toString() ?? match[0]!, + ); } } -class _AppLocalizationsDelegate extends LocalizationsDelegate { +class _AppLocalizationsDelegate + extends LocalizationsDelegate { const _AppLocalizationsDelegate(); - + @override bool isSupported(Locale locale) { - return ['zh', 'en'].contains(locale.languageCode); + return AppLocalizations.supportedLocales.any( + (supported) => supported.languageCode == locale.languageCode, + ); } - + @override Future load(Locale locale) async { final localizations = AppLocalizations(locale); await localizations.load(); return localizations; } - + @override bool shouldReload(_AppLocalizationsDelegate old) => false; } diff --git a/lib/core/localization/locale_cubit.dart b/lib/core/localization/locale_cubit.dart index 4f635865..cdd0f2db 100644 --- a/lib/core/localization/locale_cubit.dart +++ b/lib/core/localization/locale_cubit.dart @@ -2,44 +2,57 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'app_localizations.dart'; + class LocaleCubit extends Cubit { - static const String _localeKey = 'app_locale'; - static const String _chosenKey = 'app_locale_chosen'; + static const _languageKey = 'app_locale_lang'; + static const _countryKey = 'app_locale_country'; + static const _chosenKey = 'app_locale_chosen'; - /// 用户是否已明确选择过语言(决定登录页是否弹强制语言选择框) - bool hasChosenLanguage = false; + LocaleCubit(this._preferences) + : _hasChosenLanguage = _preferences.get(_chosenKey) == true, + super(_savedLocale(_preferences)); - LocaleCubit() : super(const Locale('en', 'US')) { - _loadSavedLocale(); + final SharedPreferences _preferences; + bool _hasChosenLanguage; + Future _pendingSave = Future.value(); + + /// 用户是否已明确选择过语言。 + bool get hasChosenLanguage => _hasChosenLanguage; + + static Locale _savedLocale(SharedPreferences preferences) { + if (preferences.get(_chosenKey) != true) return AppLocalizations.english; + return AppLocalizations.localeForLanguage( + preferences.get(_languageKey)?.toString(), + ); } - Future _loadSavedLocale() async { + Future setLocale(Locale locale) { + if (isClosed) return Future.value(); + final selected = AppLocalizations.localeForLanguage(locale.languageCode); + _hasChosenLanguage = true; + emit(selected); + + // 快速切换时按点选顺序写入,最后一次选择用于下次启动。 + return _pendingSave = _pendingSave.then((_) => _persist(selected)); + } + + Future _persist(Locale locale) async { try { - final prefs = await SharedPreferences.getInstance(); - hasChosenLanguage = prefs.getBool(_chosenKey) ?? false; - if (hasChosenLanguage) { - final languageCode = prefs.getString('${_localeKey}_lang') ?? 'en'; - final countryCode = prefs.getString('${_localeKey}_country') ?? 'US'; - emit(Locale(languageCode, countryCode)); - } else { - // 未选择过:默认英文(登录页仍会弹出强制选择框) - emit(const Locale('en', 'US')); + final languageSaved = await _preferences.setString( + _languageKey, + locale.languageCode, + ); + final countrySaved = await _preferences.setString( + _countryKey, + locale.countryCode!, + ); + final chosenSaved = await _preferences.setBool(_chosenKey, true); + if (!languageSaved || !countrySaved || !chosenSaved) { + debugPrint('[LocaleCubit] 语言偏好未写入存储'); } - } catch (e) { - emit(const Locale('en', 'US')); - } - } - - Future setLocale(Locale locale) async { - try { - final prefs = await SharedPreferences.getInstance(); - await prefs.setString('${_localeKey}_lang', locale.languageCode); - await prefs.setString('${_localeKey}_country', locale.countryCode ?? ''); - await prefs.setBool(_chosenKey, true); - hasChosenLanguage = true; - emit(locale); - } catch (e) { - debugPrint('❌ [LocaleCubit] 保存语言设置失败: $e'); + } catch (error) { + debugPrint('[LocaleCubit] 保存语言设置失败: $error'); } } diff --git a/lib/core/network/mqtt/data/datasources/mower_realtime_datasource.dart b/lib/core/network/mqtt/data/datasources/mower_realtime_datasource.dart index 9464518c..76c2b120 100644 --- a/lib/core/network/mqtt/data/datasources/mower_realtime_datasource.dart +++ b/lib/core/network/mqtt/data/datasources/mower_realtime_datasource.dart @@ -24,6 +24,11 @@ abstract class MowerRealtimeDataSource { /// 🔥 主机实时状态(device/{sn}/host/realTime/message,新增话题,纯附加) Stream get hostRealtimeStream; + /// 按设备观察概览所需的电量和控制模式,订阅随监听者释放。 + Stream<({double? battery, String controlMode})> watchOverviewStatus( + String deviceSn, + ); + /// 按设备 SN 启动订阅:自动退订旧设备主题、同 SN 去重 Future startListening({required String deviceSn}); @@ -76,6 +81,70 @@ class MowerRealtimeDataSourceImpl implements MowerRealtimeDataSource { String _routeTopic(String sn) => 'device/$sn/$_routeSuffix'; String _hostRealtimeTopic(String sn) => 'device/$sn/$_hostRealtimeSuffix'; + @override + Stream<({double? battery, String controlMode})> watchOverviewStatus( + String deviceSn, + ) { + final sn = deviceSn.trim(); + final messages = mqttClient.messageStream; + if (sn.isEmpty || messages == null) return const Stream.empty(); + + final topic = _hostRealtimeTopic(sn); + StreamSubscription? messageSubscription; + Future? topicSubscription; + double? lastBattery; + late final StreamController<({double? battery, String controlMode})> + controller; + + controller = StreamController( + onListen: () { + // 先监听报文再订阅 Topic,接住订阅时立即到达的消息。 + messageSubscription = messages.where((msg) => msg.topic == topic).listen( + (message) { + try { + final json = jsonDecode(message.payload); + if (json is! Map) return; + final payload = json['data']; + final data = payload is Map ? payload : json; + final battery = HostRealtimeMessageEntity.parseBatteryPercentage( + data['battery_percentage'], + ); + lastBattery = battery ?? lastBattery; + controller.add( + ( + battery: lastBattery, + controlMode: data['control_mode']?.toString().trim() ?? '', + ), + ); + } on FormatException { + // 忽略格式异常的单帧,等待下一次上报。 + } + }, + onError: controller.addError, + onDone: controller.close, + ); + topicSubscription = mqttClient.subscribe(topic).catchError( + (Object error, StackTrace stackTrace) { + if (!controller.isClosed) controller.addError(error, stackTrace); + }, + ); + }, + onCancel: () async { + await messageSubscription?.cancel(); + final subscription = topicSubscription; + if (subscription == null) return; + await subscription; + try { + // 客户端按引用计数释放,详情页仍在使用时会保留其订阅。 + await mqttClient.unsubscribe(topic); + } catch (error) { + debugPrint('[设备概览] 释放订阅失败 $topic: $error'); + } + }, + ); + return controller.stream.distinct(); + } + @override Future startListening({required String deviceSn}) async { if (deviceSn.isEmpty) { diff --git a/lib/core/network/mqtt/data/repositories/mower_realtime_repository_impl.dart b/lib/core/network/mqtt/data/repositories/mower_realtime_repository_impl.dart index 5e659712..dd578bdd 100644 --- a/lib/core/network/mqtt/data/repositories/mower_realtime_repository_impl.dart +++ b/lib/core/network/mqtt/data/repositories/mower_realtime_repository_impl.dart @@ -28,6 +28,11 @@ class MowerRealtimeRepositoryImpl implements MowerRealtimeRepository { Stream get hostRealtimeStream => dataSource.hostRealtimeStream; + @override + Stream<({double? battery, String controlMode})> watchOverviewStatus( + String deviceSn, + ) => dataSource.watchOverviewStatus(deviceSn); + @override Future> startListening({ required String deviceSn, diff --git a/lib/core/network/mqtt/domain/entities/host_realtime_message_entity.dart b/lib/core/network/mqtt/domain/entities/host_realtime_message_entity.dart index afb1844c..319e2a2d 100644 --- a/lib/core/network/mqtt/domain/entities/host_realtime_message_entity.dart +++ b/lib/core/network/mqtt/domain/entities/host_realtime_message_entity.dart @@ -66,7 +66,7 @@ class HostRealtimeMessageEntity extends Equatable { /// [data] 为报文 `data` 子对象(由 DataSource 提取,与 MowerLocationEntity 一致) factory HostRealtimeMessageEntity.fromJson(Map data) { return HostRealtimeMessageEntity( - batteryPercentage: _toDouble(data['battery_percentage']), + batteryPercentage: parseBatteryPercentage(data['battery_percentage']) ?? 0, batteryVoltage: _toDouble(data['battery_voltage']), leftMotorCurrent: _toDouble(data['left_motor_current']), rightMotorCurrent: _toDouble(data['right_motor_current']), @@ -95,6 +95,20 @@ class HostRealtimeMessageEntity extends Equatable { ); } + /// 供主机状态和设备概览使用,区分无效值与真实的 0%。 + static double? parseBatteryPercentage(Object? value) { + final percentage = value is num + ? value.toDouble() + : double.tryParse(value?.toString() ?? ''); + if (percentage == null || + !percentage.isFinite || + percentage < 0 || + percentage > 100) { + return null; + } + return percentage; + } + static double _toDouble(dynamic value) { if (value == null) return 0; if (value is num) return value.toDouble(); diff --git a/lib/core/network/mqtt/domain/repositories/mower_realtime_repository.dart b/lib/core/network/mqtt/domain/repositories/mower_realtime_repository.dart index 64252a36..2f200a1b 100644 --- a/lib/core/network/mqtt/domain/repositories/mower_realtime_repository.dart +++ b/lib/core/network/mqtt/domain/repositories/mower_realtime_repository.dart @@ -13,6 +13,10 @@ abstract class MowerRealtimeRepository { Stream get routeStatusStream; Stream get hostRealtimeStream; + Stream<({double? battery, String controlMode})> watchOverviewStatus( + String deviceSn, + ); + Future> startListening({ required String deviceSn, }); diff --git a/lib/core/update/update_cubit.dart b/lib/core/update/update_cubit.dart index a3eaabc0..bac54c52 100644 --- a/lib/core/update/update_cubit.dart +++ b/lib/core/update/update_cubit.dart @@ -1,7 +1,11 @@ +import 'dart:async'; import 'dart:io'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter/services.dart'; import 'package:logger/logger.dart'; +import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart'; +import 'package:maibu_satabot_v2/core/app/app_user_state.dart'; +import 'package:maibu_satabot_v2/core/domain/entities/user_entity.dart'; import 'package:open_file/open_file.dart'; import 'package:path_provider/path_provider.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -11,19 +15,52 @@ import 'update_state.dart'; /// 更新 Cubit class UpdateCubit extends Cubit { final VersionCheckService _versionService; - final Logger _logger; + final AppUserCubit _users; + final Logger _logger = Logger(); + late final StreamSubscription _adminChanges; + UserEntity? _updateOwner; - UpdateCubit(this._versionService) - : _logger = Logger(), - super(UpdateInitial()); + UpdateCubit(this._versionService, this._users) : super(const UpdateInitial()) { + _adminChanges = _users.stream.listen((_) { + final owner = _updateOwner; + if (owner != null && !_canContinue(owner)) { + _updateOwner = null; + emit(const UpdateInitial()); + } + }); + } + + UserEntity? get _adminUser { + final user = _users.state.user; + return user?.isAdmin == true ? user : null; + } + + UserEntity? _beginUpdate() { + if (isClosed) return null; + final admin = _adminUser; + if (admin != null) _updateOwner = admin; + return admin; + } + + bool _canContinue(UserEntity admin) => + !isClosed && identical(_updateOwner, admin) && identical(_adminUser, admin); + + @override + Future close() async { + await _adminChanges.cancel(); + await super.close(); + } /// 检查版本更新 Future checkUpdate() async { - emit(UpdateChecking()); + final admin = _beginUpdate(); + if (admin == null) return; + emit(const UpdateChecking()); try { // 从 pubspec.yaml 读取版本信息 final String versionString = await rootBundle.loadString('pubspec.yaml'); + if (!_canContinue(admin)) return; final versionMatch = RegExp(r'version:\s*(\d+\.\d+\.\d+)\+(\d+)').firstMatch(versionString); final currentVersion = versionMatch?.group(1) ?? '1.0.0'; @@ -37,6 +74,7 @@ class UpdateCubit extends Cubit { currentVersionCode: currentVersionCode, ); + if (!_canContinue(admin)) return; if (versionInfo == null) { _logger.i('✅ 已是最新版本'); emit(UpdateUpToDate()); @@ -49,6 +87,7 @@ class UpdateCubit extends Cubit { emit(UpdateAvailable(versionInfo)); } catch (e) { + if (!_canContinue(admin)) return; _logger.e('❌ 检查更新失败: $e'); emit(UpdateFailure('检查更新失败: $e')); } @@ -56,6 +95,8 @@ class UpdateCubit extends Cubit { /// 应用差量补丁 Future applyPatch(String patchUrl, String version, int targetVersionCode, {String? md5}) async { + final admin = _beginUpdate(); + if (admin == null) return; emit(const UpdateDownloading(0.0, isPatch: true)); try { @@ -67,11 +108,13 @@ class UpdateCubit extends Cubit { targetVersionCode: targetVersionCode, md5: md5, onProgress: (progress) { - // 🔥 实时更新下载进度 - emit(UpdateDownloading(progress, isPatch: true)); + if (_canContinue(admin)) { + emit(UpdateDownloading(progress, isPatch: true)); + } }, ); + if (!_canContinue(admin)) return; if (success) { emit(const UpdateInstalling(isPatch: true)); emit(UpdateSuccess()); @@ -79,6 +122,7 @@ class UpdateCubit extends Cubit { emit(const UpdateFailure('补丁应用失败')); } } catch (e) { + if (!_canContinue(admin)) return; _logger.e('❌ 应用补丁异常: $e'); emit(UpdateFailure('应用补丁失败: $e')); } @@ -86,15 +130,20 @@ class UpdateCubit extends Cubit { /// 自动下载并安装 APK(App 内下载) Future downloadAndInstallApk(String apkUrl) async { + final admin = _beginUpdate(); + if (admin == null) return; emit(const UpdateDownloading(0.0, isPatch: false)); try { _logger.i('⬇️ 开始下载完整 APK'); final apkPath = await _versionService.downloadApk(apkUrl, (progress) { - emit(UpdateDownloading(progress, isPatch: false)); + if (_canContinue(admin)) { + emit(UpdateDownloading(progress, isPatch: false)); + } }); + if (!_canContinue(admin)) return; if (apkPath != null) { _logger.i('✅ APK 下载完成: $apkPath'); // 🔥 关键:先清理版本号记录,并等待用户看到提示 @@ -105,6 +154,7 @@ class UpdateCubit extends Cubit { // 🔥 短暂延迟,让用户看到清理完成的提示 await Future.delayed(const Duration(milliseconds: 800)); + if (!_canContinue(admin)) return; // 🔥 直接调起系统安装页面,不再等待用户点击 _logger.i('📦 自动调起系统安装页面'); @@ -113,6 +163,7 @@ class UpdateCubit extends Cubit { emit(const UpdateFailure('APK 下载失败')); } } catch (e) { + if (!_canContinue(admin)) return; _logger.e('❌ 下载安装 APK 异常: $e'); emit(UpdateFailure('下载安装 APK 失败: $e')); } @@ -120,6 +171,8 @@ class UpdateCubit extends Cubit { /// 触发系统安装页面 Future triggerInstall(String apkPath) async { + final admin = _beginUpdate(); + if (admin == null) return; emit(const UpdateInstalling(isPatch: false)); try { @@ -129,6 +182,7 @@ class UpdateCubit extends Cubit { // 🔥 验证文件是否存在 final file = File(apkPath); if (!await file.exists()) { + if (!_canContinue(admin)) return; _logger.e('❌ APK 文件不存在: $apkPath'); emit(UpdateFailure('APK 文件不存在,请重新下载')); return; @@ -139,6 +193,7 @@ class UpdateCubit extends Cubit { // 🔥 关键修复:将APK复制到外部存储,避免某些Android版本的安装限制 final externalDir = await getExternalStorageDirectory(); + if (!_canContinue(admin)) return; String finalApkPath = apkPath; if (externalDir != null) { @@ -157,7 +212,9 @@ class UpdateCubit extends Cubit { // 打开 APK 文件,触发系统安装界面 _logger.i('🚀 调用 OpenFile.open...'); _logger.i('🚀 最终APK路径: $finalApkPath'); + if (!_canContinue(admin)) return; final result = await OpenFile.open(finalApkPath); + if (!_canContinue(admin)) return; _logger.i('📦 安装结果: ${result.message} (type: ${result.type})'); // 如果用户取消安装,显示提示信息并保留文件路径 @@ -180,6 +237,7 @@ class UpdateCubit extends Cubit { emit(UpdateSuccess()); } } catch (e) { + if (!_canContinue(admin)) return; _logger.e('❌ 调起安装页面异常: $e'); emit(UpdateFailure('调起安装页面失败: $e')); } @@ -187,24 +245,29 @@ class UpdateCubit extends Cubit { /// 整包更新:浏览器下载 + 引导弹窗 Future fullApkUpdateWithBrowser(String apkUrl) async { + final admin = _beginUpdate(); + if (admin == null) return; try { _logger.i('🌐 整包更新:打开浏览器下载'); final uri = Uri.parse(apkUrl); - if (await canLaunchUrl(uri)) { + final canLaunch = await canLaunchUrl(uri); + if (!_canContinue(admin)) return; + if (canLaunch) { await launchUrl(uri, mode: LaunchMode.externalApplication); _logger.i('✅ 已打开浏览器下载'); // 🔥 整包更新后,立即清除补丁版本记录(避免死循环) await _versionService.clearPatchVersionInfo(); _logger.i('🗑️ 已清除补丁版本记录'); - - emit(UpdateSuccess()); + + if (_canContinue(admin)) emit(const UpdateSuccess()); } else { _logger.e('❌ 无法打开浏览器'); emit(const UpdateFailure('无法打开浏览器')); } } catch (e) { + if (!_canContinue(admin)) return; _logger.e('❌ 打开浏览器异常: $e'); emit(UpdateFailure('打开浏览器失败: $e')); } @@ -212,6 +275,7 @@ class UpdateCubit extends Cubit { /// 取消更新 void cancelUpdate() { + _updateOwner = null; _logger.i('❌ 用户取消更新'); emit(UpdateInitial()); } diff --git a/lib/features/auth/presentation/pages/login_page_v2.dart b/lib/features/auth/presentation/pages/login_page_v2.dart index 2f98603e..7e6adde6 100644 --- a/lib/features/auth/presentation/pages/login_page_v2.dart +++ b/lib/features/auth/presentation/pages/login_page_v2.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; +import 'package:maibu_satabot_v2/components/app_logo.dart'; import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; import 'package:maibu_satabot_v2/core/localization/locale_cubit.dart'; import 'package:maibu_satabot_v2/components/language_selection_dialog.dart'; @@ -14,9 +15,9 @@ import '../bloc/login_state.dart'; /// /// 说明: /// - 视觉:背景纵向浅蓝渐变、主按钮横向蓝色渐变胶囊、顶部 logo + 语言胶囊、 -/// 中部机器人 Hero 卡片、白色表单卡片内含「登录 / 注册」分段 Tab。 +/// 中部机器人 Hero 卡片、白色登录表单卡片。 /// - 逻辑:完全复用现有 [LoginCubit](账号密码登录,sourceType=2),未改动数据层。 -/// - 「注册」暂不支持:点击注册 Tab 仅弹出胶囊提示,不跳转。 +/// - 上架版暂时隐藏注册入口。 /// - 旧登录页 login_page.dart 原样保留,路由默认指向本页。 class LoginPageV2 extends StatefulWidget { const LoginPageV2({super.key}); @@ -104,6 +105,7 @@ class _LoginPageV2State extends State @override Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context); return Scaffold( backgroundColor: _bgTop, body: DecoratedBox( @@ -174,9 +176,9 @@ class _LoginPageV2State extends State child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text( - '欢迎使用飒沓机器人', - style: TextStyle( + Text( + l10n.translate('login.welcome_title'), + style: const TextStyle( fontSize: 22, fontWeight: FontWeight.bold, color: _navy, @@ -184,9 +186,9 @@ class _LoginPageV2State extends State ), ), const SizedBox(height: 4), - const Text( - '统一管理您的机器人设备', - style: TextStyle( + Text( + l10n.translate('login.welcome_subtitle'), + style: const TextStyle( fontSize: 13, color: _grayText, ), @@ -206,12 +208,12 @@ class _LoginPageV2State extends State animation: _interval(0.26, 0.63), child: _buildFormCard(), ), - const SizedBox(height: 12), - // 帮助与客服 - _Entrance( - animation: _interval(0.40, 0.75), - child: Center(child: _buildHelpRow()), - ), + // 暂时隐藏登录页的帮助与客服入口。 + // const SizedBox(height: 12), + // _Entrance( + // animation: _interval(0.40, 0.75), + // child: Center(child: _buildHelpRow()), + // ), const SizedBox(height: 16), ], ), @@ -239,14 +241,7 @@ class _LoginPageV2State extends State mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Image.asset( - // 中文用国内版 logo,英文用英文专版 logo(随语言切换实时更新) - locale.languageCode == 'zh' - ? 'assets/images/logo_sata.png' - : 'assets/images/logo_stata-en.png', - height: 40, - fit: BoxFit.contain, - ), + const AppLogo(size: 40), GestureDetector( onTap: () { showDialog( @@ -294,7 +289,7 @@ class _LoginPageV2State extends State fit: StackFit.expand, children: [ Image.asset( - 'assets/images/robot_logo_login.png', + 'assets/images/img.png', fit: BoxFit.cover, ), // 底部渐变遮罩,衬托文字 @@ -310,12 +305,12 @@ class _LoginPageV2State extends State ), ), ), - const Positioned( + Positioned( left: 12, bottom: 8, child: Text( - 'SMART ROBOTICS · CONNECTED', - style: TextStyle( + AppLocalizations.of(context).translate('login.hero_caption'), + style: const TextStyle( color: Colors.white, fontSize: 11, letterSpacing: 1.5, @@ -331,6 +326,7 @@ class _LoginPageV2State extends State // ===== 白色表单卡片 ===== Widget _buildFormCard() { + final l10n = AppLocalizations.of(context); return Container( width: double.infinity, padding: const EdgeInsets.fromLTRB(16, 16, 16, 18), @@ -351,21 +347,21 @@ class _LoginPageV2State extends State _buildSegmentTab(), const SizedBox(height: 14), // 账号 - _buildFieldLabel('账号'), + _buildFieldLabel(l10n.translate('login.username')), const SizedBox(height: 6), _buildTextField( controller: _userCtrl, icon: Icons.person_outline, - hint: AppLocalizations.of(context).translate('login.username_hint'), + hint: l10n.translate('login.username_hint'), ), const SizedBox(height: 12), // 密码 - _buildFieldLabel('密码'), + _buildFieldLabel(l10n.translate('login.password')), const SizedBox(height: 6), _buildTextField( controller: _pwdCtrl, icon: Icons.lock_outline, - hint: AppLocalizations.of(context).translate('login.password_hint'), + hint: l10n.translate('login.password_hint'), obscureText: _obscurePwd, suffix: IconButton( icon: Icon( @@ -380,6 +376,8 @@ class _LoginPageV2State extends State ), const SizedBox(height: 12), _buildProtocolSection(), + // 注册入口隐藏时同时隐藏注册专用协议提示。 + /* const SizedBox(height: 4), Padding( padding: const EdgeInsets.only(left: 32), @@ -388,6 +386,7 @@ class _LoginPageV2State extends State style: const TextStyle(fontSize: 12, color: _grayText), ), ), + */ const SizedBox(height: 14), // 登录按钮 BlocBuilder( @@ -427,8 +426,13 @@ class _LoginPageV2State extends State ), child: Row( children: [ - Expanded(child: _buildTabItem(0, '登录')), - Expanded(child: _buildTabItem(1, '注册')), + Expanded( + child: _buildTabItem( + 0, + AppLocalizations.of(context).translate('login.title'), + ), + ), + // Expanded(child: _buildTabItem(1, '注册')), ], ), ); @@ -571,6 +575,7 @@ class _LoginPageV2State extends State ); } + /* Widget _buildHelpRow() { return Row( mainAxisSize: MainAxisSize.min, @@ -587,6 +592,7 @@ class _LoginPageV2State extends State ], ); } + */ void _showProtocolDetail(String title) { showModalBottomSheet( @@ -659,6 +665,7 @@ class _GradientButton extends StatelessWidget { @override Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context); final enabled = !isLoading; return Opacity( opacity: enabled ? 1 : 0.7, @@ -693,15 +700,18 @@ class _GradientButton extends StatelessWidget { color: Colors.white, ), ) - : const Row( + : Row( mainAxisSize: MainAxisSize.min, children: [ - Icon(Icons.arrow_forward_rounded, - size: 20, color: Colors.white), - SizedBox(width: 8), + const Icon( + Icons.arrow_forward_rounded, + size: 20, + color: Colors.white, + ), + const SizedBox(width: 8), Text( - '登录', - style: TextStyle( + l10n.translate('login.login_button'), + style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white, diff --git a/lib/features/auth/presentation/routes/auth_routes.dart b/lib/features/auth/presentation/routes/auth_routes.dart index b26e3aec..535bd91b 100644 --- a/lib/features/auth/presentation/routes/auth_routes.dart +++ b/lib/features/auth/presentation/routes/auth_routes.dart @@ -4,7 +4,7 @@ import 'package:maibu_satabot_v2/features/auth/presentation/pages/login_page_v2. // 旧登录页保留备用:如需回退,将下方 LoginPageV2 换回 LoginPage 并恢复对应 import。 // import 'package:maibu_satabot_v2/features/auth/presentation/pages/login_page.dart'; -import '../pages/register_page.dart'; +// import '../pages/register_page.dart'; import '../pages/splash_page.dart'; class AuthRoutes { @@ -20,7 +20,9 @@ class AuthRoutes { ), GoRoute( path: RoutePaths.register, - builder: (context, state) => const RegisterPage(), + // 上架版关闭注册,旧链接跳转到登录页。 + // builder: (context, state) => const RegisterPage(), + redirect: (context, state) => RoutePaths.login, ), ]; } diff --git a/lib/features/autonomous_work/data/gateways/path_planning_work_gateway.dart b/lib/features/autonomous_work/data/gateways/path_planning_work_gateway.dart index fc59ce07..ad69a388 100644 --- a/lib/features/autonomous_work/data/gateways/path_planning_work_gateway.dart +++ b/lib/features/autonomous_work/data/gateways/path_planning_work_gateway.dart @@ -434,7 +434,9 @@ class PathPlanningWorkGateway if (node is! Map) return null; final lat = node['lat'] ?? node['latitude']; final lng = node['lng'] ?? node['lon'] ?? node['longitude']; - if (lat is! num || lng is! num) return null; + if (lat is! num || lng is! num || + !lat.isFinite || !lng.isFinite || + lat < -90 || lat > 90 || lng < -180 || lng > 180) return null; return LatLng(lat.toDouble(), lng.toDouble()); } @@ -485,6 +487,7 @@ class PathPlanningWorkGateway ReturnObstaclePoint( center: center, alias: (e['alias'] ?? e['name'] ?? '').toString(), + shapeType: (e['shapeType'] ?? 'rect').toString(), sizeX: asSize(e['size_x'] ?? e['sizeX'] ?? e['width']), sizeY: asSize(e['size_y'] ?? e['sizeY'] ?? e['height']), source: (e['source'] ?? 'platform').toString(), diff --git a/lib/features/device_control_mode/presentation/cubit/control_mode_entry_cubit.dart b/lib/features/device_control_mode/presentation/cubit/control_mode_entry_cubit.dart index 563b214f..c6467d88 100644 --- a/lib/features/device_control_mode/presentation/cubit/control_mode_entry_cubit.dart +++ b/lib/features/device_control_mode/presentation/cubit/control_mode_entry_cubit.dart @@ -30,13 +30,15 @@ class ControlModeEntryState { class ControlModeEntryCubit extends Cubit { ControlModeEntryCubit({ required this.deviceId, - required this.target, + required ControlModeTarget target, required this.watchMode, required this.changeMode, this.timeout = const Duration(seconds: 12), - }) : super(const ControlModeEntryState()); + }) : _target = target, + super(const ControlModeEntryState()); final String deviceId; - final ControlModeTarget target; + ControlModeTarget _target; + ControlModeTarget get target => _target; final WatchDeviceControlModeUseCase watchMode; final ChangeDeviceControlModeUseCase changeMode; final Duration timeout; @@ -109,6 +111,19 @@ class ControlModeEntryCubit extends Cubit { ); } + /// 通用模式切换弹窗允许用户选择目标;远程入口仍使用固定目标。 + void selectTarget(ControlModeTarget value) { + if (isClosed || + state.busy || + state.phase == ControlModeEntryPhase.confirmed || + state.errorKey == 'invalid_device' || + target == value) + return; + _target = value; + _trace('选择目标模式'); + emit(ControlModeEntryState(reading: state.reading)); + } + Future confirm() async { _trace('点击确定'); if (isClosed || !state.canConfirm) { diff --git a/lib/features/device_control_mode/presentation/widgets/control_mode_entry_gate.dart b/lib/features/device_control_mode/presentation/widgets/control_mode_entry_gate.dart index c7b88e5e..7c46ea98 100644 --- a/lib/features/device_control_mode/presentation/widgets/control_mode_entry_gate.dart +++ b/lib/features/device_control_mode/presentation/widgets/control_mode_entry_gate.dart @@ -13,6 +13,8 @@ Future showControlModeEntryDialog( required String deviceId, required ControlModeTarget target, String? deviceName, + bool allowTargetSelection = false, + bool cancelToPreview = false, ControlModeEntryCubit? cubit, }) async { final entry = @@ -25,12 +27,22 @@ Future showControlModeEntryDialog( ); try { entry.start(); - return await showDialog( + return await showModalBottomSheet( context: context, - barrierDismissible: false, + useRootNavigator: true, + useSafeArea: true, + backgroundColor: Colors.transparent, + barrierColor: const Color(0x8C0B1B2B), + isScrollControlled: true, + isDismissible: false, + enableDrag: false, builder: (_) => BlocProvider.value( value: entry, - child: _ControlModeEntryDialog(deviceName: deviceName), + child: _ControlModeEntryDialog( + deviceName: deviceName, + allowTargetSelection: allowTargetSelection, + cancelToPreview: cancelToPreview, + ), ), ) ?? false; @@ -39,7 +51,7 @@ Future showControlModeEntryDialog( } } -/// 当前模式已符合或切换接口成功后进入;不改动摇杆归零与停止协议。 +/// 模式确认后启用操作。启用预览时,取消确认会保留页面画面和重试入口。 class ControlModeEntryGate extends StatefulWidget { const ControlModeEntryGate({ super.key, @@ -48,12 +60,14 @@ class ControlModeEntryGate extends StatefulWidget { required this.child, this.deviceName, this.onReady, + this.cancelToPreview = false, }); final String deviceId; final String? deviceName; final ControlModeTarget target; final Widget child; final VoidCallback? onReady; + final bool cancelToPreview; @override State createState() => _ControlModeEntryGateState(); } @@ -78,11 +92,14 @@ class _ControlModeEntryGateState extends State { deviceId: widget.deviceId, deviceName: widget.deviceName, target: widget.target, + cancelToPreview: widget.cancelToPreview, ); if (!mounted) return; if (accepted) { setState(() => _ready = true); widget.onReady?.call(); + } else if (widget.cancelToPreview) { + setState(() => _cancelled = true); } else { final popped = await Navigator.of(context).maybePop(); if (!popped && mounted) setState(() => _cancelled = true); @@ -96,8 +113,13 @@ class _ControlModeEntryGateState extends State { Widget build(BuildContext context) => Stack( fit: StackFit.expand, children: [ - IgnorePointer(ignoring: !_ready, child: widget.child), - if (_cancelled) + ExcludeFocus( + excluding: !_ready, + child: IgnorePointer(ignoring: !_ready, child: widget.child), + ), + if (_cancelled && widget.cancelToPreview) + _buildPreviewControls(context) + else if (_cancelled) ColoredBox( color: Colors.black54, child: Center( @@ -113,11 +135,144 @@ class _ControlModeEntryGateState extends State { ), ], ); + + Widget _buildPreviewControls(BuildContext context) { + final l10n = AppLocalizations.of(context); + return Positioned( + left: 0, + right: 0, + bottom: 0, + child: SafeArea( + top: false, + minimum: const EdgeInsets.fromLTRB(12, 0, 12, 10), + child: Align( + alignment: Alignment.bottomCenter, + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 520), + child: Material( + color: const Color(0xF21A2B4A), + borderRadius: BorderRadius.circular(14), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 4, + ), + child: Row( + children: [ + const Icon( + Icons.visibility_outlined, + color: Colors.white, + size: 18, + ), + const SizedBox(width: 8), + Expanded( + child: Text( + l10n.translate('device_control_mode.preview_status'), + style: const TextStyle( + fontSize: 12, + color: Colors.white, + ), + ), + ), + TextButton( + onPressed: _enter, + style: TextButton.styleFrom( + foregroundColor: Colors.white, + ), + child: Text( + l10n.translate('device_control_mode.confirm_mode'), + ), + ), + IconButton( + tooltip: l10n.translate('common.back'), + onPressed: () => Navigator.of(context).maybePop(), + icon: const Icon( + Icons.arrow_back_rounded, + color: Colors.white, + size: 20, + ), + ), + ], + ), + ), + ), + ), + ), + ), + ); + } } class _ControlModeEntryDialog extends StatelessWidget { - const _ControlModeEntryDialog({this.deviceName}); + const _ControlModeEntryDialog({ + this.deviceName, + this.allowTargetSelection = false, + this.cancelToPreview = false, + }); + + static const _navy = Color(0xFF1A2B4A); + static const _gray = Color(0xFF86909C); + static const _blue = Color(0xFF1C96F6); + static const _border = Color(0xFFE5EDF7); + static const _softBlue = Color(0xFFEAF4FE); + static const _noteText = Color(0xFF5C6B84); + final String? deviceName; + final bool allowTargetSelection; + final bool cancelToPreview; + + Widget _modeCard({ + required String label, + required String value, + required IconData icon, + bool target = false, + }) { + return Container( + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: target ? _softBlue : const Color(0xFFF6FAFE), + borderRadius: BorderRadius.circular(14), + border: Border.all(color: target ? const Color(0xFFD6E9FC) : _border), + ), + child: Row( + children: [ + Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + ), + child: Icon(icon, color: _blue, size: 21), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + label, + style: const TextStyle(fontSize: 11.5, color: _gray), + ), + const SizedBox(height: 4), + Text( + value, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w700, + color: _navy, + ), + ), + ], + ), + ), + if (target) + const Icon(Icons.check_circle_rounded, size: 21, color: _blue), + ], + ), + ); + } + @override Widget build(BuildContext context) { final l10n = AppLocalizations.of(context); @@ -132,8 +287,14 @@ class _ControlModeEntryDialog extends StatelessWidget { debugPrint( '[控制模式切换][弹窗状态] deviceId=${cubit.deviceId}, currentRawMode=${state.reading?.rawMode}, targetMode=${cubit.target.value}, phase=${state.phase.name}, confirmEnabled=${state.canConfirm}', ); - if (state.phase == ControlModeEntryPhase.confirmed) { - Navigator.of(context).pop(true); + if (state.phase != ControlModeEntryPhase.confirmed) return; + final route = ModalRoute.of(context); + if (route == null || !route.isActive) return; + final navigator = Navigator.of(context); + if (route.isCurrent) { + navigator.pop(true); + } else { + navigator.removeRoute(route, true); } }, builder: (context, state) { @@ -142,76 +303,247 @@ class _ControlModeEntryDialog extends StatelessWidget { l10n, '${cubit.target.value}', ); + final note = state.busy + ? tr('submitting') + : matches + ? tr(allowTargetSelection ? 'selection_matched' : 'matched') + : state.reading?.hasReportedMode == true + ? tr( + allowTargetSelection ? 'selection_hint' : 'mismatch', + ).replaceAll('%s', targetText) + : tr('unknown_mode').replaceAll('%s', targetText); + final error = state.errorKey != null + ? tr(state.errorKey!) + : state.error; + + final canCancel = cancelToPreview || !state.busy; + final cancelText = cancelToPreview + ? tr('cancel_to_preview') + : l10n.translate('common.cancel'); + void cancel() { + if (ModalRoute.of(context)?.isCurrent == true) { + Navigator.of(context).pop(false); + } + } + return PopScope( - canPop: !state.busy, - child: AlertDialog( - title: Text(tr('title')), - content: SizedBox( - width: 380, - child: SingleChildScrollView( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - deviceName?.trim().isNotEmpty == true - ? '$deviceName · ${cubit.deviceId}' - : cubit.deviceId, - ), - const SizedBox(height: 12), - Text( - '${tr('current')}:${controlModeDisplayText(l10n, state.reading?.rawMode)}', - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, + canPop: canCancel, + child: ConstrainedBox( + constraints: BoxConstraints( + maxHeight: MediaQuery.sizeOf(context).height * 0.9, + ), + child: Material( + color: Colors.white, + borderRadius: const BorderRadius.vertical( + top: Radius.circular(24), + ), + clipBehavior: Clip.antiAlias, + child: SafeArea( + top: false, + child: SingleChildScrollView( + padding: const EdgeInsets.fromLTRB(18, 16, 18, 16), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + children: [ + Expanded( + child: Text( + tr( + allowTargetSelection ? 'switch_title' : 'title', + ), + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.w800, + color: _navy, + ), + ), + ), + IconButton( + tooltip: cancelToPreview + ? cancelText + : l10n.translate('common.close'), + onPressed: canCancel ? cancel : null, + icon: const Icon(Icons.close_rounded, size: 22), + color: _navy, + visualDensity: VisualDensity.compact, + ), + ], ), - ), - const SizedBox(height: 8), - Text('${tr('target')}:$targetText'), - const SizedBox(height: 12), - Text( - state.busy - ? tr('submitting') - : matches - ? tr('matched') - : state.reading?.hasReportedMode == true - ? tr('mismatch').replaceAll('%s', targetText) - : tr('unknown_mode').replaceAll('%s', targetText), - ), - if (state.error != null || state.errorKey != null) ...[ - const SizedBox(height: 10), + const SizedBox(height: 8), + if (deviceName?.trim().isNotEmpty == true) ...[ + Text( + deviceName!, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w700, + color: _navy, + ), + ), + const SizedBox(height: 4), + ], Text( - state.errorKey != null - ? tr(state.errorKey!) - : state.error!, - style: TextStyle( - color: Theme.of(context).colorScheme.error, + cubit.deviceId, + style: const TextStyle( + fontSize: 11.5, + height: 1.5, + color: _gray, ), ), - ], - if (state.busy) ...[ + const SizedBox(height: 16), + _modeCard( + label: tr('current'), + value: controlModeDisplayText( + l10n, + state.reading?.rawMode, + ), + icon: Icons.sensors_rounded, + ), + const SizedBox(height: 10), + // 自主任务选项继续停用,由后端处理;这里展示本次确认的目标。 + _modeCard( + label: tr( + allowTargetSelection ? 'selection_target' : 'target', + ), + value: + allowTargetSelection && + cubit.target == ControlModeTarget.remote + ? tr('switch_manual') + : targetText, + icon: Icons.swap_horiz_rounded, + target: true, + ), const SizedBox(height: 12), - const LinearProgressIndicator(), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 10, + ), + decoration: BoxDecoration( + color: _softBlue, + borderRadius: BorderRadius.circular(10), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Padding( + padding: EdgeInsets.only(top: 2), + child: Icon( + Icons.info_outline_rounded, + size: 16, + color: _blue, + ), + ), + const SizedBox(width: 8), + Expanded( + child: Text( + note, + style: const TextStyle( + fontSize: 12, + height: 1.5, + color: _noteText, + ), + ), + ), + ], + ), + ), + if (error != null) ...[ + const SizedBox(height: 10), + Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: const Color(0xFFFFF1F0), + borderRadius: BorderRadius.circular(10), + ), + child: Text( + error, + style: const TextStyle( + fontSize: 12, + height: 1.5, + color: Color(0xFFF0483E), + ), + ), + ), + ], + if (state.phase == ControlModeEntryPhase.failed && + state.errorKey != 'invalid_device') + Align( + alignment: Alignment.centerRight, + child: TextButton.icon( + onPressed: cubit.start, + icon: const Icon(Icons.refresh_rounded, size: 17), + label: Text(tr('retry')), + style: TextButton.styleFrom(foregroundColor: _blue), + ), + ), + const SizedBox(height: 18), + Row( + children: [ + Expanded( + child: OutlinedButton.icon( + onPressed: canCancel ? cancel : null, + icon: const Icon(Icons.close_rounded, size: 18), + style: OutlinedButton.styleFrom( + foregroundColor: _blue, + minimumSize: const Size.fromHeight(48), + side: BorderSide( + color: canCancel ? _blue : _border, + width: 1.2, + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + textStyle: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w700, + ), + ), + label: Text(cancelText), + ), + ), + const SizedBox(width: 12), + Expanded( + child: FilledButton( + onPressed: state.canConfirm + ? cubit.confirm + : null, + style: FilledButton.styleFrom( + backgroundColor: _blue, + foregroundColor: Colors.white, + disabledBackgroundColor: const Color( + 0xFFDCEBFA, + ), + disabledForegroundColor: _gray, + minimumSize: const Size.fromHeight(48), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + textStyle: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w700, + ), + ), + child: state.busy + ? const SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator( + strokeWidth: 2, + color: _blue, + ), + ) + : Text(l10n.translate('common.ok')), + ), + ), + ], + ), ], - ], + ), ), ), ), - actions: [ - TextButton( - onPressed: state.busy - ? null - : () => Navigator.of(context).pop(false), - child: Text(l10n.translate('common.back')), - ), - if (state.phase == ControlModeEntryPhase.failed && - state.errorKey != 'invalid_device') - TextButton(onPressed: cubit.start, child: Text(tr('retry'))), - FilledButton( - onPressed: state.canConfirm ? cubit.confirm : null, - child: Text(l10n.translate('common.ok')), - ), - ], ), ); }, diff --git a/lib/features/home/presentation/widgets/common/enum.dart b/lib/features/home/presentation/widgets/common/enum.dart index 0a203257..0fe05a04 100644 --- a/lib/features/home/presentation/widgets/common/enum.dart +++ b/lib/features/home/presentation/widgets/common/enum.dart @@ -21,11 +21,12 @@ enum WorkStatus { } /// 后端 workRecord.routeType(Java 枚举 RouteType):规划类型,保存打点时必填。 -/// 缺失时后端返回「未选择规划类型」;code 必须与后端枚举 name() 完全一致。 +/// 缺失时后端返回「未选择规划类型」;code 按后端约定原样传递。 /// 新版「地图与区域编辑」与旧版路径规划共用 /iot/workRecord/add,因此共用这一个定义。 enum RouteType { mowingTask('MOWING_TASK', '割草任务'), inspectionTask('INSPECTION_TASK', '巡检任务'), + predefinedPath('predefined_path', '预定义模式'), // backToRestPoint('BACK_TO_REST_POINT', '返航任务'), // 暂不展示 other('OTHER', '其他类型'); diff --git a/lib/features/main_container/domain/tab_config.dart b/lib/features/main_container/domain/tab_config.dart index 1f123f6c..0a6dbb24 100644 --- a/lib/features/main_container/domain/tab_config.dart +++ b/lib/features/main_container/domain/tab_config.dart @@ -1,4 +1,5 @@ import 'package:equatable/equatable.dart'; +import 'package:maibu_satabot_v2/core/domain/entities/user_entity.dart'; class TabConfigItem extends Equatable { final String id; @@ -50,39 +51,21 @@ class TabConfig extends Equatable { return enabled; } - /// roleKey == 'personal'(个人角色):底部导航与「系统设置 → Tab 设置」强制只保留 - /// 「设备(device) + 我的(me)」,且常显、开关锁定不可关闭;其他角色不受影响。 static const String personalRoleKey = 'personal'; - static const Set personalVisibleTabIds = {'device', 'me'}; + static const _standardTabIds = {'device', 'work', 'me'}; - /// 底部导航实际渲染的 Tab: - /// - personal:强制返回 设备 + 我的(忽略 isEnabled,恒为启用),按 order 排序 - /// - 其他角色:返回用户启用的 Tab(enabledItems) - List navItemsForRole(String? roleKey) { - if (roleKey == personalRoleKey) { - final forced = items - .where((item) => personalVisibleTabIds.contains(item.id)) - .map((item) => item.copyWith(isEnabled: true)) - .toList(); - forced.sort((a, b) => a.order.compareTo(b.order)); - return forced; - } - return enabledItems; - } + // 普通用户的导航固定显示这三个 Tab,独立于管理员的开关配置。 + static final _standardTabs = List.unmodifiable( + defaultConfig().items + .where((item) => _standardTabIds.contains(item.id)) + .map((item) => item.copyWith(isEnabled: true)), + ); - /// 「Tab 设置」列表应展示的 Tab: - /// - personal:只列出 设备 + 我的,按 order 排序 - /// - 其他角色:列出全部 - List settingItemsForRole(String? roleKey) { - if (roleKey == personalRoleKey) { - final visible = items - .where((item) => personalVisibleTabIds.contains(item.id)) - .toList(); - visible.sort((a, b) => a.order.compareTo(b.order)); - return visible; - } - return items; - } + List navItemsForRole(String? roleKey) => + roleKey == UserEntity.adminRoleKey ? enabledItems : _standardTabs; + + List settingItemsForRole(String? roleKey) => + roleKey == UserEntity.adminRoleKey ? items : _standardTabs; TabConfig copyWith({List? items}) { return TabConfig(items: items ?? this.items); diff --git a/lib/features/main_container/presentation/main_wrapper.dart b/lib/features/main_container/presentation/main_wrapper.dart index 20cf12f8..85e73fd6 100644 --- a/lib/features/main_container/presentation/main_wrapper.dart +++ b/lib/features/main_container/presentation/main_wrapper.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:get_it/get_it.dart'; @@ -40,8 +41,9 @@ class MainWrapper extends StatefulWidget { } class _MainWrapperState extends State { - int _currentIndex = 0; - final PageController _pageController = PageController(); + String? _selectedTabId; + List _tabIds = const []; + PageController? _pageController; @override void initState() { @@ -53,15 +55,34 @@ class _MainWrapperState extends State { @override void dispose() { - _pageController.dispose(); + _pageController?.dispose(); super.dispose(); } - void _onTabChanged(int index) { - setState(() { - _currentIndex = index; - }); - _pageController.jumpToPage(index); + int _syncTabPages(List tabs) { + final ids = tabs.map((tab) => tab.id).toList(); + final selectedIndex = ids.indexOf(_selectedTabId ?? ''); + final index = selectedIndex < 0 ? 0 : selectedIndex; + if (!listEquals(ids, _tabIds)) { + final previousController = _pageController; + _pageController = PageController(initialPage: index, keepPage: false); + _tabIds = ids; + _selectedTabId = ids[index]; + if (previousController != null) { + WidgetsBinding.instance.addPostFrameCallback((_) { + previousController.dispose(); + }); + } + } + return index; + } + + void _onTabChanged(String tabId) { + final controller = _pageController; + final index = _tabIds.indexOf(tabId); + if (controller == null || !controller.hasClients || index < 0) return; + setState(() => _selectedTabId = tabId); + controller.jumpToPage(index); } /// Tab 图标:选中用 filled(实心),未选用 outlined(描边),对比更清晰 @@ -94,10 +115,7 @@ class _MainWrapperState extends State { } } - Widget _buildCurrentPage( - TabConfigItem tab, - List enabledItems, - ) { + Widget _buildCurrentPage(TabConfigItem tab, String activeTabId) { switch (tab.id) { case 'home_v2': return BlocProvider( @@ -107,17 +125,16 @@ class _MainWrapperState extends State { case 'home': return const HomePage(); case 'device': - return const DeviceStatusPageV2(); + return DeviceStatusPageV2( + isActive: activeTabId == tab.id, + ); // 作业首页(W01):返回键切回「设备」tab case 'work': return WorkHomePageV2( - isActive: enabledItems[_currentIndex].id == tab.id, - onBack: () { - final int deviceIndex = enabledItems.indexWhere( - (item) => item.id == 'device', - ); - _onTabChanged(deviceIndex >= 0 ? deviceIndex : 0); - }, + isActive: activeTabId == tab.id, + onBack: () => _onTabChanged( + _tabIds.contains('device') ? 'device' : _tabIds.first, + ), ); case 'ai': return const AiPage(); @@ -141,8 +158,8 @@ class _MainWrapperState extends State { @override Widget build(BuildContext context) { - // 🔥 个人角色(roleKey == 'personal')底部导航强制只显示「设备 + 我的」 - final roleKey = context.watch().state.user?.roleKey; + final user = context.watch().state.user; + final isAdmin = user?.isAdmin == true; return BlocBuilder( builder: (context, state) { if (state is! TabConfigLoaded) { @@ -152,15 +169,15 @@ class _MainWrapperState extends State { } final config = state.config; - final enabledItems = config.navItemsForRole(roleKey); + final enabledItems = config.navItemsForRole(user?.roleKey); if (enabledItems.isEmpty) { return const Scaffold(body: Center(child: Text('请至少启用一个 Tab'))); } - if (_currentIndex >= enabledItems.length) { - _currentIndex = 0; - } + final currentIndex = _syncTabPages(enabledItems); + final controller = _pageController!; + final activeTabId = enabledItems[currentIndex].id; // 键盘弹出时 body 已被 Scaffold 缩短到底栏之上,无需再叠加导航高度 final mq = MediaQuery.of(context); @@ -184,28 +201,27 @@ class _MainWrapperState extends State { child: Stack( children: [ PageView( - controller: _pageController, - // 🔥 启用左右滑动切换 Tab + key: ObjectKey(controller), + controller: controller, physics: const BouncingScrollPhysics(), onPageChanged: (index) { - setState(() { - _currentIndex = index; - }); - }, - children: enabledItems - .map((tab) => _buildCurrentPage(tab, enabledItems)) - .toList(), - ), - // 悬浮条 - 可拖动的悬浮按钮 - ValueListenableBuilder( - valueListenable: FloatBarSettingService.settingNotifier, - builder: (context, isEnabled, child) { - return Visibility( - visible: isEnabled, - child: const FloatBarWidget(), - ); + if (_pageController != controller) return; + final tabId = enabledItems[index].id; + if (tabId != _selectedTabId) { + setState(() => _selectedTabId = tabId); + } }, + children: [ + for (final tab in enabledItems) + _buildCurrentPage(tab, activeTabId), + ], ), + if (isAdmin) + ValueListenableBuilder( + valueListenable: FloatBarSettingService.settingNotifier, + builder: (context, isEnabled, child) => + isEnabled ? const FloatBarWidget() : const SizedBox.shrink(), + ), ], ), ), @@ -220,7 +236,7 @@ class _MainWrapperState extends State { final double maxBarWidth = constraints.maxWidth; // 3 个及以上 Tab 直接铺满可用宽度:每格自然等分(3 个时约 108/格), // 不会像固定 84/格 那样缩成一小段胶囊; - // 只有 2 个 Tab(如个人角色:设备 + 我的)才收窄居中,避免太空旷 + // 管理员只启用 1~2 个 Tab 时收窄居中 final double barWidth = itemCount >= 3 ? maxBarWidth : (itemCount * 116 < maxBarWidth @@ -265,7 +281,7 @@ class _MainWrapperState extends State { AnimatedPositioned( duration: const Duration(milliseconds: 280), curve: Curves.easeOutCubic, - left: _currentIndex * tabWidth + + left: currentIndex * tabWidth + (tabWidth - indicatorW) / 2, top: (56 - indicatorH) / 2, width: indicatorW, @@ -295,14 +311,14 @@ class _MainWrapperState extends State { enabledItems.asMap().entries.map((entry) { final index = entry.key; final item = entry.value; - final isSelected = _currentIndex == index; + final isSelected = currentIndex == index; return Expanded( child: InkWell( borderRadius: BorderRadius.circular( indicatorH / 2, ), - onTap: () => _onTabChanged(index), + onTap: () => _onTabChanged(item.id), child: Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/features/main_container/presentation/pages/custom_main_container.dart b/lib/features/main_container/presentation/pages/custom_main_container.dart index c8a6bc82..f60ceb59 100644 --- a/lib/features/main_container/presentation/pages/custom_main_container.dart +++ b/lib/features/main_container/presentation/pages/custom_main_container.dart @@ -68,7 +68,7 @@ class _CustomMainContainerState extends State children: [ IndexedStack( index: currentIndex, - children: _buildPages(enabledTabs), + children: _buildPages(enabledTabs, enabledTabs[currentIndex].id), ), // TCP状态指示灯 - 右上角,带白色背景确保可见,点击弹出设备状态模态框 Positioned( @@ -135,7 +135,7 @@ class _CustomMainContainerState extends State ); } - List _buildPages(List enabledTabs) { + List _buildPages(List enabledTabs, String activeTabId) { return enabledTabs.map((tab) { debugPrint('🔍 [buildPages] Tab ID: ${tab.id}, Name: ${tab.name}'); switch (tab.id) { @@ -144,7 +144,10 @@ class _CustomMainContainerState extends State return const HomeV2Page(key: ValueKey('home_v2')); case 'device': debugPrint('✅ 匹配到 device'); - return const DeviceStatusPageV2(key: ValueKey('device')); + return DeviceStatusPageV2( + key: const ValueKey('device'), + isActive: activeTabId == 'device', + ); case 'ai': debugPrint('✅ 匹配到 ai'); return const AiPage(key: ValueKey('ai')); diff --git a/lib/features/main_container/presentation/pages/tab_settings_page.dart b/lib/features/main_container/presentation/pages/tab_settings_page.dart index 3994bc91..86dc401e 100644 --- a/lib/features/main_container/presentation/pages/tab_settings_page.dart +++ b/lib/features/main_container/presentation/pages/tab_settings_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart'; import 'package:maibu_satabot_v2/features/main_container/presentation/cubit/tab_config_cubit.dart'; import 'package:cc_ui_kit/cc_ui_kit.dart'; @@ -8,6 +9,8 @@ class TabSettingsPage extends StatelessWidget { @override Widget build(BuildContext context) { + final user = context.watch().state.user; + final isAdmin = user?.isAdmin == true; return Scaffold( appBar: AppBar( title: const Text('Tab 配置'), @@ -20,15 +23,15 @@ class TabSettingsPage extends StatelessWidget { if (state is! TabConfigLoaded) { return const Center(child: CircularProgressIndicator()); } - - final tabs = state.config.items; - + + final tabs = state.config.settingItemsForRole(user?.roleKey); + return ListView.builder( padding: const EdgeInsets.all(16), itemCount: tabs.length, itemBuilder: (context, index) { final tab = tabs[index]; - + return Card( margin: const EdgeInsets.only(bottom: 8), child: ListTile( @@ -37,9 +40,10 @@ class TabSettingsPage extends StatelessWidget { subtitle: Text(tab.nameEn), trailing: Switch( value: tab.isEnabled, - onChanged: (value) { - context.read().toggleTab(tab.id); - }, + onChanged: isAdmin + ? (_) => + context.read().toggleTab(tab.id) + : null, ), ), ); @@ -47,18 +51,20 @@ class TabSettingsPage extends StatelessWidget { ); }, ), - bottomNavigationBar: Padding( - padding: const EdgeInsets.all(16), - child: CCPrimaryButton( - text: '重置为默认', - onPressed: () { - context.read().resetToDefault(); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('已重置为默认配置')), - ); - }, - ), - ), + bottomNavigationBar: !isAdmin + ? null + : Padding( + padding: const EdgeInsets.all(16), + child: CCPrimaryButton( + text: '重置为默认', + onPressed: () { + context.read().resetToDefault(); + ScaffoldMessenger.of( + context, + ).showSnackBar(const SnackBar(content: Text('已重置为默认配置'))); + }, + ), + ), ); } @@ -70,6 +76,8 @@ class TabSettingsPage extends StatelessWidget { return Icons.grid_view_rounded; case 'devices_rounded': return Icons.devices_rounded; + case 'map_rounded': + return Icons.map_rounded; case 'auto_awesome_rounded': return Icons.auto_awesome_rounded; case 'warning_amber_rounded': diff --git a/lib/features/pv_control/presentation/pages/pv_control_page.dart b/lib/features/pv_control/presentation/pages/pv_control_page.dart index ff073697..bfa9da02 100644 --- a/lib/features/pv_control/presentation/pages/pv_control_page.dart +++ b/lib/features/pv_control/presentation/pages/pv_control_page.dart @@ -678,6 +678,7 @@ class _PvControlPageState extends State { deviceId: widget.deviceId, deviceName: widget.deviceName, target: ControlModeTarget.remote, + cancelToPreview: true, onReady: _startControl, child: _buildPage(context), ); diff --git a/lib/features/pv_control/presentation/widgets/pv_work_map.dart b/lib/features/pv_control/presentation/widgets/pv_work_map.dart index 8eca5c70..5c992e3d 100644 --- a/lib/features/pv_control/presentation/widgets/pv_work_map.dart +++ b/lib/features/pv_control/presentation/widgets/pv_work_map.dart @@ -55,6 +55,7 @@ class PvWorkMap extends StatefulWidget { this.draftCrosshair = false, this.returnPoints = const [], this.followDevice = true, + this.centerOnDeviceOnOpen = false, this.recenterSignal = 0, this.clearTraceSignal = 0, this.onCenterChanged, @@ -66,9 +67,12 @@ class PvWorkMap extends StatefulWidget { this.traceDiagnosticsEnabled = false, this.showDevice = true, this.extraMapLayers = const [], + this.foregroundMapLayer, + this.onMapTap, this.focusPoints = const [], this.focusSignal = 0, this.focusPadding = const EdgeInsets.all(40), + this.focusMaxZoom, }); /// 设备 SN:用于过滤路线推送(deviceId 不匹配的消息直接丢弃)。 @@ -139,6 +143,9 @@ class PvWorkMap extends StatefulWidget { /// 否则每次定位推送都会把地图挪走,正在打的位置就跑了。 final bool followDevice; + /// 打开地图时优先使用已收到的设备位置。 + final bool centerOnDeviceOnOpen; + /// 外部「回到设备位置」信号:每次 +1 就把地图移回设备当前坐标 /// (与路径规划竖浮菜单的「定位」同一个行为)。 final int recenterSignal; @@ -163,9 +170,12 @@ class PvWorkMap extends StatefulWidget { /// 业务页面提供独立叠加层,共享地图无需依赖具体分区业务。 final List extraMapLayers; + final Widget? foregroundMapLayer; + final ValueChanged? onMapTap; final List focusPoints; final int focusSignal; final EdgeInsets focusPadding; + final double? focusMaxZoom; @override State createState() => _PvWorkMapState(); @@ -339,7 +349,7 @@ class _PvWorkMapState extends State { CameraFit.bounds( bounds: LatLngBounds.fromPoints(widget.focusPoints), padding: widget.focusPadding, - maxZoom: _previewZoom, + maxZoom: widget.focusMaxZoom ?? _previewZoom, ), ); }); @@ -546,7 +556,10 @@ class _PvWorkMapState extends State { FlutterMap( mapController: _map, options: MapOptions( - initialCenter: _pos ?? _fallbackCenter(), + initialCenter: + _pos ?? + (widget.centerOnDeviceOnOpen ? marker : null) ?? + _fallbackCenter(), initialZoom: _centerZoom, maxZoom: 22, minZoom: 3, @@ -558,7 +571,9 @@ class _PvWorkMapState extends State { ), onMapReady: () { _ready = true; - if (widget.onDevicePosition != null && widget.showDevice) { + if (widget.showDevice && + (widget.centerOnDeviceOnOpen || + widget.onDevicePosition != null)) { final current = context.read().state; if (current is DeviceStatusUpdated) _onLocation(current); } @@ -577,7 +592,7 @@ class _PvWorkMapState extends State { }, onPositionChanged: _notifyCenter, onMapEvent: _onMapEvent, - onTap: (_, _) {}, // 空实现:地图本身不响应点击 + onTap: (_, point) => widget.onMapTap?.call(point), ), children: [ /// 底图:中文=ESRI,非中文=Google(不可达自动回退 ESRI) @@ -927,6 +942,7 @@ class _PvWorkMapState extends State { ), ], ), + ?widget.foregroundMapLayer, ], ), // 还没收到定位推送时的提示(此时图面停在场站中心,机器不出现) diff --git a/lib/features/regions/presentation/widgets/no_device_crosshair_hint.dart b/lib/features/regions/presentation/widgets/no_device_crosshair_hint.dart index d88f4d96..d6aee231 100644 --- a/lib/features/regions/presentation/widgets/no_device_crosshair_hint.dart +++ b/lib/features/regions/presentation/widgets/no_device_crosshair_hint.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; class NoDeviceCrosshairHint extends StatefulWidget { const NoDeviceCrosshairHint({super.key, required this.hasDevice}); @@ -8,6 +9,8 @@ class NoDeviceCrosshairHint extends StatefulWidget { } class _NoDeviceCrosshairHintState extends State { + AppLocalizations get _l10n => AppLocalizations.of(context); + bool _dismissed = false; @override Widget build(BuildContext context) { @@ -27,9 +30,9 @@ class _NoDeviceCrosshairHintState extends State { color: Color(0xFF9B6500), ), const SizedBox(width: 7), - const Expanded( + Expanded( child: Text( - '未选择设备,请使用「准星打点」:移动地图,将准星对准目标位置后点「+」。', + _l10n.translate('region_editor.no_device_crosshair_hint'), style: TextStyle( fontSize: 11.5, color: Color(0xFF9B6500), @@ -40,8 +43,8 @@ class _NoDeviceCrosshairHintState extends State { InkWell( key: const ValueKey('dismiss_crosshair_hint'), onTap: () => setState(() => _dismissed = true), - child: const Tooltip( - message: '关闭提示', + child: Tooltip( + message: _l10n.translate('region_editor.dismiss_tip'), child: Padding( padding: EdgeInsets.all(3), child: Icon( diff --git a/lib/features/regions/presentation/widgets/region_form_dialog.dart b/lib/features/regions/presentation/widgets/region_form_dialog.dart index 8a458f6d..f1d6e34f 100644 --- a/lib/features/regions/presentation/widgets/region_form_dialog.dart +++ b/lib/features/regions/presentation/widgets/region_form_dialog.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; +import 'package:maibu_satabot_v2/features/regions/presentation/region_error_text.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../domain/entities/region_draft.dart'; import '../cubit/region_editor_cubit.dart'; @@ -29,6 +31,8 @@ class RegionFormDialog extends StatefulWidget { } class _RegionFormDialogState extends State { + AppLocalizations get _l10n => AppLocalizations.of(context); + final _form = GlobalKey(); late final TextEditingController _name; late final TextEditingController _code; @@ -61,7 +65,10 @@ class _RegionFormDialogState extends State { final state = widget.cubit.state; if (state.isSaving || !_form.currentState!.validate()) return; if (!widget.isScopeCurrent()) { - setState(() => _scopeError = '场站或账号已切换,请重新进入编辑器后保存'); + setState( + () => + _scopeError = _l10n.translate('region_editor.scope_changed_reopen'), + ); return; } setState(() => _scopeError = null); @@ -86,7 +93,10 @@ class _RegionFormDialogState extends State { Map _options(RegionEditorState state) { final result = {for (final route in state.routes) route.id: route.name}; for (final id in [..._bound, ?_defaultRoute]) { - result.putIfAbsent(id, () => '路线 #$id'); + result.putIfAbsent( + id, + () => _l10n.translate('autonomous_work.route_number', {'id': id}), + ); } return result; } @@ -98,7 +108,7 @@ class _RegionFormDialogState extends State { context: context, builder: (dialogContext) => StatefulBuilder( builder: (_, update) => AlertDialog( - title: const Text('绑定路线'), + title: Text(_l10n.translate('region_editor.bind_routes')), content: SizedBox( width: 420, height: (MediaQuery.sizeOf(dialogContext).height * 0.5).clamp( @@ -106,7 +116,11 @@ class _RegionFormDialogState extends State { 300.0, ), child: options.isEmpty - ? const Center(child: Text('当前场站暂无可绑定路线')) + ? Center( + child: Text( + _l10n.translate('region_editor.no_routes_to_bind'), + ), + ) : ListView( children: [ for (final route in options.entries) @@ -129,11 +143,11 @@ class _RegionFormDialogState extends State { actions: [ TextButton( onPressed: () => Navigator.of(dialogContext).pop(), - child: const Text('取消'), + child: Text(_l10n.translate('common.cancel')), ), FilledButton( onPressed: () => Navigator.of(dialogContext).pop(selected), - child: const Text('确定'), + child: Text(_l10n.translate('common.ok')), ), ], ), @@ -181,7 +195,9 @@ class _RegionFormDialogState extends State { children: [ Expanded( child: Text( - state.draft.id == null ? '新建分区' : '编辑分区', + state.draft.id == null + ? _l10n.translate('region_editor.new_region') + : _l10n.translate('region_editor.edit_region'), style: const TextStyle( fontSize: 18, fontWeight: FontWeight.w800, @@ -210,17 +226,25 @@ class _RegionFormDialogState extends State { TextFormField( key: const ValueKey('region_name'), controller: _name, - decoration: _decoration('分区名称 *'), + decoration: _decoration( + _l10n.translate( + 'region_editor.region_name_field', + ), + ), validator: (value) => value == null || value.trim().isEmpty - ? '请填写分区名称' + ? _l10n.translate( + 'region_editor.region_name_required', + ) : null, ), const SizedBox(height: 16), TextFormField( key: const ValueKey('region_code'), controller: _code, - decoration: _decoration('分区编码'), + decoration: _decoration( + _l10n.translate('region_editor.region_code'), + ), ), const SizedBox(height: 16), if (loading) ...[ @@ -233,7 +257,14 @@ class _RegionFormDialogState extends State { children: [ Expanded( child: Text( - state.routesError ?? '路线加载失败', + state.routesError == null + ? _l10n.translate( + 'region_editor.route_load_failed', + ) + : regionErrorText( + state.routesError!, + _l10n, + ), style: const TextStyle( color: Colors.red, fontSize: 12, @@ -242,12 +273,18 @@ class _RegionFormDialogState extends State { ), TextButton( onPressed: widget.cubit.loadRoutes, - child: const Text('重新加载路线'), + child: Text( + _l10n.translate( + 'region_editor.reload_routes', + ), + ), ), ], ), InputDecorator( - decoration: _decoration('默认路线'), + decoration: _decoration( + _l10n.translate('region_editor.default_route'), + ), child: Row( children: [ Expanded( @@ -261,7 +298,13 @@ class _RegionFormDialogState extends State { isDense: true, menuMaxHeight: 260, hint: Text( - loading ? '路线加载中' : '请选择默认路线(可选)', + loading + ? _l10n.translate( + 'region_editor.routes_loading', + ) + : _l10n.translate( + 'region_editor.pick_default_route', + ), style: const TextStyle(fontSize: 13), ), items: [ @@ -308,18 +351,22 @@ class _RegionFormDialogState extends State { ? null : () => _pickBoundRoutes(options), child: InputDecorator( - decoration: _decoration('绑定路线'), + decoration: _decoration( + _l10n.translate('region_editor.bind_routes'), + ), child: Wrap( spacing: 6, runSpacing: 4, children: [ if (_bound.isEmpty) - const Padding( + Padding( padding: EdgeInsets.symmetric( vertical: 4, ), child: Text( - '请选择绑定路线(可多选)', + _l10n.translate( + 'region_editor.pick_linked_routes', + ), style: TextStyle( fontSize: 13, color: Colors.grey, @@ -329,7 +376,11 @@ class _RegionFormDialogState extends State { for (final id in _bound) InputChip( label: Text( - options[id] ?? '路线 #$id', + options[id] ?? + _l10n.translate( + 'autonomous_work.route_number', + {'id': id}, + ), style: const TextStyle(fontSize: 12), ), onDeleted: () => @@ -345,11 +396,15 @@ class _RegionFormDialogState extends State { controller: _remark, minLines: 2, maxLines: 3, - decoration: _decoration('备注'), + decoration: _decoration( + _l10n.translate('work_v2.record.remark'), + ), ), const SizedBox(height: 12), Text( - '当前区域范围点数:${state.draft.scope.length}/4', + _l10n.translate('region_editor.boundary_count', { + 'count': state.draft.scope.length, + }), style: TextStyle( fontSize: 12, color: state.draft.scopeError == null @@ -359,7 +414,7 @@ class _RegionFormDialogState extends State { ), if (state.draft.scopeError != null) Text( - state.draft.scopeError!, + regionErrorText(state.draft.scopeError!, _l10n), style: const TextStyle( fontSize: 12, color: Colors.red, @@ -369,7 +424,8 @@ class _RegionFormDialogState extends State { Padding( padding: const EdgeInsets.only(top: 10), child: Text( - _scopeError ?? state.error!, + _scopeError ?? + regionErrorText(state.error!, _l10n), key: const ValueKey('region_save_error'), style: const TextStyle( color: Colors.red, @@ -392,7 +448,7 @@ class _RegionFormDialogState extends State { onPressed: state.isSaving ? null : () => Navigator.of(context).pop(false), - child: const Text('取消'), + child: Text(_l10n.translate('common.cancel')), ), const SizedBox(width: 12), FilledButton( @@ -412,7 +468,9 @@ class _RegionFormDialogState extends State { color: Colors.white, ), ) - : const Text('确认保存'), + : Text( + _l10n.translate('region_editor.save_confirm'), + ), ), ], ), diff --git a/lib/features/regions/presentation/widgets/region_list_panel.dart b/lib/features/regions/presentation/widgets/region_list_panel.dart index 3514edc6..a4afca01 100644 --- a/lib/features/regions/presentation/widgets/region_list_panel.dart +++ b/lib/features/regions/presentation/widgets/region_list_panel.dart @@ -1,9 +1,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; +import 'package:maibu_satabot_v2/features/regions/presentation/region_error_text.dart'; +import 'package:maibu_satabot_v2/features/v2/device_list/presentation/widgets/autonomous/work_ui.dart'; import '../../../../components/capsule_toast.dart'; import '../../domain/entities/region_draft.dart'; import '../cubit/region_list_cubit.dart'; +typedef RegionListPageHeaderBuilder = + Widget Function( + BuildContext context, + RegionListState state, + VoidCallback? onCreate, + VoidCallback? onRefresh, + ); + /// 地图分区入口、竖屏区域管理共享的真实列表与操作界面。 class RegionListPanel extends StatelessWidget { const RegionListPanel({ @@ -16,6 +27,7 @@ class RegionListPanel extends StatelessWidget { this.onSelect, this.onDeleted, this.onClose, + this.pageHeaderBuilder, }); final RegionListCubit cubit; final VoidCallback onCreate; @@ -25,39 +37,50 @@ class RegionListPanel extends StatelessWidget { final VoidCallback onRefresh; final VoidCallback? onClose; final Object? Function() currentScope; + final RegionListPageHeaderBuilder? pageHeaderBuilder; Future _delete(BuildContext context, RegionDraft region) async { + final l10n = AppLocalizations.of(context); final scope = currentScope(); if (scope != cubit.scopeKey) return; final confirmed = await showDialog( context: context, builder: (dialogContext) => AlertDialog( - title: const Text('删除分区'), + title: Text(l10n.translate('region_editor.delete_region')), content: Text( - '确定删除「${region.name.isEmpty ? '分区 #${region.id}' : region.name}」?删除后无法恢复。', + l10n.translate('region_editor.delete_region_message', { + 'region': region.name.isEmpty + ? l10n.translate('region_editor.region_number', { + 'id': region.id, + }) + : region.name, + }), ), actions: [ TextButton( onPressed: () => Navigator.of(dialogContext).pop(false), - child: const Text('取消'), + child: Text(l10n.translate('common.cancel')), ), FilledButton( key: const ValueKey('region_delete_confirm'), onPressed: () => Navigator.of(dialogContext).pop(true), - child: const Text('删除'), + child: Text(l10n.translate('route_planning.delete')), ), ], ), ); if (!context.mounted || confirmed != true) return; if (currentScope() != scope || cubit.scopeKey != scope) { - CapsuleToast.show('场站或账号已切换,请重新选择分区', showCheck: false); + CapsuleToast.show( + l10n.translate('region_editor.scope_changed_select_region'), + showCheck: false, + ); return; } final deleted = await cubit.deleteRegion(region); if (!context.mounted || !deleted) return; onDeleted?.call(region); - CapsuleToast.show('分区已删除'); + CapsuleToast.show(l10n.translate('region_editor.region_deleted')); } @override @@ -66,56 +89,66 @@ class RegionListPanel extends StatelessWidget { ) => BlocBuilder( bloc: cubit, builder: (context, state) { + final l10n = AppLocalizations.of(context); final busy = state.deletingId != null; final scoped = state.siteId != null && currentScope() == cubit.scopeKey; + final pageHeader = pageHeaderBuilder; + final pageLayout = pageHeader != null; + final create = scoped && !busy ? onCreate : null; + final refresh = busy || state.status == RegionListStatus.loading + ? null + : onRefresh; return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Padding( - padding: const EdgeInsets.fromLTRB(12, 6, 4, 4), - child: Row( - children: [ - Expanded( - child: Text( - state.status == RegionListStatus.ready - ? '分区列表(${state.regions.length})' - : '分区列表', - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w800, - color: Color(0xFF1A2B4A), + if (pageHeader != null) + pageHeader(context, state, create, refresh) + else + Padding( + padding: const EdgeInsets.fromLTRB(12, 6, 4, 4), + child: Row( + children: [ + Expanded( + child: Text( + state.status == RegionListStatus.ready + ? l10n.translate('region_editor.regions_count', { + 'count': state.regions.length, + }) + : l10n.translate('region_editor.regions'), + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w800, + color: Color(0xFF1A2B4A), + ), ), ), - ), - TextButton.icon( - key: const ValueKey('region_list_create'), - onPressed: !scoped || busy ? null : onCreate, - icon: const Icon(Icons.add_rounded, size: 17), - label: const Text('新增'), - ), - IconButton( - tooltip: '刷新分区', - visualDensity: VisualDensity.compact, - onPressed: busy || state.status == RegionListStatus.loading - ? null - : onRefresh, - icon: const Icon(Icons.refresh_rounded, size: 19), - ), - if (onClose != null) - IconButton( - tooltip: '关闭列表', - visualDensity: VisualDensity.compact, - onPressed: busy ? null : onClose, - icon: const Icon(Icons.close_rounded, size: 19), + TextButton.icon( + key: const ValueKey('region_list_create'), + onPressed: create, + icon: const Icon(Icons.add_rounded, size: 17), + label: Text(l10n.translate('region_editor.add_region')), ), - ], + IconButton( + tooltip: l10n.translate('region_editor.refresh_regions'), + visualDensity: VisualDensity.compact, + onPressed: refresh, + icon: const Icon(Icons.refresh_rounded, size: 19), + ), + if (onClose != null) + IconButton( + tooltip: l10n.translate('region_editor.close_regions'), + visualDensity: VisualDensity.compact, + onPressed: busy ? null : onClose, + icon: const Icon(Icons.close_rounded, size: 19), + ), + ], + ), ), - ), if (state.operationError != null) Padding( padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), child: Text( - state.operationError!, + regionErrorText(state.operationError!, l10n), key: const ValueKey('region_delete_error'), style: const TextStyle(fontSize: 12, color: Colors.red), ), @@ -125,9 +158,13 @@ class RegionListPanel extends StatelessWidget { RegionListStatus.loading || RegionListStatus.idle => const Center( child: CircularProgressIndicator(strokeWidth: 2), ), - RegionListStatus.noUser => const Center(child: Text('请先登录')), - RegionListStatus.noSite => const Center( - child: Text('请选择场站后查看分区'), + RegionListStatus.noUser => Center( + child: Text(l10n.translate('region_editor.sign_in_first')), + ), + RegionListStatus.noSite => Center( + child: Text( + l10n.translate('region_editor.select_site_for_regions'), + ), ), RegionListStatus.failure => Center( child: Padding( @@ -136,13 +173,19 @@ class RegionListPanel extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text( - state.error ?? '分区加载失败', + state.error == null + ? l10n.translate( + 'region_editor.regions_load_failed', + ) + : regionErrorText(state.error!, l10n), textAlign: TextAlign.center, ), const SizedBox(height: 8), TextButton( onPressed: onRefresh, - child: const Text('重新加载分区'), + child: Text( + l10n.translate('region_editor.reload_regions'), + ), ), ], ), @@ -150,21 +193,33 @@ class RegionListPanel extends StatelessWidget { ), RegionListStatus.ready => state.regions.isEmpty - ? const Center(child: Text('当前场站暂无分区,可点击「新增」')) + ? pageLayout + ? _buildPageEmpty(context) + : Center( + child: Text( + l10n.translate('region_editor.regions_empty'), + ), + ) : ListView.separated( - padding: const EdgeInsets.fromLTRB(10, 4, 10, 16), + padding: pageLayout + ? const EdgeInsets.only(bottom: 12) + : const EdgeInsets.fromLTRB(10, 4, 10, 16), itemCount: state.regions.length, - separatorBuilder: (_, _) => const SizedBox(height: 8), + separatorBuilder: (_, _) => + SizedBox(height: pageLayout ? 10 : 8), itemBuilder: (context, index) { final region = state.regions[index]; final selected = state.selectedId == region.id; + final radius = BorderRadius.circular( + pageLayout ? 16 : 12, + ); return Material( key: ValueKey('region_row_${region.id}'), color: selected ? const Color(0xFFEAF3FE) : Colors.white, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), + borderRadius: radius, side: BorderSide( color: selected ? const Color(0xFF1C96F6) @@ -172,7 +227,7 @@ class RegionListPanel extends StatelessWidget { ), ), child: InkWell( - borderRadius: BorderRadius.circular(12), + borderRadius: radius, onTap: !scoped || busy ? null : () { @@ -180,69 +235,128 @@ class RegionListPanel extends StatelessWidget { onSelect?.call(region); }, child: Padding( - padding: const EdgeInsets.fromLTRB( - 12, - 10, - 8, - 4, - ), + padding: pageLayout + ? const EdgeInsets.fromLTRB(14, 14, 14, 8) + : const EdgeInsets.fromLTRB(12, 10, 8, 4), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Row( children: [ + if (pageLayout) ...[ + Container( + width: 32, + height: 32, + decoration: BoxDecoration( + color: kWtSoftBlue, + borderRadius: + BorderRadius.circular(10), + ), + child: const Icon( + Icons.layers_outlined, + size: 18, + color: kWtBlue, + ), + ), + const SizedBox(width: 10), + ], Expanded( child: Text( region.name.isEmpty - ? '分区 #${region.id}' + ? l10n.translate( + 'region_editor.region_number', + {'id': region.id}, + ) : region.name, maxLines: 2, overflow: TextOverflow.ellipsis, - style: const TextStyle( + style: TextStyle( fontWeight: FontWeight.w800, - fontSize: 14, + fontSize: pageLayout ? 15 : 14, + color: pageLayout + ? kWtNavy + : null, ), ), ), const SizedBox(width: 6), - Text( - region.enabled ? '启用' : '停用', - style: TextStyle( - fontSize: 11, - color: region.enabled + if (pageLayout) + WorkChip( + text: region.enabled + ? l10n.translate( + 'region_editor.enabled', + ) + : l10n.translate( + 'region_editor.disabled', + ), + background: region.enabled + ? kWtGreenBg + : kWtLocked, + foreground: region.enabled ? const Color(0xFF1D9E57) - : Colors.grey, + : kWtGray2, + ) + else + Text( + region.enabled + ? l10n.translate( + 'region_editor.enabled', + ) + : l10n.translate( + 'region_editor.disabled', + ), + style: TextStyle( + fontSize: 11, + color: region.enabled + ? const Color(0xFF1D9E57) + : Colors.grey, + ), ), - ), ], ), if (region.code.isNotEmpty) ...[ const SizedBox(height: 6), Text( - '编码:${region.code}', - style: const TextStyle( + l10n.translate( + 'region_editor.code_value', + {'code': region.code}, + ), + style: TextStyle( fontSize: 12, - color: Colors.grey, + color: pageLayout + ? kWtGray + : Colors.grey, ), ), ], const SizedBox(height: 6), Text( - '${region.scope.length} 个范围点 · ${region.boundRouteIds.length} 条绑定路线', - style: const TextStyle( + l10n.translate( + 'region_editor.region_summary', + { + 'points': region.scope.length, + 'routes': region.boundRouteIds.length, + }, + ), + style: TextStyle( fontSize: 11.5, - color: Colors.grey, + color: pageLayout + ? kWtGray + : Colors.grey, ), ), if (region.scopeError != null) - const Text( - '范围需重新打点', + Text( + l10n.translate( + 'region_editor.redraw_required', + ), style: TextStyle( fontSize: 11, color: Colors.orange, ), ), + if (pageLayout) const SizedBox(height: 4), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -253,8 +367,21 @@ class RegionListPanel extends StatelessWidget { onPressed: !scoped || busy ? null : () => onEdit(region), - child: const Text('修改'), + style: pageLayout + ? _pageActionStyle( + context, + kWtBlue, + kWtSoftBlue, + ) + : null, + child: Text( + l10n.translate( + 'region_editor.edit', + ), + ), ), + if (pageLayout) + const SizedBox(width: 8), TextButton( key: ValueKey( 'region_delete_${region.id}', @@ -262,6 +389,13 @@ class RegionListPanel extends StatelessWidget { onPressed: !scoped || busy ? null : () => _delete(context, region), + style: pageLayout + ? _pageActionStyle( + context, + kWtDanger, + kWtSegBg, + ) + : null, child: state.deletingId == region.id ? const SizedBox( width: 14, @@ -271,11 +405,17 @@ class RegionListPanel extends StatelessWidget { strokeWidth: 2, ), ) - : const Text( - '删除', - style: TextStyle( - color: Color(0xFFD54941), + : Text( + l10n.translate( + 'route_planning.delete', ), + style: pageLayout + ? null + : const TextStyle( + color: Color( + 0xFFD54941, + ), + ), ), ), ], @@ -293,4 +433,42 @@ class RegionListPanel extends StatelessWidget { ); }, ); + + ButtonStyle _pageActionStyle( + BuildContext context, + Color foreground, + Color background, + ) => TextButton.styleFrom( + foregroundColor: foreground, + backgroundColor: background, + minimumSize: const Size(54, 32), + padding: const EdgeInsets.symmetric(horizontal: 12), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + textStyle: Theme.of( + context, + ).textTheme.labelLarge?.copyWith(fontSize: 12, fontWeight: FontWeight.w700), + ); + + Widget _buildPageEmpty(BuildContext context) => Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 56, + height: 56, + decoration: const BoxDecoration( + color: Colors.white, + shape: BoxShape.circle, + ), + child: const Icon(Icons.layers_outlined, size: 26, color: kWtMuted), + ), + const SizedBox(height: 10), + Text( + AppLocalizations.of(context).translate('work_v2.area.empty_site'), + textAlign: TextAlign.center, + style: const TextStyle(fontSize: 12.5, color: kWtGray), + ), + ], + ), + ); } diff --git a/lib/features/remote_control/presentation/pages/remote_control_page.dart b/lib/features/remote_control/presentation/pages/remote_control_page.dart index aa045ed8..aa794ae3 100644 --- a/lib/features/remote_control/presentation/pages/remote_control_page.dart +++ b/lib/features/remote_control/presentation/pages/remote_control_page.dart @@ -157,6 +157,7 @@ class _RemoteControlPageState extends State { Widget build(BuildContext context) => ControlModeEntryGate( deviceId: _modeDeviceId, target: ControlModeTarget.remote, + cancelToPreview: true, onReady: () { if (_cubit.state.targetDevice?.deviceName != _modeDeviceId) return; _controlSessionStarted = true; diff --git a/lib/features/v2/device_list/data/models/robot_data_model.dart b/lib/features/v2/device_list/data/models/robot_data_model.dart index fb2e6f27..8fc3d531 100644 --- a/lib/features/v2/device_list/data/models/robot_data_model.dart +++ b/lib/features/v2/device_list/data/models/robot_data_model.dart @@ -26,6 +26,9 @@ class RobotDataModel { /// 展示位置在版本号(PRO / PLUS / STD)之前:`MC700 · PRO 旗舰版`。 final String? deviceType; + /// 设备类型名称,保留接口 deviceTypeName 的原文。 + final String? deviceTypeName; + /// 归属信息:当前挂在哪个组织 / 场站 / 负责人下。 /// /// 后端 getSiteList 不一定回传这些字段,因此全部可空: @@ -51,6 +54,7 @@ class RobotDataModel { this.productName, this.productModel, this.deviceType, + this.deviceTypeName, this.orgId, this.orgName, this.siteId, @@ -72,12 +76,13 @@ class RobotDataModel { // 设备状态码(原始 status 字段) final statusCode = json['status'] ?? 0; + final deviceTypeName = _pickStr(json['deviceTypeName']); return RobotDataModel( name: json['deviceName'] ?? json['name'] ?? '', id: json['deviceId']?.toString() ?? json['id']?.toString() ?? '', alias: json['deviceAlias'] as String?, // 获取别名字段 - type: _convertType(json['deviceTypeName'] ?? json['type'] ?? '未知类型'), + type: _convertType(deviceTypeName ?? _pickStr(json['type']) ?? '未知类型'), status: isOnline ? '在线' : '离线', isOnline: isOnline, statusCode: statusCode is int ? statusCode : 0, @@ -86,7 +91,8 @@ class RobotDataModel { hasHost: json['hasHost'] as bool? ?? false, productName: _pickStr(json['productName']), productModel: _pickStr(json['productModel']), - deviceType: _pickStr(json['deviceType'] ?? json['device_type']), + deviceType: _pickStr(json['deviceType']) ?? _pickStr(json['device_type']), + deviceTypeName: deviceTypeName, orgId: _pickInt(json, const ['orgId', 'org_id', 'organizationId']), orgName: _pickStr( json['orgName'] ?? json['org_name'] ?? json['organizationName'], @@ -153,6 +159,7 @@ class RobotDataModel { 'productName': productName, 'productModel': productModel, 'deviceType': deviceType, + 'deviceTypeName': deviceTypeName, 'orgId': orgId, 'orgName': orgName, 'siteId': siteId, diff --git a/lib/features/v2/device_list/presentation/pages/device_detail_page_v2.dart b/lib/features/v2/device_list/presentation/pages/device_detail_page_v2.dart index f5689510..b7378362 100644 --- a/lib/features/v2/device_list/presentation/pages/device_detail_page_v2.dart +++ b/lib/features/v2/device_list/presentation/pages/device_detail_page_v2.dart @@ -7,7 +7,10 @@ import 'package:maibu_satabot_v2/components/device_status_modal.dart'; import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; import 'package:maibu_satabot_v2/features/pv_control/presentation/pages/pv_control_page.dart'; import 'package:maibu_satabot_v2/features/pv_control/presentation/widgets/pv_work_map.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import '../../../../device_control_mode/domain/entities/device_control_mode.dart'; +import '../../../../device_control_mode/presentation/widgets/control_mode_entry_gate.dart'; import '../../../../devices/domain/entities/device_entity.dart'; import '../../../../devices/presentation/bloc/device_status_bloc.dart'; import '../../../../devices/presentation/bloc/device_status_state.dart'; @@ -15,10 +18,14 @@ import '../../../../devices/presentation/bloc/devices_cubit.dart'; import '../../../../remote_control/presentation/bloc/remote_control_cubit.dart'; import '../../../device_run_param/presentation/pages/robot_param_settings_page.dart'; import '../../../local_camera/presentation/pages/local_camera_page.dart'; +import '../../../work/presentation/pages/work_record_page_v2.dart'; import '../../data/models/robot_data_model.dart'; import '../../domain/entities/device_model_info.dart'; import '../../domain/usecases/update_device_alias_usecase.dart'; import '../widgets/device_card_v2.dart'; +import '../widgets/device_quick_actions.dart'; +import '../widgets/device_task_control_tile.dart'; +import '../../../../autonomous_work/domain/repositories/autonomous_work_gateway.dart'; import '../widgets/find_robot_sheet.dart'; import '../widgets/rename_device_dialog.dart'; import '../widgets/voice_broadcast_sheet.dart'; @@ -26,11 +33,9 @@ import 'device_all_functions_page_v2.dart'; import 'robot_app_power_page_v2.dart'; import 'robot_autonomous_work_page_v2.dart'; import 'robot_control_page.dart'; -import 'robot_fault_center_page_v2.dart'; -import 'robot_firmware_page_v2.dart'; +// import 'robot_fault_center_page_v2.dart'; // 恢复旧故障诊断入口时启用。 import 'robot_light_sound_page_v2.dart'; import 'robot_network_location_page_v2.dart'; -import 'robot_run_record_page_v2.dart'; import 'robot_sensor_page_v2.dart'; import 'route_editor_page_v2.dart'; @@ -71,40 +76,34 @@ class _MonitorRow { }); } -/// 设置项:右侧三选一(箭头 / 状态药丸 / 开关) class _SettingItem { final IconData icon; final String title; - final String subtitle; - final String? badge; - final bool badgeGreen; - final bool? switchValue; - final ValueChanged? onSwitchChanged; - - /// 点击跳转;为空则统一提示未开发 + final String? subtitle; + final String? status; + final bool showUnavailableSwitch; final VoidCallback? onTap; const _SettingItem({ required this.icon, required this.title, - required this.subtitle, - this.badge, - this.badgeGreen = false, - this.switchValue, - this.onSwitchChanged, + this.subtitle, + this.status, + this.showUnavailableSwitch = false, this.onTap, }); } -/// 设置分组:标题 + 可选右上蓝色权限提示 + 条目列表 class _SettingGroup { + final IconData icon; final String title; - final String? trailingText; + final String subtitle; final List<_SettingItem> items; const _SettingGroup({ + required this.icon, required this.title, - this.trailingText, + required this.subtitle, required this.items, }); } @@ -122,13 +121,14 @@ class _DeviceDetailPageV2State extends State { static const _danger = Color(0xFFF0483E); static const _tabKeys = [ 'tab_overview', - 'tab_monitor', + // 'tab_monitor', // 上架版暂时隐藏监测分栏。 'tab_control', 'tab_record', 'tab_settings', ]; - int _tab = 0; + String _tabKey = 'tab_overview'; + bool _modeDialogOpen = false; /// 当前机型的版本(来自列表接口 productModel);null/空串时为 unknown DeviceEdition get _edition => widget.robot.modelInfo.edition; @@ -137,10 +137,6 @@ class _DeviceDetailPageV2State extends State { String _modelLabelOf(AppLocalizations l10n) => widget.robot.modelLabelOf(l10n); - // 安全设置里的两个开关(后端未下发口径,先做本地交互态) - bool _autoStopBlade = true; - bool _autoResumeBlade = true; - // 解绑请求进行中(防重复点击) bool _isUnbinding = false; @@ -166,9 +162,7 @@ class _DeviceDetailPageV2State extends State { String _workLabelOf(AppLocalizations l10n) => switch (_status) { DeviceV2Status.working => l10n.translate('device_list_v2.stat_working'), - DeviceV2Status.online => l10n.translate( - 'device_list_v2.work_text_online', - ), + DeviceV2Status.online => l10n.translate('device_list_v2.work_text_online'), DeviceV2Status.offline => l10n.translate('device_list_v2.offline'), }; @@ -198,9 +192,7 @@ class _DeviceDetailPageV2State extends State { final targetDeviceId = widget.robot.name.isNotEmpty ? widget.robot.name : widget.robot.id; - debugPrint( - '>>> [DetailRename] 下发 deviceId=$targetDeviceId alias=$newName', - ); + debugPrint('>>> [DetailRename] 下发 deviceId=$targetDeviceId alias=$newName'); final result = await GetIt.I().execute( deviceId: targetDeviceId, @@ -260,7 +252,7 @@ class _DeviceDetailPageV2State extends State { const SizedBox(height: 10), _buildTabs(), const SizedBox(height: 10), - if (_tab == 0) ...[ + if (_tabKey == 'tab_overview') ...[ _buildOverviewSection(), const SizedBox(height: 12), _buildMapSection(), @@ -270,21 +262,19 @@ class _DeviceDetailPageV2State extends State { _buildFunctionSection(), const SizedBox(height: 10), _buildAllFunctionButton(), - ] else if (_tab == 1) + ] else if (_tabKey == 'tab_monitor') _buildMonitorTab() - else if (_tab == 2) + else if (_tabKey == 'tab_control') _buildControlTab() - else if (_tab == 3) + else if (_tabKey == 'tab_record') _buildRecordTab() else _buildSettingsTab(), const SizedBox(height: 8), Text( - _tab == 4 + _tabKey == 'tab_settings' ? l10n - .translate( - 'device_detail_v2.footer_settings', - ) + .translate('device_detail_v2.footer_settings') .replaceAll('%s', _editionLabelOf(l10n)) : l10n.translate('device_detail_v2.footer_demo'), textAlign: TextAlign.center, @@ -333,9 +323,7 @@ class _DeviceDetailPageV2State extends State { ), const SizedBox(width: 12), Text( - AppLocalizations.of( - context, - ).translate('device_detail_v2.title'), + AppLocalizations.of(context).translate('device_detail_v2.title'), style: const TextStyle( fontSize: 18, fontWeight: FontWeight.bold, @@ -534,7 +522,7 @@ class _DeviceDetailPageV2State extends State { ); } - // ===== 页签:概览/监测/控制/记录/设置 ===== + // ===== 详情页签 ===== Widget _buildTabs() { return Container( padding: const EdgeInsets.all(3), @@ -546,17 +534,17 @@ class _DeviceDetailPageV2State extends State { children: [ for (int i = 0; i < _tabKeys.length; i++) ...[ if (i > 0) const SizedBox(width: 2), - Expanded(child: _tabSegment(i)), + Expanded(child: _tabSegment(_tabKeys[i])), ], ], ), ); } - Widget _tabSegment(int i) { - final selected = _tab == i; + Widget _tabSegment(String tabKey) { + final selected = _tabKey == tabKey; return GestureDetector( - onTap: () => setState(() => _tab = i), + onTap: () => setState(() => _tabKey = tabKey), behavior: HitTestBehavior.opaque, child: Container( height: 32, @@ -575,9 +563,7 @@ class _DeviceDetailPageV2State extends State { ), alignment: Alignment.center, child: Text( - AppLocalizations.of( - context, - ).translate('device_detail_v2.${_tabKeys[i]}'), + AppLocalizations.of(context).translate('device_detail_v2.$tabKey'), style: TextStyle( fontSize: 13, fontWeight: selected ? FontWeight.w700 : FontWeight.w400, @@ -613,8 +599,7 @@ class _DeviceDetailPageV2State extends State { final knife = (st?.knifeCuttingSpeed ?? '').trim(); final knifeText = (knife.isEmpty || knife == '0') ? '--' : knife; - final hasFix = - st != null && !(st.latitude == 0 && st.longitude == 0); + final hasFix = st != null && !(st.latitude == 0 && st.longitude == 0); final gnssText = hasFix ? '${st.latitude.toStringAsFixed(2)},${st.longitude.toStringAsFixed(2)}' : '--'; @@ -681,11 +666,7 @@ class _DeviceDetailPageV2State extends State { color: _blue, ), ), - const Icon( - Icons.arrow_forward, - size: 13, - color: _blue, - ), + const Icon(Icons.arrow_forward, size: 13, color: _blue), ], ), ), @@ -800,10 +781,8 @@ class _DeviceDetailPageV2State extends State { ), const Spacer(), GestureDetector( - onTap: () => CapsuleToast.show( - l10n.translate('device_list_v2.feature_todo'), - showCheck: false, - ), + onTap: _showLocationMap, + behavior: HitTestBehavior.opaque, child: Row( mainAxisSize: MainAxisSize.min, children: [ @@ -887,9 +866,7 @@ class _DeviceDetailPageV2State extends State { children: [ Text( l10n - .translate( - 'device_detail_v2.current_location', - ) + .translate('device_detail_v2.current_location') .replaceAll('%s', location), style: const TextStyle( fontSize: 13, @@ -899,13 +876,8 @@ class _DeviceDetailPageV2State extends State { ), const SizedBox(height: 4), Text( - l10n.translate( - 'device_detail_v2.location_hint', - ), - style: const TextStyle( - fontSize: 11, - color: _gray, - ), + l10n.translate('device_detail_v2.location_hint'), + style: const TextStyle(fontSize: 11, color: _gray), ), ], ), @@ -924,6 +896,67 @@ class _DeviceDetailPageV2State extends State { ); } + void _showLocationMap() { + final l10n = AppLocalizations.of(context); + final statusBloc = context.read(); + showModalBottomSheet( + context: context, + isScrollControlled: true, + useSafeArea: true, + enableDrag: false, + backgroundColor: Colors.white, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(24)), + ), + builder: (sheetContext) => SafeArea( + top: false, + child: SizedBox( + height: MediaQuery.sizeOf(sheetContext).height * 0.76, + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 6, 16, 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + children: [ + Expanded( + child: Text( + l10n.translate('device_detail_v2.view_map'), + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w800, + color: _navy, + ), + ), + ), + IconButton( + tooltip: l10n.translate('common.close'), + onPressed: () => Navigator.of(sheetContext).pop(), + icon: const Icon(Icons.close_rounded, color: _navy), + ), + ], + ), + Expanded( + child: ClipRRect( + borderRadius: BorderRadius.circular(14), + child: BlocProvider.value( + value: statusBloc, + child: PvWorkMap( + deviceSn: widget.robot.name, + recordLocationTrace: false, + centerOnDeviceOnOpen: true, + ), + ), + ), + ), + ], + ), + ), + ), + ), + ); + } + // ===== 监测 tab:实时监测(图 1)+ 传感器监测/故障状态/快捷诊断(图 2) ===== Widget _buildMonitorTab() { final tileWidth = (MediaQuery.of(context).size.width - 32 - 20) / 3; @@ -1580,9 +1613,7 @@ class _DeviceDetailPageV2State extends State { child: _buildActionCard( icon: Icons.assignment_outlined, title: l10n.translate('device_detail_v2.ctrl_task_mgr'), - subtitle: l10n.translate( - 'device_detail_v2.ctrl_task_mgr_sub', - ), + subtitle: l10n.translate('device_detail_v2.ctrl_task_mgr_sub'), hint: l10n.translate('device_detail_v2.ctrl_task_mgr_hint'), onTap: _openTaskManager, ), @@ -1768,7 +1799,7 @@ class _DeviceDetailPageV2State extends State { Icons.toggle_on_outlined, 'device_detail_v2.op_manual_switch', 'device_detail_v2.op_manual_switch_sub', - null, + _openControlModeSwitch, ), ( Icons.smart_toy_outlined, @@ -1805,7 +1836,16 @@ class _DeviceDetailPageV2State extends State { runSpacing: 10, children: [ for (final op in ops) - SizedBox(width: tileWidth, child: _controlOpTile(op)), + SizedBox( + width: tileWidth, + child: op.$2 == 'device_detail_v2.op_task_pause' + ? DeviceTaskControlTile( + key: ValueKey('task-control/${widget.robot.name}'), + deviceId: widget.robot.name, + gateway: GetIt.I(), + ) + : _controlOpTile(op), + ), ], ), ], @@ -1872,14 +1912,14 @@ class _DeviceDetailPageV2State extends State { children: [ _buildLinkHeader( l10n.translate('device_detail_v2.rec_fault_title'), - onTap: _openFaultCenter, + onTap: _showFaultRecords, ), const SizedBox(height: 10), _buildFaultRecordCard(), const SizedBox(height: 16), _buildLinkHeader( l10n.translate('device_detail_v2.rec_work_title'), - onTap: _openRunRecord, + onTap: _openWorkRecord, ), const SizedBox(height: 10), _buildWorkRecordCard(), @@ -1887,60 +1927,45 @@ class _DeviceDetailPageV2State extends State { ); } - // 分组标题 + 右侧蓝色「查看全部 →」 - Widget _buildLinkHeader( - String title, { - String? link, - VoidCallback? onTap, - }) { + Widget _buildLinkHeader(String title, {required VoidCallback onTap}) { final l10n = AppLocalizations.of(context); - return Row( - children: [ - Text( - title, - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w800, - color: _navy, - ), - ), - const Spacer(), - GestureDetector( - onTap: - onTap ?? - () => CapsuleToast.show( - l10n.translate('device_list_v2.feature_todo'), - showCheck: false, + return GestureDetector( + onTap: onTap, + behavior: HitTestBehavior.opaque, + child: Row( + children: [ + Expanded( + child: Text( + title, + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w800, + color: _navy, ), - behavior: HitTestBehavior.opaque, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - link ?? l10n.translate('device_detail_v2.view_all'), - style: const TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - color: _blue, - ), - ), - const SizedBox(width: 2), - const Icon(Icons.arrow_forward, size: 13, color: _blue), - ], + ), ), - ), - ], + Text( + l10n.translate('device_detail_v2.view_all'), + style: const TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: _blue, + ), + ), + const SizedBox(width: 2), + const Icon(Icons.arrow_forward, size: 13, color: _blue), + ], + ), ); } - // 故障与预警记录卡:警告红图标 + 汇总文案 + 红色条数药丸 Widget _buildFaultRecordCard() { final l10n = AppLocalizations.of(context); return GestureDetector( - onTap: _openFaultCenter, + onTap: _showFaultRecords, behavior: HitTestBehavior.opaque, child: Container( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), + padding: const EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), @@ -1952,13 +1977,119 @@ class _DeviceDetailPageV2State extends State { width: 36, height: 36, decoration: BoxDecoration( - color: const Color(0xFFFDECEC), + color: _offlineBg, borderRadius: BorderRadius.circular(10), ), child: const Icon( Icons.warning_amber_rounded, size: 20, - color: Color(0xFFF0483E), + color: _offlineGray, + ), + ), + const SizedBox(width: 10), + Expanded( + child: Text( + l10n.translate('robot_fault_v2.empty'), + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: _gray, + ), + ), + ), + const Icon(Icons.chevron_right, size: 18, color: Color(0xFFC9CDD4)), + ], + ), + ), + ); + } + + void _showFaultRecords() { + final l10n = AppLocalizations.of(context); + showModalBottomSheet( + context: context, + isScrollControlled: true, + useSafeArea: true, + backgroundColor: Colors.white, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(24)), + ), + builder: (sheetContext) => SafeArea( + top: false, + child: SingleChildScrollView( + padding: const EdgeInsets.fromLTRB(16, 6, 16, 32), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + children: [ + Expanded( + child: Text( + l10n.translate('device_detail_v2.rec_fault_title'), + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w800, + color: _navy, + ), + ), + ), + IconButton( + tooltip: l10n.translate('common.close'), + onPressed: () => Navigator.of(sheetContext).pop(), + icon: const Icon(Icons.close_rounded, color: _navy), + ), + ], + ), + const SizedBox(height: 20), + Container( + width: 48, + height: 48, + decoration: BoxDecoration( + color: _offlineBg, + borderRadius: BorderRadius.circular(14), + ), + child: const Icon( + Icons.receipt_long_outlined, + color: _offlineGray, + ), + ), + const SizedBox(height: 10), + Text( + l10n.translate('robot_fault_v2.empty'), + style: const TextStyle(fontSize: 14, color: _gray), + ), + ], + ), + ), + ), + ); + } + + Widget _buildWorkRecordCard() { + final l10n = AppLocalizations.of(context); + return GestureDetector( + onTap: _openWorkRecord, + behavior: HitTestBehavior.opaque, + child: Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16), + border: Border.all(color: const Color(0xFFE5EDF7)), + ), + child: Row( + children: [ + Container( + width: 36, + height: 36, + decoration: BoxDecoration( + color: const Color(0xFFEAF3FE), + borderRadius: BorderRadius.circular(10), + ), + child: const Icon( + Icons.assignment_outlined, + size: 19, + color: _blue, ), ), const SizedBox(width: 10), @@ -1967,44 +2098,22 @@ class _DeviceDetailPageV2State extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - l10n.translate('device_detail_v2.rec_7d'), - maxLines: 1, - overflow: TextOverflow.ellipsis, + l10n.translate('work_v2.record.device_history_scope'), style: const TextStyle( fontSize: 14, fontWeight: FontWeight.w700, color: _navy, ), ), - const SizedBox(height: 3), + const SizedBox(height: 2), Text( - l10n.translate('device_detail_v2.rec_7d_sub'), - maxLines: 1, - overflow: TextOverflow.ellipsis, + l10n.translate('work_v2.record.device_page_subtitle'), style: const TextStyle(fontSize: 11, color: _gray), ), ], ), ), const SizedBox(width: 8), - Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), - decoration: BoxDecoration( - color: const Color(0xFFFDECEC), - borderRadius: BorderRadius.circular(12), - ), - child: Text( - l10n - .translate('device_detail_v2.rec_count') - .replaceAll('%s', '3'), - style: const TextStyle( - fontSize: 11, - fontWeight: FontWeight.w700, - color: Color(0xFFF0483E), - ), - ), - ), - const SizedBox(width: 2), const Icon(Icons.chevron_right, size: 18, color: Color(0xFFC9CDD4)), ], ), @@ -2012,166 +2121,69 @@ class _DeviceDetailPageV2State extends State { ); } - // 作业记录卡:今日作业 + 作业中药丸 + 三列指标 - Widget _buildWorkRecordCard() { - final l10n = AppLocalizations.of(context); - final now = DateTime.now(); - return GestureDetector( - onTap: _openRunRecord, - behavior: HitTestBehavior.opaque, - child: Container( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(16), - border: Border.all(color: const Color(0xFFE5EDF7)), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Row( - children: [ - Container( - width: 36, - height: 36, - decoration: BoxDecoration( - color: const Color(0xFFEAF3FE), - borderRadius: BorderRadius.circular(10), - ), - child: const Icon( - Icons.assignment_outlined, - size: 19, - color: _blue, - ), - ), - const SizedBox(width: 10), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - l10n.translate('device_detail_v2.rec_today'), - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.w700, - color: _navy, - ), - ), - const SizedBox(height: 2), - Text( - l10n - .translate('device_detail_v2.rec_date') - .replaceAll('%s', '${now.month}') - .replaceAll('%s', '${now.day}'), - style: const TextStyle(fontSize: 11, color: _gray), - ), - ], - ), - ), - Container( - padding: const EdgeInsets.symmetric( - horizontal: 10, - vertical: 4, - ), - decoration: BoxDecoration( - color: const Color(0xFFE7F3FE), - borderRadius: BorderRadius.circular(12), - ), - child: Text( - _workLabelOf(AppLocalizations.of(context)), - style: const TextStyle( - fontSize: 11, - fontWeight: FontWeight.w700, - color: _blue, - ), - ), - ), - ], - ), - const SizedBox(height: 10), - const Divider(height: 1, thickness: 0.6, color: Color(0xFFF0F4FA)), - const SizedBox(height: 10), - Row( - children: [ - Expanded( - child: _recordMetric( - l10n.translate('device_detail_v2.rec_area'), - '2.38 ha', - ), - ), - _metricDivider(), - Expanded( - child: _recordMetric( - l10n.translate('device_detail_v2.rec_duration'), - '56 min', - ), - ), - _metricDivider(), - Expanded( - child: _recordMetric( - l10n.translate('device_detail_v2.rec_efficiency'), - '2.55 ha/h', - ), - ), - const Icon( - Icons.chevron_right, - size: 18, - color: Color(0xFFC9CDD4), - ), - ], - ), - ], - ), - ), - ); - } - - Widget _recordMetric(String label, String value) { - return Column( - children: [ - Text(label, style: const TextStyle(fontSize: 10.5, color: _gray)), - const SizedBox(height: 4), - Text( - value, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w800, - color: _navy, - ), - ), - ], - ); - } - - Widget _metricDivider() { - return Container( - width: 0.8, - height: 26, - margin: const EdgeInsets.symmetric(horizontal: 6), - color: const Color(0xFFEDF2F9), - ); - } - - // ===== 设置 tab:两套机型设置项已全部并入,将来按机型字段动态显隐 ===== Widget _buildSettingsTab() { - final groups = _settingGroups(); return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - for (int i = 0; i < groups.length; i++) ...[ - if (i > 0) const SizedBox(height: 14), - _buildSettingGroupHeader(groups[i]), - const SizedBox(height: 8), - _buildSettingCard(groups[i]), - ], + _buildSettingCard([ + for (final group in _settingGroups()) + _SettingItem( + icon: group.icon, + title: group.title, + subtitle: group.subtitle, + onTap: () => _showSettingsGroup(group), + ), + ]), const SizedBox(height: 20), _buildUnbindButton(), ], ); } + void _showSettingsGroup(_SettingGroup group) { + final l10n = AppLocalizations.of(context); + showModalBottomSheet( + context: context, + isScrollControlled: true, + useSafeArea: true, + backgroundColor: Colors.white, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(24)), + ), + builder: (sheetContext) => SafeArea( + top: false, + child: SingleChildScrollView( + padding: const EdgeInsets.fromLTRB(16, 6, 16, 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + children: [ + Expanded( + child: Text( + l10n.translate(group.title), + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w800, + color: _navy, + ), + ), + ), + IconButton( + tooltip: l10n.translate('common.close'), + onPressed: () => Navigator.of(sheetContext).pop(), + icon: const Icon(Icons.close_rounded, color: _navy), + ), + ], + ), + _buildSettingCard(group.items), + ], + ), + ), + ), + ); + } + // ===== 解绑设备:置于设置页最底部(白底细边,主色改为警示红) ===== Widget _buildUnbindButton() { final l10n = AppLocalizations.of(context); @@ -2269,10 +2281,9 @@ class _DeviceDetailPageV2State extends State { final error = cubit.state.errorMessage; if (error == null || error.isEmpty) { CapsuleToast.show( - l10n.translate('device_detail_v2.unbind_success').replaceAll( - '%s', - _displayName, - ), + l10n + .translate('device_detail_v2.unbind_success') + .replaceAll('%s', _displayName), ); Navigator.of(context).pop(); } else { @@ -2281,7 +2292,9 @@ class _DeviceDetailPageV2State extends State { } catch (e) { if (mounted) { CapsuleToast.show( - l10n.translate('device_detail_v2.unbind_error').replaceAll('%s', '$e'), + l10n + .translate('device_detail_v2.unbind_error') + .replaceAll('%s', '$e'), showCheck: false, ); } @@ -2290,36 +2303,7 @@ class _DeviceDetailPageV2State extends State { } } - Widget _buildSettingGroupHeader(_SettingGroup group) { - final l10n = AppLocalizations.of(context); - return Row( - children: [ - Text( - l10n.translate(group.title), - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w800, - color: _navy, - ), - ), - const Spacer(), - if (group.trailingText != null) ...[ - const Icon(Icons.lock_outline, size: 12, color: _blue), - const SizedBox(width: 3), - Text( - l10n.translate(group.trailingText!), - style: const TextStyle( - fontSize: 11, - fontWeight: FontWeight.w600, - color: _blue, - ), - ), - ], - ], - ); - } - - Widget _buildSettingCard(_SettingGroup group) { + Widget _buildSettingCard(List<_SettingItem> items) { return Container( padding: const EdgeInsets.symmetric(horizontal: 12), decoration: BoxDecoration( @@ -2330,14 +2314,14 @@ class _DeviceDetailPageV2State extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - for (int i = 0; i < group.items.length; i++) ...[ + for (int i = 0; i < items.length; i++) ...[ if (i > 0) const Divider( height: 1, thickness: 0.6, color: Color(0xFFF0F4FA), ), - _buildSettingRow(group.items[i]), + _buildSettingRow(items[i]), ], ], ), @@ -2346,15 +2330,8 @@ class _DeviceDetailPageV2State extends State { Widget _buildSettingRow(_SettingItem item) { final l10n = AppLocalizations.of(context); - final hasSwitch = item.switchValue != null; return GestureDetector( - onTap: hasSwitch - ? null - : (item.onTap ?? - () => CapsuleToast.show( - l10n.translate('device_list_v2.feature_todo'), - showCheck: false, - )), + onTap: item.onTap, behavior: HitTestBehavior.opaque, child: Padding( padding: const EdgeInsets.symmetric(vertical: 10), @@ -2364,10 +2341,16 @@ class _DeviceDetailPageV2State extends State { width: 34, height: 34, decoration: BoxDecoration( - color: const Color(0xFFEAF3FE), + color: item.onTap == null + ? _offlineBg + : const Color(0xFFEAF3FE), borderRadius: BorderRadius.circular(10), ), - child: Icon(item.icon, size: 18, color: _blue), + child: Icon( + item.icon, + size: 18, + color: item.onTap == null ? _offlineGray : _blue, + ), ), const SizedBox(width: 10), Expanded( @@ -2376,82 +2359,74 @@ class _DeviceDetailPageV2State extends State { children: [ Text( l10n.translate(item.title), - maxLines: 1, - overflow: TextOverflow.ellipsis, style: const TextStyle( fontSize: 13.5, fontWeight: FontWeight.w700, color: _navy, ), ), - const SizedBox(height: 2), - Text( - l10n.translate(item.subtitle), - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle(fontSize: 11, color: _gray), - ), + if (item.subtitle case final subtitle?) ...[ + const SizedBox(height: 2), + Text( + l10n.translate(subtitle), + style: const TextStyle(fontSize: 11, color: _gray), + ), + ], ], ), ), const SizedBox(width: 8), - if (hasSwitch) - SizedBox( - height: 30, - child: FittedBox( - fit: BoxFit.contain, - child: Switch( - value: item.switchValue!, - onChanged: item.onSwitchChanged, - activeThumbColor: Colors.white, - activeTrackColor: _blue, - inactiveThumbColor: Colors.white, - inactiveTrackColor: const Color(0xFFD8DFE9), + if (item.showUnavailableSwitch) + const ExcludeSemantics( + child: SizedBox( + height: 30, + child: FittedBox( + fit: BoxFit.contain, + child: Switch( + value: false, + onChanged: null, + thumbIcon: WidgetStatePropertyAll( + Icon(Icons.remove, size: 14), + ), + ), ), ), ) - else ...[ - if (item.badge != null) ...[ - _settingBadge(l10n.translate(item.badge!), green: item.badgeGreen), - const SizedBox(width: 4), - ], + else if (item.status case final status?) + Container( + padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 3), + decoration: BoxDecoration( + color: _offlineBg, + borderRadius: BorderRadius.circular(10), + ), + child: Text( + l10n.translate(status), + style: const TextStyle( + fontSize: 10.5, + fontWeight: FontWeight.w700, + color: _offlineGray, + ), + ), + ) + else if (item.onTap != null) const Icon( Icons.chevron_right, size: 18, color: Color(0xFFC9CDD4), ), - ], ], ), ), ); } - Widget _settingBadge(String text, {bool green = false}) { - return Container( - padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 3), - decoration: BoxDecoration( - color: green ? _onlineBg : const Color(0xFFE7F3FE), - borderRadius: BorderRadius.circular(10), - ), - child: Text( - text, - style: TextStyle( - fontSize: 10.5, - fontWeight: FontWeight.w700, - color: green ? const Color(0xFF1D9E57) : _blue, - ), - ), - ); - } - - /// 设置分组数据:所有设置项当前全机型展示。 - /// title/subtitle/badge 均存语言包 key,由渲染处 translate。 - /// 后续要按机型屏蔽某项,用 `_edition`(std/plus/pro)在这里判断即可,UI 不用动。 List<_SettingGroup> _settingGroups() { + // 上架版暂时隐藏视频、遥控偏好、声光、AI、人员跟随和地图参数入口。 return [ _SettingGroup( + icon: Icons.tune, title: 'device_detail_v2.set_group_device', + subtitle: 'device_detail_v2.set_group_device_sub', items: [ _SettingItem( icon: Icons.tune, @@ -2459,396 +2434,134 @@ class _DeviceDetailPageV2State extends State { subtitle: 'device_detail_v2.set_param_sub', onTap: _openParamSettings, ), - _SettingItem( + // OTA 接入后恢复固件升级页面入口。 + const _SettingItem( icon: Icons.system_update_alt, title: 'device_detail_v2.set_firmware', - subtitle: 'device_detail_v2.set_firmware_sub', - badge: 'device_detail_v2.set_check_update', - onTap: _openFirmware, + status: 'device_detail_v2.set_unavailable', ), ], ), const _SettingGroup( + icon: Icons.shield_outlined, title: 'device_detail_v2.set_group_blade', - trailingText: 'device_detail_v2.set_manage_perm', + subtitle: 'device_detail_v2.set_group_blade_sub', items: [ _SettingItem( icon: Icons.content_cut_outlined, title: 'device_detail_v2.set_obstacle_stop', - subtitle: 'device_detail_v2.set_obstacle_stop_sub', - badge: 'device_detail_v2.set_enabled', - badgeGreen: true, + subtitle: 'device_detail_v2.set_not_connected', + showUnavailableSwitch: true, ), _SettingItem( icon: Icons.shield_outlined, - title: 'device_detail_v2.set_blade_resume', - subtitle: 'device_detail_v2.set_blade_resume_sub', - badge: 'device_detail_v2.set_manual_confirm', - ), - _SettingItem( - icon: Icons.show_chart, - title: 'device_detail_v2.set_chassis', - subtitle: 'device_detail_v2.set_chassis_sub', - badge: 'device_detail_v2.set_view', - ), - ], - ), - _SettingGroup( - title: 'device_detail_v2.set_group_comm', - items: [ - _SettingItem( - icon: Icons.wifi, - title: 'device_detail_v2.set_network', - subtitle: 'device_detail_v2.set_network_sub', - onTap: _openNetworkLocation, - ), - const _SettingItem( - icon: Icons.videocam_outlined, - title: 'device_detail_v2.set_video', - subtitle: 'device_detail_v2.set_video_sub', - ), - ], - ), - const _SettingGroup( - title: 'device_detail_v2.set_group_map', - items: [ - _SettingItem( - icon: Icons.map_outlined, - title: 'device_detail_v2.set_map', - subtitle: 'device_detail_v2.set_map_sub', - ), - ], - ), - _SettingGroup( - title: 'device_detail_v2.set_group_safety', - items: [ - _SettingItem( - icon: Icons.content_cut_outlined, - title: 'device_detail_v2.set_auto_stop', - subtitle: 'device_detail_v2.set_auto_stop_sub', - switchValue: _autoStopBlade, - onSwitchChanged: (v) => setState(() => _autoStopBlade = v), - ), - _SettingItem( - icon: Icons.autorenew, title: 'device_detail_v2.set_auto_resume', - subtitle: 'device_detail_v2.set_auto_resume_sub', - switchValue: _autoResumeBlade, - onSwitchChanged: (v) => setState(() => _autoResumeBlade = v), - ), - _SettingItem( - icon: Icons.lightbulb_outline, - title: 'device_detail_v2.set_alarm', - subtitle: 'device_detail_v2.set_alarm_sub', - onTap: _openLightSound, - ), - ], - ), - const _SettingGroup( - title: 'device_detail_v2.set_group_control', - items: [ - _SettingItem( - icon: Icons.sports_esports_outlined, - title: 'device_detail_v2.set_rc_pref', - subtitle: 'device_detail_v2.set_rc_pref_sub', - badge: 'device_detail_v2.set_config', - ), - _SettingItem( - icon: Icons.videocam_outlined, - title: 'device_detail_v2.set_video_pref', - subtitle: 'device_detail_v2.set_video_sub', - badge: 'device_detail_v2.set_config', - ), - _SettingItem( - icon: Icons.lightbulb_outline, - title: 'device_detail_v2.set_light_pref', - subtitle: 'device_detail_v2.set_light_pref_sub', - badge: 'device_detail_v2.set_config', - ), - ], - ), - const _SettingGroup( - title: 'device_detail_v2.set_group_advanced', - items: [ - _SettingItem( - icon: Icons.smart_toy_outlined, - title: 'device_detail_v2.set_ai', - subtitle: 'device_detail_v2.set_ai_sub', - ), - _SettingItem( - icon: Icons.person_outline, - title: 'device_detail_v2.set_follow', - subtitle: 'device_detail_v2.set_follow_sub', - ), - _SettingItem( - icon: Icons.sports_esports_outlined, - title: 'device_detail_v2.set_remote_ctrl', - subtitle: 'device_detail_v2.set_remote_ctrl_sub', + subtitle: 'device_detail_v2.set_not_connected', + showUnavailableSwitch: true, ), ], ), _SettingGroup( - title: 'device_detail_v2.set_group_maintain', + icon: Icons.wifi, + title: 'device_detail_v2.set_group_network', + subtitle: 'device_detail_v2.set_net_loc_sub', items: [ _SettingItem( icon: Icons.wifi, title: 'device_detail_v2.set_net_loc', subtitle: 'device_detail_v2.set_net_loc_sub', - badge: 'device_detail_v2.set_view', onTap: _openNetworkLocation, ), - _SettingItem( - icon: Icons.system_update_alt, - title: 'device_detail_v2.set_firmware', - subtitle: 'device_detail_v2.set_firmware_sub_old', - badge: 'device_detail_v2.set_check_update', - onTap: _openFirmware, - ), ], ), ]; } - // ===== 故障状态:当前无故障(位于常用功能之上) ===== + // 故障详情接口接入前使用占位文案。 Widget _buildFaultSection() { final l10n = AppLocalizations.of(context); return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Row( - children: [ - Text( - l10n.translate('device_detail_v2.fault_state'), - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w800, - color: _navy, - ), - ), - const Spacer(), - GestureDetector( - onTap: () => CapsuleToast.show( - l10n.translate('device_list_v2.feature_todo'), - showCheck: false, - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - l10n.translate('device_detail_v2.view_detail'), - style: const TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - color: _blue, - ), - ), - const Icon(Icons.arrow_forward, size: 13, color: _blue), - ], - ), - ), - ], + Text( + l10n.translate('device_detail_v2.fault_state'), + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w800, + color: _navy, + ), ), const SizedBox(height: 10), - GestureDetector( - onTap: () => CapsuleToast.show( - l10n.translate('device_list_v2.feature_todo'), - showCheck: false, + Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16), + border: Border.all(color: const Color(0xFFE5EDF7)), ), - child: Container( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(16), - border: Border.all(color: const Color(0xFFE5EDF7)), - ), - child: Row( - children: [ - Container( - width: 40, - height: 40, - decoration: BoxDecoration( - color: _onlineBg, - borderRadius: BorderRadius.circular(12), - ), - child: Center( - child: Container( - width: 28, - height: 28, - decoration: const BoxDecoration( - color: _onlineGreen, - shape: BoxShape.circle, - ), - child: const Icon( - Icons.check, - color: Colors.white, - size: 16, + child: Row( + children: [ + Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: _offlineBg, + borderRadius: BorderRadius.circular(12), + ), + child: const Icon( + Icons.info_outline, + size: 22, + color: _offlineGray, + ), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + l10n.translate('device_detail_v2.fault_none'), + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w800, + color: _navy, ), ), - ), + const SizedBox(height: 2), + Text( + l10n.translate('device_detail_v2.fault_none_sub'), + style: const TextStyle(fontSize: 12, color: _gray), + ), + ], ), - const SizedBox(width: 12), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - l10n.translate('device_detail_v2.fault_none'), - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w800, - color: _navy, - ), - ), - const SizedBox(height: 2), - Text( - l10n.translate('device_detail_v2.fault_none_sub'), - style: const TextStyle(fontSize: 12, color: _gray), - ), - ], - ), - ), - const Icon( - Icons.chevron_right, - size: 20, - color: Color(0xFFC9CDD4), - ), - ], - ), + ), + ], ), ), ], ); } - // ===== 常用功能:六磁贴(导航入口,不重建功能页) ===== - Widget _buildFunctionSection() { - final l10n = AppLocalizations.of(context); - final tiles = <(IconData, String, VoidCallback)>[ - ( - Icons.videocam_outlined, - l10n.translate('device_detail_v2.fn_realtime_video'), - () => Navigator.of( + Widget _buildFunctionSection() => DeviceQuickActions( + preferences: GetIt.I(), + actions: { + 'fn_realtime_video': ( + icon: Icons.videocam_outlined, + onTap: () => Navigator.of( context, ).push(MaterialPageRoute(builder: (_) => const LocalCameraPage())), ), - // 远程遥控:一键直进手动控制 HUD(旧控制详情页 + 选模式弹窗不再在这条链路里) - ( - Icons.sports_esports_outlined, - l10n.translate('device_detail_v2.fn_remote'), - _openManualControlHud, + 'fn_remote': ( + icon: Icons.sports_esports_outlined, + onTap: _openManualControlHud, ), - ( - Icons.my_location_outlined, - l10n.translate('device_detail_v2.fn_find'), - _openFindRobot, - ), - ( - Icons.power_settings_new, - l10n.translate('device_detail_v2.fn_app_power'), - _openAppPower, - ), - ( - Icons.warning_amber_outlined, - l10n.translate('device_detail_v2.fn_fault'), - _openFaultCenter, - ), - ( - Icons.sensors_outlined, - l10n.translate('device_detail_v2.fn_sensor'), - _openSensor, - ), - ]; - return Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Row( - children: [ - Text( - l10n.translate('device_detail_v2.fn_title'), - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w800, - color: _navy, - ), - ), - const Spacer(), - GestureDetector( - onTap: () => CapsuleToast.show( - l10n.translate('device_list_v2.feature_todo'), - showCheck: false, - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const Icon(Icons.edit_outlined, size: 13, color: _blue), - const SizedBox(width: 4), - Text( - l10n.translate('device_detail_v2.fn_edit_order'), - style: const TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - color: _blue, - ), - ), - ], - ), - ), - ], - ), - const SizedBox(height: 8), - Row( - children: [ - Expanded(child: _tile(tiles[0])), - const SizedBox(width: 10), - Expanded(child: _tile(tiles[1])), - const SizedBox(width: 10), - Expanded(child: _tile(tiles[2])), - ], - ), - const SizedBox(height: 8), - Row( - children: [ - Expanded(child: _tile(tiles[3])), - const SizedBox(width: 10), - Expanded(child: _tile(tiles[4])), - const SizedBox(width: 10), - Expanded(child: _tile(tiles[5])), - ], - ), - ], - ); - } - - Widget _tile((IconData, String, VoidCallback) t) { - final (icon, label, onTap) = t; - return GestureDetector( - onTap: onTap, - child: Container( - padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 4), - decoration: BoxDecoration( - color: _statBg, - borderRadius: BorderRadius.circular(12), - border: Border.all(color: const Color(0xFFD9E8F8)), - ), - child: Column( - children: [ - Icon(icon, size: 22, color: _blue), - const SizedBox(height: 6), - Text( - label, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - color: _navy, - ), - ), - ], - ), - ), - ); - } + 'fn_find': (icon: Icons.my_location_outlined, onTap: _openFindRobot), + 'fn_app_power': (icon: Icons.power_settings_new, onTap: _openAppPower), + // 上架版暂时隐藏这两个常用功能入口。 + // 'fn_fault': (icon: Icons.warning_amber_outlined, onTap: _openFaultCenter), + // 'fn_sensor': (icon: Icons.sensors_outlined, onTap: _openSensor), + }, + ); /// 一键寻车:公共底部弹窗(与全部功能中心同一实现) void _openFindRobot() { @@ -2914,25 +2627,15 @@ class _DeviceDetailPageV2State extends State { ); } - /// 故障诊断:进「故障诊断中心」页(与全部功能中心同一页) - void _openFaultCenter() { - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => RobotFaultCenterPageV2(robot: widget.robot), - ), - ); - } - - /// 固件与OTA升级:进「软件与固件升级」页 - void _openFirmware() { - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => RobotFirmwarePageV2(robot: widget.robot), - ), - ); - } + // 保留旧故障诊断跳转,供常用功能入口恢复时使用。 + // void _openFaultCenter() { + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (_) => RobotFaultCenterPageV2(robot: widget.robot), + // ), + // ); + // } /// 网络与定位参数:进「网络与定位设置」页 void _openNetworkLocation() { @@ -2944,14 +2647,8 @@ class _DeviceDetailPageV2State extends State { ); } - /// 运行记录:进「运行记录与健康分析」页(作业记录、查看全部共用) - void _openRunRecord() { - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => RobotRunRecordPageV2(robot: widget.robot), - ), - ); + void _openWorkRecord() { + Navigator.of(context).push(WorkRecordPageV2.route(robot: widget.robot)); } /// 传感器监测:进「传感器与通信详情」页(与全部功能中心同一页) @@ -3012,6 +2709,31 @@ class _DeviceDetailPageV2State extends State { }; } + /// 复用远程遥控的实时模式及切换用例,只切换模式,不启动控制循环或作业。 + Future _openControlModeSwitch() async { + if (_modeDialogOpen) return; + _modeDialogOpen = true; + try { + final accepted = await showControlModeEntryDialog( + context, + deviceId: widget.robot.name, + deviceName: _displayName, + target: ControlModeTarget.remote, + allowTargetSelection: true, + ); + if (mounted && accepted) { + CapsuleToast.show( + AppLocalizations.of( + context, + ).translate('device_control_mode.switch_confirmed'), + showCheck: true, + ); + } + } finally { + _modeDialogOpen = false; + } + } + // ===== 远程遥控前置:构造与旧直进分支逐行一致的待控制设备 ===== DeviceEntity _prepareControlTarget() { final robot = widget.robot; diff --git a/lib/features/v2/device_list/presentation/pages/device_status_page_v2.dart b/lib/features/v2/device_list/presentation/pages/device_status_page_v2.dart index d58a6796..54415924 100644 --- a/lib/features/v2/device_list/presentation/pages/device_status_page_v2.dart +++ b/lib/features/v2/device_list/presentation/pages/device_status_page_v2.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; +// import 'package:maibu_satabot_v2/components/app_logo.dart'; import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; import 'package:maibu_satabot_v2/core/theme/AppTheme.dart'; import '../../../../../core/di/injection.dart'; @@ -40,6 +41,7 @@ import 'bind_device_page_v2.dart'; import 'no_device_page_v2.dart'; import 'package:maibu_satabot_v2/components/capsule_toast.dart'; import '../widgets/device_card_v2.dart'; +import '../widgets/overview_device_telemetry.dart'; import '../widgets/rename_device_dialog.dart'; import 'package:maibu_satabot_v2/features/pv_control/presentation/widgets/pv_work_map.dart'; import '../../data/models/robot_data_model.dart'; @@ -57,7 +59,9 @@ import 'package:get_it/get_it.dart'; /// 卡片点击跳转、蓝牙连接流程等逻辑与旧页逐行一致,仅替换视觉层; /// 旧页保留可随时回退(main_wrapper 切回 DeviceStatusPage 即可)。 class DeviceStatusPageV2 extends StatelessWidget { - const DeviceStatusPageV2({super.key}); + const DeviceStatusPageV2({super.key, this.isActive = true}); + + final bool isActive; @override Widget build(BuildContext context) { @@ -74,14 +78,16 @@ class DeviceStatusPageV2 extends StatelessWidget { // 设备改名:UI 只调 Cubit,不直接依赖 UseCase/DataSource BlocProvider(create: (_) => sl()), ], - child: const DeviceStatusViewV2(), + child: DeviceStatusViewV2(isActive: isActive), ); } } /// 设备状态视图 V2 class DeviceStatusViewV2 extends StatefulWidget { - const DeviceStatusViewV2({super.key}); + const DeviceStatusViewV2({super.key, this.isActive = true}); + + final bool isActive; @override State createState() => _DeviceStatusViewV2State(); @@ -89,6 +95,8 @@ class DeviceStatusViewV2 extends StatefulWidget { class _DeviceStatusViewV2State extends State { final _searchController = TextEditingController(); + final _v2SearchController = TextEditingController(); + final _v2SearchFocus = FocusNode(); /// 🔥 监听电站切换:只要电站发生变化,就根据当前选中的标签栏自动刷新对应接口 StreamSubscription? _siteSub; @@ -138,6 +146,8 @@ class _DeviceStatusViewV2State extends State { void dispose() { _siteSub?.cancel(); _searchController.dispose(); + _v2SearchController.dispose(); + _v2SearchFocus.dispose(); super.dispose(); } @@ -462,7 +472,7 @@ class _DeviceStatusViewV2State extends State { final offlineCount = items .where((e) => e.status == DeviceV2Status.offline) .length; - final visible = switch (_statusFilter) { + final statusMatches = switch (_statusFilter) { 'online' => items.where((e) => e.status != DeviceV2Status.offline).toList(), 'working' => @@ -471,6 +481,10 @@ class _DeviceStatusViewV2State extends State { items.where((e) => e.status == DeviceV2Status.offline).toList(), _ => items, }; + final query = _v2SearchController.text.trim().toLowerCase(); + final visible = query.isEmpty + ? statusMatches + : statusMatches.where((item) => item.matchesSearch(query)).toList(); // 集中概览模式:统计卡 + 设备分布地图 + 复用状态药丸 + 设备表格 if (_viewMode == 'overview') { @@ -506,7 +520,7 @@ class _DeviceStatusViewV2State extends State { // 搜索框 + 状态药丸用 SliverPersistentHeader 吸顶 child: RefreshIndicator( color: _v2Blue, - edgeOffset: _v2PinnedExtentCard, + edgeOffset: _v2PinnedFilterExtent, onRefresh: () async { // 与旧「全部」下拉刷新一致:统计 + 两个列表一起重拉 context.read().add( @@ -516,6 +530,8 @@ class _DeviceStatusViewV2State extends State { }, child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), + keyboardDismissBehavior: + ScrollViewKeyboardDismissBehavior.onDrag, slivers: [ SliverToBoxAdapter( child: Column( @@ -527,22 +543,11 @@ class _DeviceStatusViewV2State extends State { ], ), ), - SliverPersistentHeader( - pinned: true, - delegate: _V2PinnedHeaderDelegate( - extent: _v2PinnedExtentCard, - child: Column( - children: [ - _buildV2SearchBox(), - _buildStatusPills( - items.length, - onlineCount, - workingCount, - offlineCount, - ), - ], - ), - ), + _buildV2Filters( + items.length, + onlineCount, + workingCount, + offlineCount, ), if (stillLoading) const SliverToBoxAdapter( @@ -791,22 +796,19 @@ class _DeviceStatusViewV2State extends State { } } - // ===== V2 顶栏:logo + 铃铛/蓝色⊕(与无设备页同款) ===== + // ===== V2 顶栏:添加设备按钮(与无设备页同款) ===== Widget _buildV2TopBar(BuildContext context) { return Padding( padding: const EdgeInsets.fromLTRB(16, 8, 16, 0), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Image.asset( - 'assets/images/me_left_logo.png', - height: 44, - fit: BoxFit.contain, - ), + // const AppLogo(size: 44), // 暂时隐藏设备页左上角 Logo。 + const Spacer(), Row( children: [ - _buildV2TopIconButton(Icons.notifications_none, onTap: _v2Todo), - const SizedBox(width: 10), + // 上架版隐藏消息入口,接入真实通知后恢复。 + // _buildV2TopIconButton(Icons.notifications_none, onTap: _v2Todo), + // const SizedBox(width: 10), _buildV2TopIconButton( Icons.add, onTap: () => _showV2AddSheet(context), @@ -1102,33 +1104,88 @@ class _DeviceStatusViewV2State extends State { ); } - // ===== 搜索框:纯展示。后端设备列表缺对应字段,暂不接搜索 ===== + Widget _buildV2Filters(int all, int online, int working, int offline) { + return SliverPersistentHeader( + pinned: true, + delegate: _V2PinnedHeaderDelegate( + extent: _v2PinnedFilterExtent, + child: Column( + children: [ + _buildV2SearchBox(), + _buildStatusPills(all, online, working, offline), + ], + ), + ), + ); + } + Widget _buildV2SearchBox() { + final hint = AppLocalizations.of( + context, + ).translate('device_list_v2.search_hint_full'); return Padding( padding: const EdgeInsets.fromLTRB(16, 12, 16, 0), - child: IgnorePointer( - child: Container( - height: 44, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(14), - border: Border.all(color: _v2Border), - ), - child: Row( - children: [ - const SizedBox(width: 14), - const Icon(Icons.search, size: 20, color: Color(0xFFC9CDD4)), - const SizedBox(width: 10), - Text( - AppLocalizations.of( - context, - ).translate('device_list_v2.search_hint_full'), - style: const TextStyle( - fontSize: 14, - color: Color(0xFFB9C2CF), + child: TextFieldTapRegion( + child: GestureDetector( + onTap: _v2SearchFocus.requestFocus, + child: Container( + height: 44, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(14), + border: Border.all(color: _v2Border), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const SizedBox(width: 14), + const Icon(Icons.search, size: 20, color: Color(0xFFC9CDD4)), + const SizedBox(width: 10), + Expanded( + child: Stack( + alignment: Alignment.centerLeft, + children: [ + Semantics( + label: hint, + child: TextField( + controller: _v2SearchController, + focusNode: _v2SearchFocus, + textInputAction: TextInputAction.search, + style: const TextStyle(fontSize: 14, color: _v2Navy), + cursorColor: _v2Blue, + onChanged: (_) => setState(() {}), + decoration: null, + ), + ), + if (_v2SearchController.text.isEmpty) + IgnorePointer( + child: ExcludeSemantics( + child: Text( + hint, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 14, + color: Color(0xFFB9C2CF), + ), + ), + ), + ), + ], + ), ), - ), - ], + if (_v2SearchController.text.isNotEmpty) + IconButton( + tooltip: MaterialLocalizations.of( + context, + ).clearButtonTooltip, + icon: const Icon(Icons.close, size: 18, color: _v2Gray), + onPressed: () => setState(_v2SearchController.clear), + ) + else + const SizedBox(width: 14), + ], + ), ), ), ), @@ -1212,9 +1269,11 @@ class _DeviceStatusViewV2State extends State { children: [ _buildOverviewAppBar(), Expanded( - // 与卡片视图同口径:标题/视图切换随内容滚走,状态药丸吸顶 + // 标题和视图切换随内容滚动,搜索和状态筛选吸顶。 child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), + keyboardDismissBehavior: + ScrollViewKeyboardDismissBehavior.onDrag, slivers: [ SliverToBoxAdapter( child: Column( @@ -1224,17 +1283,11 @@ class _DeviceStatusViewV2State extends State { ], ), ), - SliverPersistentHeader( - pinned: true, - delegate: _V2PinnedHeaderDelegate( - extent: _v2PinnedExtentPills, - child: _buildStatusPills( - all, - onlineCount, - workingCount, - offlineCount, - ), - ), + _buildV2Filters( + all, + onlineCount, + workingCount, + offlineCount, ), SliverToBoxAdapter( child: Padding( @@ -1328,7 +1381,7 @@ class _DeviceStatusViewV2State extends State { ); } - /// 四张统计卡:设备总数 / 在线设备 / 作业中 / 告警离线 + /// 四张统计卡:设备总数 / 在线设备 / 作业中 / 离线 Widget _buildStatCards(int all, int online, int working, int offline) { final l10n = AppLocalizations.of(context); final stats = [ @@ -1346,10 +1399,10 @@ class _DeviceStatusViewV2State extends State { l10n.translate('device_list_v2.stat_working'), ), ( - Icons.warning_amber_rounded, - const Color(0xFFE5484D), + Icons.link_off, + const Color(0xFF6B7280), offline, - l10n.translate('device_list_v2.stat_alarm_offline'), + l10n.translate('device_list_v2.offline'), ), ]; return Row( @@ -1494,7 +1547,7 @@ class _DeviceStatusViewV2State extends State { child: Text( AppLocalizations.of( context, - ).translate('device_list_v2.th_location_task'), + ).translate('device_detail_v2.stat_control_mode'), style: const TextStyle(fontSize: 12, color: _v2Gray), ), ), @@ -1567,31 +1620,7 @@ class _DeviceStatusViewV2State extends State { ), ), Expanded(flex: 3, child: _buildOverviewBadge(e.status)), - Expanded( - flex: 2, - child: Text( - _buildOverviewBattery(e), - style: const TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - color: _v2Navy, - ), - ), - ), - Expanded( - flex: 4, - child: Text( - e.robot != null - ? '${DeviceV2Display.locationOf(e.snKey, AppLocalizations.of(context))} · ${e.robot!.task}' - : DeviceV2Display.locationOf( - e.snKey, - AppLocalizations.of(context), - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle(fontSize: 11, color: _v2Gray), - ), - ), + Expanded(flex: 6, child: _buildOverviewTelemetry(e)), const Icon(Icons.chevron_right, size: 18, color: Color(0xFFC9CDD4)), ], ), @@ -1648,10 +1677,18 @@ class _DeviceStatusViewV2State extends State { ); } - String _buildOverviewBattery(_V2DeviceItem e) { - final b = e.battery; - if (e.status == DeviceV2Status.offline || b == null) return '—'; - return '$b%'; + Widget _buildOverviewTelemetry(_V2DeviceItem e) { + final sn = e.robot?.name.trim(); + final online = e.status != DeviceV2Status.offline; + final battery = e.battery; + return OverviewDeviceTelemetry( + deviceSn: widget.isActive && online && sn != null && sn.isNotEmpty + ? sn + : null, + batteryFallback: e.robot != null + ? '--' + : (battery == null ? '—' : '$battery%'), + ); } /// 行内设备缩略图:蓝渐变底 + logo;离线置灰 @@ -3160,12 +3197,8 @@ class _DeviceStatusViewV2State extends State { } } -/// V2 卡片列表的统一展示项:机器人 / 无人机机场二选一 -/// 吸顶过滤栏高度:卡片视图 = 搜索框(56) + 状态药丸(42) -const double _v2PinnedExtentCard = 98; - -/// 吸顶过滤栏高度:集中概览视图 = 状态药丸(42) -const double _v2PinnedExtentPills = 42; +/// 吸顶过滤栏高度 = 搜索框(56) + 状态药丸(42) +const double _v2PinnedFilterExtent = 98; /// 吸顶过滤栏:滚动压过内容时平滑补上底色与阴影,避免卡片从下方穿帮 class _V2PinnedHeaderDelegate extends SliverPersistentHeaderDelegate { @@ -3237,4 +3270,19 @@ class _V2DeviceItem { final int? battery; final RobotDataModel? robot; final DroneStationEntity? station; + + bool matchesSearch(String query) { + final fields = [ + name, + modelText, + snKey, + robot?.name, + robot?.productName, + robot?.productModel, + station?.deviceSn, + ]; + return fields.whereType().any( + (field) => field.toLowerCase().contains(query), + ); + } } diff --git a/lib/features/v2/device_list/presentation/pages/no_device_page_v2.dart b/lib/features/v2/device_list/presentation/pages/no_device_page_v2.dart index 26d3815b..ee391490 100644 --- a/lib/features/v2/device_list/presentation/pages/no_device_page_v2.dart +++ b/lib/features/v2/device_list/presentation/pages/no_device_page_v2.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:get_it/get_it.dart'; +// import 'package:maibu_satabot_v2/components/app_logo.dart'; import 'package:maibu_satabot_v2/components/capsule_toast.dart'; import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart'; import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; @@ -19,7 +20,7 @@ import 'qr_scanner_page_v2.dart'; /// DeviceStatusLoaded 且 devices 为空时,由 DeviceStatusView 整页切换到本页。 /// /// 说明: -/// - 顶栏按设计稿换新:SATA logo + 铃铛/⊕ 白底按钮; +/// - 顶栏右侧提供添加设备按钮; /// - 右上角按钮下方小字「(场站名)」为切换场站入口,个人角色追加「个人账号」说明; /// - 「添加机器人」与卡片蓝色 ⊕ 均弹出底部添加弹窗,内部各项保持原跳转; /// - 「新手入门」三条二级内容未开发,统一 Toast 提示; @@ -141,24 +142,20 @@ class NoDevicePageV2 extends StatelessWidget { ); } - // ===== 顶栏:logo + 铃铛/⊕(设计稿新样式) ===== + // ===== 顶栏:添加设备按钮 ===== Widget _buildTopBar(BuildContext context) { return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Image.asset( - 'assets/images/me_left_logo.png', - height: 44, - fit: BoxFit.contain, - ), + // const AppLogo(size: 44), // 暂时隐藏设备页左上角 Logo。 + const Spacer(), Row( children: [ - _buildTopIconButton( - Icons.notifications_none, - onTap: () => _todoTap(context), - ), - const SizedBox(width: 10), - // 设计稿:右上角 ⊕ 是蓝底白号主色按钮,与铃铛的白底按钮区分 + // 上架版隐藏消息入口,接入真实通知后恢复。 + // _buildTopIconButton( + // Icons.notifications_none, + // onTap: () => _todoTap(context), + // ), + // const SizedBox(width: 10), _buildTopIconButton( Icons.add, onTap: () => _showAddSheet(context), diff --git a/lib/features/v2/device_list/presentation/pages/robot_autonomous_work_page_v2.dart b/lib/features/v2/device_list/presentation/pages/robot_autonomous_work_page_v2.dart index 5b1b1ef5..68853b3e 100644 --- a/lib/features/v2/device_list/presentation/pages/robot_autonomous_work_page_v2.dart +++ b/lib/features/v2/device_list/presentation/pages/robot_autonomous_work_page_v2.dart @@ -3,6 +3,7 @@ import 'dart:async'; // import 'package:maibu_satabot_v2/features/device_control_mode/presentation/widgets/control_mode_entry_gate.dart'; import 'package:flutter/material.dart'; +import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:latlong2/latlong.dart'; @@ -70,6 +71,8 @@ class RobotAutonomousWorkPageV2 extends StatefulWidget { } class _RobotAutonomousWorkPageV2State extends State { + AppLocalizations get _l10n => AppLocalizations.of(context); + final _traceDiagnostics = WorkTraceDiagnostics(); /// 与原生 MainActivity 的窗口通道(挖孔区域占用控制) @@ -106,7 +109,10 @@ class _RobotAutonomousWorkPageV2State extends State { String get _deviceId => widget.robot.name; bool get _isOnline => widget.robot.isOnline; - String get _routeName => _route?.name ?? _session?.routeName ?? '未选择作业路线'; + String get _routeName => + _route?.name ?? + _session?.routeName ?? + _l10n.translate('autonomous_work.no_route'); List get _previewRoute => _route?.previewPoints ?? const []; /// 覆盖模式的作业区域边界框(自定义模式为空,与路径规划一致) @@ -125,19 +131,19 @@ class _RobotAutonomousWorkPageV2State extends State { s is DeviceStatusUpdated ? s.status : null; /// 定位质量枚举 → 文案(与设备数据监控 _getLocationQualityText 同口径) - static String _qualText(int? q) => switch (q) { - null => '未知', - 0 => '无定位', - 1 => '单点定位', - 2 => '差分定位', - 3 => '惯性导航', - 4 => 'RTK 固定解', - 5 => 'RTK 浮点解', - 6 => '单点(无航向)', - 7 => '差分(无航向)', - 8 => 'RTK 固定(无航向)', - 9 => 'RTK 浮点(无航向)', - _ => '未知', + String _qualText(int? q) => switch (q) { + null => _l10n.translate('common.unknown'), + 0 => _l10n.translate('pv_control.qual_none'), + 1 => _l10n.translate('pv_control.qual_single'), + 2 => _l10n.translate('pv_control.qual_differential'), + 3 => _l10n.translate('pv_control.qual_ins'), + 4 => _l10n.translate('pv_control.qual_rtk_fixed'), + 5 => _l10n.translate('pv_control.qual_rtk_float'), + 6 => _l10n.translate('autonomous_work.position_single_no_heading'), + 7 => _l10n.translate('autonomous_work.position_diff_no_heading'), + 8 => _l10n.translate('pv_control.qual_rtk_fixed_nh'), + 9 => _l10n.translate('pv_control.qual_rtk_float_nh'), + _ => _l10n.translate('common.unknown'), }; /// 是否 RTK 固定解(4=固定,8=固定无航向)——绿色高亮依据 @@ -257,7 +263,9 @@ class _RobotAutonomousWorkPageV2State extends State { _lastFinishedTaskId = task.taskId; _finishTraceTimer?.cancel(); CapsuleToast.show( - task.rawStatus == 'FINISH' ? '作业已完成' : '作业已结束', + task.rawStatus == 'FINISH' + ? _l10n.translate('autonomous_work.work_completed') + : _l10n.translate('autonomous_work.work_ended'), showCheck: true, ); _finishTraceTimer = Timer(const Duration(seconds: 1), () { @@ -368,7 +376,10 @@ class _RobotAutonomousWorkPageV2State extends State { final result = await _gateway.loadTasks(deviceId: _deviceId); if (!mounted) return; if (!result.isOk) { - CapsuleToast.show(result.error ?? '任务恢复失败', showCheck: false); + CapsuleToast.show( + result.error ?? _l10n.translate('autonomous_work.restore_failed'), + showCheck: false, + ); } } @@ -380,7 +391,10 @@ class _RobotAutonomousWorkPageV2State extends State { final route = widget.initialRoute; if (!mounted || route == null) return; if (_session != null && _phase == WorkRunState.running) { - CapsuleToast.show('作业执行中,已保留当前任务路线', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.route_kept'), + showCheck: false, + ); return; } if (await _selectRoute(route) && mounted) { @@ -393,7 +407,11 @@ class _RobotAutonomousWorkPageV2State extends State { _clearTraceSignal++; }); } - CapsuleToast.show('已选择路线:${route.name}'); + CapsuleToast.show( + _l10n.translate('autonomous_work.route_selected', { + 'route': route.name, + }), + ); } } @@ -415,7 +433,10 @@ class _RobotAutonomousWorkPageV2State extends State { return true; } CapsuleToast.show( - result.error ?? '「${route.name}」没有可用的路径数据', + result.error ?? + _l10n.translate('autonomous_work.route_no_geometry', { + 'route': route.name, + }), showCheck: false, ); return false; @@ -462,24 +483,37 @@ class _RobotAutonomousWorkPageV2State extends State { Future _startWork() async { final route = _route; if (route == null) { - CapsuleToast.show('请先在「路线库」选择作业路线', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.pick_route_first'), + showCheck: false, + ); return; } if (!_isOnline) { - CapsuleToast.show('设备离线,无法下发作业', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.dispatch_offline'), + showCheck: false, + ); return; } + final routeSummary = workRouteSummary(route, _l10n); final ok = await showWorkConfirmDialog( context, - title: '开始作业 · 二次确认', - desc: - '路线:${route.name}' - '${route.metaText != null ? ' · ${route.metaText}' : ''}' - '${route.hasGeometry ? '' : '(无路径数据,可能下发失败)'}' - '。确认后开始执行。', - checks: const ['设备已上电、控制权符合要求', '定位有效,路线及电子围栏匹配', '作业区域安全,割刀与急停互锁有效'], - confirmLabel: '确认开始作业', + title: _l10n.translate('autonomous_work.start_title'), + desc: _l10n.translate('autonomous_work.start_description', { + 'route': route.name, + 'details': routeSummary.isEmpty ? '' : ' · $routeSummary', + 'warning': route.hasGeometry + ? '' + : _l10n.translate('autonomous_work.no_path_warning'), + }), + checks: [ + _l10n.translate('autonomous_work.check_power'), + _l10n.translate('autonomous_work.check_location'), + _l10n.translate('autonomous_work.check_site'), + ], + confirmLabel: _l10n.translate('autonomous_work.start_confirm'), ); if (ok != true || !mounted) return; @@ -490,7 +524,10 @@ class _RobotAutonomousWorkPageV2State extends State { WorkTaskSnapshot? reuse; if (!pooled.isOk) { - CapsuleToast.show(pooled.error ?? '任务查询失败', showCheck: false); + CapsuleToast.show( + pooled.error ?? _l10n.translate('autonomous_work.task_query_failed'), + showCheck: false, + ); return; } final candidates = pooled.data ?? const []; @@ -507,7 +544,9 @@ class _RobotAutonomousWorkPageV2State extends State { // ② 已有任务跑的是别的路线:不静默覆盖,交给用户先处理 if (reuse != null && reuse.routeId != null && reuse.routeId != route.id) { CapsuleToast.show( - '设备上已有其它路线的任务(${reuse.routeName ?? reuse.routeId}),请先在「任务队列」处理', + _l10n.translate('autonomous_work.other_route_active', { + 'route': reuse.routeName ?? reuse.routeId, + }), showCheck: false, ); return; @@ -523,28 +562,42 @@ class _RobotAutonomousWorkPageV2State extends State { ); if (!mounted) return; if (!result.isOk) { - CapsuleToast.show(result.error ?? '作业下发失败', showCheck: false); + CapsuleToast.show( + result.error ?? _l10n.translate('autonomous_work.dispatch_failed'), + showCheck: false, + ); return; } _startedByUser = result.data?.state == WorkRunState.queued; _applySession(result.data); - CapsuleToast.show('作业已下发:${route.name}'); + CapsuleToast.show( + _l10n.translate('autonomous_work.dispatched_route', { + 'route': route.name, + }), + ); }); } Future _pauseWork() async { final task = _session; if (task == null) { - CapsuleToast.show('当前没有可暂停的任务', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.no_pausing_task'), + showCheck: false, + ); return; } final ok = await showWorkConfirmDialog( context, - title: '暂停作业 · 确认', - desc: '暂停后保留当前任务ID、路线及作业断点;机器人需要先完成安全停止。', - checks: const ['行驶速度降至安全状态', '割刀按任务安全暂停策略停转', '保存断点位置与已覆盖区域'], - confirmLabel: '确认暂停', + title: _l10n.translate('autonomous_work.pause_title'), + desc: _l10n.translate('autonomous_work.pause_description'), + checks: [ + _l10n.translate('autonomous_work.check_pause_speed'), + _l10n.translate('autonomous_work.check_pause_blade'), + _l10n.translate('autonomous_work.check_pause_progress'), + ], + confirmLabel: _l10n.translate('autonomous_work.pause_confirm'), ); if (ok != true || !mounted) return; @@ -552,26 +605,36 @@ class _RobotAutonomousWorkPageV2State extends State { final result = await _gateway.pauseWork(deviceId: _deviceId, task: task); if (!mounted) return; if (!result.isOk) { - CapsuleToast.show(result.error ?? '暂停失败', showCheck: false); + CapsuleToast.show( + result.error ?? _l10n.translate('autonomous_work.pause_failed'), + showCheck: false, + ); return; } _applySession(result.data); - CapsuleToast.show('已下发暂停指令'); + CapsuleToast.show(_l10n.translate('autonomous_work.pause_sent')); }); } Future _stopWork() async { final task = _session; if (task == null) { - CapsuleToast.show('当前没有可停止的任务', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.no_stopping_task'), + showCheck: false, + ); return; } final ok = await showWorkConfirmDialog( context, - title: '停止作业 · 二次确认', - desc: '本次任务将被终止,不会自动续作。已完成区域、轨迹与停止时间会保存到作业记录。', - checks: const ['先安全停止底盘与割刀', '记录人工停止原因与实际完成区域', '已终止任务不能用“继续”恢复'], - confirmLabel: '确认停止作业', + title: _l10n.translate('autonomous_work.stop_title'), + desc: _l10n.translate('autonomous_work.stop_description'), + checks: [ + _l10n.translate('autonomous_work.check_stop_hardware'), + _l10n.translate('autonomous_work.check_stop_record'), + _l10n.translate('autonomous_work.check_stop_final'), + ], + confirmLabel: _l10n.translate('autonomous_work.stop_confirm'), danger: true, ); if (ok != true || !mounted) return; @@ -580,29 +643,41 @@ class _RobotAutonomousWorkPageV2State extends State { final result = await _gateway.stopWork(deviceId: _deviceId, task: task); if (!mounted) return; if (!result.isOk) { - CapsuleToast.show(result.error ?? '停止失败', showCheck: false); + CapsuleToast.show( + result.error ?? _l10n.translate('autonomous_work.stop_failed'), + showCheck: false, + ); return; } // 先钉住「已结束」,再清空快照,避免 _applySession(null) 把阶段弹回准备 setState(() => _phase = WorkRunState.finished); _startedByUser = false; _applySession(null); - CapsuleToast.show('作业已停止'); + CapsuleToast.show(_l10n.translate('autonomous_work.work_stopped')); }); } Future _resumeWork() async { final task = _session; if (task == null) { - CapsuleToast.show('没有可继续的任务', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.no_resuming_task'), + showCheck: false, + ); return; } final ok = await showWorkConfirmDialog( context, - title: '继续 / 断点续作 · 确认', - desc: '继续原任务「$_routeName」,沿用原路线与已保存的覆盖区域。', - checks: const ['暂停或故障原因已消除', '任务ID、地图、路线与断点匹配', '定位质量、控制权限、割刀与底盘状态合格'], - confirmLabel: '确认继续作业', + title: _l10n.translate('autonomous_work.resume_title'), + desc: _l10n.translate('autonomous_work.resume_description', { + 'route': _routeName, + }), + checks: [ + _l10n.translate('autonomous_work.check_resume_cause'), + _l10n.translate('autonomous_work.check_resume_task'), + _l10n.translate('autonomous_work.check_resume_safety'), + ], + confirmLabel: _l10n.translate('autonomous_work.resume_confirm'), ); if (ok != true || !mounted) return; @@ -610,27 +685,36 @@ class _RobotAutonomousWorkPageV2State extends State { final result = await _gateway.resumeWork(deviceId: _deviceId, task: task); if (!mounted) return; if (!result.isOk) { - CapsuleToast.show(result.error ?? '继续失败', showCheck: false); + CapsuleToast.show( + result.error ?? _l10n.translate('autonomous_work.resume_failed'), + showCheck: false, + ); return; } _startedByUser = result.data?.state == WorkRunState.queued; _applySession(result.data); - CapsuleToast.show('已下发继续指令'); + CapsuleToast.show(_l10n.translate('autonomous_work.resume_sent')); }); } Future _cancelQueued() async { final task = _session; if (task == null) { - CapsuleToast.show('没有待取消的任务', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.no_canceling_task'), + showCheck: false, + ); return; } final ok = await showWorkConfirmDialog( context, - title: '取消待执行任务 · 确认', - desc: '取消只撤销尚未运行的任务,不会把运行中的任务当作取消处理。', - checks: const ['确认目标任务尚未开始执行', '取消后路线仍保留在路线库'], - confirmLabel: '确认取消任务', + title: _l10n.translate('autonomous_work.cancel_title'), + desc: _l10n.translate('autonomous_work.cancel_description'), + checks: [ + _l10n.translate('autonomous_work.check_cancel_queued'), + _l10n.translate('autonomous_work.check_cancel_route'), + ], + confirmLabel: _l10n.translate('autonomous_work.cancel_confirm'), danger: true, ); if (ok != true || !mounted) return; @@ -642,12 +726,15 @@ class _RobotAutonomousWorkPageV2State extends State { ); if (!mounted) return; if (!result.isOk) { - CapsuleToast.show(result.error ?? '取消失败', showCheck: false); + CapsuleToast.show( + result.error ?? _l10n.translate('autonomous_work.cancel_failed'), + showCheck: false, + ); return; } setState(() => _phase = WorkRunState.idle); _applySession(null); - CapsuleToast.show('已取消待执行任务'); + CapsuleToast.show(_l10n.translate('autonomous_work.task_canceled')); }); } @@ -659,7 +746,7 @@ class _RobotAutonomousWorkPageV2State extends State { context: context, barrierDismissible: false, builder: (dialogContext) => AlertDialog( - title: const Text('设备上存在多个活跃任务'), + title: Text(_l10n.translate('autonomous_work.multiple_active_tasks')), content: SizedBox( width: 420, child: Column( @@ -668,10 +755,14 @@ class _RobotAutonomousWorkPageV2State extends State { for (final task in tasks) ListTile( dense: true, - title: Text('任务 #${task.taskId}'), + title: Text( + _l10n.translate('autonomous_work.task_number', { + 'id': task.taskId, + }), + ), subtitle: Text( - '${task.routeName ?? task.routeId ?? '未知路线'}' - ' · ${task.state.label}' + '${task.routeName ?? task.routeId ?? _l10n.translate('autonomous_work.unknown_route')}' + ' · ${workRunStateLabel(task.state, _l10n)}' '${task.rawStatus.isEmpty ? '' : ' · ${task.rawStatus}'}', ), trailing: const Icon(Icons.chevron_right_rounded), @@ -683,7 +774,7 @@ class _RobotAutonomousWorkPageV2State extends State { actions: [ TextButton( onPressed: () => Navigator.of(dialogContext).pop(), - child: const Text('取消'), + child: Text(_l10n.translate('common.cancel')), ), ], ), @@ -693,7 +784,10 @@ class _RobotAutonomousWorkPageV2State extends State { // ===== 右侧功能栏 ===== Future _openRouteLibrary() async { if (!_gateway.capabilities.routeLibrary) { - CapsuleToast.show('当前环境未启用路线库', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.library_unavailable'), + showCheck: false, + ); return; } final result = await showWorkRouteLibraryPanel( @@ -705,7 +799,10 @@ class _RobotAutonomousWorkPageV2State extends State { if (result.editRequested) { if (!_gateway.capabilities.routeEditing) { - CapsuleToast.show('当前环境不支持在线编辑路线', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.online_edit_unavailable'), + showCheck: false, + ); return; } // 进「地图与区域编辑」:本页已是横屏,直接推入(自定义淡入 + 极轻缩放转场) @@ -726,7 +823,10 @@ class _RobotAutonomousWorkPageV2State extends State { final route = result.route; if (route == null) return; if (_phase == WorkRunState.running) { - CapsuleToast.show('作业执行中,请先暂停或停止后再更换路线', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.pause_before_route_change'), + showCheck: false, + ); return; } if (await _selectRoute(route) && mounted) { @@ -739,13 +839,20 @@ class _RobotAutonomousWorkPageV2State extends State { _clearTraceSignal++; }); } - CapsuleToast.show('已选择路线:${route.name}'); + CapsuleToast.show( + _l10n.translate('autonomous_work.route_selected', { + 'route': route.name, + }), + ); } } void _openTaskQueue() { if (!_gateway.capabilities.taskQueue) { - CapsuleToast.show('当前环境未启用任务队列', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.queue_unavailable'), + showCheck: false, + ); return; } showWorkTaskQueuePanel(context, deviceId: _deviceId); @@ -760,46 +867,69 @@ class _RobotAutonomousWorkPageV2State extends State { } void _onReturnHome() { - CapsuleToast.show('返航指令通道未接入(设备端未开放),仅作界面演示', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.return_demo'), + showCheck: false, + ); } void _openMorePanel() { showWorkRightPanel( context, builder: (close) => WorkPanelScaffold( - title: '更多功能', - desc: '以下为设备常用能力的快捷入口,点击后进入对应页面或面板。', + title: _l10n.translate('autonomous_work.more'), + desc: _l10n.translate('autonomous_work.more_description'), body: Column( children: [ _moreRow( Icons.sports_motorsports_outlined, - '手动遥控', - '进入遥控页(横屏)', + _l10n.translate('autonomous_work.manual_control'), + _l10n.translate('autonomous_work.manual_control_description'), () { close(); _pushLegacyControl(); }, ), const SizedBox(height: 8), - _moreRow(Icons.location_on_outlined, '一键寻车', '让机器人发出提示音并闪灯', () { - close(); - showFindRobotSheet(context, robot: widget.robot); - }), + _moreRow( + Icons.location_on_outlined, + _l10n.translate('pv_control.rail_find_vehicle'), + _l10n.translate('autonomous_work.find_description'), + () { + close(); + showFindRobotSheet(context, robot: widget.robot); + }, + ), const SizedBox(height: 8), - _moreRow(Icons.mic_none_outlined, '语音喊话', '远程语音播报', () { - close(); - showVoiceBroadcastSheet(context, robot: widget.robot); - }), + _moreRow( + Icons.mic_none_outlined, + _l10n.translate('device_detail_v2.op_voice'), + _l10n.translate('device_detail_v2.op_voice_sub'), + () { + close(); + showVoiceBroadcastSheet(context, robot: widget.robot); + }, + ), const SizedBox(height: 8), - _moreRow(Icons.lightbulb_outline, '灯光与声光', '灯光与提示音偏好', () { - close(); - _pushPortrait(RobotLightSoundPageV2(robot: widget.robot)); - }), + _moreRow( + Icons.lightbulb_outline, + _l10n.translate('device_detail_v2.op_light'), + _l10n.translate('autonomous_work.light_sound_description'), + () { + close(); + _pushPortrait(RobotLightSoundPageV2(robot: widget.robot)); + }, + ), const SizedBox(height: 8), - _moreRow(Icons.sensors_outlined, '传感器与运行状态', '查看传感器与实时状态详情', () { - close(); - _pushPortrait(RobotSensorPageV2(robot: widget.robot)); - }), + _moreRow( + Icons.sensors_outlined, + _l10n.translate('autonomous_work.sensors_status'), + _l10n.translate('autonomous_work.sensors_description'), + () { + close(); + _pushPortrait(RobotSensorPageV2(robot: widget.robot)); + }, + ), ], ), ), @@ -978,7 +1108,7 @@ class _RobotAutonomousWorkPageV2State extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - '自主作业中心', + _l10n.translate('autonomous_work.title'), maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -1044,7 +1174,10 @@ class _RobotAutonomousWorkPageV2State extends State { String _topSubtitle() { final alias = widget.robot.alias; final name = alias != null && alias.isNotEmpty ? alias : widget.robot.name; - return '$name · ${widget.robot.type} · PLUS 智能版'; + return _l10n.translate('autonomous_work.robot_model', { + 'name': name, + 'type': widget.robot.type, + }); } Widget _topBackButton(_WorkLayout m) { @@ -1089,7 +1222,9 @@ class _RobotAutonomousWorkPageV2State extends State { ), SizedBox(width: (5 * k).clamp(3.0, 5.0)), Text( - _isOnline ? '在线' : '离线', + _isOnline + ? _l10n.translate('pv_control.online') + : _l10n.translate('pv_control.offline'), style: TextStyle( fontSize: m.topChipFont, height: 1.1, @@ -1134,7 +1269,7 @@ class _RobotAutonomousWorkPageV2State extends State { borderRadius: BorderRadius.circular(999), ), child: Text( - state.label, + workRunStateLabel(state, _l10n), style: TextStyle( fontSize: m.topChipFont, height: 1.1, @@ -1204,7 +1339,9 @@ class _RobotAutonomousWorkPageV2State extends State { // 只展实时电量(host/realTime/message);未收到数据时显示“未知”, // 不回退设备列表的静态电量(列表值常为默认 100%,会误导)。 final fg = pct == null ? kWtMuted : (pct > 20 ? kWtGreen : kWtDanger); - final text = pct == null ? '未知' : '${pct.round()}%'; + final text = pct == null + ? _l10n.translate('common.unknown') + : '${pct.round()}%'; return Row( mainAxisSize: MainAxisSize.min, children: [ @@ -1257,7 +1394,7 @@ class _RobotAutonomousWorkPageV2State extends State { border: Border.all(color: kWtBorder), ), child: Text( - '状态详情', + _l10n.translate('autonomous_work.status_details'), style: TextStyle( fontSize: (13.5 * k).clamp(10.0, 13.5), height: 1.1, @@ -1286,7 +1423,9 @@ class _RobotAutonomousWorkPageV2State extends State { child: ConstrainedBox( constraints: BoxConstraints(maxWidth: m.size.width * 0.4), child: _mapHintPill( - '当前任务正在执行,修改路线前需要安全暂停', + _l10n.translate( + 'autonomous_work.route_change_requires_pause', + ), icon: Icons.info_outline_rounded, color: kWtWarn, fontSize: compact ? 10 : 11.5, @@ -1304,7 +1443,9 @@ class _RobotAutonomousWorkPageV2State extends State { child: ConstrainedBox( constraints: BoxConstraints(maxWidth: m.size.width * 0.5), child: _mapHintPill( - '「${route.name}」无路径数据,地图上无法显示轨迹', + _l10n.translate('autonomous_work.cannot_plot_route', { + 'route': route.name, + }), icon: Icons.wrong_location_outlined, color: kWtDanger, fontSize: compact ? 10 : 11.5, @@ -1428,7 +1569,7 @@ class _RobotAutonomousWorkPageV2State extends State { SizedBox(width: m.tiny ? 5 : 7), Expanded( child: Text( - '机器人信息', + _l10n.translate('device_detail_v2.op_robot_info'), style: TextStyle( fontSize: m.fsx(14, 10), fontWeight: FontWeight.w800, @@ -1537,40 +1678,59 @@ class _RobotAutonomousWorkPageV2State extends State { children: [ _kvRow( m, - '设备运行', + _l10n.translate('autonomous_work.device_status'), _runText(), color: _phase.isPaused ? kWtWarn : (_phase.isRunning ? kWtGreen : kWtNavy), ), - _kvRow(m, '当前任务', _taskText()), _kvRow( m, - '电量', - battery == null ? '未知' : '${battery.round()}%', + _l10n.translate('pv_control.task_current'), + _taskText(), ), _kvRow( m, - '定位', + _l10n.translate('device_list_v2.battery_level'), + battery == null + ? _l10n.translate('common.unknown') + : '${battery.round()}%', + ), + _kvRow( + m, + _l10n.translate('route_planning.location'), _qualText(st?.qual), color: fixed ? kWtGreen : kWtNavy, ), _kvRow( m, - '割刀状态', - knife == null ? '未知' : (knife > 0 ? '运行中' : '已停止'), + _l10n.translate('pv_control.mower_status'), + knife == null + ? _l10n.translate('common.unknown') + : (knife > 0 + ? _l10n.translate( + 'pv_control.mower_running', + ) + : _l10n.translate( + 'autonomous_work.stopped', + )), color: (knife != null && knife > 0) ? kWtGreen : kWtNavy, ), _kvRow( m, - '行驶速度', + _l10n.translate('pv_control.drive_speed'), speed == null ? '-- m/s' : '${speed.abs().toStringAsFixed(1)} m/s', ), - _kvRow(m, '当前故障', '0 项', color: kWtGreen), + _kvRow( + m, + _l10n.translate('autonomous_work.current_faults'), + _l10n.translate('autonomous_work.no_fault_count'), + color: kWtGreen, + ), ], ); }, @@ -1598,7 +1758,7 @@ class _RobotAutonomousWorkPageV2State extends State { borderRadius: BorderRadius.circular(10), ), child: Text( - '查看传感器与运行状态 ›', + _l10n.translate('autonomous_work.view_sensors'), maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -1626,23 +1786,23 @@ class _RobotAutonomousWorkPageV2State extends State { String _runText() { switch (_phase) { case WorkRunState.running: - return '自主作业中'; + return _l10n.translate('device_list_v2.work_text_working'); case WorkRunState.paused: - return '作业已暂停'; + return _l10n.translate('autonomous_work.work_paused'); case WorkRunState.queued: - return '等待执行'; + return _l10n.translate('autonomous_work.waiting'); case WorkRunState.failed: - return '作业异常中断'; + return _l10n.translate('autonomous_work.work_interrupted'); case WorkRunState.idle: case WorkRunState.finished: - return '待机'; + return _l10n.translate('device_list_v2.work_text_online'); } } String _taskText() { switch (_phase) { case WorkRunState.idle: - return '暂无进行中'; + return _l10n.translate('autonomous_work.no_running_task'); case WorkRunState.queued: case WorkRunState.running: case WorkRunState.paused: @@ -1688,12 +1848,14 @@ class _RobotAutonomousWorkPageV2State extends State { final task = _session; final progress = task?.progress; // null = 该环境不提供进度 final subTitle = switch (_phase) { - WorkRunState.running => '当前任务 · 执行中', - WorkRunState.paused => '当前任务 · 已暂停', - WorkRunState.failed => '当前任务 · 异常中断', - WorkRunState.queued => '当前任务 · 待执行', - WorkRunState.idle => '当前任务 · 未开始', - WorkRunState.finished => '当前任务 · 已结束', + WorkRunState.running => _l10n.translate('autonomous_work.task_running'), + WorkRunState.paused => _l10n.translate('autonomous_work.task_paused'), + WorkRunState.failed => _l10n.translate( + 'autonomous_work.task_interrupted', + ), + WorkRunState.queued => _l10n.translate('autonomous_work.task_queued'), + WorkRunState.idle => _l10n.translate('autonomous_work.task_not_started'), + WorkRunState.finished => _l10n.translate('autonomous_work.task_ended'), }; return Container( padding: EdgeInsets.all(m.compact ? 10 : 14), @@ -1735,17 +1897,30 @@ class _RobotAutonomousWorkPageV2State extends State { ), ), const SizedBox(height: 12), - _kvRow(m, '任务编号', task == null ? '—' : '#${task.taskId}'), _kvRow( m, - '任务状态', - task == null || task.rawStatus.isEmpty - ? _phase.label - : '${_phase.label} · ${task.rawStatus}', + _l10n.translate('pv_control.task_field_no'), + task == null ? '—' : '#${task.taskId}', + ), + _kvRow( + m, + _l10n.translate('pv_control.task_field_status'), + task == null || task.rawStatus.isEmpty + ? workRunStateLabel(_phase, _l10n) + : '${workRunStateLabel(_phase, _l10n)} · ${task.rawStatus}', + ), + _kvRow(m, _l10n.translate('work_v2.all_work.route'), _routeName), + if (task?.routeId != null) + _kvRow( + m, + _l10n.translate('pv_control.task_field_route'), + task!.routeId!, + ), + _kvRow( + m, + _l10n.translate('autonomous_work.dispatched_at'), + task?.createdAt ?? '—', ), - _kvRow(m, '作业路线', _routeName), - if (task?.routeId != null) _kvRow(m, '路线编号', task!.routeId!), - _kvRow(m, '下发时间', task?.createdAt ?? '—'), ], ), ); @@ -1757,13 +1932,43 @@ class _RobotAutonomousWorkPageV2State extends State { final caps = _gateway.capabilities; final items = <(IconData, String, VoidCallback, Color)>[ if (caps.routeLibrary) - (Icons.route_outlined, '路线库', _openRouteLibrary, kWtNavy), - (Icons.tune_rounded, '作业设置', _openSettingPanel, kWtNavy), - (Icons.assignment_outlined, '作业记录', _openRecordPanel, kWtNavy), - (Icons.home_outlined, '一键返航', _onReturnHome, kWtDanger), + ( + Icons.route_outlined, + _l10n.translate('work_v2.feature_route_library'), + _openRouteLibrary, + kWtNavy, + ), + ( + Icons.tune_rounded, + _l10n.translate('autonomous_work.settings'), + _openSettingPanel, + kWtNavy, + ), + ( + Icons.assignment_outlined, + _l10n.translate('work_v2.feature_record'), + _openRecordPanel, + kWtNavy, + ), + ( + Icons.home_outlined, + _l10n.translate('pv_control.rail_return_home'), + _onReturnHome, + kWtDanger, + ), if (caps.taskQueue) - (Icons.list_alt_rounded, '任务队列', _openTaskQueue, kWtNavy), - (Icons.more_horiz_rounded, '更多功能', _openMorePanel, kWtNavy), + ( + Icons.list_alt_rounded, + _l10n.translate('autonomous_work.queue'), + _openTaskQueue, + kWtNavy, + ), + ( + Icons.more_horiz_rounded, + _l10n.translate('autonomous_work.more'), + _openMorePanel, + kWtNavy, + ), ]; final gap = m.railGap; final itemH = (m.railMaxH - gap * (items.length - 1)) / items.length; @@ -1968,19 +2173,28 @@ class _RobotAutonomousWorkPageV2State extends State { if (task == null) { switch (_phase) { case WorkRunState.finished: - return '本次作业已结束'; + return _l10n.translate('autonomous_work.run_ended'); case WorkRunState.running: - return '任务执行中'; + return _l10n.translate('autonomous_work.run_in_progress'); default: - return '尚未下发任务 · 选择路线后开始作业'; + return _l10n.translate('autonomous_work.pick_route_to_start'); } } final parts = [ - if (task.progress != null) '已完成 ${(task.progress! * 100).round()}%', + if (task.progress != null) + _l10n.translate('autonomous_work.progress', { + 'percent': (task.progress! * 100).round(), + }), if (task.coveredArea != null && task.plannedArea != null) - '已覆盖 ${task.coveredArea} / ${task.plannedArea} 亩', - '任务 #${task.taskId}', - if (task.createdAt != null) '下发 ${task.createdAt}', + _l10n.translate('autonomous_work.covered_area', { + 'covered': task.coveredArea, + 'total': task.plannedArea, + }), + _l10n.translate('autonomous_work.task_number', {'id': task.taskId}), + if (task.createdAt != null) + _l10n.translate('autonomous_work.dispatched_time', { + 'time': task.createdAt, + }), ]; return parts.join(' · '); } @@ -1988,18 +2202,32 @@ class _RobotAutonomousWorkPageV2State extends State { (String, Color, Color) _badgeStyle() { switch (_phase) { case WorkRunState.idle: - return ('准备就绪', kWtSoftBlue, kWtBlue); + return (_l10n.translate('autonomous_work.ready'), kWtSoftBlue, kWtBlue); case WorkRunState.queued: - return ('待执行', kWtSoftBlue, kWtBlue); + return (_l10n.translate('work_v2.stat_pending'), kWtSoftBlue, kWtBlue); case WorkRunState.running: - return ('执行中', kWtGreenBg, kWtGreen); + return ( + _l10n.translate('pv_control.task_executing'), + kWtGreenBg, + kWtGreen, + ); case WorkRunState.paused: - return ('暂停 · 保留断点', kWtWarnBg, kWtWarn); + return ( + _l10n.translate('autonomous_work.paused_with_checkpoint'), + kWtWarnBg, + kWtWarn, + ); case WorkRunState.failed: - return ('异常中断', kWtWarnBg, kWtWarn); + return ( + _l10n.translate('autonomous_work.interrupted'), + kWtWarnBg, + kWtWarn, + ); case WorkRunState.finished: return ( - _session?.rawStatus == 'FINISH' ? '已完成' : '已结束', + _session?.rawStatus == 'FINISH' + ? _l10n.translate('work_v2.plan.status_done') + : _l10n.translate('autonomous_work.ended'), kWtGreenBg, kWtGreen, ); @@ -2013,26 +2241,69 @@ class _RobotAutonomousWorkPageV2State extends State { switch (_phase) { case WorkRunState.idle: return [ - ('放弃准备', null, 2, () => Navigator.of(context).maybePop()), - if (caps.routeLibrary) ('预览 / 选择路线', null, 2, _openRouteLibrary), - ('开始作业', Icons.play_arrow_rounded, 0, _startWork), + ( + _l10n.translate('autonomous_work.leave_setup'), + null, + 2, + () => Navigator.of(context).maybePop(), + ), + if (caps.routeLibrary) + ( + _l10n.translate('autonomous_work.preview_route'), + null, + 2, + _openRouteLibrary, + ), + ( + _l10n.translate('route_planning.start_work'), + Icons.play_arrow_rounded, + 0, + _startWork, + ), ]; case WorkRunState.queued: return [ - if (caps.cancelQueued) ('取消待执行任务', null, 1, _cancelQueued), - if (caps.taskQueue) ('查看任务队列', null, 2, _openTaskQueue), + if (caps.cancelQueued) + ( + _l10n.translate('autonomous_work.cancel_queued'), + null, + 1, + _cancelQueued, + ), + if (caps.taskQueue) + ( + _l10n.translate('autonomous_work.view_queue'), + null, + 2, + _openTaskQueue, + ), ]; case WorkRunState.running: return [ - if (caps.pause) ('暂停作业', Icons.pause_rounded, 0, _pauseWork), - if (caps.stop) ('停止作业', Icons.stop_rounded, 1, _stopWork), + if (caps.pause) + ( + _l10n.translate('pv_control.rail_pause_work'), + Icons.pause_rounded, + 0, + _pauseWork, + ), + if (caps.stop) + ( + _l10n.translate('autonomous_work.stop'), + Icons.stop_rounded, + 1, + _stopWork, + ), ( - '查看状态', + _l10n.translate('autonomous_work.view_status'), null, 2, () { setState(() => _infoExpanded = true); - CapsuleToast.show('已展开「机器人信息」运行状态', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.robot_status_opened'), + showCheck: false, + ); }, ), ]; @@ -2040,13 +2311,35 @@ class _RobotAutonomousWorkPageV2State extends State { case WorkRunState.failed: return [ if (caps.resume) - ('继续 / 断点续作', Icons.play_arrow_rounded, 0, _resumeWork), - if (caps.stop) ('停止作业', Icons.stop_rounded, 1, _stopWork), + ( + _l10n.translate('autonomous_work.resume'), + Icons.play_arrow_rounded, + 0, + _resumeWork, + ), + if (caps.stop) + ( + _l10n.translate('autonomous_work.stop'), + Icons.stop_rounded, + 1, + _stopWork, + ), ]; case WorkRunState.finished: return [ - ('查看作业记录', null, 0, _openRecordPanel), - if (caps.routeLibrary) ('选择新任务', null, 2, _openRouteLibrary), + ( + _l10n.translate('autonomous_work.view_records'), + null, + 0, + _openRecordPanel, + ), + if (caps.routeLibrary) + ( + _l10n.translate('autonomous_work.new_task'), + null, + 2, + _openRouteLibrary, + ), ]; } } @@ -2166,8 +2459,15 @@ class _DraggableVideoPip extends StatefulWidget { } class _DraggableVideoPipState extends State<_DraggableVideoPip> { + AppLocalizations get _l10n => AppLocalizations.of(context); + /// 视频源方向(演示:点击小窗循环切换) - static const List _cams = ['前置', '左视', '右视', '后视']; + static const List _cams = [ + 'autonomous_work.camera_front', + 'autonomous_work.camera_left', + 'autonomous_work.camera_right', + 'autonomous_work.camera_rear', + ]; /// 拖动后的左上角位置;null 表示仍在默认位置(左下角) Offset? _pos; @@ -2193,7 +2493,12 @@ class _DraggableVideoPipState extends State<_DraggableVideoPip> { behavior: HitTestBehavior.opaque, onTap: () { setState(() => _cam = (_cam + 1) % _cams.length); - CapsuleToast.show('已切换为「${_cams[_cam]}」视频(演示)', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.camera_demo_switched', { + 'camera': _l10n.translate(_cams[_cam]), + }), + showCheck: false, + ); }, onPanUpdate: (details) { setState( @@ -2240,7 +2545,7 @@ class _DraggableVideoPipState extends State<_DraggableVideoPip> { borderRadius: BorderRadius.circular(999), ), child: Text( - _cams[_cam], + _l10n.translate(_cams[_cam]), style: TextStyle( fontSize: m.fsx(10, 8), height: 1.1, diff --git a/lib/features/v2/device_list/presentation/pages/robot_full_info_page_v2.dart b/lib/features/v2/device_list/presentation/pages/robot_full_info_page_v2.dart index 52635f3c..cee12509 100644 --- a/lib/features/v2/device_list/presentation/pages/robot_full_info_page_v2.dart +++ b/lib/features/v2/device_list/presentation/pages/robot_full_info_page_v2.dart @@ -24,7 +24,7 @@ class RobotFullInfoPageV2 extends StatelessWidget { static const Color _cardBorder = Color(0xFFE5EDF7); static const Color _green = Color(0xFF2FBF6B); static const Color _greenBg = Color(0xFFE5F8EC); - static const Color _statBg = Color(0xFFEAF3FE); + // static const Color _statBg = Color(0xFFEAF3FE); // 运行与控制信息。 static const Color _divider = Color(0xFFF0F4FA); static const String _robotImage = 'assets/images/robot_logo_login.png'; @@ -53,12 +53,22 @@ class RobotFullInfoPageV2 extends StatelessWidget { .replaceFirst('%s', sn.substring(sn.length - 2)); } + /* /// 电量:0 视为未上报 String get _batteryText { final b = robot.battery; if (b <= 0) return '--'; return '${b.round()}%'; } + */ + + String get _deviceTypeText { + final types = { + robot.deviceTypeName?.trim() ?? '', + robot.deviceType?.trim() ?? '', + }..remove(''); + return types.isEmpty ? '--' : types.join(' · '); + } /// 运行模式:任务字段为“无/空”时按待机展示(返回空串表示待机) String get _modeText { @@ -108,12 +118,15 @@ class RobotFullInfoPageV2 extends StatelessWidget { ), const SizedBox(height: 10), _buildProfileCard(l10n), + // 上架版暂时隐藏运行与控制信息。 + /* const SizedBox(height: 18), _buildSectionTitle( l10n.translate('robot_full_info_v2.sec_runtime'), ), const SizedBox(height: 10), _buildRuntimeCard(l10n), + */ const SizedBox(height: 14), Center( child: Text( @@ -339,22 +352,27 @@ class RobotFullInfoPageV2 extends StatelessWidget { ), _buildInfoRow( l10n.translate('robot_full_info_v2.row_type'), - l10n.translate('robot_full_info_v2.val_type'), + _deviceTypeText, ), _buildInfoRow( l10n.translate('robot_full_info_v2.row_power'), l10n.translate('robot_full_info_v2.val_power'), + isLast: true, ), + // 上架版暂时隐藏最近上报。 + /* _buildInfoRow( l10n.translate('robot_full_info_v2.row_report'), l10n.translate('robot_full_info_v2.val_report'), isLast: true, ), + */ ], ), ); } + /* // ===== 运行与控制卡 ===== Widget _buildRuntimeCard(AppLocalizations l10n) { return Container( @@ -448,6 +466,7 @@ class RobotFullInfoPageV2 extends StatelessWidget { ), ); } + */ // ===== 通用信息行:左标签 / 右值 ===== Widget _buildInfoRow( diff --git a/lib/features/v2/device_list/presentation/pages/route_editor_page_v2.dart b/lib/features/v2/device_list/presentation/pages/route_editor_page_v2.dart index e244d471..9cdee41e 100644 --- a/lib/features/v2/device_list/presentation/pages/route_editor_page_v2.dart +++ b/lib/features/v2/device_list/presentation/pages/route_editor_page_v2.dart @@ -4,9 +4,12 @@ import 'dart:math' as math; import 'dart:ui' as ui; import 'package:flutter/material.dart'; +import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; +import 'package:maibu_satabot_v2/features/regions/presentation/region_error_text.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_map/flutter_map.dart' show LatLngBounds; import 'package:go_router/go_router.dart'; import 'package:image/image.dart' as img; import 'package:latlong2/latlong.dart'; @@ -41,6 +44,7 @@ import 'package:maibu_satabot_v2/features/regions/presentation/widgets/region_bo import 'package:maibu_satabot_v2/features/regions/presentation/widgets/no_device_crosshair_hint.dart'; import '../widgets/autonomous/work_ui.dart'; +import '../widgets/obstacle_resize_layer.dart'; /// 地图与区域编辑(横屏)——路线库「+ 新建 / 编辑」进入。 /// @@ -60,12 +64,16 @@ class RouteEditorPageV2 extends StatefulWidget { this.exitToLandscape = false, this.initialRegion, this.startRegionEditor = false, + this.startReturnEditor = false, }); final String deviceSn; final RegionDraft? initialRegion; final bool startRegionEditor; + /// 路线库返航分栏进入时,直接查询并编辑本场站返航方案。 + final bool startReturnEditor; + /// 退出本页后交还的方向归属: /// true = 上一个页面是横屏锁定页(自主作业中心),退出时锁回横屏; /// false = 上一个页面是竖屏页(设备详情 / 作业首页等),退出时恢复系统方向。 @@ -79,12 +87,14 @@ class RouteEditorPageV2 extends StatefulWidget { bool exitToLandscape = false, RegionDraft? initialRegion, bool startRegionEditor = false, + bool startReturnEditor = false, }) { final page = RouteEditorPageV2( deviceSn: deviceSn, exitToLandscape: exitToLandscape, initialRegion: initialRegion, startRegionEditor: startRegionEditor, + startReturnEditor: startReturnEditor, ); return PageRouteBuilder( transitionDuration: const Duration(milliseconds: 260), @@ -113,19 +123,21 @@ class RouteEditorPageV2 extends StatefulWidget { } class _RouteEditorPageV2State extends State { + AppLocalizations get _l10n => AppLocalizations.of(context); + /// 左侧竖栏:与路径规划竖浮菜单同名同功能,末尾追加「一键返航」。 /// 「一键返航」为独立模块:只叠加返航点图层与面板,不读写圈地状态。 static const List<(IconData, String)> _tools = <(IconData, String)>[ - (Icons.crop_free_rounded, '圈地'), + (Icons.crop_free_rounded, 'region_editor.mark_area'), // 按需求隐藏「列表」入口(_openRouteList 实现保留,恢复时取消注释即可)。 // ⚠️ 取消注释后,下面 _onToolTap 的 case 编号与两处「一键返航」的 _tool = 5 // 都要整体后移一位,否则工具点击会串位。 // (Icons.format_list_bulleted_rounded, '列表'), - (Icons.train_rounded, '场站'), - (Icons.navigation_rounded, '定位'), - (Icons.refresh_rounded, '刷新'), - (Icons.videocam_rounded, '监控'), - (Icons.u_turn_left_rounded, '一键返航'), + (Icons.train_rounded, 'route_planning.station'), + (Icons.navigation_rounded, 'route_planning.location'), + (Icons.refresh_rounded, 'route_planning.refresh'), + (Icons.videocam_rounded, 'route_planning.monitoring'), + (Icons.u_turn_left_rounded, 'pv_control.rail_return_home'), ]; late String _deviceSn; @@ -260,7 +272,7 @@ class _RouteEditorPageV2State extends State { _ReturnPoint( point: points.single, deviceSn: raw['deviceSn'] as String?, - deviceLabel: raw['deviceLabel'] as String? ?? '未选择设备', + deviceLabel: raw['deviceLabel'] as String? ?? '', alias: raw['alias'] as String?, ), ); @@ -435,6 +447,7 @@ class _RouteEditorPageV2State extends State { final List _markedPoints = []; // 作业区打点(WGS84) final List> _obstacleHoles = >[]; // 已完成的禁行区 + List? _selectedObstacle; final List _currentObstaclePoints = []; // 正在画的禁行区 bool _isObstacleEditing = false; // 是否处于禁行区编辑状态 bool _isWorkAreaCompleted = false; // 作业区是否已生成路线 @@ -461,34 +474,34 @@ class _RouteEditorPageV2State extends State { /// 定位质量枚举 → 文案(与设备数据监控 _getLocationQualityText 同口径); /// short = 窄屏短版:顶栏横排空间有限,长文案会撞出 RenderFlex 溢出 - static String _qualText(int? q, {bool short = false}) => short + String _qualText(int? q, {bool short = false}) => short ? switch (q) { - null => '未知', - 0 => '无定位', - 1 => '单点', - 2 => '差分', - 3 => '惯导', - 4 => '固定解', - 5 => '浮点解', - 6 => '单点', - 7 => '差分', - 8 => '固定', - 9 => '浮点', - _ => '未知', + null => _l10n.translate('common.unknown'), + 0 => _l10n.translate('pv_control.qual_none'), + 1 => _l10n.translate('region_editor.position_single_short'), + 2 => _l10n.translate('region_editor.position_diff_short'), + 3 => _l10n.translate('region_editor.position_ins_short'), + 4 => _l10n.translate('region_editor.position_fixed_short'), + 5 => _l10n.translate('region_editor.position_float_short'), + 6 => _l10n.translate('region_editor.position_single_short'), + 7 => _l10n.translate('region_editor.position_diff_short'), + 8 => _l10n.translate('region_editor.position_fixed'), + 9 => _l10n.translate('region_editor.position_float'), + _ => _l10n.translate('common.unknown'), } : switch (q) { - null => '定位未知', - 0 => '无定位', - 1 => '单点定位', - 2 => '差分定位', - 3 => '惯性导航', - 4 => 'RTK 固定解', - 5 => 'RTK 浮点解', - 6 => '单点(无航向)', - 7 => '差分(无航向)', - 8 => 'RTK 固定(无航向)', - 9 => 'RTK 浮点(无航向)', - _ => '定位未知', + null => _l10n.translate('region_editor.position_unknown'), + 0 => _l10n.translate('pv_control.qual_none'), + 1 => _l10n.translate('pv_control.qual_single'), + 2 => _l10n.translate('pv_control.qual_differential'), + 3 => _l10n.translate('pv_control.qual_ins'), + 4 => _l10n.translate('pv_control.qual_rtk_fixed'), + 5 => _l10n.translate('pv_control.qual_rtk_float'), + 6 => _l10n.translate('autonomous_work.position_single_no_heading'), + 7 => _l10n.translate('autonomous_work.position_diff_no_heading'), + 8 => _l10n.translate('pv_control.qual_rtk_fixed_nh'), + 9 => _l10n.translate('pv_control.qual_rtk_float_nh'), + _ => _l10n.translate('region_editor.position_unknown'), }; /// 是否 RTK 固定解(4=固定,8=固定无航向) @@ -547,7 +560,13 @@ class _RouteEditorPageV2State extends State { } } unawaited( - _restoreDraft().then((_) { + _restoreDraft().then((_) async { + if (!mounted) return; + if (widget.startReturnEditor) { + await _enterReturnMode(); + if (mounted && _pendingReturnDraft != null) _selectReturnPlan(); + return; + } if (mounted && (widget.startRegionEditor || widget.initialRegion != null)) { setState(() { @@ -699,7 +718,7 @@ class _RouteEditorPageV2State extends State { return [...points, LatLng(first.latitude, first.longitude)]; } - /// 障碍物矩形默认尺寸(米):点「+」落矩形时的初值,随后弹窗可改 X/Y + /// 障碍物矩形默认尺寸(米)。 static const double _defaultObstacleW = 2.0; static const double _defaultObstacleH = 2.0; @@ -756,6 +775,73 @@ class _RouteEditorPageV2State extends State { return _fmtRectName(w, h); } + bool get _editingObstacles => _isReturnMode + ? _returnDropObstacle + : _isDropPanel && _dropMode == 2; + + List> get _activeObstacleHoles => + _isReturnMode ? _returnObstacleHoles : _obstacleHoles; + + void _focusObstacle(List corners) { + _selectedObstacle = corners; + _regionFocusPoints = List.of(corners); + _regionFocusSignal++; + } + + void _selectObstacleAt(LatLng point) { + for (final corners in _activeObstacleHoles.reversed) { + if (corners.length == 4 && + LatLngBounds.fromPoints(corners).contains(point)) { + if (!identical(corners, _selectedObstacle)) { + setState(() => _focusObstacle(corners)); + } + return; + } + } + } + + void _placeObstacle(LatLng center, {bool forReturn = false}) { + final corners = _rectCorners(center, _defaultObstacleW, _defaultObstacleH); + setState(() { + if (forReturn) { + _returnObstacleHoles.add(corners); + _returnObstacleNames.add(null); + _returnObstacleSizes.add((_defaultObstacleW, _defaultObstacleH)); + _returnSaved = false; + } else { + _obstacleHoles.add(corners); + } + _focusObstacle(corners); + }); + } + + void _updateObstacle( + List obstacle, + List corners, { + required bool forReturn, + (double, double)? size, + }) { + if (!mounted) return; + final holes = forReturn ? _returnObstacleHoles : _obstacleHoles; + final index = holes.indexOf(obstacle); + if (index < 0) return; + setState(() { + // 保留列表对象,拖动期间选中项和编号不变。 + obstacle + ..clear() + ..addAll(corners); + if (forReturn) { + while (_returnObstacleSizes.length <= index) { + _returnObstacleSizes.add( + _rectSizeOf(holes[_returnObstacleSizes.length]), + ); + } + _returnObstacleSizes[index] = size ?? _rectSizeOf(corners); + _returnSaved = false; + } + }); + } + /// 增加点(复刻 _addMarkedPoint):准星取地图中心,设备取实时坐标。 void _addMarkedPoint() { if (_areaMode == AreaMode.work && _isWorkAreaCompleted) { @@ -770,13 +856,13 @@ class _RouteEditorPageV2State extends State { if (_robotMode == RobotMode.point) { point = _mapCenter; if (point == null) { - _toast('地图中心尚未就绪,请稍后重试'); + _toast(_l10n.translate('region_editor.map_not_ready')); return; } } else { point = _devicePos; if (point == null) { - _toast('设备坐标无效,无法添加打点!'); + _toast(_l10n.translate('region_editor.invalid_device_point')); return; } } @@ -791,24 +877,16 @@ class _RouteEditorPageV2State extends State { _outerPoints = []; } }); - _toast('已添加第 ${_markedPoints.length} 个作业区域打点'); + _toast( + _l10n.translate('region_editor.work_point_added', { + 'count': _markedPoints.length, + }), + ); return; } // 障碍物与分区相互独立:不依赖作业区打点,随时可单独落矩形。 - // 点一下在准星/设备中心落一个默认尺寸矩形,随即弹窗改 X/Y(尺寸即名字) - final LatLng center = point!; - _showRectSizeDialog( - center: center, - w: _defaultObstacleW, - h: _defaultObstacleH, - onOk: (double w, double h) { - setState(() { - _obstacleHoles.add(_rectCorners(center, w, h)); - }); - _toast('已添加禁行区矩形(${_fmtRectName(w, h)})'); - }, - ); + _placeObstacle(point); } /// 障碍物已改为「点一下落矩形即成组」,原「≥3 点成组」的 _completeObstacle 移除。 @@ -819,7 +897,8 @@ class _RouteEditorPageV2State extends State { Future _generatePath({bool showTips = true}) async { if (_workMode == WorkMode.custom) { if (_markedPoints.isEmpty) { - if (showTips) _toast('请先添加作业区域打点!'); + if (showTips) + _toast(_l10n.translate('region_editor.add_work_points_first')); return; } setState(() { @@ -828,21 +907,28 @@ class _RouteEditorPageV2State extends State { _outerPoints = []; }); if (showTips) { - _toast('已生成路线(自定义模式,${_pathPoints.length} 个点)'); + _toast( + _l10n.translate('region_editor.custom_route_generated', { + 'count': _pathPoints.length, + }), + ); } return; } if (_areaMode == AreaMode.work && _markedPoints.isEmpty) { - if (showTips) _toast('请先添加作业区域打点!'); + if (showTips) + _toast(_l10n.translate('region_editor.add_work_points_first')); return; } if (_areaMode == AreaMode.work && _markedPoints.length < 3) { - if (showTips) _toast('作业区域至少需要3个打点才能生成路径!'); + if (showTips) + _toast(_l10n.translate('region_editor.route_needs_three_points')); return; } if (_markedPoints.length < 3) { - if (showTips) _toast('作业区域至少需要3个打点才能生成路径!'); + if (showTips) + _toast(_l10n.translate('region_editor.route_needs_three_points')); return; } @@ -854,7 +940,11 @@ class _RouteEditorPageV2State extends State { _outerPoints = []; }); if (showTips) { - _toast('已生成路线(覆盖模式,${_pathPoints.length} 个点)'); + _toast( + _l10n.translate('region_editor.coverage_route_generated', { + 'count': _pathPoints.length, + }), + ); } } @@ -863,7 +953,7 @@ class _RouteEditorPageV2State extends State { Future _undoAction() async { if (_areaMode == AreaMode.work) { if (_markedPoints.isEmpty) { - _toast('暂无作业区域点可撤回'); + _toast(_l10n.translate('route_planning.no_work_points')); return; } setState(() { @@ -872,24 +962,32 @@ class _RouteEditorPageV2State extends State { _pathPoints = []; _outerPoints = []; }); - _toast('已撤回作业区域最后一个点,剩余 ${_markedPoints.length} 个点'); + _toast( + _l10n.translate('region_editor.work_point_undone', { + 'count': _markedPoints.length, + }), + ); return; } if (_obstacleHoles.isNotEmpty) { setState(() => _obstacleHoles.removeLast()); if (_isWorkAreaCompleted) await _generatePath(showTips: false); - _toast('已撤回上一个禁行区矩形,剩余 ${_obstacleHoles.length} 个'); + _toast( + _l10n.translate('region_editor.obstacle_undone', { + 'count': _obstacleHoles.length, + }), + ); return; } - _toast('暂无可撤回的禁行区'); + _toast(_l10n.translate('region_editor.no_obstacle_to_undo')); } /// 删除全部(复刻 _deleteAllAction):作业区清作业点 + 路径,禁行区清所有空洞。 Future _deleteAllAction() async { if (_areaMode == AreaMode.work) { if (_markedPoints.isEmpty) { - _toast('暂无作业区域点可删除'); + _toast(_l10n.translate('region_editor.no_point_to_delete')); return; } setState(() { @@ -901,12 +999,12 @@ class _RouteEditorPageV2State extends State { _isObstacleEditing = false; _isWorkAreaCompleted = false; }); - _toast('已清空所有作业区域点和路径'); + _toast(_l10n.translate('route_planning.clear_work_area')); return; } if (_obstacleHoles.isEmpty) { - _toast('暂无可删除的禁行区'); + _toast(_l10n.translate('region_editor.no_obstacle_to_delete')); return; } setState(() { @@ -915,7 +1013,7 @@ class _RouteEditorPageV2State extends State { _isObstacleEditing = false; }); if (_isWorkAreaCompleted) await _generatePath(showTips: false); - _toast('已清空所有禁行区'); + _toast(_l10n.translate('region_editor.obstacles_cleared')); } /// 左侧竖栏:与路径规划竖浮菜单同一个映射 @@ -990,13 +1088,17 @@ class _RouteEditorPageV2State extends State { _regionFocusSignal++; } }); - _toast(region == null ? '移动地图,用准星依次打 4 个边界点后保存分区' : '已回填分区范围,可修改信息或重画边界'); + _toast( + region == null + ? _l10n.translate('region_editor.region_create_hint') + : _l10n.translate('region_editor.region_edit_hint'), + ); } /// 分区先展示列表,新增和修改才进入独立的四点编辑状态。 void _onZoneTap(int index) { if (index == 0 && !_regionScopeCurrent) { - _toast('请先选择场站并登录;场站或账号切换后需重新进入编辑器'); + _toast(_l10n.translate('region_editor.region_requires_scope')); return; } // 返航编辑中点分区类工具:先退出返航,保留已打返航点 @@ -1015,7 +1117,7 @@ class _RouteEditorPageV2State extends State { _focusRegionSelection(); unawaited(_reloadRegions()); } else { - _toast('障碍物模式:点「+」独立添加禁行区矩形(与分区互不影响)'); + _toast(_l10n.translate('region_editor.obstacle_mode_hint')); } } @@ -1035,26 +1137,32 @@ class _RouteEditorPageV2State extends State { if (point == null) { _toast( _regionRobotMode == RobotMode.point - ? '地图中心尚未就绪,请稍后重试' - : '设备坐标无效,无法添加分区点', + ? _l10n.translate('region_editor.map_not_ready') + : _l10n.translate('region_editor.invalid_region_point'), ); return; } final error = _regionEditor.addPoint( RegionPoint(lat: point.latitude, lng: point.longitude), ); - _toast(error ?? '已添加分区第 ${_regionEditor.state.draft.scope.length}/4 个点'); + _toast( + error == null + ? _l10n.translate('region_editor.region_point_added', { + 'count': _regionEditor.state.draft.scope.length, + }) + : regionErrorText(error, _l10n), + ); } Future _showRegionDialog() async { final state = _regionEditor.state; if (state.isSaving) return; if (state.savedWithoutId) { - _toast('该分区已保存,请点「新建」绘制下一个分区'); + _toast(_l10n.translate('region_editor.region_already_saved')); return; } if (state.draft.scopeError != null) { - _toast(state.draft.scopeError!); + _toast(regionErrorText(state.draft.scopeError!, _l10n)); return; } final saved = await showRegionFormDialog( @@ -1067,7 +1175,11 @@ class _RouteEditorPageV2State extends State { sl().state.user?.userId == _regionOwnerId, ); if (!mounted || saved != true) return; - _toast('分区「${_regionEditor.state.draft.name.trim()}」已保存'); + _toast( + _l10n.translate('region_editor.region_saved', { + 'name': _regionEditor.state.draft.name.trim(), + }), + ); setState(() { _isDropPanel = false; _isRegionListOpen = true; @@ -1082,20 +1194,22 @@ class _RouteEditorPageV2State extends State { children: [ Expanded( child: Text( - '分区 ${state.draft.scope.length}/4 个点', + _l10n.translate('region_editor.region_point_count', { + 'count': state.draft.scope.length, + }), style: TextStyle(fontSize: m.fs(11), color: kWtGray2), ), ), _barButton( m, - '取消', + _l10n.translate('common.cancel'), primary: false, onPressed: state.isSaving ? null : _closeDropPanel, ), const SizedBox(width: 5), _barButton( m, - '撤回', + _l10n.translate('route_planning.undo'), primary: false, icon: Icons.undo_rounded, onPressed: @@ -1108,7 +1222,9 @@ class _RouteEditorPageV2State extends State { const SizedBox(width: 5), _barButton( m, - state.savedWithoutId ? '新建' : '重画', + state.savedWithoutId + ? _l10n.translate('pv_control.task_new') + : _l10n.translate('region_editor.redraw'), primary: false, onPressed: state.isSaving ? null @@ -1122,10 +1238,10 @@ class _RouteEditorPageV2State extends State { _barButton( m, state.savedWithoutId - ? '已保存' + ? _l10n.translate('region_editor.saved') : state.draft.id == null - ? '保存' - : '修改', + ? _l10n.translate('route_planning.save') + : _l10n.translate('region_editor.edit'), primary: true, icon: Icons.save_outlined, onPressed: state.isSaving || state.savedWithoutId @@ -1147,12 +1263,22 @@ class _RouteEditorPageV2State extends State { _pathPoints = []; _outerPoints = []; }); - _toast('已删除第 ${index + 1} 个点,剩余 ${_markedPoints.length} 个'); + _toast( + _l10n.translate('region_editor.work_point_deleted', { + 'index': index + 1, + 'count': _markedPoints.length, + }), + ); return; } if (index < 0 || index >= _obstacleHoles.length) return; setState(() => _obstacleHoles.removeAt(index)); - _toast('已删除第 ${index + 1} 个禁行区矩形,剩余 ${_obstacleHoles.length} 个'); + _toast( + _l10n.translate('region_editor.obstacle_deleted', { + 'index': index + 1, + 'count': _obstacleHoles.length, + }), + ); } /// 圈地入口:与路径规划 _showModeDialog 同一逻辑 @@ -1162,8 +1288,10 @@ class _RouteEditorPageV2State extends State { final result = await showDialog( context: context, barrierDismissible: false, - builder: (dialogContext) => - _WorkModeDialog(initial: _workMode, title: '选择作业模式'), + builder: (dialogContext) => _WorkModeDialog( + initial: _workMode, + title: _l10n.translate('route_planning.select_work_mode'), + ), ); if (result == null || !mounted) return; // 只切模式 + 开面板,不动作业区已有打点与已生成路线(同原版 onWorkModeSelected) @@ -1173,7 +1301,11 @@ class _RouteEditorPageV2State extends State { _isPanelOpen = true; _panelTabLand = true; }); - _toast(result == WorkMode.bow ? '覆盖模式:沿边界打点,生成时首尾闭合' : '自定义模式:按打点顺序生成路线'); + _toast( + result == WorkMode.bow + ? _l10n.translate('region_editor.coverage_mode_hint') + : _l10n.translate('region_editor.custom_mode_hint'), + ); } /// 列表:按当前场站拉作业记录(同路径规划 onListBox), @@ -1183,7 +1315,7 @@ class _RouteEditorPageV2State extends State { Future _openRouteList() async { final siteId = sl().state.selectedSite?.id; if (siteId == null) { - _toast('请先在场站列表中选择一个场站!'); + _toast(_l10n.translate('region_editor.select_site_first')); return; } setState(() { @@ -1199,7 +1331,10 @@ class _RouteEditorPageV2State extends State { ? (result.data ?? const []) : const []; }); - if (!result.isOk) _toast(result.error ?? '作业记录加载失败'); + if (!result.isOk) + _toast( + result.error ?? _l10n.translate('region_editor.records_load_failed'), + ); } /// 选中一条作业记录:补齐几何后回显(同路径规划点选列表项) @@ -1220,7 +1355,9 @@ class _RouteEditorPageV2State extends State { ); if (!mounted) return; if (!result.isOk) { - _toast(result.error ?? '路线几何加载失败'); + _toast( + result.error ?? _l10n.translate('region_editor.geometry_load_failed'), + ); return; } final geo = result.data ?? route; @@ -1247,13 +1384,13 @@ class _RouteEditorPageV2State extends State { _isPanelOpen = true; _tool = 0; }); - _toast('已载入「${geo.name}」,可继续编辑并另存'); + _toast(_l10n.translate('region_editor.route_loaded', {'name': geo.name})); } /// 定位:把地图移回设备当前坐标(同路径规划 _handleGotoLocation) void _recenter() { setState(() => _recenterSignal++); - _toast('已回到设备当前位置'); + _toast(_l10n.translate('region_editor.centered_on_device')); } /// 刷新:彻底重置绘制与模式(同路径规划 _handleRefresh) @@ -1301,7 +1438,7 @@ class _RouteEditorPageV2State extends State { _regionEditor.initialize(RegionDraft(siteId: _draftSiteId ?? 0)); _regionRobotMode = RobotMode.point; unawaited(_reloadRegions()); - _toast('已重置页面状态'); + _toast(_l10n.translate('region_editor.editor_reset')); } finally { if (mounted) setState(() => _refreshing = false); } @@ -1345,7 +1482,7 @@ class _RouteEditorPageV2State extends State { } String _labelOfDevice(String? sn) { - if (sn == null || sn.isEmpty) return '未选择设备'; + if (sn == null || sn.isEmpty) return ''; for (final (value, label) in _deviceOptions) { if (value == sn) return label; } @@ -1358,13 +1495,22 @@ class _RouteEditorPageV2State extends State { String get _returnHint { if (_returnPoints.isEmpty) { - return '打点方式:${_robotMode == RobotMode.point ? '准星' : '设备'} · 点「+」添加返航点'; + return _l10n.translate('region_editor.return_mark_hint', { + 'mode': _robotMode == RobotMode.point + ? _l10n.translate('region_editor.crosshair') + : _l10n.translate('region_editor.device'), + }); } final int bound = _returnPoints .where((point) => (point.deviceSn ?? '').isNotEmpty) .length; - return '共 ${_returnPoints.length} 点 · 已绑定设备 $bound 台' - '${_returnSaved ? ' · 已保存' : ''}'; + return _l10n.translate('region_editor.return_point_summary', { + 'points': _returnPoints.length, + 'devices': bound, + 'saved': _returnSaved + ? _l10n.translate('region_editor.saved_suffix') + : '', + }); } /// 进入返航:先按当前全局选中的场站查已有方案(一个场站只允许一条)。 @@ -1374,7 +1520,7 @@ class _RouteEditorPageV2State extends State { Future _enterReturnMode() async { final siteId = sl().state.selectedSite?.id; if (siteId == null) { - _toast('请先在场站列表中选择一个场站!'); + _toast(_l10n.translate('region_editor.select_site_first')); return; } setState(() { @@ -1399,7 +1545,9 @@ class _RouteEditorPageV2State extends State { setState(() => _returnLoading = false); if (!result.isOk) { // 失败不臆断为「无方案」:保留编辑器现状,仅提示 - _toast(result.error ?? '返航方案加载失败'); + _toast( + result.error ?? _l10n.translate('region_editor.return_load_failed'), + ); return; } final draft = result.data; @@ -1431,7 +1579,7 @@ class _RouteEditorPageV2State extends State { _returnDropObstacle = false; }); _persistDraft(); - _toast('新建返航方案:点绿色「+」添加返航点'); + _toast(_l10n.translate('region_editor.return_new_hint')); } /// 选中列表里那条方案:直接回填已拉到的几何 = 修改态(按钮「修改」,带 id) @@ -1446,7 +1594,7 @@ class _RouteEditorPageV2State extends State { _returnDropObstacle = false; }); _persistDraft(); - _toast('已载入返航方案,修改后点「修改」保存'); + _toast(_l10n.translate('region_editor.return_edit_hint')); } /// 把服务器方案回填到编辑器:返航点(含绑定设备/自定义名)+ 障碍矩形。 @@ -1490,7 +1638,7 @@ class _RouteEditorPageV2State extends State { _returnPlanId = null; } }); - if (clear) _toast('已退出返航打点模式'); + if (clear) _toast(_l10n.translate('region_editor.return_mode_exited')); } /// 增加返航点:准星取地图中心,设备取实时坐标(复用圈地的打点方式) @@ -1500,7 +1648,9 @@ class _RouteEditorPageV2State extends State { : _devicePos; if (point == null) { _toast( - _robotMode == RobotMode.point ? '地图中心尚未就绪,请稍后重试' : '设备坐标无效,无法添加返航点!', + _robotMode == RobotMode.point + ? _l10n.translate('region_editor.map_not_ready') + : _l10n.translate('region_editor.invalid_return_point'), ); return; } @@ -1514,35 +1664,27 @@ class _RouteEditorPageV2State extends State { ); _returnSaved = false; }); - _toast('已添加第 ${_returnPoints.length} 个返航点'); + _toast( + _l10n.translate('region_editor.return_point_added', { + 'count': _returnPoints.length, + }), + ); } - /// 在返航线上落一个障碍矩形(返航方案独立一套):取准星/设备中心为默认尺寸建矩形,随即弹窗改 X/Y + /// 在返航方案里放置一个可拖动的障碍矩形。 void _addReturnObstacle() { final LatLng? point = _robotMode == RobotMode.point ? _mapCenter : _devicePos; if (point == null) { _toast( - _robotMode == RobotMode.point ? '地图中心尚未就绪,请稍后重试' : '设备坐标无效,无法添加障碍!', + _robotMode == RobotMode.point + ? _l10n.translate('region_editor.map_not_ready') + : _l10n.translate('region_editor.invalid_obstacle_point'), ); return; } - final LatLng center = point; - _showRectSizeDialog( - center: center, - w: _defaultObstacleW, - h: _defaultObstacleH, - onOk: (double w, double h) { - setState(() { - _returnObstacleHoles.add(_rectCorners(center, w, h)); - _returnObstacleNames.add(null); - _returnObstacleSizes.add((w, h)); - _returnSaved = false; - }); - _toast('已添加返航禁行区矩形(${_fmtRectName(w, h)})'); - }, - ); + _placeObstacle(point, forReturn: true); } /// 编辑返航障碍矩形尺寸:以当前中心为锚重建四角替换 @@ -1555,16 +1697,12 @@ class _RouteEditorPageV2State extends State { center: center, w: w, h: h, - onOk: (double nw, double nh) { - setState(() { - _returnObstacleHoles[index] = _rectCorners(center, nw, nh); - while (_returnObstacleSizes.length <= index) { - _returnObstacleSizes.add(_rectSizeOf(corners)); - } - _returnObstacleSizes[index] = (nw, nh); - _returnSaved = false; - }); - }, + onOk: (double nw, double nh) => _updateObstacle( + corners, + _rectCorners(center, nw, nh), + forReturn: true, + size: (nw, nh), + ), ); } @@ -1580,12 +1718,17 @@ class _RouteEditorPageV2State extends State { } _returnSaved = false; }); - _toast('已删除第 ${index + 1} 个返航禁行区,剩余 ${_returnObstacleHoles.length} 个'); + _toast( + _l10n.translate('region_editor.return_obstacle_deleted', { + 'index': index + 1, + 'count': _returnObstacleHoles.length, + }), + ); } void _undoReturnObstacle() { if (_returnObstacleHoles.isEmpty) { - _toast('暂无可撤回的返航禁行区'); + _toast(_l10n.translate('region_editor.no_return_obstacle_to_undo')); return; } setState(() { @@ -1598,7 +1741,11 @@ class _RouteEditorPageV2State extends State { } _returnSaved = false; }); - _toast('已撤回上一个返航禁行区,剩余 ${_returnObstacleHoles.length} 个'); + _toast( + _l10n.translate('region_editor.return_obstacle_undone', { + 'count': _returnObstacleHoles.length, + }), + ); } void _removeReturnPoint(int index) { @@ -1607,19 +1754,27 @@ class _RouteEditorPageV2State extends State { _returnPoints.removeAt(index); if (_returnPoints.isEmpty) _returnSaved = false; }); - _toast('已取消该返航点,剩余 ${_returnPoints.length} 个'); + _toast( + _l10n.translate('region_editor.return_point_canceled', { + 'count': _returnPoints.length, + }), + ); } void _undoReturnPoint() { if (_returnPoints.isEmpty) { - _toast('暂无可撤回的返航点'); + _toast(_l10n.translate('region_editor.no_return_point_to_undo')); return; } setState(() { _returnPoints.removeLast(); if (_returnPoints.isEmpty) _returnSaved = false; }); - _toast('已撤回最后一个返航点,剩余 ${_returnPoints.length} 个'); + _toast( + _l10n.translate('region_editor.return_point_undone', { + 'count': _returnPoints.length, + }), + ); } void _setReturnPointDevice(int index, String sn) { @@ -1638,7 +1793,9 @@ class _RouteEditorPageV2State extends State { final name = _returnPoints[index].alias?.trim() ?? ''; return name.isNotEmpty ? name - : '返航点-${(index + 1).toString().padLeft(2, '0')}'; + : _l10n.translate('region_editor.return_point_name', { + 'index': (index + 1).toString().padLeft(2, '0'), + }); } /// 返航障碍显示名:自定义优先,否则尺寸「Wm×Hm」 @@ -1655,14 +1812,18 @@ class _RouteEditorPageV2State extends State { final point = _returnPoints[index]; showInputConfirmDialog( context: context, - title: '命名返航点 ${index + 1}', - hintText: '给这个返航点起个名字(留空用默认编号)', - labelText: '名字', - confirmText: '确定', - cancelText: '取消', + title: _l10n.translate('region_editor.rename_return_point', { + 'index': index + 1, + }), + hintText: _l10n.translate('region_editor.rename_return_point_hint'), + labelText: _l10n.translate('region_editor.name'), + confirmText: _l10n.translate('common.ok'), + cancelText: _l10n.translate('common.cancel'), maxWidth: 260, initialText: point.alias?.trim() ?? '', - inputValidator: (text) => text.length > 20 ? '名字不能超过 20 个字符' : null, + inputValidator: (text) => text.length > 20 + ? _l10n.translate('region_editor.name_too_long') + : null, onConfirm: (text) { setState(() { _returnPoints[index] = _ReturnPoint( @@ -1685,14 +1846,18 @@ class _RouteEditorPageV2State extends State { : ''; showInputConfirmDialog( context: context, - title: '命名障碍 ${index + 1}', - hintText: '给这个障碍起个名字(留空用尺寸)', - labelText: '名字', - confirmText: '确定', - cancelText: '取消', + title: _l10n.translate('region_editor.rename_obstacle', { + 'index': index + 1, + }), + hintText: _l10n.translate('region_editor.rename_obstacle_hint'), + labelText: _l10n.translate('region_editor.name'), + confirmText: _l10n.translate('common.ok'), + cancelText: _l10n.translate('common.cancel'), maxWidth: 260, initialText: current, - inputValidator: (text) => text.length > 20 ? '名字不能超过 20 个字符' : null, + inputValidator: (text) => text.length > 20 + ? _l10n.translate('region_editor.name_too_long') + : null, onConfirm: (text) { setState(() { while (_returnObstacleNames.length <= index) { @@ -1711,16 +1876,16 @@ class _RouteEditorPageV2State extends State { Future _saveReturnPlan() async { if (_savingReturn) return; if (_returnPoints.isEmpty && _returnObstacleHoles.isEmpty) { - _toast('请先在地图上添加返航点'); + _toast(_l10n.translate('region_editor.add_return_points_first')); return; } final site = sl().state.selectedSite; if (site == null) { - _toast('请先选择一个场站!'); + _toast(_l10n.translate('region_editor.select_site')); return; } if (site.id != _draftSiteId) { - _toast('场站已切换,请重新进入编辑器后保存'); + _toast(_l10n.translate('region_editor.site_changed')); return; } @@ -1736,7 +1901,7 @@ class _RouteEditorPageV2State extends State { for (int i = 0; i < _returnObstacleHoles.length; i++) () { final List corners = _returnObstacleHoles[i]; - // 直接用用户在尺寸弹窗里填写的宽高(避免从四角反算出现 3.99999 漂移); + // 直接用编辑时记录的宽高,避免再次从四角反算产生浮点误差。 // 若无记录(旧草稿)才退回四角反算。 final (double w, double h) = i < _returnObstacleSizes.length ? _returnObstacleSizes[i] @@ -1746,7 +1911,11 @@ class _RouteEditorPageV2State extends State { : ''; return ReturnObstaclePoint( center: _rectCenter(corners), - alias: custom.isNotEmpty ? custom : '障碍物点-${i + 1}', + alias: custom.isNotEmpty + ? custom + : _l10n.translate('region_editor.obstacle_point_name', { + 'index': i + 1, + }), sizeX: w, sizeY: h, ); @@ -1767,7 +1936,9 @@ class _RouteEditorPageV2State extends State { setState(() => _savingReturn = false); if (!result.isOk) { - _toast(result.error ?? '返航方案保存失败'); + _toast( + result.error ?? _l10n.translate('region_editor.return_save_failed'), + ); return; } setState(() { @@ -1777,15 +1948,21 @@ class _RouteEditorPageV2State extends State { }); _persistDraft(); CapsuleToast.show( - '返航方案已保存:${restPoints.length} 个返航点' - '${obstacles.isEmpty ? '' : ' · ${obstacles.length} 个障碍'}', + _l10n.translate('region_editor.return_saved', { + 'points': restPoints.length, + 'obstacles': obstacles.isEmpty + ? '' + : _l10n.translate('region_editor.obstacles_suffix', { + 'count': obstacles.length, + }), + }), ); } /// 设备返航接口未开放,保留草稿,不模拟下发成功。 Future _executeReturnPlan() async { _persistDraft(); - _toast('返航执行接口尚未接入,返航点已保留'); + _toast(_l10n.translate('region_editor.return_execute_unavailable')); } /// 监控视频流:与路径规划同一套拼接(device/{sn}/live + 登录 token) @@ -1799,11 +1976,11 @@ class _RouteEditorPageV2State extends State { /// 保存区域(复刻 _showSavePlotDialog):先选规划类型,再输名称,再截图上传。 Future _showSaveDialog() async { if (_markedPoints.isEmpty) { - _toast('请先添加作业区域打点!'); + _toast(_l10n.translate('region_editor.add_work_points_first')); return; } if (_workMode == WorkMode.bow && _markedPoints.length < 3) { - _toast('作业区域至少需要 3 个打点!'); + _toast(_l10n.translate('region_editor.work_area_needs_three_points')); return; } // 后端 workRecord.routeType 必填(与旧版路径规划共用同一接口) @@ -1815,15 +1992,17 @@ class _RouteEditorPageV2State extends State { if (routeType == null || !mounted) return; await showInputConfirmDialog( context: context, - title: '保存区域', - hintText: '请输入区域名称(最多 20 字)', - labelText: '区域名称', - confirmText: '保存', - cancelText: '取消', + title: _l10n.translate('region_editor.save_area'), + hintText: _l10n.translate('region_editor.area_name_hint'), + labelText: _l10n.translate('region_editor.area_name'), + confirmText: _l10n.translate('route_planning.save'), + cancelText: _l10n.translate('common.cancel'), maxWidth: 260, inputValidator: (text) { - if (text.isEmpty) return '区域名称不能为空'; - if (text.length > 20) return '区域名称不能超过 20 个字符'; + if (text.isEmpty) + return _l10n.translate('region_editor.area_name_required'); + if (text.length > 20) + return _l10n.translate('region_editor.area_name_too_long'); return null; }, onConfirm: (name) => _saveRecord(name, routeType), @@ -1832,12 +2011,14 @@ class _RouteEditorPageV2State extends State { Future _saveRecord(String name, RouteType routeType) async { if (sl().state.selectedSite?.id != _draftSiteId) { - _toast('场站已切换,请重新进入编辑器后保存'); + _toast(_l10n.translate('region_editor.site_changed')); return; } setState(() => _saving = true); String? imageBase64; try { + await WidgetsBinding.instance.endOfFrame; + if (!mounted) return; imageBase64 = await _captureMapToJpgBase64(); } catch (e) { debugPrint('[区域编辑] 地图截图失败: $e'); @@ -1858,10 +2039,16 @@ class _RouteEditorPageV2State extends State { setState(() => _saving = false); if (!result.isOk) { - _toast(result.error ?? '保存失败'); + _toast(result.error ?? _l10n.translate('route_planning.save_failed')); return; } - _toast(imageBase64 == null ? '「$name」已保存,但地图截图生成失败' : '「$name」已保存'); + _toast( + imageBase64 == null + ? _l10n.translate('region_editor.saved_without_screenshot', { + 'name': name, + }) + : _l10n.translate('region_editor.area_saved', {'name': name}), + ); // 保存成功后清空,回到可以画下一块地的状态(同路径规划) setState(() { _markedPoints.clear(); @@ -1905,8 +2092,13 @@ class _RouteEditorPageV2State extends State { } String get _statusTextOfArea { - return '作业区 ${_markedPoints.length} 点 · 禁行区 ${_obstacleHoles.length} 处 · ' - '${_workMode == WorkMode.bow ? '覆盖' : '自定义'}模式'; + return _l10n.translate('region_editor.area_summary', { + 'points': _markedPoints.length, + 'obstacles': _obstacleHoles.length, + 'mode': _workMode == WorkMode.bow + ? _l10n.translate('region_editor.coverage') + : _l10n.translate('region_editor.custom'), + }); } @override @@ -2042,6 +2234,16 @@ class _RouteEditorPageV2State extends State { } Widget _buildMapLayer() { + final canResize = _editingObstacles && !_saving && !_savingReturn; + final selected = _selectedObstacle; + final editableObstacle = + canResize && + selected != null && + selected.length == 4 && + _activeObstacleHoles.contains(selected) + ? selected + : null; + final forReturn = _isReturnMode; return Stack( fit: StackFit.expand, children: [ @@ -2075,8 +2277,22 @@ class _RouteEditorPageV2State extends State { previewOuter: _outerPoints, previewCoverage: _workMode == WorkMode.bow, extraMapLayers: _regionMapLayers(), + foregroundMapLayer: editableObstacle == null + ? null + : ObstacleResizeLayer( + key: ObjectKey(editableObstacle), + corners: editableObstacle, + dimensions: _rectName(editableObstacle), + onChanged: (corners) => _updateObstacle( + editableObstacle, + corners, + forReturn: forReturn, + ), + ), + onMapTap: canResize ? _selectObstacleAt : null, focusPoints: _regionFocusPoints, focusSignal: _regionFocusSignal, + focusMaxZoom: editableObstacle == null ? null : 22, focusPadding: EdgeInsets.fromLTRB( 110, 70, @@ -2158,7 +2374,11 @@ class _RouteEditorPageV2State extends State { selected: region.id == _regionList.state.selectedId, enabled: region.enabled, showVertices: false, - label: region.name.isEmpty ? '分区 #${region.id}' : region.name, + label: region.name.isEmpty + ? _l10n.translate('region_editor.region_number', { + 'id': region.id, + }) + : region.name, ), if (editing) RegionBoundaryLayer( @@ -2202,7 +2422,7 @@ class _RouteEditorPageV2State extends State { Flexible( flex: 2, child: Text( - '地图与区域编辑', + _l10n.translate('region_editor.title'), maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -2219,7 +2439,13 @@ class _RouteEditorPageV2State extends State { builder: (context, _) => _deviceChip(m), ), SizedBox(width: (14 * m.k).clamp(8.0, 14.0)), - Flexible(child: _statusText(m, Icons.wifi_rounded, '4G在线')), + Flexible( + child: _statusText( + m, + Icons.wifi_rounded, + _l10n.translate('region_editor.network_online'), + ), + ), SizedBox(width: (12 * m.k).clamp(7.0, 12.0)), // 定位质量(实时):与自主作业中心同口径,取 DeviceStatusBloc 的 qual; // 窄屏用短文案,并包 Flexible 兑底防溢出 @@ -2250,7 +2476,11 @@ class _RouteEditorPageV2State extends State { m, Icons.battery_5_bar_rounded, pct == null - ? (m.tiny ? '--' : '电量未知') + ? (m.tiny + ? '--' + : _l10n.translate( + 'region_editor.battery_unknown', + )) : '${pct.round()}%', color: pct == null ? kWtMuted @@ -2309,7 +2539,7 @@ class _RouteEditorPageV2State extends State { } return sn; // 列表尚未加载/未含该设备:兑底显示编码本身 } - return '未选择设备'; + return _l10n.translate('pv_control.no_device'); } Widget _deviceChip(_EL m) { @@ -2397,7 +2627,7 @@ class _RouteEditorPageV2State extends State { ), SizedBox(width: (4 * m.k).clamp(2.0, 4.0)), Text( - '竖屏', + _l10n.translate('region_editor.portrait'), maxLines: 1, style: TextStyle( fontSize: m.fs(12), @@ -2415,7 +2645,10 @@ class _RouteEditorPageV2State extends State { Widget _sunButton(_EL m) { final side = (34 * m.k).clamp(24.0, 34.0); return InkWell( - onTap: () => CapsuleToast.show('地图亮度调节暂未开发(演示)', showCheck: false), + onTap: () => CapsuleToast.show( + _l10n.translate('region_editor.brightness_demo'), + showCheck: false, + ), borderRadius: BorderRadius.circular(999), child: Container( width: side, @@ -2483,7 +2716,7 @@ class _RouteEditorPageV2State extends State { _railTile( m, _tools[i].$1, - _tools[i].$2, + _l10n.translate(_tools[i].$2), _tool == i, () => _onToolTap(i), itemH, @@ -2520,7 +2753,7 @@ class _RouteEditorPageV2State extends State { _railTile( m, Icons.category_rounded, - '分区', + _l10n.translate('region_editor.region'), workSel, () => _onZoneTap(0), zoneItemH, @@ -2533,7 +2766,7 @@ class _RouteEditorPageV2State extends State { _railTile( m, Icons.block_rounded, - '障碍物', + _l10n.translate('region_editor.obstacle'), obstacleSel, () => _onZoneTap(1), zoneItemH, @@ -2612,7 +2845,9 @@ class _RouteEditorPageV2State extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - _isReturnMode ? '一键返航 · 返航点' : '当前场站 · 新建区域', + _isReturnMode + ? _l10n.translate('region_editor.return_points_title') + : _l10n.translate('region_editor.new_area_at_site'), style: TextStyle( fontSize: m.fs(14.5), height: 1.15, @@ -2729,7 +2964,7 @@ class _RouteEditorPageV2State extends State { if (!m.tiny) ...[ const SizedBox(height: 3), Text( - '点「圈地」选择作业模式 → 打点 → 完成 → 保存区域', + _l10n.translate('region_editor.new_area_steps'), maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -2745,7 +2980,7 @@ class _RouteEditorPageV2State extends State { SizedBox(width: (10 * m.k).clamp(6.0, 10.0)), _barButton( m, - '保存区域', + _l10n.translate('region_editor.save_area'), primary: false, icon: Icons.save_outlined, onPressed: _showSaveDialog, @@ -2753,7 +2988,7 @@ class _RouteEditorPageV2State extends State { SizedBox(width: (8 * m.k).clamp(5.0, 8.0)), _barButton( m, - '圈地', + _l10n.translate('region_editor.mark_area'), primary: true, icon: Icons.crop_free_rounded, onPressed: () { @@ -2828,23 +3063,27 @@ class _RouteEditorPageV2State extends State { ) = switch (mode) { 1 => ( Icons.category_rounded, - '分区 · 四点范围', + _l10n.translate('region_editor.region_four_point_title'), _regionEditor.state.draft.scope.length, - '依次打 4 个边界点', + _l10n.translate('region_editor.mark_four_points'), ), 2 => ( Icons.block_rounded, - '障碍物 · 禁行区矩形', + _l10n.translate('region_editor.obstacle_mode'), _obstacleHoles.length, - '点「+」落矩形,改 X/Y 尺寸', + _l10n.translate('region_editor.resize_rectangle_hint'), ), _ => ( _returnDropObstacle ? Icons.block_rounded : Icons.u_turn_left_rounded, - _returnDropObstacle ? '一键返航 · 障碍点' : '一键返航 · 返航点', + _returnDropObstacle + ? _l10n.translate('region_editor.return_obstacles_title') + : _l10n.translate('region_editor.return_points_title'), _returnDropObstacle ? _returnObstacleHoles.length : _returnPoints.length, - _returnDropObstacle ? '点「+」在返航线上落障碍矩形' : '按打点顺序返航', + _returnDropObstacle + ? _l10n.translate('region_editor.resize_rectangle_hint') + : _l10n.translate('region_editor.return_order'), ), }; return Row( @@ -2894,7 +3133,7 @@ class _RouteEditorPageV2State extends State { ), const SizedBox(width: 3), Text( - '已保存', + _l10n.translate('region_editor.saved'), style: TextStyle( fontSize: m.fs(11), fontWeight: FontWeight.w700, @@ -2942,7 +3181,16 @@ class _RouteEditorPageV2State extends State { _dropdown( m, value: _dropMode == 1 ? _regionRobotMode : _robotMode, - items: const [(RobotMode.point, '准星打点'), (RobotMode.robot, '设备打点')], + items: [ + ( + RobotMode.point, + _l10n.translate('region_editor.mark_with_crosshair'), + ), + ( + RobotMode.robot, + _l10n.translate('region_editor.mark_with_device'), + ), + ], onChanged: (mode) { setState(() { if (_dropMode == 1) { @@ -2953,10 +3201,12 @@ class _RouteEditorPageV2State extends State { }); _toast( _dropMode == 0 - ? (mode == RobotMode.point ? '准星打点:地图中心即返航点' : '设备打点:取设备实时坐标') + ? (mode == RobotMode.point + ? _l10n.translate('region_editor.crosshair_return_hint') + : _l10n.translate('region_editor.device_mark_hint')) : (mode == RobotMode.point - ? '准星打点:地图中心即打点位置' - : '设备打点:取设备实时坐标'), + ? _l10n.translate('region_editor.crosshair_mark_hint') + : _l10n.translate('region_editor.device_mark_hint')), ); }, ), @@ -2978,7 +3228,7 @@ class _RouteEditorPageV2State extends State { ...[ SizedBox(width: (8 * m.k).clamp(5.0, 8.0)), Text( - '默认设备', + _l10n.translate('region_editor.default_device'), style: TextStyle( fontSize: m.fs(11.5), fontWeight: FontWeight.w600, @@ -3060,13 +3310,25 @@ class _RouteEditorPageV2State extends State { return Row( mainAxisSize: MainAxisSize.min, children: [ - pill(Icons.u_turn_left_rounded, '返航点', !_returnDropObstacle, () { - if (_returnDropObstacle) setState(() => _returnDropObstacle = false); - }), + pill( + Icons.u_turn_left_rounded, + _l10n.translate('work_v2.route_lib.return_points'), + !_returnDropObstacle, + () { + if (_returnDropObstacle) + setState(() => _returnDropObstacle = false); + }, + ), SizedBox(width: (6 * m.k).clamp(4.0, 6.0)), - pill(Icons.block_rounded, '障碍点', _returnDropObstacle, () { - if (!_returnDropObstacle) setState(() => _returnDropObstacle = true); - }), + pill( + Icons.block_rounded, + _l10n.translate('region_editor.obstacle_point'), + _returnDropObstacle, + () { + if (!_returnDropObstacle) + setState(() => _returnDropObstacle = true); + }, + ), ], ); } @@ -3106,9 +3368,19 @@ class _RouteEditorPageV2State extends State { return Row( mainAxisSize: MainAxisSize.min, children: [ - pill(Icons.crop_square_rounded, '矩形', true, true), + pill( + Icons.crop_square_rounded, + _l10n.translate('work_v2.route_lib.return_shape_rect'), + true, + true, + ), SizedBox(width: (6 * m.k).clamp(4.0, 6.0)), - pill(Icons.radio_button_unchecked_rounded, '圆形', false, false), + pill( + Icons.radio_button_unchecked_rounded, + _l10n.translate('work_v2.route_lib.return_shape_circle'), + false, + false, + ), ], ); } @@ -3117,7 +3389,7 @@ class _RouteEditorPageV2State extends State { Widget _returnDeviceChip(_EL m) { final options = _deviceOptions; final String label = _returnDeviceSn == null - ? '选择设备' + ? _l10n.translate('region_editor.choose_device') : _labelOfDevice(_returnDeviceSn); return PopupMenuButton( tooltip: '', @@ -3130,7 +3402,7 @@ class _RouteEditorPageV2State extends State { enabled: false, height: 34, child: Text( - '暂无可用设备', + _l10n.translate('region_editor.devices_empty'), style: TextStyle(fontSize: m.fs(12), color: kWtGray), ), ), @@ -3230,6 +3502,7 @@ class _RouteEditorPageV2State extends State { separatorBuilder: (_, _) => const SizedBox(width: 8), itemBuilder: (context, index) { final corners = holes[index]; + final selected = identical(corners, _selectedObstacle); final String label = nameOf != null ? nameOf(corners, index) : _rectName(corners); @@ -3240,26 +3513,38 @@ class _RouteEditorPageV2State extends State { ), alignment: Alignment.center, decoration: BoxDecoration( - color: Colors.white, + color: selected ? kWtSoftBlue : Colors.white, borderRadius: BorderRadius.circular(10), - border: Border.all(color: kWtBorder), + border: Border.all(color: selected ? kWtBlue : kWtBorder), ), child: Row( children: [ - Container( - width: 16, - height: 16, - alignment: Alignment.center, - decoration: const BoxDecoration( - color: kWtWarn, - shape: BoxShape.circle, - ), - child: Text( - '${index + 1}', - style: const TextStyle( - color: Colors.white, - fontSize: 9, - fontWeight: FontWeight.w800, + Tooltip( + message: _l10n.translate('region_editor.select_rectangle'), + child: InkWell( + onTap: corners.length == 4 + ? () => setState(() => _focusObstacle(corners)) + : null, + borderRadius: BorderRadius.circular(14), + child: Padding( + padding: const EdgeInsets.all(5), + child: Container( + width: 16, + height: 16, + alignment: Alignment.center, + decoration: BoxDecoration( + color: selected ? kWtBlue : kWtWarn, + shape: BoxShape.circle, + ), + child: Text( + '${index + 1}', + style: const TextStyle( + color: Colors.white, + fontSize: 9, + fontWeight: FontWeight.w800, + ), + ), + ), ), ), ), @@ -3348,7 +3633,7 @@ class _RouteEditorPageV2State extends State { onDelete: _removeReturnObstacle, nameOf: (corners, i) => _returnObstacleDisplay(i), onRename: _renameReturnObstacle, - emptyHint: '对准障碍位置点绿色「+」在返航线上落一个矩形(点名字可改名)', + emptyHint: _l10n.translate('region_editor.return_obstacle_empty_hint'), ); } // 障碍物(圈地):每个矩形一张卡,显示名字 + 编辑尺寸 + 删除 @@ -3358,7 +3643,7 @@ class _RouteEditorPageV2State extends State { _obstacleHoles, onEdit: _editObstacleRect, onDelete: _removeDraftPoint, - emptyHint: '对准障碍物位置点绿色「+」落一个矩形', + emptyHint: _l10n.translate('region_editor.obstacle_empty_hint'), ); } // 分区(作业区):序号 + 坐标 + 删除 @@ -3374,7 +3659,7 @@ class _RouteEditorPageV2State extends State { border: Border.all(color: kWtBorder), ), child: Text( - '尚未加分区点:点绿色「+」依次打 4 个边界点', + _l10n.translate('region_editor.region_points_empty'), maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: m.fs(11.5), color: kWtGray), @@ -3465,7 +3750,7 @@ class _RouteEditorPageV2State extends State { border: Border.all(color: kWtBorder), ), child: Text( - '尚未添加返航点:点绿色「+」在当前准星/设备位置打点', + _l10n.translate('region_editor.return_points_empty'), maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: m.fs(11.5), color: kWtGray), @@ -3581,7 +3866,7 @@ class _RouteEditorPageV2State extends State { enabled: false, height: 34, child: Text( - '暂无可用设备', + _l10n.translate('region_editor.devices_empty'), style: TextStyle(fontSize: m.fs(12), color: kWtGray), ), ), @@ -3620,7 +3905,9 @@ class _RouteEditorPageV2State extends State { const SizedBox(width: 3), Expanded( child: Text( - point.deviceLabel, + (point.deviceSn ?? '').isEmpty + ? _l10n.translate('pv_control.no_device') + : point.deviceLabel, maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -3664,7 +3951,7 @@ class _RouteEditorPageV2State extends State { SizedBox(width: (10 * m.k).clamp(6.0, 10.0)), _barButton( m, - '取消', + _l10n.translate('common.cancel'), primary: false, icon: Icons.close_rounded, onPressed: _closeDropPanel, @@ -3672,7 +3959,7 @@ class _RouteEditorPageV2State extends State { SizedBox(width: (6 * m.k).clamp(4.0, 6.0)), _barButton( m, - '撤回', + _l10n.translate('route_planning.undo'), primary: false, icon: Icons.undo_rounded, onPressed: _undoAction, @@ -3682,7 +3969,7 @@ class _RouteEditorPageV2State extends State { SizedBox(width: (6 * m.k).clamp(4.0, 6.0)), _barButton( m, - '完成', + _l10n.translate('route_planning.complete'), primary: false, icon: Icons.check_rounded, onPressed: _onCompleteTap, @@ -3691,7 +3978,7 @@ class _RouteEditorPageV2State extends State { SizedBox(width: (6 * m.k).clamp(4.0, 6.0)), _barButton( m, - '保存', + _l10n.translate('route_planning.save'), primary: true, icon: Icons.save_outlined, onPressed: _showSaveDialog, @@ -3704,8 +3991,12 @@ class _RouteEditorPageV2State extends State { Expanded( child: Text( _returnDropObstacle - ? '障碍点 ${_returnObstacleHoles.length} 个' - '${_returnSaved ? ' · 已保存' : ' · 与分区/障碍互不影响'}' + ? _l10n.translate('region_editor.return_obstacle_summary', { + 'count': _returnObstacleHoles.length, + 'note': _returnSaved + ? _l10n.translate('region_editor.saved_suffix') + : _l10n.translate('region_editor.independent_suffix'), + }) : _returnHint, maxLines: 1, overflow: TextOverflow.ellipsis, @@ -3720,7 +4011,7 @@ class _RouteEditorPageV2State extends State { SizedBox(width: (10 * m.k).clamp(6.0, 10.0)), _barButton( m, - '取消', + _l10n.translate('common.cancel'), primary: false, icon: Icons.close_rounded, onPressed: () => _exitReturnMode(clear: true), @@ -3728,7 +4019,7 @@ class _RouteEditorPageV2State extends State { SizedBox(width: (6 * m.k).clamp(4.0, 6.0)), _barButton( m, - '撤回', + _l10n.translate('route_planning.undo'), primary: false, icon: Icons.undo_rounded, onPressed: _returnDropObstacle @@ -3738,7 +4029,11 @@ class _RouteEditorPageV2State extends State { SizedBox(width: (6 * m.k).clamp(4.0, 6.0)), _barButton( m, - _savingReturn ? '保存中' : (_returnPlanId != null ? '修改' : '保存'), + _savingReturn + ? _l10n.translate('region_editor.saving') + : (_returnPlanId != null + ? _l10n.translate('region_editor.edit') + : _l10n.translate('route_planning.save')), primary: false, icon: _savingReturn ? Icons.autorenew_rounded : Icons.save_outlined, onPressed: _saveReturnPlan, @@ -3746,7 +4041,7 @@ class _RouteEditorPageV2State extends State { SizedBox(width: (6 * m.k).clamp(4.0, 6.0)), _barButton( m, - '执行', + _l10n.translate('region_editor.execute'), primary: true, icon: Icons.send_rounded, onPressed: _executeReturnPlan, @@ -3816,11 +4111,22 @@ class _RouteEditorPageV2State extends State { _dropdown( m, value: _robotMode, - items: const [(RobotMode.point, '准星打点'), (RobotMode.robot, '设备打点')], + items: [ + ( + RobotMode.point, + _l10n.translate('region_editor.mark_with_crosshair'), + ), + ( + RobotMode.robot, + _l10n.translate('region_editor.mark_with_device'), + ), + ], onChanged: (mode) { setState(() => _robotMode = mode); _toast( - mode == RobotMode.point ? '准星打点:地图中心即打点位置' : '设备打点:取设备实时坐标', + mode == RobotMode.point + ? _l10n.translate('region_editor.crosshair_mark_hint') + : _l10n.translate('region_editor.device_mark_hint'), ); }, ), @@ -3831,9 +4137,12 @@ class _RouteEditorPageV2State extends State { _dropdown( m, value: _areaMode, - items: const [ - (AreaMode.work, '作业区域'), - (AreaMode.obstacle, '障碍区域'), + items: [ + (AreaMode.work, _l10n.translate('route_planning.work_area')), + ( + AreaMode.obstacle, + _l10n.translate('route_planning.obstacle_area'), + ), ], onChanged: (mode) => setState(() => _areaMode = mode), ) @@ -3848,22 +4157,28 @@ class _RouteEditorPageV2State extends State { _roundAction( m, Icons.delete_outline_rounded, - '删除', + _l10n.translate('route_planning.delete'), true, () => _deleteAllAction(), ), _roundAction( m, Icons.undo_rounded, - '撤回', + _l10n.translate('route_planning.undo'), canUndo, () => _undoAction(), ), - _roundAction(m, Icons.check_rounded, '完成', true, _onCompleteTap), + _roundAction( + m, + Icons.check_rounded, + _l10n.translate('route_planning.complete'), + true, + _onCompleteTap, + ), _roundAction( m, Icons.save_outlined, - '保存', + _l10n.translate('route_planning.save'), _markedPoints.isNotEmpty, _showSaveDialog, ), @@ -3878,7 +4193,7 @@ class _RouteEditorPageV2State extends State { Row( children: [ Text( - '作业行距', + _l10n.translate('region_editor.row_spacing'), style: TextStyle( fontSize: m.fs(12.5), fontWeight: FontWeight.w700, @@ -3912,7 +4227,7 @@ class _RouteEditorPageV2State extends State { Row( children: [ Text( - '航线方向', + _l10n.translate('route_planning.route_direction'), style: TextStyle( fontSize: m.fs(12.5), fontWeight: FontWeight.w700, @@ -3922,7 +4237,9 @@ class _RouteEditorPageV2State extends State { const Spacer(), _barButton( m, - _angle < 0 ? '最优航向' : '${_angle.toStringAsFixed(0)}°', + _angle < 0 + ? _l10n.translate('route_planning.optimal_heading') + : '${_angle.toStringAsFixed(0)}°', primary: false, onPressed: _showDirectionDialog, ), @@ -3946,11 +4263,8 @@ class _RouteEditorPageV2State extends State { center: center, w: w, h: h, - onOk: (double nw, double nh) { - setState(() { - _obstacleHoles[index] = _rectCorners(center, nw, nh); - }); - }, + onOk: (double nw, double nh) => + _updateObstacle(corners, _rectCorners(center, nw, nh), forReturn: false), ); } @@ -3985,7 +4299,9 @@ class _RouteEditorPageV2State extends State { borderRadius: BorderRadius.circular(8), ), child: Text( - land ? '地块' : '航线', + land + ? _l10n.translate('route_planning.land') + : _l10n.translate('route_planning.route'), style: TextStyle( fontSize: m.fs(12), fontWeight: selected ? FontWeight.w800 : FontWeight.w600, @@ -4155,7 +4471,7 @@ class _RouteEditorPageV2State extends State { horizontal: 80, vertical: 24, ), - title: const Text('航线方向'), + title: Text(_l10n.translate('route_planning.route_direction')), content: SizedBox( width: 240, child: Column( @@ -4163,7 +4479,11 @@ class _RouteEditorPageV2State extends State { children: [ Row( children: [ - const Expanded(child: Text('使用最优航向')), + Expanded( + child: Text( + _l10n.translate('region_editor.use_optimal_heading'), + ), + ), Switch( value: optimal, onChanged: (v) => setDialogState(() => optimal = v), @@ -4186,14 +4506,14 @@ class _RouteEditorPageV2State extends State { actions: [ TextButton( onPressed: () => Navigator.pop(dialogContext), - child: const Text('取消'), + child: Text(_l10n.translate('common.cancel')), ), ElevatedButton( onPressed: () { setState(() => _angle = optimal ? -1 : angle); Navigator.pop(dialogContext); }, - child: const Text('确认'), + child: Text(_l10n.translate('common.confirm')), ), ], ), @@ -4219,8 +4539,10 @@ class _RouteEditorPageV2State extends State { Widget _buildReturnListPanel(_EL m) { final draft = _pendingReturnDraft; if (draft == null) return const SizedBox.shrink(); - final subtitle = - '${draft.restPoints.length} 个返航点 · ${draft.obstacles.length} 个障碍'; + final subtitle = _l10n.translate('region_editor.return_counts', { + 'points': draft.restPoints.length, + 'obstacles': draft.obstacles.length, + }); return Positioned.fill( child: Column( children: [ @@ -4279,7 +4601,7 @@ class _RouteEditorPageV2State extends State { ), const SizedBox(width: 9), Text( - '一键返航', + _l10n.translate('pv_control.rail_return_home'), style: TextStyle( fontSize: m.fs(16), fontWeight: FontWeight.w800, @@ -4348,7 +4670,7 @@ class _RouteEditorPageV2State extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - '返航方案', + _l10n.translate('region_editor.return_plan'), maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -4380,7 +4702,7 @@ class _RouteEditorPageV2State extends State { borderRadius: BorderRadius.circular(999), ), child: Text( - '修改', + _l10n.translate('region_editor.edit'), style: TextStyle( fontSize: m.fs(11.5), fontWeight: FontWeight.w700, @@ -4460,7 +4782,7 @@ class _RouteEditorPageV2State extends State { ), const SizedBox(width: 9), Text( - '作业记录', + _l10n.translate('work_v2.feature_record'), style: TextStyle( fontSize: m.fs(16), fontWeight: FontWeight.w800, @@ -4529,7 +4851,7 @@ class _RouteEditorPageV2State extends State { ), const SizedBox(height: 10), Text( - '当前场站暂无作业记录', + _l10n.translate('region_editor.records_empty'), style: TextStyle(fontSize: m.fs(13), color: kWtGray), ), ], @@ -4571,7 +4893,9 @@ class _RouteEditorPageV2State extends State { children: [ Text( route.name.isEmpty - ? '未命名作业' + ? _l10n.translate( + 'region_editor.unnamed_work', + ) : route.name, maxLines: 1, overflow: TextOverflow.ellipsis, @@ -4584,7 +4908,7 @@ class _RouteEditorPageV2State extends State { if (route.planModeLabel != null) ...[ const SizedBox(height: 2), Text( - route.planModeLabel!, + workRouteModeLabel(route, _l10n), maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -4635,7 +4959,7 @@ class _RouteEditorPageV2State extends State { children: [ Center( child: Text( - '未获取到视频流', + _l10n.translate('region_editor.no_video'), style: TextStyle(fontSize: m.fs(12), color: Colors.white), ), ), @@ -4763,6 +5087,8 @@ class _WorkModeDialog extends StatefulWidget { } class _WorkModeDialogState extends State<_WorkModeDialog> { + AppLocalizations get _l10n => AppLocalizations.of(context); + late WorkMode _selected = widget.initial; @override @@ -4788,16 +5114,18 @@ class _WorkModeDialogState extends State<_WorkModeDialog> { ), const SizedBox(height: 12), _modeItem( - title: '覆盖模式', - subtitle: '标准全覆盖路径规划', + title: _l10n.translate('route_planning.bow_mode'), + subtitle: _l10n.translate('route_planning.bow_mode_subtitle'), icon: Icons.crop_free_rounded, selected: _selected == WorkMode.bow, onTap: () => setState(() => _selected = WorkMode.bow), ), const SizedBox(height: 10), _modeItem( - title: '自定义模式', - subtitle: '手动设定作业区域', + title: _l10n.translate('route_planning.custom_mode'), + subtitle: _l10n.translate( + 'route_planning.custom_mode_subtitle', + ), icon: Icons.route_rounded, selected: _selected == WorkMode.custom, onTap: () => setState(() => _selected = WorkMode.custom), @@ -4808,7 +5136,7 @@ class _WorkModeDialogState extends State<_WorkModeDialog> { children: [ TextButton( onPressed: () => Navigator.pop(context), - child: const Text('取消'), + child: Text(_l10n.translate('common.cancel')), ), const SizedBox(width: 6), ElevatedButton( @@ -4821,7 +5149,7 @@ class _WorkModeDialogState extends State<_WorkModeDialog> { borderRadius: BorderRadius.circular(9), ), ), - child: const Text('确认'), + child: Text(_l10n.translate('common.confirm')), ), ], ), @@ -4901,6 +5229,8 @@ class _RectSizeDialog extends StatefulWidget { } class _RectSizeDialogState extends State<_RectSizeDialog> { + AppLocalizations get _l10n => AppLocalizations.of(context); + late final TextEditingController _wCtrl = TextEditingController( text: widget.initialW.toStringAsFixed(1), ); @@ -4956,8 +5286,8 @@ class _RectSizeDialogState extends State<_RectSizeDialog> { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - const Text( - '矩形尺寸', + Text( + _l10n.translate('region_editor.rectangle_dimensions'), style: TextStyle(fontSize: 17, fontWeight: FontWeight.w700), ), const SizedBox(height: 12), @@ -4975,7 +5305,11 @@ class _RectSizeDialogState extends State<_RectSizeDialog> { decimal: true, ), inputFormatters: _digits, - decoration: const InputDecoration(labelText: '宽 X(米)'), + decoration: InputDecoration( + labelText: _l10n.translate( + 'region_editor.rectangle_width', + ), + ), onChanged: (_) => setState(() {}), ), const SizedBox(height: 12), @@ -4986,14 +5320,21 @@ class _RectSizeDialogState extends State<_RectSizeDialog> { decimal: true, ), inputFormatters: _digits, - decoration: const InputDecoration(labelText: '高 Y(米)'), + decoration: InputDecoration( + labelText: _l10n.translate( + 'region_editor.rectangle_height', + ), + ), onChanged: (_) => setState(() {}), ), const SizedBox(height: 12), Align( alignment: Alignment.centerLeft, child: Text( - '名字:${previewW.toStringAsFixed(1)}m×${previewH.toStringAsFixed(1)}m', + _l10n.translate('region_editor.rectangle_preview', { + 'width': previewW.toStringAsFixed(1), + 'height': previewH.toStringAsFixed(1), + }), style: const TextStyle( fontSize: 13, fontWeight: FontWeight.w700, @@ -5003,10 +5344,12 @@ class _RectSizeDialogState extends State<_RectSizeDialog> { ), if (!_valid) ...[ const SizedBox(height: 4), - const Align( + Align( alignment: Alignment.centerLeft, child: Text( - '请输入大于 0 的宽高', + _l10n.translate( + 'region_editor.rectangle_positive_dimensions', + ), style: TextStyle(fontSize: 12, color: kWtDanger), ), ), @@ -5022,7 +5365,7 @@ class _RectSizeDialogState extends State<_RectSizeDialog> { children: [ TextButton( onPressed: () => Navigator.pop(context), - child: const Text('取消'), + child: Text(_l10n.translate('common.cancel')), ), ElevatedButton( onPressed: () { @@ -5034,7 +5377,7 @@ class _RectSizeDialogState extends State<_RectSizeDialog> { } Navigator.pop(context, (ww, hh)); }, - child: const Text('确定'), + child: Text(_l10n.translate('common.ok')), ), ], ), @@ -5051,7 +5394,7 @@ class _ReturnPoint { const _ReturnPoint({ required this.point, this.deviceSn, - this.deviceLabel = '未选择设备', + this.deviceLabel = '', this.alias, }); diff --git a/lib/features/v2/device_list/presentation/widgets/autonomous/work_confirm_dialog.dart b/lib/features/v2/device_list/presentation/widgets/autonomous/work_confirm_dialog.dart index 16bc9d53..22928a0c 100644 --- a/lib/features/v2/device_list/presentation/widgets/autonomous/work_confirm_dialog.dart +++ b/lib/features/v2/device_list/presentation/widgets/autonomous/work_confirm_dialog.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; /// 自主作业二次确认弹窗(横屏)——对应设计稿 5 种确认框: /// 开始作业 / 暂停作业 / 停止作业 / 取消待执行 / 继续·断点续作。 @@ -52,6 +53,7 @@ class _WorkConfirmDialog extends StatelessWidget { @override Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context); final accent = danger ? _danger : _blue; return Dialog( backgroundColor: Colors.transparent, @@ -124,12 +126,12 @@ class _WorkConfirmDialog extends StatelessWidget { ), const SizedBox(height: 14), for (final check in checks) ...[ - _checkRow(check), + _checkRow(check, l10n), const SizedBox(height: 8), ], const SizedBox(height: 6), - const Text( - '这是视觉交互演示。实际确认结果必须等待机器人回执;超时不能直接显示成功。', + Text( + l10n.translate('autonomous_work.confirmation_demo_note'), style: TextStyle( fontSize: 11.5, height: 1.6, @@ -146,7 +148,7 @@ class _WorkConfirmDialog extends StatelessWidget { children: [ Expanded( child: _button( - label: '返回', + label: l10n.translate('common.back'), onTap: () => Navigator.of(context).pop(false), ), ), @@ -168,7 +170,7 @@ class _WorkConfirmDialog extends StatelessWidget { ); } - Widget _checkRow(String text) { + Widget _checkRow(String text, AppLocalizations l10n) { return Container( width: double.infinity, padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 11), @@ -191,8 +193,8 @@ class _WorkConfirmDialog extends StatelessWidget { ), ), const SizedBox(width: 8), - const Text( - '待设备校验', + Text( + l10n.translate('autonomous_work.pending_device_check'), style: TextStyle( fontSize: 11, fontWeight: FontWeight.w700, diff --git a/lib/features/v2/device_list/presentation/widgets/autonomous/work_record_panels.dart b/lib/features/v2/device_list/presentation/widgets/autonomous/work_record_panels.dart index f998c297..b0fd6d37 100644 --- a/lib/features/v2/device_list/presentation/widgets/autonomous/work_record_panels.dart +++ b/lib/features/v2/device_list/presentation/widgets/autonomous/work_record_panels.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; import 'package:maibu_satabot_v2/core/di/injection.dart'; import 'package:maibu_satabot_v2/features/autonomous_work/domain/entities/work_session_models.dart'; import 'package:maibu_satabot_v2/features/autonomous_work/domain/repositories/autonomous_work_gateway.dart'; @@ -25,6 +26,8 @@ class _WorkRecordPanel extends StatefulWidget { } class _WorkRecordPanelState extends State<_WorkRecordPanel> { + AppLocalizations get _l10n => AppLocalizations.of(context); + late Future>> _records = _load(); Future>> _load() async { final gateway = sl(); @@ -33,14 +36,16 @@ class _WorkRecordPanelState extends State<_WorkRecordPanel> { deviceId: widget.deviceId, ); } - return const WorkResult.fail('当前环境尚未提供真实作业记录'); + return WorkResult.fail( + _l10n.translate('autonomous_work.records_unavailable'), + ); } @override Widget build(BuildContext context) { return WorkPanelScaffold( - title: '自主作业记录', - desc: '显示任务池中的结束任务及本机收到的完成通知;未提供的面积、耗时不作估算。', + title: _l10n.translate('autonomous_work.records_title'), + desc: _l10n.translate('autonomous_work.records_description'), body: FutureBuilder>>( future: _records, builder: (context, snapshot) { @@ -48,9 +53,14 @@ class _WorkRecordPanelState extends State<_WorkRecordPanel> { return const Center(child: CircularProgressIndicator()); } final result = snapshot.data!; - if (!result.isOk) return Text(result.error ?? '记录加载失败'); + if (!result.isOk) + return Text( + result.error ?? + _l10n.translate('autonomous_work.records_load_failed'), + ); final records = result.data ?? const []; - if (records.isEmpty) return const Text('该设备暂无可查询的作业记录'); + if (records.isEmpty) + return Text(_l10n.translate('autonomous_work.records_empty')); return Column( children: [ for (final task in records) @@ -61,15 +71,36 @@ class _WorkRecordPanelState extends State<_WorkRecordPanel> { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - task.routeName ?? '任务 #${task.taskId}', + task.routeName ?? + _l10n.translate('autonomous_work.task_number', { + 'id': task.taskId, + }), style: const TextStyle(fontWeight: FontWeight.w700), ), const SizedBox(height: 6), - Text(task.rawStatus == 'FINISH' ? '已完成' : '已终止'), - Text('任务 ID:${task.taskId}'), + Text( + task.rawStatus == 'FINISH' + ? _l10n.translate('work_v2.plan.status_done') + : _l10n.translate('autonomous_work.terminated'), + ), + Text( + _l10n.translate('autonomous_work.record_task_id', { + 'id': task.taskId, + }), + ), if (task.createdAt != null) - Text('下发时间:${task.createdAt}'), - Text('已接收到达点:${task.completedPoints.length} 个'), + Text( + _l10n.translate( + 'autonomous_work.record_dispatched_at', + {'time': task.createdAt}, + ), + ), + Text( + _l10n.translate( + 'autonomous_work.record_completed_points', + {'count': task.completedPoints.length}, + ), + ), ], ), ), @@ -82,14 +113,14 @@ class _WorkRecordPanelState extends State<_WorkRecordPanel> { children: [ Expanded( child: WorkButton( - label: '刷新记录', + label: _l10n.translate('autonomous_work.records_refresh'), onTap: () => setState(() => _records = _load()), ), ), const SizedBox(width: 12), Expanded( child: WorkButton( - label: '返回地图', + label: _l10n.translate('autonomous_work.back_to_map'), primary: true, onTap: widget.onClose, ), diff --git a/lib/features/v2/device_list/presentation/widgets/autonomous/work_route_panels.dart b/lib/features/v2/device_list/presentation/widgets/autonomous/work_route_panels.dart index 7307553a..4d1b26a5 100644 --- a/lib/features/v2/device_list/presentation/widgets/autonomous/work_route_panels.dart +++ b/lib/features/v2/device_list/presentation/widgets/autonomous/work_route_panels.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; import 'package:maibu_satabot_v2/components/capsule_toast.dart'; import 'package:maibu_satabot_v2/core/di/injection.dart'; import 'package:maibu_satabot_v2/features/autonomous_work/domain/entities/work_session_models.dart'; @@ -55,6 +56,8 @@ class _RouteLibraryPanel extends StatefulWidget { } class _RouteLibraryPanelState extends State<_RouteLibraryPanel> { + AppLocalizations get _l10n => AppLocalizations.of(context); + late final AutonomousWorkGateway _gateway = sl(); List _routes = const []; @@ -80,7 +83,7 @@ class _RouteLibraryPanelState extends State<_RouteLibraryPanel> { if (!mounted) return; setState(() { _loading = false; - _error = '请先在首页选择场站'; + _error = _l10n.translate('work_v2.plan_create.no_site'); }); return; } @@ -89,7 +92,7 @@ class _RouteLibraryPanelState extends State<_RouteLibraryPanel> { setState(() { _loading = false; _routes = result.data ?? const []; - _error = _routes.isEmpty ? (result.error ?? '该场站下暂无作业路线') : null; + _error = _routes.isEmpty ? (result.error ?? _l10n.translate('work_v2.route_lib.empty_site')) : null; if (_selectedId != null && !_routes.any((r) => r.id == _selectedId)) { _selectedId = null; } @@ -107,15 +110,15 @@ class _RouteLibraryPanelState extends State<_RouteLibraryPanel> { Widget build(BuildContext context) { final showEdit = _gateway.capabilities.routeEditing; return WorkPanelScaffold( - title: '路线库 · 选择已有路线', - desc: '一个区域可保存多条路线。执行期间可预览,但更换执行路线前必须先安全停止原任务并重新确认。', + title: _l10n.translate('autonomous_work.route_library_title'), + desc: _l10n.translate('autonomous_work.route_library_description'), body: _buildBody(), footer: Row( children: [ if (showEdit) ...[ Expanded( child: WorkButton( - label: '+ 新建 / 编辑', + label: _l10n.translate('autonomous_work.route_create_edit'), onTap: () => Navigator.of( context, ).pop(const WorkRoutePanelResult.edit()), @@ -125,12 +128,12 @@ class _RouteLibraryPanelState extends State<_RouteLibraryPanel> { ], Expanded( child: WorkButton( - label: '确认路线', + label: _l10n.translate('autonomous_work.route_confirm'), primary: true, onTap: () { final route = _selectedRoute(); if (route == null) { - CapsuleToast.show('请先选择一条路线', showCheck: false); + CapsuleToast.show(_l10n.translate('autonomous_work.route_required'), showCheck: false); return; } Navigator.of(context).pop(WorkRoutePanelResult.select(route)); @@ -156,7 +159,7 @@ class _RouteLibraryPanelState extends State<_RouteLibraryPanel> { children: [ Text(error, style: const TextStyle(fontSize: 12.5, color: kWtGray)), const SizedBox(height: 12), - WorkButton(label: '重新加载', onTap: _load), + WorkButton(label: _l10n.translate('work_v2.all_work.retry'), onTap: _load), ], ); } @@ -173,7 +176,7 @@ class _RouteLibraryPanelState extends State<_RouteLibraryPanel> { Widget _routeRow(int index, WorkRouteOption route) { final selected = _selectedId == route.id; // 列表接口往往只给元数据(几何在选中后补全),所以不在这里提示“无路径数据” - final subtitle = route.metaText ?? route.planModeLabel ?? ''; + final subtitle = workRouteSummary(route, _l10n); return InkWell( onTap: () => setState(() => _selectedId = route.id), borderRadius: BorderRadius.circular(14), @@ -242,7 +245,7 @@ class _RouteLibraryPanelState extends State<_RouteLibraryPanel> { ), const SizedBox(height: 3), Text( - subtitle.isEmpty ? '路线 #${route.id}' : subtitle, + subtitle.isEmpty ? _l10n.translate('autonomous_work.route_number', {'id': route.id}) : subtitle, maxLines: 1, overflow: TextOverflow.ellipsis, style: const TextStyle(fontSize: 11.5, color: kWtGray), @@ -291,6 +294,8 @@ class _TaskQueuePanel extends StatefulWidget { } class _TaskQueuePanelState extends State<_TaskQueuePanel> { + AppLocalizations get _l10n => AppLocalizations.of(context); + late final AutonomousWorkGateway _gateway = sl(); StreamSubscription? _sub; @@ -363,10 +368,10 @@ class _TaskQueuePanelState extends State<_TaskQueuePanel> { if (!mounted) return; setState(() => _busyTaskId = null); if (!result.isOk) { - CapsuleToast.show(result.error ?? '取消失败', showCheck: false); + CapsuleToast.show(result.error ?? _l10n.translate('autonomous_work.cancel_failed'), showCheck: false); return; } - CapsuleToast.show('已取消任务 #${task.taskId}'); + CapsuleToast.show(_l10n.translate('autonomous_work.queue_task_canceled', {'id': task.taskId})); _load(); } @@ -385,28 +390,28 @@ class _TaskQueuePanelState extends State<_TaskQueuePanel> { if (!mounted) return; setState(() => _busyTaskId = null); if (!result.isOk) { - CapsuleToast.show(result.error ?? '切换任务失败', showCheck: false); + CapsuleToast.show(result.error ?? _l10n.translate('autonomous_work.queue_switch_failed'), showCheck: false); return; } widget.onClose(); - CapsuleToast.show('已切换到任务 #${task.taskId}'); + CapsuleToast.show(_l10n.translate('autonomous_work.queue_task_switched', {'id': task.taskId})); } @override Widget build(BuildContext context) { return WorkPanelScaffold( - title: '多区域连续任务队列', - desc: '尚未启动的任务可在此取消;正在执行的任务需要通过“停止作业”安全终止。', + title: _l10n.translate('autonomous_work.queue_title'), + desc: _l10n.translate('autonomous_work.queue_description'), body: _buildBody(), footer: Row( children: [ Expanded( - child: WorkButton(label: '刷新队列', onTap: _load), + child: WorkButton(label: _l10n.translate('autonomous_work.queue_refresh'), onTap: _load), ), const SizedBox(width: 12), Expanded( child: WorkButton( - label: '关闭', + label: _l10n.translate('common.close'), primary: true, onTap: widget.onClose, ), @@ -430,16 +435,16 @@ class _TaskQueuePanelState extends State<_TaskQueuePanel> { children: [ Text(error, style: const TextStyle(fontSize: 12.5, color: kWtGray)), const SizedBox(height: 12), - WorkButton(label: '重新加载', onTap: _load), + WorkButton(label: _l10n.translate('work_v2.all_work.retry'), onTap: _load), ], ); } if (_tasks.isEmpty) { - return const Padding( + return Padding( padding: EdgeInsets.symmetric(vertical: 24), child: Center( child: Text( - '该设备当前没有活跃任务', + _l10n.translate('autonomous_work.queue_empty'), style: TextStyle(fontSize: 12.5, color: kWtGray), ), ), @@ -491,7 +496,7 @@ class _TaskQueuePanelState extends State<_TaskQueuePanel> { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - task.routeName ?? '任务 #${task.taskId}', + task.routeName ?? _l10n.translate('autonomous_work.task_number', {'id': task.taskId}), maxLines: 1, overflow: TextOverflow.ellipsis, style: const TextStyle( @@ -504,14 +509,14 @@ class _TaskQueuePanelState extends State<_TaskQueuePanel> { Row( children: [ WorkChip( - text: task.state.label, + text: workRunStateLabel(task.state, _l10n), background: bg, foreground: fg, ), const SizedBox(width: 6), Expanded( child: Text( - task.createdAt ?? '任务 #${task.taskId}', + task.createdAt ?? _l10n.translate('autonomous_work.task_number', {'id': task.taskId}), maxLines: 1, overflow: TextOverflow.ellipsis, style: const TextStyle(fontSize: 11, color: kWtGray), @@ -525,7 +530,7 @@ class _TaskQueuePanelState extends State<_TaskQueuePanel> { if (cancelable) TextButton( onPressed: busy ? null : () => _cancel(task), - child: Text(busy ? '处理中…' : '取消'), + child: Text(busy ? _l10n.translate('autonomous_work.processing') : _l10n.translate('common.cancel')), ) else const Icon( @@ -573,45 +578,47 @@ class _SchedulePanel extends StatefulWidget { } class _SchedulePanelState extends State<_SchedulePanel> { + AppLocalizations get _l10n => AppLocalizations.of(context); + bool _enabled = true; @override Widget build(BuildContext context) { return WorkPanelScaffold( - title: '定时任务计划', - desc: '时间到达后需执行安全准入验证,不代表机器人可以无人监护地无条件启动。', + title: _l10n.translate('autonomous_work.schedule_title'), + desc: _l10n.translate('autonomous_work.schedule_description'), body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ _field( - label: '作业路线', - child: WorkSelectPill('A区 · 路线01', onTap: _demoSelect), + label: _l10n.translate('work_v2.all_work.route'), + child: WorkSelectPill(_l10n.translate('autonomous_work.demo_route'), onTap: _demoSelect), ), const SizedBox(height: 14), _field( - label: '执行日期', + label: _l10n.translate('autonomous_work.schedule_date'), child: _textFieldLike('10/21/2026', Icons.calendar_today_outlined), ), const SizedBox(height: 14), _field( - label: '时间', + label: _l10n.translate('autonomous_work.schedule_time'), child: _textFieldLike('08:30 AM', Icons.schedule_outlined), ), const SizedBox(height: 14), _field( - label: '重复规则', - child: WorkSelectPill('仅一次', onTap: _demoSelect), + label: _l10n.translate('autonomous_work.schedule_repeat'), + child: WorkSelectPill(_l10n.translate('autonomous_work.schedule_once'), onTap: _demoSelect), ), const SizedBox(height: 16), WorkCard( child: Row( children: [ - const Expanded( + Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - '启用计划', + _l10n.translate('autonomous_work.schedule_enabled'), style: TextStyle( fontSize: 13.5, fontWeight: FontWeight.w800, @@ -620,7 +627,7 @@ class _SchedulePanelState extends State<_SchedulePanel> { ), SizedBox(height: 4), Text( - '需满足安全策略与权限', + _l10n.translate('autonomous_work.schedule_safety'), style: TextStyle(fontSize: 11.5, color: kWtGray), ), ], @@ -638,15 +645,15 @@ class _SchedulePanelState extends State<_SchedulePanel> { footer: Row( children: [ Expanded( - child: WorkButton(label: '取消', onTap: widget.onClose), + child: WorkButton(label: _l10n.translate('common.cancel'), onTap: widget.onClose), ), const SizedBox(width: 12), Expanded( child: WorkButton( - label: '保存计划', + label: _l10n.translate('autonomous_work.schedule_save'), primary: true, onTap: () { - CapsuleToast.show('计划下发通道未接入,仅作视觉演示', showCheck: false); + CapsuleToast.show(_l10n.translate('autonomous_work.schedule_demo'), showCheck: false); widget.onClose(); }, ), @@ -704,6 +711,6 @@ class _SchedulePanelState extends State<_SchedulePanel> { } void _demoSelect() { - CapsuleToast.show('表单选项为演示数据', showCheck: false); + CapsuleToast.show(_l10n.translate('autonomous_work.schedule_demo_options'), showCheck: false); } } diff --git a/lib/features/v2/device_list/presentation/widgets/autonomous/work_setting_panel.dart b/lib/features/v2/device_list/presentation/widgets/autonomous/work_setting_panel.dart index 6d37dbad..77819ca9 100644 --- a/lib/features/v2/device_list/presentation/widgets/autonomous/work_setting_panel.dart +++ b/lib/features/v2/device_list/presentation/widgets/autonomous/work_setting_panel.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; import 'package:maibu_satabot_v2/components/capsule_toast.dart'; import 'work_ui.dart'; @@ -25,13 +26,15 @@ class _WorkSettingPanel extends StatefulWidget { } class _WorkSettingPanelState extends State<_WorkSettingPanel> { + AppLocalizations get _l10n => AppLocalizations.of(context); + static const List _tabs = [ - '路线覆盖', - '执行割刀', - '避障安全', - '断点恢复', - '返航策略', - '弱网策略', + 'autonomous_work.settings_coverage', + 'autonomous_work.settings_blades', + 'autonomous_work.settings_obstacles', + 'autonomous_work.settings_resume', + 'autonomous_work.settings_return', + 'autonomous_work.settings_network', ]; int _tab = 0; @@ -47,8 +50,8 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> { @override Widget build(BuildContext context) { return WorkPanelScaffold( - title: '自主作业设置', - desc: '本次任务可使用默认配置;任务执行中改变运动/割刀参数应先安全暂停并重新校验。', + title: _l10n.translate('autonomous_work.settings_title'), + desc: _l10n.translate('autonomous_work.settings_description'), body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -64,15 +67,21 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> { footer: Row( children: [ Expanded( - child: WorkButton(label: '取消', onTap: widget.onClose), + child: WorkButton( + label: _l10n.translate('common.cancel'), + onTap: widget.onClose, + ), ), const SizedBox(width: 12), Expanded( child: WorkButton( - label: '保存设置(演示)', + label: _l10n.translate('autonomous_work.settings_save'), primary: true, onTap: () { - CapsuleToast.show('设置已保存为本地演示偏好,未向设备下发参数', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.settings_saved'), + showCheck: false, + ); widget.onClose(); }, ), @@ -95,7 +104,7 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> { border: Border.all(color: selected ? Colors.transparent : kWtBorder), ), child: Text( - _tabs[index], + _l10n.translate(_tabs[index]), style: TextStyle( fontSize: 12.5, fontWeight: FontWeight.w700, @@ -128,14 +137,32 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const WorkSectionTitle('路径与覆盖规划参数'), - _paramRow(title: '作业割幅', subtitle: '依据机型割刀尺寸', value: '1.20 m'), + WorkSectionTitle(_l10n.translate('autonomous_work.coverage_title')), + _paramRow( + title: _l10n.translate('autonomous_work.cut_width'), + subtitle: _l10n.translate('autonomous_work.cut_width_detail'), + value: '1.20 m', + ), const SizedBox(height: 8), - _paramRow(title: '路线重叠率', subtitle: '仅影响新规划任务', value: '10%'), + _paramRow( + title: _l10n.translate('autonomous_work.route_overlap'), + subtitle: _l10n.translate('autonomous_work.route_overlap_detail'), + value: '10%', + ), const SizedBox(height: 8), - _paramRow(title: '规划方向', subtitle: '沿光伏阵列方向优先', value: '沿阵列'), + _paramRow( + title: _l10n.translate('autonomous_work.planning_direction'), + subtitle: _l10n.translate( + 'autonomous_work.planning_direction_detail', + ), + value: _l10n.translate('autonomous_work.along_array'), + ), const SizedBox(height: 8), - _paramRow(title: '边缘处理', subtitle: '地块边界贴边作业策略', value: '标准'), + _paramRow( + title: _l10n.translate('autonomous_work.edge_handling'), + subtitle: _l10n.translate('autonomous_work.edge_handling_detail'), + value: _l10n.translate('autonomous_work.standard'), + ), ], ); } @@ -145,21 +172,29 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const WorkSectionTitle('作业执行与割刀'), - _paramRow(title: '自主作业速度', subtitle: '受最大安全速度限制', value: '0.6 m/s'), + WorkSectionTitle(_l10n.translate('autonomous_work.blade_section')), + _paramRow( + title: _l10n.translate('autonomous_work.autonomous_speed'), + subtitle: _l10n.translate('autonomous_work.autonomous_speed_detail'), + value: '0.6 m/s', + ), const SizedBox(height: 8), WorkParamRow( - title: '任务内割刀自动启停', - subtitle: '依据任务状态和必要的安全条件', + title: _l10n.translate('autonomous_work.automatic_blade'), + subtitle: _l10n.translate('autonomous_work.automatic_blade_detail'), trailing: WorkSwitch( value: _mowerAuto, onChanged: (v) => setState(() => _mowerAuto = v), ), ), const SizedBox(height: 8), - _paramRow(title: '底盘高度策略', subtitle: '当前设备可用时开放', value: '按任务配置'), + _paramRow( + title: _l10n.translate('autonomous_work.chassis_height'), + subtitle: _l10n.translate('autonomous_work.chassis_height_detail'), + value: _l10n.translate('autonomous_work.configured_per_task'), + ), const SizedBox(height: 12), - const WorkNoteBar(text: '割刀动作前必须核验安全互锁;没有可靠高度反馈的机器不展示虚假的刀盘状态。'), + WorkNoteBar(text: _l10n.translate('autonomous_work.blade_safety_note')), ], ); } @@ -169,28 +204,36 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const WorkSectionTitle('避障与安全策略'), + WorkSectionTitle(_l10n.translate('autonomous_work.obstacle_section')), WorkParamRow( - title: '避障状态监测', - subtitle: '查看前向感知和超声波状态', + title: _l10n.translate('autonomous_work.obstacle_monitoring'), + subtitle: _l10n.translate( + 'autonomous_work.obstacle_monitoring_detail', + ), trailing: WorkSwitch( value: _avoidMonitor, onChanged: (v) => setState(() => _avoidMonitor = v), ), ), const SizedBox(height: 8), - _paramRow(title: '障碍触发的任务处理', subtitle: '安全停车为优先策略', value: '暂停并等待'), + _paramRow( + title: _l10n.translate('autonomous_work.obstacle_response'), + subtitle: _l10n.translate('autonomous_work.obstacle_response_detail'), + value: _l10n.translate('autonomous_work.pause_wait'), + ), const SizedBox(height: 8), WorkParamRow( - title: '人员接近预警', - subtitle: '适用的警示机制保持启用', + title: _l10n.translate('autonomous_work.person_alert'), + subtitle: _l10n.translate('autonomous_work.person_alert_detail'), trailing: WorkSwitch( value: _personAlert, onChanged: (v) => setState(() => _personAlert = v), ), ), const SizedBox(height: 12), - const WorkNoteBar(text: '不可通过此页面关闭不可绕过的碰撞保护、急停及必要的安全互锁。'), + WorkNoteBar( + text: _l10n.translate('autonomous_work.obstacle_safety_note'), + ), ], ); } @@ -200,20 +243,24 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const WorkSectionTitle('断点与恢复'), + WorkSectionTitle(_l10n.translate('autonomous_work.resume_section')), WorkParamRow( - title: '断点续作', - subtitle: '任务中断或暂停后保留断点位置与已覆盖区域', + title: _l10n.translate('autonomous_work.resume_checkpoint'), + subtitle: _l10n.translate('autonomous_work.resume_checkpoint_detail'), trailing: WorkSwitch( value: _breakpointResume, onChanged: (v) => setState(() => _breakpointResume = v), ), ), const SizedBox(height: 8), - _paramRow(title: '恢复前校验', subtitle: '定位质量与路线版本必须匹配', value: '严格校验'), + _paramRow( + title: _l10n.translate('autonomous_work.resume_checks'), + subtitle: _l10n.translate('autonomous_work.resume_checks_detail'), + value: _l10n.translate('autonomous_work.strict_checks'), + ), const SizedBox(height: 12), - const WorkNoteBar( - text: '断点恢复依赖可靠的定位与任务回执;校验不通过时应重新选择任务。', + WorkNoteBar( + text: _l10n.translate('autonomous_work.resume_note'), background: kWtSoftBlue, foreground: kWtBlue, ), @@ -226,12 +273,26 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const WorkSectionTitle('返航与收尾'), - _paramRow(title: '任务结束后动作', subtitle: '任务完成后设备默认动作', value: '原地待命'), + WorkSectionTitle(_l10n.translate('autonomous_work.return_section')), + _paramRow( + title: _l10n.translate('autonomous_work.completion_action'), + subtitle: _l10n.translate('autonomous_work.completion_action_detail'), + value: _l10n.translate('autonomous_work.standby_in_place'), + ), const SizedBox(height: 8), - _paramRow(title: '低电量返航阈值', subtitle: '低于阈值触发返航提示', value: '20%'), + _paramRow( + title: _l10n.translate('autonomous_work.low_battery_threshold'), + subtitle: _l10n.translate( + 'autonomous_work.low_battery_threshold_detail', + ), + value: '20%', + ), const SizedBox(height: 8), - _paramRow(title: '返航通道', subtitle: '当前设备未开放自动返航指令位', value: '仅提示'), + _paramRow( + title: _l10n.translate('autonomous_work.return_channel'), + subtitle: _l10n.translate('autonomous_work.return_channel_detail'), + value: _l10n.translate('autonomous_work.notify_only'), + ), const SizedBox(height: 12), ], ); @@ -242,29 +303,33 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const WorkSectionTitle('弱网与重连'), + WorkSectionTitle(_l10n.translate('autonomous_work.network_section')), WorkParamRow( - title: '弱网重连', - subtitle: '信号波动时自动重建链路', + title: _l10n.translate('autonomous_work.network_reconnect'), + subtitle: _l10n.translate('autonomous_work.network_reconnect_detail'), trailing: WorkSwitch( value: _weakReconnect, onChanged: (v) => setState(() => _weakReconnect = v), ), ), const SizedBox(height: 8), - _paramRow(title: '指令超时处理', subtitle: '超时后不重发危险指令', value: '仅提示'), + _paramRow( + title: _l10n.translate('autonomous_work.command_timeout'), + subtitle: _l10n.translate('autonomous_work.command_timeout_detail'), + value: _l10n.translate('autonomous_work.notify_only'), + ), const SizedBox(height: 8), WorkParamRow( - title: '定时任务准入', - subtitle: '启用计划任务执行前的安全准入验证', + title: _l10n.translate('autonomous_work.scheduled_safety'), + subtitle: _l10n.translate('autonomous_work.scheduled_safety_detail'), trailing: WorkSwitch( value: _scheduleEnabled, onChanged: (v) => setState(() => _scheduleEnabled = v), ), ), const SizedBox(height: 12), - const WorkNoteBar( - text: '弱网下不缓存危险指令;恢复后可先在界面重新确认再下发。', + WorkNoteBar( + text: _l10n.translate('autonomous_work.network_safety_note'), background: kWtSoftBlue, foreground: kWtBlue, ), @@ -285,6 +350,9 @@ class _WorkSettingPanelState extends State<_WorkSettingPanel> { } void _demoSelect() { - CapsuleToast.show('参数下发通道未接入,本页仅作视觉演示', showCheck: false); + CapsuleToast.show( + _l10n.translate('autonomous_work.settings_demo'), + showCheck: false, + ); } } diff --git a/lib/features/v2/device_list/presentation/widgets/autonomous/work_ui.dart b/lib/features/v2/device_list/presentation/widgets/autonomous/work_ui.dart index b69992ae..73d5e802 100644 --- a/lib/features/v2/device_list/presentation/widgets/autonomous/work_ui.dart +++ b/lib/features/v2/device_list/presentation/widgets/autonomous/work_ui.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; +import 'package:maibu_satabot_v2/features/autonomous_work/domain/entities/work_session_models.dart'; // 自主作业中心(横屏)共享视觉与通用组件(色板 / 抽屉 / 卡片 / 按钮)。 // @@ -25,6 +27,36 @@ const Color kWtLocked = Color(0xFFF4F6F9); const Color kWtMuted = Color(0xFFB0BAC9); const Color kWtBarrier = Color(0x8C0B1B2B); +String workRunStateLabel(WorkRunState state, AppLocalizations l10n) => + l10n.translate(switch (state) { + WorkRunState.idle => 'autonomous_work.stage_setup', + WorkRunState.queued => 'work_v2.stat_pending', + WorkRunState.running => 'work_v2.stat_running', + WorkRunState.paused => 'autonomous_work.stage_pause', + WorkRunState.finished => 'autonomous_work.ended', + WorkRunState.failed => 'autonomous_work.interrupted', + }); + +String workRouteModeLabel(WorkRouteOption route, AppLocalizations l10n) => + l10n.translate(route.coverageMode + ? 'route_planning.bow_mode' + : 'route_planning.custom_mode'); + +String workRouteSummary(WorkRouteOption route, AppLocalizations l10n) { + final details = [ + if (route.pathPoints.isNotEmpty) + l10n.translate('autonomous_work.path_point_count', { + 'count': route.pathPoints.length, + }), + if (route.outerPoints.isNotEmpty) + l10n.translate('autonomous_work.boundary_point_count', { + 'count': route.outerPoints.length, + }), + if (route.planModeLabel != null) workRouteModeLabel(route, l10n), + ]; + return details.isEmpty ? route.metaText ?? '' : details.join(' · '); +} + /// 右侧抽屉面板:从右侧滑入的浮层卡片(设计稿为右侧浮动大卡)。 Future showWorkRightPanel( BuildContext context, { diff --git a/lib/features/v2/my/presentation/pages/help_feedback_page.dart b/lib/features/v2/my/presentation/pages/help_feedback_page.dart index 7f76c8ce..53acf623 100644 --- a/lib/features/v2/my/presentation/pages/help_feedback_page.dart +++ b/lib/features/v2/my/presentation/pages/help_feedback_page.dart @@ -6,7 +6,9 @@ import 'package:maibu_satabot_v2/core/theme/AppTheme.dart'; /// 帮助与反馈页面 class HelpFeedbackPage extends StatefulWidget { - const HelpFeedbackPage({super.key}); + const HelpFeedbackPage({super.key, this.faqOnly = false}); + + final bool faqOnly; @override State createState() => _HelpFeedbackPageState(); @@ -81,6 +83,7 @@ class _HelpFeedbackPageState extends State @override Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context); return AnnotatedRegion( value: const SystemUiOverlayStyle( statusBarColor: Colors.transparent, @@ -95,7 +98,9 @@ class _HelpFeedbackPageState extends State onPressed: () => Navigator.pop(context), ), title: Text( - AppLocalizations.of(context).translate('my_v2.help_feedback'), + l10n.translate( + widget.faqOnly ? 'help_feedback.tab_faq' : 'my_v2.help_feedback', + ), style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, @@ -103,25 +108,26 @@ class _HelpFeedbackPageState extends State ), ), centerTitle: true, - bottom: TabBar( - controller: _tabController, - labelColor: const Color(0xFF165DFF), - unselectedLabelColor: context.appColors.textTertiary, - indicatorColor: const Color(0xFF165DFF), - indicatorSize: TabBarIndicatorSize.label, - tabs: [ - Tab(text: AppLocalizations.of(context).translate('help_feedback.tab_faq')), - Tab(text: AppLocalizations.of(context).translate('help_feedback.tab_feedback')), - ], - ), - ), - body: TabBarView( - controller: _tabController, - children: [ - _buildFAQTab(), - _buildFeedbackTab(), - ], + bottom: widget.faqOnly + ? null + : TabBar( + controller: _tabController, + labelColor: const Color(0xFF165DFF), + unselectedLabelColor: context.appColors.textTertiary, + indicatorColor: const Color(0xFF165DFF), + indicatorSize: TabBarIndicatorSize.label, + tabs: [ + Tab(text: l10n.translate('help_feedback.tab_faq')), + Tab(text: l10n.translate('help_feedback.tab_feedback')), + ], + ), ), + body: widget.faqOnly + ? _buildFAQTab() + : TabBarView( + controller: _tabController, + children: [_buildFAQTab(), _buildFeedbackTab()], + ), ), ); } @@ -129,12 +135,17 @@ class _HelpFeedbackPageState extends State // ==================== 常见问题 ==================== Widget _buildFAQTab() { + const guideCategories = {'cat_bind', 'cat_path', 'cat_remote'}; return ListView( padding: const EdgeInsets.all(16), children: [ - ..._faqList.map((category) => _buildFAQCategory(category)), - const SizedBox(height: 20), - _buildContactSection(), + for (final category in _faqList) + if (!widget.faqOnly || guideCategories.contains(category['category'])) + _buildFAQCategory(category), + if (!widget.faqOnly) ...[ + const SizedBox(height: 20), + _buildContactSection(), + ], ], ); } diff --git a/lib/features/v2/my/presentation/pages/my_page_v2.dart b/lib/features/v2/my/presentation/pages/my_page_v2.dart index e86efaf5..d1878718 100644 --- a/lib/features/v2/my/presentation/pages/my_page_v2.dart +++ b/lib/features/v2/my/presentation/pages/my_page_v2.dart @@ -2,26 +2,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:get_it/get_it.dart'; import 'package:go_router/go_router.dart'; +// import 'package:maibu_satabot_v2/components/app_logo.dart'; import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart'; import 'package:maibu_satabot_v2/core/router/route_paths.dart'; -import 'package:maibu_satabot_v2/core/storage/user_storage.dart'; import 'package:maibu_satabot_v2/core/utils/image_url_util.dart'; -import 'package:maibu_satabot_v2/components/capsule_toast.dart'; import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; import 'package:maibu_satabot_v2/features/auth/presentation/bloc/auth_cubit.dart'; +import 'package:maibu_satabot_v2/features/v2/device_list/presentation/widgets/device_confirm_dialog.dart'; import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/help_feedback_page.dart'; import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/profile_detail_page.dart'; import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/system_settings_page.dart'; -/// 我的页面 V2 —— 按 M01「我的首页」设计稿实现。 -/// -/// 说明: -/// - 视觉:背景渐变复用登录页 V2(纵向浅蓝 + 左上/右上径向光晕); -/// 顶部 me_left_logo.png + 铃铛/设置按钮;用户卡片底图用 logo_me_bg.png 切图。 -/// - 保留旧版 my_page.dart(本文件为新版,路由/Tab 已切到本页)。 -/// - 「编辑个人资料」→ 现有 ProfileDetailPage;「通用设置」→ 现有 SystemSettingsPage。 -/// - 数字(工单/保养/未读)暂无接口,按约定显示「未知」;未实现入口统一 Toast。 -/// - 退出登录按需求放在页脚下方。 +/// 我的首页提供个人信息、设置和常见问题入口。 class MyPageV2 extends StatelessWidget { const MyPageV2({super.key}); @@ -33,30 +25,29 @@ class MyPageV2 extends StatelessWidget { static const _grayText = Color(0xFF86909C); static const _subText = Color(0xFF4E5969); static const _primaryBlue = Color(0xFF1C96F6); - static const _orange = Color(0xFFF5A623); static const _iconBgBlue = Color(0xFFE9F3FE); - static const _iconBgOrange = Color(0xFFFEF3E3); static const _divider = Color(0xFFF0F4FA); - static const _noteBg = Color(0xFFEAF3FD); // 设计稿卡片描边:白卡周围那圈淡蓝边(实测约 RGB 241,247,254) static const _cardBorder = Color(0xFFE9F1FA); - /// 未实现入口的统一提示 - static void _todoTap(BuildContext context) { - CapsuleToast.show( - AppLocalizations.of(context).translate('my_v2.todo_developing'), - showCheck: false, - ); - } - @override Widget build(BuildContext context) { final user = context.watch().state.user; - final userName = - user?.nickname ?? - user?.username ?? - AppLocalizations.of(context).translate('my_v2.default_user_name'); - final userContact = user?.email ?? user?.phone; + final l10n = AppLocalizations.of(context); + final userName = [user?.nickname, user?.username] + .whereType() + .map((name) => name.trim()) + .firstWhere( + (name) => name.isNotEmpty, + orElse: () => l10n.translate('my_v2.default_user_name'), + ); + final userContact = [user?.email, user?.phone] + .whereType() + .map((contact) => contact.trim()) + .firstWhere( + (contact) => contact.isNotEmpty, + orElse: () => l10n.translate('my_v2.contact_not_set'), + ); return Scaffold( backgroundColor: _bgTop, @@ -101,35 +92,12 @@ class MyPageV2 extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 12), - _buildTopBar(context), - const SizedBox(height: 16), + // const AppLogo(size: 44), // 暂时隐藏「我的」页左上角 Logo。 + // const SizedBox(height: 16), _buildUserCard(context, userName, userContact, user?.avatar), - const SizedBox(height: 14), - _buildStatsRow(context), - const SizedBox(height: 22), - _buildSectionTitle( - AppLocalizations.of(context).translate('my_v2.service_support'), - ), - const SizedBox(height: 10), - _buildServiceGroup(context), - const SizedBox(height: 22), - _buildSectionTitle( - AppLocalizations.of(context).translate('my_v2.account_settings'), - ), - const SizedBox(height: 10), - _buildAccountGroup(context), const SizedBox(height: 16), - _buildNoteCard(context), - const SizedBox(height: 14), - // 页脚灰字(设计稿) - Center( - child: Text( - AppLocalizations.of(context).translate('my_v2.footer_note'), - style: const TextStyle(fontSize: 11, color: _grayText), - ), - ), - const SizedBox(height: 10), - // 退出登录:按需求放在设计稿内容下方 + _buildLinks(context, isAdmin: user?.isAdmin == true), + const SizedBox(height: 16), _buildLogoutButton(context), const SizedBox(height: 24), ], @@ -141,61 +109,11 @@ class MyPageV2 extends StatelessWidget { ); } - // ===== 顶部栏:logo + 铃铛/设置按钮 ===== - Widget _buildTopBar(BuildContext context) { - return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Image.asset( - 'assets/images/me_left_logo.png', - height: 44, - fit: BoxFit.contain, - ), - Row( - children: [ - _buildTopIconButton( - Icons.notifications_none, - onTap: () => _todoTap(context), - ), - const SizedBox(width: 10), - _buildTopIconButton( - Icons.settings_outlined, - onTap: () => _push(context, const SystemSettingsPage()), - ), - ], - ), - ], - ); - } - - Widget _buildTopIconButton(IconData icon, {required VoidCallback onTap}) { - return GestureDetector( - onTap: onTap, - child: Container( - width: 44, - height: 44, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(14), - border: Border.all(color: _cardBorder), - boxShadow: [ - BoxShadow( - color: _primaryBlue.withValues(alpha: 0.05), - blurRadius: 8, - offset: const Offset(0, 2), - ), - ], - ), - child: Icon(icon, size: 22, color: _navy), - ), - ); - } - // ===== 用户卡片:底图用 logo_me_bg.png 切图 ===== Widget _buildUserCard( BuildContext context, String userName, - String? userContact, + String userContact, String? avatarUrl, ) { final l10n = AppLocalizations.of(context); @@ -204,77 +122,64 @@ class MyPageV2 extends StatelessWidget { // 切图自身已烘进圆角、细描边与透明留白:不能再套 ClipRRect+cover, // 否则裁切会把描边线残留在卡片内部形成痕迹;fill 原样呈现即可。 child: Stack( - children: [ - Positioned.fill( - child: Image.asset( - 'assets/images/logo_me_bg.png', - fit: BoxFit.fill, - ), + children: [ + Positioned.fill( + child: Image.asset( + 'assets/images/logo_me_bg.png', + fit: BoxFit.fill, ), - Padding( - padding: const EdgeInsets.all(16), - child: Row( - children: [ - _buildAvatar(avatarUrl), - const SizedBox(width: 12), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Flexible( - child: Text( - userName, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - fontSize: 19, - fontWeight: FontWeight.bold, - color: _navy, - ), - ), - ), - const Icon( - Icons.chevron_right, - size: 18, - color: _navy, - ), - ], + ), + Padding( + padding: const EdgeInsets.all(16), + child: Row( + children: [ + _buildAvatar(avatarUrl), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + userName, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 19, + fontWeight: FontWeight.bold, + color: _navy, ), - const SizedBox(height: 3), - Text( - '${l10n.translate('my_v2.personal_account')} · ${userContact ?? l10n.translate('my_v2.contact_not_set')}', - style: const TextStyle( - fontSize: 12.5, - color: _subText, - ), - ), - const SizedBox(height: 8), - Row( - children: [ - Text( - l10n.translate('my_v2.edit_profile'), - style: const TextStyle( - fontSize: 13.5, - fontWeight: FontWeight.w600, - color: _primaryBlue, - ), - ), - const Icon( - Icons.chevron_right, - size: 16, + ), + const SizedBox(height: 3), + Text( + userContact, + style: const TextStyle(fontSize: 12.5, color: _subText), + ), + const SizedBox(height: 8), + Row( + children: [ + Text( + l10n.translate('my_v2.personal_info'), + style: const TextStyle( + fontSize: 13.5, + fontWeight: FontWeight.w600, color: _primaryBlue, ), - ], - ), - ], - ), + ), + const Icon( + Icons.chevron_right, + size: 16, + color: _primaryBlue, + ), + ], + ), + ], ), - ], - ), + ), + ], ), - ], - ), + ), + ], + ), ); } @@ -285,7 +190,10 @@ class MyPageV2 extends StatelessWidget { width: 60, height: 60, clipBehavior: Clip.antiAlias, - decoration: const BoxDecoration(color: Colors.white, shape: BoxShape.circle), + decoration: const BoxDecoration( + color: Colors.white, + shape: BoxShape.circle, + ), child: url != null && url.isNotEmpty ? Image.network( url, @@ -301,102 +209,8 @@ class MyPageV2 extends StatelessWidget { return const Icon(Icons.person, size: 36, color: _primaryBlue); } - // ===== 三个数据卡 ===== - Widget _buildStatsRow(BuildContext context) { + Widget _buildLinks(BuildContext context, {required bool isAdmin}) { final l10n = AppLocalizations.of(context); - return Row( - children: [ - Expanded( - child: _buildStatCard( - icon: Icons.assignment_outlined, - iconColor: _primaryBlue, - value: l10n.translate('my_v2.unknown'), - label: l10n.translate('my_v2.stat_processing_order'), - onTap: () => _todoTap(context), - ), - ), - const SizedBox(width: 12), - Expanded( - child: _buildStatCard( - icon: Icons.build_outlined, - iconColor: _orange, - value: l10n.translate('my_v2.unknown'), - label: l10n.translate('my_v2.stat_maintenance_reminder'), - onTap: () => _todoTap(context), - ), - ), - const SizedBox(width: 12), - Expanded( - child: _buildStatCard( - icon: Icons.article_outlined, - iconColor: _primaryBlue, - value: l10n.translate('my_v2.stat_tutorial'), - label: l10n.translate('my_v2.stat_usage_help'), - onTap: () => _push(context, const HelpFeedbackPage()), - ), - ), - ], - ); - } - - Widget _buildStatCard({ - required IconData icon, - required Color iconColor, - required String value, - required String label, - required VoidCallback onTap, - }) { - return GestureDetector( - onTap: onTap, - child: Container( - padding: const EdgeInsets.symmetric(vertical: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(14), - border: Border.all(color: _cardBorder), - boxShadow: [ - BoxShadow( - color: _primaryBlue.withValues(alpha: 0.05), - blurRadius: 10, - offset: const Offset(0, 2), - ), - ], - ), - child: Column( - children: [ - Icon(icon, size: 20, color: iconColor), - const SizedBox(height: 4), - // 字号与登录页统一:数值 16 ≈ 登录按钮字号 - Text( - value, - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - color: _navy, - ), - ), - const SizedBox(height: 1), - // 标签 11.5 ≈ 登录页辅助文字,略小于输入提示 14 - Text(label, style: const TextStyle(fontSize: 11.5, color: _grayText)), - ], - ), - ), - ); - } - - // ===== 分组卡片 ===== - Widget _buildSectionTitle(String title) { - return Text( - title, - style: const TextStyle( - fontSize: 17, - fontWeight: FontWeight.bold, - color: _navy, - ), - ); - } - - Widget _buildGroupCard(List rows) { return Container( decoration: BoxDecoration( color: Colors.white, @@ -410,93 +224,41 @@ class MyPageV2 extends StatelessWidget { ), ], ), - child: Column(children: rows), + child: Column( + children: [ + _buildMenuRow( + icon: Icons.settings_outlined, + title: l10n.translate('my_v2.general_settings'), + subtitle: l10n.translate( + isAdmin + ? 'my_v2.general_settings_desc' + : 'my_v2.general_settings_basic_desc', + ), + onTap: () => _push(context, const SystemSettingsPage()), + ), + const Divider(height: 1, thickness: 1, color: _divider, indent: 66), + _buildMenuRow( + icon: Icons.menu_book_outlined, + title: l10n.translate('help_feedback.tab_faq'), + subtitle: l10n.translate('my_v2.help_guide_desc'), + onTap: () => _push(context, const HelpFeedbackPage(faqOnly: true)), + ), + const Divider(height: 1, thickness: 1, color: _divider, indent: 66), + _buildMenuRow( + icon: Icons.policy_outlined, + title: l10n.translate('my_v2.privacy_and_terms'), + onTap: () => _showLegalDocuments(context), + ), + ], + ), ); } - Widget _buildServiceGroup(BuildContext context) { - final l10n = AppLocalizations.of(context); - return _buildGroupCard([ - _buildMenuRow( - icon: Icons.headset_mic_outlined, - iconBg: _iconBgBlue, - iconColor: _primaryBlue, - title: l10n.translate('my_v2.after_sales_center'), - subtitle: l10n.translate('my_v2.after_sales_center_desc'), - onTap: () => _todoTap(context), - ), - _buildRowDivider(), - _buildMenuRow( - icon: Icons.build_outlined, - iconBg: _iconBgOrange, - iconColor: _orange, - title: l10n.translate('my_v2.maintenance'), - subtitle: l10n.translate('my_v2.maintenance_desc'), - onTap: () => _todoTap(context), - ), - _buildRowDivider(), - _buildMenuRow( - icon: Icons.menu_book_outlined, - iconBg: _iconBgBlue, - iconColor: _primaryBlue, - title: l10n.translate('my_v2.help_guide'), - subtitle: l10n.translate('my_v2.help_guide_desc'), - onTap: () => _push(context, const HelpFeedbackPage()), - ), - ]); - } - - Widget _buildAccountGroup(BuildContext context) { - final l10n = AppLocalizations.of(context); - return _buildGroupCard([ - _buildMenuRow( - icon: Icons.verified_user_outlined, - iconBg: _iconBgBlue, - iconColor: _primaryBlue, - title: l10n.translate('my_v2.account_security'), - subtitle: l10n.translate('my_v2.account_security_desc'), - onTap: () => _todoTap(context), - ), - _buildRowDivider(), - _buildMenuRow( - icon: Icons.notifications_none, - iconBg: _iconBgBlue, - iconColor: _primaryBlue, - title: l10n.translate('my_v2.message_notice'), - subtitle: l10n.translate('my_v2.message_notice_desc'), - // 未读接口暂无,按约定显示「未知」 - trailingText: l10n.translate('my_v2.unread_unknown'), - onTap: () => _todoTap(context), - ), - _buildRowDivider(), - _buildMenuRow( - icon: Icons.settings_outlined, - iconBg: _iconBgBlue, - iconColor: _primaryBlue, - title: l10n.translate('my_v2.general_settings'), - subtitle: l10n.translate('my_v2.general_settings_desc'), - onTap: () => _push(context, const SystemSettingsPage()), - ), - _buildRowDivider(), - _buildMenuRow( - icon: Icons.info_outline, - iconBg: _iconBgBlue, - iconColor: _primaryBlue, - title: l10n.translate('my_v2.about_legal'), - subtitle: l10n.translate('my_v2.about_legal_desc'), - onTap: () => _todoTap(context), - ), - ]); - } - Widget _buildMenuRow({ required IconData icon, - required Color iconBg, - required Color iconColor, required String title, - required String subtitle, + String? subtitle, required VoidCallback onTap, - String? trailingText, }) { return GestureDetector( onTap: onTap, @@ -509,10 +271,10 @@ class MyPageV2 extends StatelessWidget { width: 40, height: 40, decoration: BoxDecoration( - color: iconBg, + color: _iconBgBlue, borderRadius: BorderRadius.circular(12), ), - child: Icon(icon, size: 21, color: iconColor), + child: Icon(icon, size: 21, color: _primaryBlue), ), const SizedBox(width: 12), Expanded( @@ -527,19 +289,16 @@ class MyPageV2 extends StatelessWidget { color: _navy, ), ), - const SizedBox(height: 2), - Text( - subtitle, - style: const TextStyle(fontSize: 12, color: _grayText), - ), + if (subtitle != null) ...[ + const SizedBox(height: 2), + Text( + subtitle, + style: const TextStyle(fontSize: 12, color: _grayText), + ), + ], ], ), ), - if (trailingText != null) - Text( - trailingText, - style: const TextStyle(fontSize: 12.5, color: _grayText), - ), const SizedBox(width: 2), const Icon(Icons.chevron_right, size: 18, color: Color(0xFFC9CDD4)), ], @@ -548,27 +307,29 @@ class MyPageV2 extends StatelessWidget { ); } - Widget _buildRowDivider() { - return const Divider(height: 1, thickness: 1, color: _divider, indent: 66); - } - - // ===== 底部说明卡(设计稿原文) ===== - Widget _buildNoteCard(BuildContext context) { - return Container( - width: double.infinity, - padding: const EdgeInsets.all(14), - decoration: BoxDecoration( - color: _noteBg, - borderRadius: BorderRadius.circular(12), - ), - child: Text( - AppLocalizations.of(context).translate('my_v2.note_card'), - style: const TextStyle(fontSize: 12.5, color: _subText, height: 1.6), + void _showLegalDocuments(BuildContext context) { + final l10n = AppLocalizations.of(context); + showModalBottomSheet( + context: context, + showDragHandle: true, + builder: (context) => SafeArea( + child: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + for (final titleKey in ['my.privacy_policy', 'my.user_agreement']) + ListTile( + title: Text(l10n.translate(titleKey)), + subtitle: Text(l10n.translate('my_v2.legal_unavailable')), + ), + ], + ), + ), ), ); } - // ===== 退出登录(放在页脚下方) ===== + // ===== 退出登录 ===== Widget _buildLogoutButton(BuildContext context) { return GestureDetector( onTap: () => _showLogoutDialog(context), @@ -590,41 +351,27 @@ class MyPageV2 extends StatelessWidget { ); } - void _showLogoutDialog(BuildContext context) { + Future _showLogoutDialog(BuildContext context) async { final l10n = AppLocalizations.of(context); - showDialog( - context: context, - builder: (dialogContext) => AlertDialog( - title: Text(l10n.translate('my_v2.logout')), - content: Text(l10n.translate('my_v2.logout_confirm')), - actions: [ - TextButton( - onPressed: () => Navigator.pop(dialogContext), - child: Text(l10n.translate('my_v2.cancel')), - ), - TextButton( - onPressed: () async { - Navigator.pop(dialogContext); - await GetIt.I().deleteUser(); - GetIt.I().logout(); - if (dialogContext.mounted) { - GoRouter.of(dialogContext).go(RoutePaths.login); - } - }, - style: TextButton.styleFrom( - foregroundColor: const Color(0xFFF53F3F), - ), - child: Text(l10n.translate('my_v2.confirm')), - ), - ], - ), + final logoutLabel = l10n.translate('my_v2.logout'); + final confirmed = await showDeviceConfirmDialog( + context, + icon: Icons.logout_rounded, + title: logoutLabel, + message: l10n.translate('my_v2.logout_confirm'), + confirmText: logoutLabel, + cancelText: l10n.translate('my_v2.cancel'), + danger: true, ); + if (!confirmed || !context.mounted) return; + + await GetIt.I().logout(); + if (context.mounted) { + context.go(RoutePaths.login); + } } void _push(BuildContext context, Widget page) { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => page), - ); + Navigator.push(context, MaterialPageRoute(builder: (context) => page)); } } diff --git a/lib/features/v2/my/presentation/pages/profile_detail_page.dart b/lib/features/v2/my/presentation/pages/profile_detail_page.dart index 8cf2e273..0e685e14 100644 --- a/lib/features/v2/my/presentation/pages/profile_detail_page.dart +++ b/lib/features/v2/my/presentation/pages/profile_detail_page.dart @@ -51,10 +51,6 @@ class ProfileDetailPage extends StatelessWidget { // 信息列表 _buildInfoCard(context, user), - const SizedBox(height: 16), - - // 操作按钮 - _buildActionButtons(context), ], ); }, @@ -254,41 +250,4 @@ class ProfileDetailPage extends StatelessWidget { ], ); } - - /// 操作按钮 - Widget _buildActionButtons(BuildContext context) { - final l10n = AppLocalizations.of(context); - return Column( - children: [ - // 编辑资料按钮(预留) - SizedBox( - width: double.infinity, - height: 48, - child: ElevatedButton.icon( - onPressed: () { - // TODO: 跳转到编辑资料页面 - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(l10n.translate('my_v2.edit_in_progress')), - ), - ); - }, - icon: const Icon(Icons.edit, size: 20), - label: Text( - l10n.translate('my_v2.edit_profile_action'), - style: const TextStyle(fontSize: 16), - ), - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xFF165DFF), - foregroundColor: Colors.white, - elevation: 0, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), - ), - ), - ), - ), - ], - ); - } } diff --git a/lib/features/v2/my/presentation/pages/system_settings_page.dart b/lib/features/v2/my/presentation/pages/system_settings_page.dart index 29962d99..189a99b8 100644 --- a/lib/features/v2/my/presentation/pages/system_settings_page.dart +++ b/lib/features/v2/my/presentation/pages/system_settings_page.dart @@ -11,7 +11,6 @@ import 'package:maibu_satabot_v2/core/theme/AppTheme.dart'; import 'package:maibu_satabot_v2/core/storage/user_storage.dart'; import 'package:maibu_satabot_v2/features/auth/presentation/bloc/auth_cubit.dart'; import 'package:maibu_satabot_v2/features/main_container/presentation/cubit/tab_config_cubit.dart'; -import 'package:maibu_satabot_v2/features/main_container/domain/tab_config.dart'; import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart'; import 'package:maibu_satabot_v2/features/v2/device_list/presentation/float_bar/cubit/float_bar_setting_cubit.dart'; import 'package:maibu_satabot_v2/core/update/update_cubit.dart'; @@ -38,6 +37,7 @@ class _SystemSettingsPageState extends State { Future _loadVersion() async { try { final String versionString = await rootBundle.loadString('pubspec.yaml'); + if (!mounted) return; final versionMatch = RegExp(r'version:\s*(\d+\.\d+\.\d+)\+(\d+)').firstMatch(versionString); setState(() { _currentVersion = versionMatch?.group(1) ?? '1.0.0'; @@ -47,6 +47,8 @@ class _SystemSettingsPageState extends State { } @override Widget build(BuildContext context) { + final user = context.watch().state.user; + final isAdmin = user?.isAdmin == true; return Scaffold( backgroundColor: context.appColors.pageBackground, appBar: AppBar( @@ -69,16 +71,17 @@ class _SystemSettingsPageState extends State { padding: const EdgeInsets.all(16), children: [ // Tab 设置 - _buildTabSettingsSection(), + _buildTabSettingsSection(user?.roleKey, isAdmin: isAdmin), const SizedBox(height: 12), - // 悬浮条设置 - _buildFloatBarSection(), - const SizedBox(height: 12), - // 语言设置 + if (isAdmin) ...[ + _buildFloatBarSection(), + const SizedBox(height: 12), + ], _buildLanguageSection(), - const SizedBox(height: 12), - // 版本更新 - _buildUpdateSection(), + if (isAdmin) ...[ + const SizedBox(height: 12), + _buildUpdateSection(), + ], const SizedBox(height: 12), // 退出登录(已挪至“我的”页面最下边,此处注释掉) // _buildLogoutButton(context), @@ -148,10 +151,7 @@ class _SystemSettingsPageState extends State { } /// Tab 设置 - Widget _buildTabSettingsSection() { - // 🔥 个人角色(roleKey == 'personal'):Tab 设置只列出「设备 + 我的」,且开关常开锁定 - final roleKey = context.watch().state.user?.roleKey; - final isPersonal = roleKey == TabConfig.personalRoleKey; + Widget _buildTabSettingsSection(String? roleKey, {required bool isAdmin}) { return Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( @@ -177,9 +177,9 @@ class _SystemSettingsPageState extends State { ), ), const SizedBox(height: 16), - BlocBuilder( + BlocBuilder( builder: (context, state) { - if (state.runtimeType.toString() != 'TabConfigLoaded') { + if (state is! TabConfigLoaded) { return const Center(child: CircularProgressIndicator()); } @@ -208,13 +208,10 @@ class _SystemSettingsPageState extends State { ), ), Switch( - // 个人角色:设备/我的 强制常开且不可关闭 - value: isPersonal ? true : tab.isEnabled, - onChanged: isPersonal - ? null - : (value) { - context.read().toggleTab(tab.id); - }, + value: tab.isEnabled, + onChanged: isAdmin + ? (_) => context.read().toggleTab(tab.id) + : null, activeColor: const Color(0xFF165DFF), ), ], diff --git a/lib/features/v2/work/presentation/pages/work_area_page_v2.dart b/lib/features/v2/work/presentation/pages/work_area_page_v2.dart index f12ca088..778cbca9 100644 --- a/lib/features/v2/work/presentation/pages/work_area_page_v2.dart +++ b/lib/features/v2/work/presentation/pages/work_area_page_v2.dart @@ -8,6 +8,7 @@ import 'package:maibu_satabot_v2/features/regions/domain/entities/region_draft.d import 'package:maibu_satabot_v2/features/regions/presentation/cubit/region_list_cubit.dart'; import 'package:maibu_satabot_v2/features/regions/presentation/widgets/region_list_panel.dart'; import 'package:maibu_satabot_v2/features/v2/device_list/presentation/pages/route_editor_page_v2.dart'; +import 'package:maibu_satabot_v2/features/v2/device_list/presentation/widgets/autonomous/work_ui.dart'; import 'package:maibu_satabot_v2/features/v2/site/presentation/cubit/site_cubit.dart'; import 'package:maibu_satabot_v2/features/v2/work/presentation/widgets/work_phone_ui.dart'; @@ -84,27 +85,75 @@ class _WorkAreaPageV2State extends State { @override Widget build(BuildContext context) => WorkPhoneScaffold( - child: Column( - children: [ - WorkPhoneTopBar( - title: AppLocalizations.of(context).translate('work_v2.area.title'), - onBack: () => Navigator.of(context).maybePop(), - ), - const SizedBox(height: 12), - Expanded( - child: AbsorbPointer( - absorbing: _opening, - child: RegionListPanel( - cubit: _regions, - currentScope: () => _scope, - onCreate: () => _openEditor(), - onEdit: _openEditor, - onSelect: _openEditor, - onRefresh: _reload, - ), - ), - ), - ], + child: AbsorbPointer( + absorbing: _opening, + child: RegionListPanel( + cubit: _regions, + currentScope: () => _scope, + onCreate: () => _openEditor(), + onEdit: _openEditor, + onSelect: _openEditor, + onRefresh: _reload, + pageHeaderBuilder: _buildPageHeader, + ), ), ); + + Widget _buildPageHeader( + BuildContext context, + RegionListState state, + VoidCallback? onCreate, + VoidCallback? onRefresh, + ) { + final l10n = AppLocalizations.of(context); + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + WorkPhoneTopBar( + title: l10n.translate('work_v2.area.title'), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Tooltip( + message: l10n.translate('work_v2.area.refresh'), + child: WorkSquareButton( + icon: Icons.refresh_rounded, + onTap: onRefresh, + ), + ), + const SizedBox(width: 8), + WorkSquareButton( + key: const ValueKey('region_list_create'), + icon: Icons.add_rounded, + label: l10n.translate('work_v2.area.new'), + primary: true, + onTap: onCreate, + ), + ], + ), + ), + const SizedBox(height: 12), + WorkPageHeading( + title: l10n.translate('work_v2.area.page_title'), + subtitle: l10n.translate('work_v2.area.page_subtitle'), + ), + const SizedBox(height: 12), + Row( + children: [ + Expanded( + child: WorkSectionTitle( + l10n.translate('work_v2.area.filter_all'), + ), + ), + if (state.status == RegionListStatus.ready) + WorkChip( + text: '${state.regions.length}', + background: kWtSoftBlue, + foreground: kWtBlue, + ), + ], + ), + ], + ); + } } diff --git a/lib/features/v2/work/presentation/pages/work_home_page_v2.dart b/lib/features/v2/work/presentation/pages/work_home_page_v2.dart index 4a1ac749..f104eda0 100644 --- a/lib/features/v2/work/presentation/pages/work_home_page_v2.dart +++ b/lib/features/v2/work/presentation/pages/work_home_page_v2.dart @@ -18,8 +18,9 @@ import 'package:maibu_satabot_v2/features/v2/device_list/presentation/pages/rout import 'package:maibu_satabot_v2/features/v2/site/presentation/cubit/site_cubit.dart'; import 'package:maibu_satabot_v2/features/v2/work/presentation/cubit/work_home_task_cubit.dart'; +import '../widgets/all_work_sheet.dart'; import 'work_area_page_v2.dart'; -import 'work_map_page_v2.dart'; +// import 'work_map_page_v2.dart'; // 旧计划列表页保留,恢复原入口时再启用。 // import 'work_plan_page_v2.dart'; import 'work_plan_create_page_v2.dart'; @@ -166,8 +167,8 @@ class _WorkHomePageV2State extends State ).translate('work_v2.section_current'), trailing: AppLocalizations.of( context, - ).translate('work_v2.all_tasks'), - onTrailingTap: () => _showTaskPool(context), + ).translate('work_v2.all_work.title'), + onTrailingTap: () => _showAllWork(context), refreshError: taskState.status == WorkHomeTaskStatus.ready ? taskState.error @@ -196,11 +197,6 @@ class _WorkHomePageV2State extends State ); } - void _todo(BuildContext context) => CapsuleToast.show( - AppLocalizations.of(context).translate('work_v2.toast_todo'), - showCheck: false, - ); - /// 「新建路线」:进入横屏「地图与区域编辑」,先画区域再生成路线。 /// /// 本页是竖屏,进入时方向交给编辑器;**等 pop 转场结束**再恢复竖屏, @@ -218,9 +214,9 @@ class _WorkHomePageV2State extends State } /// 「作业地图」:竖屏单页,一张图上同时看区域 / 路线 / 机器人 - void _openWorkMap(BuildContext context) { - Navigator.of(context).push(WorkMapPageV2.route()); - } + // void _openWorkMap(BuildContext context) { + // Navigator.of(context).push(WorkMapPageV2.route()); + // } /// 「区域管理」:竖屏区域列表,新建/编辑再进横屏编辑器 void _openArea(BuildContext context) { @@ -389,56 +385,31 @@ class _WorkHomePageV2State extends State final siteName = siteState.selectedSite?.siteName ?? l10n.translate('work_v2.no_site_selected'); - return Row( + return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - AppLocalizations.of(context).translate('work_v2.tag'), - style: const TextStyle( - fontSize: 11.5, - letterSpacing: 0.3, - color: _gray, - ), - ), - const SizedBox(height: 6), - Text( - l10n.translate('work_v2.overview'), - style: const TextStyle( - fontSize: 24, - fontWeight: FontWeight.w800, - color: _navy, - ), - ), - const SizedBox(height: 4), - Text( - '$siteName · ${l10n.translate('work_v2.all_work_robots')}', - style: const TextStyle(fontSize: 12, color: _gray), - ), - ], + Text( + l10n.translate('work_v2.tag'), + style: const TextStyle( + fontSize: 11.5, + letterSpacing: 0.3, + color: _gray, ), ), - GestureDetector( - onTap: () => _todo(context), - behavior: HitTestBehavior.opaque, - child: Container( - width: 36, - height: 36, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(12), - border: Border.all(color: _border), - ), - child: const Icon( - Icons.wb_sunny_outlined, - size: 18, - color: _blue, - ), + const SizedBox(height: 6), + Text( + l10n.translate('work_v2.overview'), + style: const TextStyle( + fontSize: 24, + fontWeight: FontWeight.w800, + color: _navy, ), ), + const SizedBox(height: 4), + Text( + '$siteName · ${l10n.translate('work_v2.all_work_robots')}', + style: const TextStyle(fontSize: 12, color: _gray), + ), ], ); }, @@ -883,6 +854,31 @@ class _WorkHomePageV2State extends State ); } + void _showAllWork(BuildContext context) { + showModalBottomSheet( + context: context, + isScrollControlled: true, + useSafeArea: true, + backgroundColor: Colors.white, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(20)), + ), + builder: (_) => AllWorkSheet( + refreshTaskPool: _refreshTasks, + taskPoolBuilder: (_, controller) => + BlocBuilder( + bloc: _tasks, + builder: (context, state) => ListView( + key: const ValueKey('all_work_task_pool'), + controller: controller, + padding: const EdgeInsets.all(16), + children: [_buildCurrentTasks(context, state)], + ), + ), + ), + ); + } + void _showTaskPool(BuildContext context, {String? status}) { showModalBottomSheet( context: context, @@ -1085,11 +1081,12 @@ class _WorkHomePageV2State extends State Widget _buildFeatureGrid(BuildContext context) { final l10n = AppLocalizations.of(context); final items = <(IconData, String, VoidCallback)>[ - ( - Icons.map_outlined, - l10n.translate('work_v2.feature_map'), - () => _openWorkMap(context), - ), + // 作业地图入口暂时隐藏,保留配置以便后续恢复。 + // ( + // Icons.map_outlined, + // l10n.translate('work_v2.feature_map'), + // () => _openWorkMap(context), + // ), ( Icons.layers_outlined, l10n.translate('work_v2.feature_area'), diff --git a/lib/features/v2/work/presentation/pages/work_plan_create_page_v2.dart b/lib/features/v2/work/presentation/pages/work_plan_create_page_v2.dart index 60e1b490..5b25a194 100644 --- a/lib/features/v2/work/presentation/pages/work_plan_create_page_v2.dart +++ b/lib/features/v2/work/presentation/pages/work_plan_create_page_v2.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:maibu_satabot_v2/features/consecutive_tasks/presentation/cubit/area_task_create_cubit.dart'; +import 'package:maibu_satabot_v2/features/consecutive_tasks/presentation/widgets/area_dispatch_section.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:maibu_satabot_v2/components/capsule_toast.dart'; @@ -23,6 +25,7 @@ enum _ExecutionTiming { immediate, scheduled } /// 新建作业任务——作业首页「下发作业计划」进入。 /// 路线立即下发先进入自主作业中心确认,定时任务仍走已有计划接口。 +/// 区域下发:选择当前场站分区及绑定路线,按用户排序创建连续任务。 /// /// 提交链路(清洁架构):页面 → [SchedulePlanCreateCubit] → /// SaveDeviceSchedulePlanUseCase → DeviceTaskRepository → DeviceTaskDatasource @@ -74,6 +77,7 @@ class _WorkPlanCreatePageV2State extends State { /// 设备列表:RobotListBloc 是 registerFactory,页面自持实例并负责 close late final RobotListBloc _robotBloc = sl(); + late final AreaTaskCreateCubit _areaCubit = sl(); // ===== 表单状态(纯 UI 输入由页面持有,接口状态归 Cubit)===== RobotDataModel? _device; @@ -88,8 +92,12 @@ class _WorkPlanCreatePageV2State extends State { DateTime _end = DateTime.now().add(const Duration(days: 30)); bool get _isRoute => _target == _DispatchTarget.route; - bool get _isScheduled => _timing == _ExecutionTiming.scheduled; - bool get _canSubmit => _isRoute; + bool get _isScheduled => _isRoute && _timing == _ExecutionTiming.scheduled; + String get _submitLabelKey => !_isRoute + ? 'work_v2.plan_create.submit_consecutive' + : _isScheduled + ? 'work_v2.plan_create.submit' + : 'work_v2.plan_create.submit_now'; @override void initState() { @@ -102,11 +110,14 @@ class _WorkPlanCreatePageV2State extends State { void dispose() { _formScrollController.dispose(); _robotBloc.close(); + _areaCubit.close(); super.dispose(); } void _toast(String text) => CapsuleToast.show(text, showCheck: false); + void _loadAreas() => _areaCubit.load(_entrySiteId ?? 0); + // ===== 选择器 ===== /// 选执行设备:底部弹窗,列表来自 RobotListBloc(当前场站设备) @@ -136,6 +147,23 @@ class _WorkPlanCreatePageV2State extends State { Flexible( child: BlocBuilder( builder: (context, state) { + if (state is RobotListError) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text(state.message), + TextButton.icon( + onPressed: () => _robotBloc.add( + RobotListLoadData(siteId: _entrySiteId), + ), + icon: const Icon(Icons.refresh_rounded), + label: Text( + l10n.translate('work_v2.plan_create.area_reload'), + ), + ), + ], + ); + } if (state is! RobotListLoaded) { return const SizedBox( height: 120, @@ -269,20 +297,16 @@ class _WorkPlanCreatePageV2State extends State { /// 组装业务实体 → Cubit → UseCase(后端字段/格式在数据层映射) Future _submit(BuildContext context) async { - debugPrint('[新建作业] 点击${_isScheduled ? '创建计划' : '立即下发'}'); final l10n = AppLocalizations.of(context); + debugPrint('[新建作业] 点击${l10n.translate(_submitLabelKey)}'); final cubit = context.read(); - if (cubit.state.isSubmitting || _openingWorkCenter) return; - // 区域模式保留页面入口,后续独立接入,不复用路线接口。 - if (!_canSubmit) return; + if (cubit.state.isSubmitting || + _areaCubit.state.isSubmitting || + _openingWorkCenter) + return; + FocusManager.instance.primaryFocus?.unfocus(); - final route = _route; - if (route == null) { - debugPrint('[新建计划] 校验未通过:未选择作业路线'); - _toast(l10n.translate('work_v2.plan_create.route_pick')); - return; - } final device = _device; if (device == null || device.name.trim().isEmpty) { _toast(l10n.translate('work_v2.plan_create.device_pick')); @@ -298,6 +322,26 @@ class _WorkPlanCreatePageV2State extends State { _toast(l10n.translate('work_v2.plan_create.selection_changed')); return; } + if (!_isRoute) { + final robots = _robotBloc.state; + if (robots is! RobotListLoaded || + robots.siteId != site.id || + !robots.robots.any((robot) => robot.name == device.name)) { + _toast(l10n.translate('work_v2.plan_create.selection_changed')); + return; + } + await _areaCubit.submit( + deviceId: device.name, + orgId: site.orgId, + siteId: site.id, + ); + return; + } + final route = _route; + if (route == null) { + _toast(l10n.translate('work_v2.plan_create.route_pick')); + return; + } if (!_isScheduled) { await _openWorkCenter(context, device, route); return; @@ -367,6 +411,42 @@ class _WorkPlanCreatePageV2State extends State { @override Widget build(BuildContext context) { + return BlocProvider.value( + value: _areaCubit, + child: BlocConsumer( + listenWhen: (previous, current) => + previous.submitStatus != current.submitStatus, + listener: (context, state) { + if (state.submitStatus == AreaTaskSubmitStatus.success) { + CapsuleToast.show( + AppLocalizations.of( + context, + ).translate('work_v2.plan_create.area_success'), + showCheck: true, + ); + // 等待提交锁随成功状态解除,再返回上一页。 + WidgetsBinding.instance.addPostFrameCallback((_) { + if (context.mounted) Navigator.of(context).maybePop(); + }); + } else if (state.submitStatus == AreaTaskSubmitStatus.failure) { + _toast( + state.submitError ?? + AppLocalizations.of( + context, + ).translate('work_v2.plan_create.failed'), + ); + _areaCubit.clearFailure(); + } + }, + builder: (context, state) => PopScope( + canPop: !state.isSubmitting, + child: _buildSchedulePage(context), + ), + ), + ); + } + + Widget _buildSchedulePage(BuildContext context) { return BlocProvider( create: (_) => sl(), child: BlocListener( @@ -391,8 +471,12 @@ class _WorkPlanCreatePageV2State extends State { } }, child: BlocBuilder( - builder: (context, state) => - _buildForm(context, state.isSubmitting || _openingWorkCenter), + builder: (context, state) => _buildForm( + context, + state.isSubmitting || + _areaCubit.state.isSubmitting || + _openingWorkCenter, + ), ), ), ); @@ -408,7 +492,9 @@ class _WorkPlanCreatePageV2State extends State { children: [ WorkPhoneTopBar( title: l10n.translate('work_v2.plan_create.title'), - onBack: () => Navigator.of(context).maybePop(), + onBack: () { + if (!submitting) Navigator.of(context).maybePop(); + }, ), const SizedBox(height: 12), AbsorbPointer(absorbing: submitting, child: _buildDispatchTabs(l10n)), @@ -422,10 +508,8 @@ class _WorkPlanCreatePageV2State extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - _buildExecutionSelector(l10n), - const SizedBox(height: 12), - if (!_canSubmit) ...[ - _buildAvailabilityNote(l10n), + if (_isRoute) ...[ + _buildExecutionSelector(l10n), const SizedBox(height: 12), ], // ===== 基本信息 ===== @@ -436,6 +520,16 @@ class _WorkPlanCreatePageV2State extends State { Icons.assignment_outlined, ), const SizedBox(height: 14), + if (!_isRoute) ...[ + _hint( + l10n.translate( + 'work_v2.plan_create.area_immediate_hint', + ), + ), + const SizedBox(height: 12), + AreaDispatchSection(onReload: _loadAreas), + const SizedBox(height: 16), + ], _selectField( label: l10n.translate( 'work_v2.plan_create.device_label', @@ -459,16 +553,6 @@ class _WorkPlanCreatePageV2State extends State { 'work_v2.plan_create.route_pick', ), onTap: _pickRoute, - ) - else - _selectField( - label: l10n.translate( - 'work_v2.plan_create.area_label', - ), - placeholder: l10n.translate( - 'work_v2.plan_create.area_pick', - ), - onTap: null, ), ], ), @@ -628,7 +712,13 @@ class _WorkPlanCreatePageV2State extends State { key: ValueKey('work_plan_dispatch_${target.name}'), borderRadius: BorderRadius.circular(12), onTap: () { + if (_target == target) return; setState(() => _target = target); + if (target == _DispatchTarget.area && + !_areaCubit.state.loaded && + !_areaCubit.state.loading) { + _loadAreas(); + } if (_formScrollController.hasClients) { _formScrollController.jumpTo(0); } @@ -747,11 +837,9 @@ class _WorkPlanCreatePageV2State extends State { const SizedBox(height: 10), Text( l10n.translate( - 'work_v2.plan_create.${_isScheduled - ? 'scheduled_hint' - : _isRoute - ? 'immediate_hint' - : 'area_immediate_hint'}', + _isScheduled + ? 'work_v2.plan_create.scheduled_hint' + : 'work_v2.plan_create.immediate_hint', ), style: const TextStyle(fontSize: 11.5, color: _gray, height: 1.5), ), @@ -759,43 +847,17 @@ class _WorkPlanCreatePageV2State extends State { ); } - Widget _buildAvailabilityNote(AppLocalizations l10n) { - return Container( - padding: const EdgeInsets.all(12), - decoration: BoxDecoration( - color: const Color(0xFFFFF6E5), - borderRadius: BorderRadius.circular(12), - border: Border.all(color: const Color(0xFFFFE1A8)), - ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Icon( - Icons.info_outline_rounded, - size: 18, - color: Color(0xFF9B6500), - ), - const SizedBox(width: 8), - Expanded( - child: Text( - l10n.translate('work_v2.plan_create.area_pending'), - style: const TextStyle( - fontSize: 12, - color: Color(0xFF9B6500), - height: 1.5, - ), - ), - ), - ], - ), - ); - } - Widget _buildSubmitBar( BuildContext context, AppLocalizations l10n, bool submitting, ) { + final dispatch = l10n.translate( + 'work_v2.plan_create.dispatch_${_target.name}', + ); + final description = _isRoute + ? '$dispatch · ${l10n.translate('work_v2.plan_create.timing_${_timing.name}')}' + : dispatch; return Container( padding: const EdgeInsets.only(top: 12, bottom: 4), decoration: const BoxDecoration( @@ -814,21 +876,12 @@ class _WorkPlanCreatePageV2State extends State { const SizedBox(width: 5), Expanded( child: Text( - '${l10n.translate('work_v2.plan_create.dispatch_${_target.name}')} · ' - '${l10n.translate('work_v2.plan_create.timing_${_timing.name}')}', + description, maxLines: 1, overflow: TextOverflow.ellipsis, style: const TextStyle(fontSize: 11.5, color: _gray), ), ), - if (!_canSubmit) - Text( - l10n.translate('work_v2.plan_create.coming_soon'), - style: const TextStyle( - fontSize: 11, - color: Color(0xFF9B6500), - ), - ), ], ), const SizedBox(height: 8), @@ -836,10 +889,8 @@ class _WorkPlanCreatePageV2State extends State { height: 48, child: FilledButton( key: const ValueKey('work_plan_submit'), - // 定时任务从当前 Cubit 保存;立即下发仅导航至作业中心。 - onPressed: submitting || !_canSubmit - ? null - : () => _submit(context), + // 路线定时保存计划、路线立即进入作业中心;区域立即提交连续任务。 + onPressed: submitting ? null : () => _submit(context), style: FilledButton.styleFrom( backgroundColor: _navy, foregroundColor: Colors.white, @@ -870,9 +921,7 @@ class _WorkPlanCreatePageV2State extends State { const SizedBox(width: 8), Flexible( child: Text( - l10n.translate( - 'work_v2.plan_create.${_isScheduled ? 'submit' : 'submit_now'}', - ), + l10n.translate(_submitLabelKey), maxLines: 1, overflow: TextOverflow.ellipsis, style: const TextStyle( diff --git a/lib/features/v2/work/presentation/pages/work_record_page_v2.dart b/lib/features/v2/work/presentation/pages/work_record_page_v2.dart index 944f6a78..b76b544e 100644 --- a/lib/features/v2/work/presentation/pages/work_record_page_v2.dart +++ b/lib/features/v2/work/presentation/pages/work_record_page_v2.dart @@ -1,443 +1,451 @@ +import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:maibu_satabot_v2/components/capsule_toast.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:maibu_satabot_v2/core/di/injection.dart'; import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; +import 'package:maibu_satabot_v2/features/v2/device_list/data/models/robot_data_model.dart'; import 'package:maibu_satabot_v2/features/v2/device_list/presentation/widgets/autonomous/work_ui.dart'; -import 'package:maibu_satabot_v2/features/v2/work/presentation/pages/work_report_page_v2.dart'; +import 'package:maibu_satabot_v2/features/v2/site/presentation/cubit/site_cubit.dart'; import 'package:maibu_satabot_v2/features/v2/work/presentation/widgets/work_phone_ui.dart'; +import 'package:maibu_satabot_v2/features/work_history/domain/entities/work_history_record.dart'; +import 'package:maibu_satabot_v2/features/work_history/presentation/cubit/work_history_cubit.dart'; -/// 作业记录中心(W09)——作业首页「作业记录」入口进入。 -/// -/// 竖屏单页:本月汇总 + 筛选 + 记录列表,点单条进入「单次作业报告」(W10)。 -/// -/// 本页为演示页:记录列表是写死的示例,不查询真实作业历史; -/// 筛选与搜索只在本地过滤,不请求接口。 +/// 作业执行历史。设备详情入口传入设备,作业页入口查看当前场站。 class WorkRecordPageV2 extends StatefulWidget { - const WorkRecordPageV2({super.key}); + const WorkRecordPageV2({super.key, this.robot}); - static Route route() => - MaterialPageRoute(builder: (_) => const WorkRecordPageV2()); + final RobotDataModel? robot; + + static Route route({RobotDataModel? robot}) => + MaterialPageRoute(builder: (_) => WorkRecordPageV2(robot: robot)); @override State createState() => _WorkRecordPageV2State(); } -/// 一条演示作业记录 -class _DemoRecord { - const _DemoRecord({ - required this.title, - required this.robot, - required this.date, - required this.area, - required this.duration, - required this.done, - required this.coverage, - }); - - final String title; - final String robot; - final String date; - final String area; - final String duration; - final bool done; - final String coverage; -} - class _WorkRecordPageV2State extends State { - static const Color _navy = kWtNavy; - static const Color _gray = kWtGray; - static const Color _border = kWtBorder; - static const Color _green = Color(0xFF00B42A); - static const Color _abort = Color(0xFFF0483E); - - /// 筛选顺序:全部 / 已完成 / 已中止 / 本周 + late final WorkHistoryCubit _history = sl(); + StreamSubscription<(int?, int?)>? _scopeSubscription; int _filter = 0; - static const List<_DemoRecord> _records = <_DemoRecord>[ - _DemoRecord( - title: 'work_v2.demo_zone_b_task', - robot: 'work_v2.demo_robot_2', - date: '2026-10-26 08:00', - area: '2 860 m²', - duration: '2 h 42 min', - done: true, - coverage: '98.6%', - ), - _DemoRecord( - title: 'work_v2.demo_task_a_inspect', - robot: 'work_v2.demo_robot_1', - date: '2026-10-25 16:20', - area: '1 240 m²', - duration: '1 h 05 min', - done: true, - coverage: '97.2%', - ), - _DemoRecord( - title: 'work_v2.demo_task_c_retry', - robot: 'work_v2.demo_robot_1', - date: '2026-10-25 09:10', - area: '640 m²', - duration: '0 h 38 min', - done: false, - coverage: '42.5%', - ), - _DemoRecord( - title: 'work_v2.demo_task_zone_a', - robot: 'work_v2.demo_robot_2', - date: '2026-10-24 14:00', - area: '3 120 m²', - duration: '3 h 12 min', - done: true, - coverage: '99.1%', - ), - _DemoRecord( - title: 'work_v2.demo_task_d_edge', - robot: 'work_v2.demo_robot_3', - date: '2026-10-23 10:30', - area: '980 m²', - duration: '1 h 12 min', - done: true, - coverage: '96.4%', - ), - ]; - - /// 顶部筛选文案(顺序:全部 / 已完成 / 已中止 / 本周) - List _filterLabels(AppLocalizations l10n) => [ - l10n.translate('work_v2.record.filter_all'), - l10n.translate('work_v2.record.filter_done'), - l10n.translate('work_v2.record.filter_aborted'), - l10n.translate('work_v2.record.filter_week'), - ]; - - void _toast(String text) => CapsuleToast.show(text, showCheck: false); - - /// 当前筛选下要显示的记录 - List<_DemoRecord> get _visible { - switch (_filter) { - case 1: - return _records.where((r) => r.done).toList(); - case 2: - return _records.where((r) => !r.done).toList(); - case 3: - // 演示:取最近 4 条当作「本周」 - return _records.take(4).toList(); - default: - return _records; - } + @override + void initState() { + super.initState(); + final sites = sl(); + var currentScope = _scopeOf(sites.state); + _scopeSubscription = sites.stream.map(_scopeOf).listen((scope) { + if (!mounted || scope == currentScope) return; + currentScope = scope; + setState(() => _filter = 0); + unawaited(_refresh()); + }); + unawaited(_refresh()); } - void _openReport(_DemoRecord r) { - Navigator.of(context).push( - WorkReportPageV2.route( - taskName: AppLocalizations.of(context).translate(r.title), - ), + (int?, int?) _scopeOf(SiteState state) { + final robot = widget.robot; + final selected = state.selectedSite; + final deviceSiteId = robot?.siteId; + if (deviceSiteId == null || deviceSiteId <= 0) { + return (selected?.id, selected?.orgId); + } + + final site = selected?.id == deviceSiteId + ? selected + : state.sites.where((site) => site.id == deviceSiteId).firstOrNull; + final siteOrgId = site?.orgId; + return ( + deviceSiteId, + siteOrgId != null && siteOrgId > 0 ? siteOrgId : robot?.orgId, ); } + Future _refresh() { + final (siteId, orgId) = _scopeOf(sl().state); + return _history.load(siteId: siteId, orgId: orgId); + } + @override - Widget build(BuildContext context) { - final l10n = AppLocalizations.of(context); - final records = _visible; - return WorkPhoneScaffold( - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - WorkPhoneTopBar( - title: l10n.translate('work_v2.record.title'), - onBack: () => Navigator.of(context).maybePop(), - trailing: WorkSquareButton( - icon: Icons.file_download_outlined, - size: 17, - onTap: () => - _toast(l10n.translate('work_v2.record.toast_export_todo')), - ), - ), - const SizedBox(height: 12), - WorkPageHeading( - title: l10n.translate('work_v2.record.title'), - subtitle: l10n.translate('work_v2.record.page_subtitle'), - ), - const SizedBox(height: 12), - _buildSummary(l10n), - const SizedBox(height: 12), - WorkFilterRow( - items: _filterLabels(l10n), - index: _filter, - onChanged: (i) => setState(() => _filter = i), - ), - const SizedBox(height: 12), - Expanded( - child: records.isEmpty - ? _buildEmpty(l10n) - : ListView.separated( - padding: const EdgeInsets.only(bottom: 8), - itemCount: records.length, - separatorBuilder: (_, _) => const SizedBox(height: 10), - itemBuilder: (context, i) => - _buildRecordCard(l10n, records[i]), - ), - ), - ], - ), - ); + void dispose() { + final subscription = _scopeSubscription; + if (subscription != null) unawaited(subscription.cancel()); + unawaited(_history.close()); + super.dispose(); } - // ===== 本月汇总 ===== - Widget _buildSummary(AppLocalizations l10n) { - return Container( - padding: const EdgeInsets.fromLTRB(14, 12, 14, 12), - decoration: BoxDecoration( - gradient: const LinearGradient( - colors: [Color(0xFF2E8DF7), Color(0xFF1C96F6)], - begin: Alignment.topLeft, - end: Alignment.bottomRight, - ), - borderRadius: BorderRadius.circular(16), - boxShadow: const [ - BoxShadow( - color: Color(0x331C96F6), - blurRadius: 12, - offset: Offset(0, 4), - ), - ], + String _t(String key) => + AppLocalizations.of(context).translate('work_v2.record.$key'); + + String _title(WorkHistoryRecord record) => record.workName.isEmpty + ? '${_t('task_id')} #${record.id}' + : record.workName; + + String _status(WorkHistoryRecord record) => record.statusLabel.isNotEmpty + ? record.statusLabel + : record.status.isNotEmpty + ? record.status + : _t('unknown_status'); + + String _device(WorkHistoryRecord record) { + final serial = record.deviceId.isEmpty ? '—' : record.deviceId; + return record.deviceAlias == null + ? serial + : '${record.deviceAlias}($serial)'; + } + + List _recordsForEntry(List records) { + final robot = widget.robot; + if (robot == null) return records; + + final deviceIds = {robot.name.trim(), robot.id.trim()}..remove(''); + return records + .where((record) => deviceIds.contains(record.deviceId)) + .toList(); + } + + List _visible(List records) { + if (_filter == 1) { + return records.where((record) => record.isCompleted).toList(); + } + if (_filter == 2) { + return records.where((record) => record.isCanceled).toList(); + } + if (_filter == 3) { + final now = DateTime.now(); + final today = DateTime(now.year, now.month, now.day); + final monday = today.subtract(Duration(days: now.weekday - 1)); + final nextMonday = monday.add(const Duration(days: 7)); + return records.where((record) { + final date = record.recordDate; + return date != null && + !date.isBefore(monday) && + date.isBefore(nextMonday); + }).toList(); + } + return records; + } + + Color _statusColor(WorkHistoryRecord record) { + if (record.isCompleted) return const Color(0xFF22A06B); + if (record.isCanceled || record.normalizedStatus == 'FAILED') { + return const Color(0xFFF0483E); + } + return kWtBlue; + } + + void _openDetails(WorkHistoryRecord record) { + final fields = <(String, String)>[ + (_t('task_id'), '${record.id}'), + (_t('device'), _device(record)), + (_t('status'), _status(record)), + (_t('created_at'), record.createdAt ?? '—'), + (_t('started_at'), record.startedAt ?? '—'), + (_t('finished_at'), record.finishedAt ?? '—'), + (_t('updated_at'), record.updatedAt ?? '—'), + (_t('route_id'), record.routeId?.toString() ?? '—'), + (_t('plan_id'), record.planId?.toString() ?? '—'), + (_t('task_type'), record.taskType ?? '—'), + (_t('route_type'), record.routeType ?? '—'), + ( + _t('accepted'), + record.accepted == null + ? '—' + : record.accepted! + ? _t('yes') + : _t('no'), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( + if (record.remark != null) (_t('remark'), record.remark!), + ]; + showModalBottomSheet( + context: context, + isScrollControlled: true, + showDragHandle: true, + backgroundColor: Colors.white, + builder: (sheetContext) => SafeArea( + child: ConstrainedBox( + constraints: BoxConstraints( + maxHeight: MediaQuery.sizeOf(sheetContext).height * 0.8, + ), + child: ListView( + shrinkWrap: true, + padding: const EdgeInsets.fromLTRB(20, 0, 20, 20), children: [ Text( - l10n.translate('work_v2.record.summary_title'), + _title(record), style: const TextStyle( - fontSize: 13, - fontWeight: FontWeight.w700, - color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.w800, + color: kWtNavy, ), ), - const Spacer(), - Container( - padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3), - decoration: BoxDecoration( - color: Colors.white.withValues(alpha: 0.22), - borderRadius: BorderRadius.circular(999), - ), - child: const Text( - '2026-10', - style: TextStyle( - fontSize: 10.5, - fontWeight: FontWeight.w700, - color: Colors.white, - ), - ), - ), - ], - ), - const SizedBox(height: 12), - Row( - children: [ - _SummaryCell( - value: '18', - label: l10n.translate('work_v2.record.summary_count'), - ), - _SummaryCell( - value: '4.6', - label: l10n.translate('work_v2.record.summary_area'), - ), - _SummaryCell( - value: '21.3', - label: l10n.translate('work_v2.record.summary_hours'), - ), - ], - ), - ], - ), - ); - } - - Widget _buildEmpty(AppLocalizations l10n) { - return Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - width: 56, - height: 56, - decoration: const BoxDecoration( - color: Colors.white, - shape: BoxShape.circle, - ), - child: const Icon( - Icons.receipt_long_outlined, - size: 26, - color: kWtMuted, - ), - ), - const SizedBox(height: 10), - Text( - l10n.translate('work_v2.record.empty'), - style: const TextStyle(fontSize: 12.5, color: _gray), - ), - ], - ), - ); - } - - // ===== 记录卡 ===== - Widget _buildRecordCard(AppLocalizations l10n, _DemoRecord r) { - final Color statusColor = r.done ? _green : _abort; - final Color statusBg = r.done - ? const Color(0xFFE8F8EC) - : const Color(0xFFFDECEB); - - return GestureDetector( - onTap: () => _openReport(r), - behavior: HitTestBehavior.opaque, - child: Container( - padding: const EdgeInsets.fromLTRB(14, 12, 12, 12), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(16), - border: Border.all(color: _border), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Expanded( - child: Text( - l10n.translate(r.title), - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w800, - color: _navy, - ), - ), - ), - const SizedBox(width: 8), - Container( - padding: const EdgeInsets.symmetric( - horizontal: 9, - vertical: 3, - ), - decoration: BoxDecoration( - color: statusBg, - borderRadius: BorderRadius.circular(999), - ), - child: Text( - r.done - ? l10n.translate('work_v2.plan.status_done') - : l10n.translate('work_v2.plan.status_aborted'), - style: TextStyle( - fontSize: 10.5, - fontWeight: FontWeight.w700, - color: statusColor, - ), - ), - ), - ], - ), - const SizedBox(height: 5), - Text( - '${l10n.translate(r.robot)} · ${r.date}', - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle(fontSize: 11.5, color: _gray), - ), - const SizedBox(height: 10), - const Divider(height: 1, color: kWtDivider), - const SizedBox(height: 9), - Row( - children: [ - // 三项指标用 Wrap:窄屏自动换行,不把「报告」顶出去 - Expanded( - child: Wrap( - spacing: 12, - runSpacing: 5, + const SizedBox(height: 12), + for (final field in fields) + Padding( + padding: const EdgeInsets.symmetric(vertical: 7), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - _metaItem(Icons.crop_free_rounded, r.area), - _metaItem(Icons.schedule_rounded, r.duration), - _metaItem(Icons.donut_large_rounded, r.coverage), + SizedBox( + width: 90, + child: Text( + field.$1, + style: const TextStyle(color: kWtGray, fontSize: 12), + ), + ), + Expanded( + child: SelectableText( + field.$2, + style: const TextStyle( + color: kWtNavy, + fontSize: 12.5, + ), + ), + ), ], ), ), - const SizedBox(width: 6), - Text( - l10n.translate('work_v2.record.report'), - style: const TextStyle( - fontSize: 11.5, - fontWeight: FontWeight.w700, - color: kWtBlue, + ], + ), + ), + ), + ); + } + + @override + Widget build( + BuildContext context, + ) => BlocBuilder( + bloc: _history, + builder: (context, state) { + final deviceEntry = widget.robot != null; + final entryRecords = _recordsForEntry(state.records); + final records = _visible(entryRecords); + final scopeLabel = _t( + deviceEntry ? 'device_history_scope' : 'history_scope', + ); + final loadedLabel = deviceEntry + ? _t( + 'device_loaded_count', + ).replaceFirst('%s', '${entryRecords.length}') + : _t('loaded_count') + .replaceFirst('%s', '${state.records.length}') + .replaceFirst('%s', '${state.total}'); + return WorkPhoneScaffold( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + WorkPhoneTopBar( + title: _t('title'), + trailing: WorkSquareButton( + icon: Icons.refresh_rounded, + onTap: () { + if (!state.loading) unawaited(_refresh()); + }, + ), + ), + const SizedBox(height: 12), + WorkPageHeading( + title: _t('title'), + subtitle: _t( + deviceEntry ? 'device_page_subtitle' : 'page_subtitle', + ), + ), + const SizedBox(height: 12), + Container( + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: kWtSoftBlue, + borderRadius: BorderRadius.circular(14), + ), + child: Row( + children: [ + const Icon(Icons.receipt_long_outlined, color: kWtBlue), + const SizedBox(width: 10), + Expanded( + child: Text( + state.loaded ? loadedLabel : scopeLabel, + style: const TextStyle( + fontSize: 12.5, + fontWeight: FontWeight.w700, + color: kWtNavy, + ), + ), ), - ), - const Icon( - Icons.chevron_right_rounded, - size: 16, - color: kWtBlue, - ), + ], + ), + ), + const SizedBox(height: 12), + WorkFilterRow( + items: [ + _t('filter_all'), + _t('filter_done'), + _t('filter_canceled'), + _t('filter_week'), ], + index: _filter, + onChanged: (value) => setState(() => _filter = value), + ), + if (state.loading && state.loaded) ...[ + const SizedBox(height: 8), + const LinearProgressIndicator(minHeight: 2), + ], + if (state.error != null) ...[ + const SizedBox(height: 8), + Row( + children: [ + Expanded( + child: Text( + state.error!, + style: const TextStyle( + fontSize: 12, + color: Color(0xFFF0483E), + ), + ), + ), + TextButton( + onPressed: () => unawaited(_refresh()), + child: Text(_t('retry')), + ), + ], + ), + ], + const SizedBox(height: 10), + Expanded( + child: RefreshIndicator( + onRefresh: _refresh, + child: ListView.separated( + physics: const AlwaysScrollableScrollPhysics(), + padding: const EdgeInsets.only(bottom: 12), + itemCount: records.isEmpty ? 1 : records.length, + separatorBuilder: (_, _) => const SizedBox(height: 10), + itemBuilder: (context, index) { + if (records.isEmpty) { + return SizedBox( + height: 160, + child: Center( + child: state.loading && !state.loaded + ? const CircularProgressIndicator(strokeWidth: 2) + : Text( + state.loaded ? _t('empty') : _t('load_hint'), + style: const TextStyle( + fontSize: 12.5, + color: kWtGray, + ), + ), + ), + ); + } + return _recordCard(records[index]); + }, + ), + ), ), ], ), - ), - ); - } + ); + }, + ); - Widget _metaItem(IconData icon, String text) { - return Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon(icon, size: 12.5, color: kWtHint), - const SizedBox(width: 3), - Text( - text, - style: const TextStyle( - fontSize: 11, - fontWeight: FontWeight.w600, - color: kWtGray2, + Widget _recordCard(WorkHistoryRecord record) { + final color = _statusColor(record); + return Material( + color: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + side: const BorderSide(color: kWtBorder), + ), + child: InkWell( + onTap: () => _openDetails(record), + borderRadius: BorderRadius.circular(16), + child: Padding( + padding: const EdgeInsets.all(14), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + children: [ + Expanded( + child: Text( + _title(record), + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w800, + color: kWtNavy, + ), + ), + ), + const SizedBox(width: 8), + Flexible( + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 9, + vertical: 4, + ), + decoration: BoxDecoration( + color: color.withValues(alpha: 0.1), + borderRadius: BorderRadius.circular(20), + ), + child: Text( + _status(record), + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w700, + color: color, + ), + ), + ), + ), + ], + ), + const SizedBox(height: 8), + Text( + _device(record), + style: const TextStyle(fontSize: 12, color: kWtGray), + ), + const SizedBox(height: 8), + Text( + '${_t('created_at')}:${record.createdAt ?? '—'}', + style: const TextStyle(fontSize: 11.5, color: kWtGray), + ), + const SizedBox(height: 4), + Text( + '${_t('started_at')}:${record.startedAt ?? '—'}', + style: const TextStyle(fontSize: 11.5, color: kWtGray), + ), + const SizedBox(height: 4), + Text( + '${_t('finished_at')}:${record.finishedAt ?? '—'}', + style: const TextStyle(fontSize: 11.5, color: kWtGray), + ), + const SizedBox(height: 8), + Row( + children: [ + Expanded( + child: Text( + '${_t('task_id')} #${record.id}', + style: const TextStyle(fontSize: 11, color: kWtHint), + ), + ), + Text( + _t('details'), + style: const TextStyle( + fontSize: 11.5, + fontWeight: FontWeight.w700, + color: kWtBlue, + ), + ), + const Icon( + Icons.chevron_right_rounded, + size: 17, + color: kWtBlue, + ), + ], + ), + ], ), ), - ], - ); - } -} - -/// 汇总卡里的一格(深蓝底上的白字) -class _SummaryCell extends StatelessWidget { - const _SummaryCell({required this.value, required this.label}); - - final String value; - final String label; - - @override - Widget build(BuildContext context) { - return Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - value, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - fontSize: 21, - fontWeight: FontWeight.w800, - color: Colors.white, - height: 1.1, - ), - ), - const SizedBox(height: 4), - Text( - label, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 10.5, - color: Colors.white.withValues(alpha: 0.82), - ), - ), - ], ), ); } diff --git a/lib/features/v2/work/presentation/pages/work_route_library_page_v2.dart b/lib/features/v2/work/presentation/pages/work_route_library_page_v2.dart index 5a6a1b71..15c7f2a7 100644 --- a/lib/features/v2/work/presentation/pages/work_route_library_page_v2.dart +++ b/lib/features/v2/work/presentation/pages/work_route_library_page_v2.dart @@ -1,4 +1,8 @@ +import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart'; +import '../cubit/return_plan_library_cubit.dart'; +import '../widgets/return_plan_library_section.dart'; import 'package:flutter/services.dart'; import 'package:latlong2/latlong.dart'; import 'package:maibu_satabot_v2/components/capsule_toast.dart'; @@ -48,6 +52,13 @@ class _WorkRouteLibraryPageV2State extends State { // 'custom', ]; int _filter = 0; + bool get _isReturn => _filterKeys[_filter] == 'return'; + late final ReturnPlanLibraryCubit _returnPlans = sl(); + StreamSubscription? _siteSubscription; + StreamSubscription? _ownerSubscription; + (int?, int?)? _siteScope; + String? _ownerId; + int _routesGeneration = 0; late final AutonomousWorkGateway _gateway = sl(); @@ -58,41 +69,94 @@ class _WorkRouteLibraryPageV2State extends State { @override void initState() { super.initState(); - _load(); + final site = sl().state.selectedSite; + _siteScope = (site?.id, site?.orgId); + _ownerId = sl().state.user?.userId; + _siteSubscription = sl().stream + .map((state) => (state.selectedSite?.id, state.selectedSite?.orgId)) + .distinct() + .listen((scope) { + if (_siteScope == scope) return; + _siteScope = scope; + _scopeChanged(); + }); + _ownerSubscription = sl().stream + .map((state) => state.user?.userId) + .distinct() + .listen((owner) { + if (_ownerId == owner) return; + _ownerId = owner; + _scopeChanged(); + }); + unawaited(_load()); } - /// 拉取当前场站下的所有路线:与自主作业抽屉面板同一链路 - /// (resolveScope → siteId → loadRoutes),页面不直接依赖任何接口。 + @override + void dispose() { + ++_routesGeneration; + _siteSubscription?.cancel(); + _ownerSubscription?.cancel(); + _returnPlans.close(); + super.dispose(); + } + + void _scopeChanged() { + if (!mounted) return; + ++_routesGeneration; + _returnPlans.clear(); + setState(() { + _routes = const []; + _error = null; + }); + unawaited(_load()); + } + + /// 两个分栏使用各自领域查询,不把场站返航方案当普通作业路线。 Future _load() async { + final site = sl().state.selectedSite; + if (_isReturn) { + await _returnPlans.load(siteId: site?.id, orgId: site?.orgId); + return; + } + final generation = ++_routesGeneration; setState(() { _loading = true; _error = null; }); - final scope = await _gateway.resolveScope(deviceId: ''); - final siteId = scope.siteId; - if (!mounted) return; - if (siteId == null) { + try { + final scope = await _gateway.resolveScope(deviceId: ''); + if (!mounted || generation != _routesGeneration) return; + final siteId = scope.siteId; + if (siteId == null) { + setState(() { + _loading = false; + _error = AppLocalizations.of( + context, + ).translate('work_v2.route_lib.no_site'); + }); + return; + } + final result = await _gateway.loadRoutes(siteId: siteId); + if (!mounted || generation != _routesGeneration) return; + final routes = result.data ?? const []; setState(() { _loading = false; - _error = AppLocalizations.of( - context, - ).translate('work_v2.route_lib.no_site'); + _routes = routes; + _error = !result.isOk + ? result.error + : routes.isEmpty + ? AppLocalizations.of( + context, + ).translate('work_v2.route_lib.empty_site') + : null; + }); + } catch (error) { + if (!mounted || generation != _routesGeneration) return; + setState(() { + _loading = false; + _error = '$error'; }); - return; } - final result = await _gateway.loadRoutes(siteId: siteId); - if (!mounted) return; - final routes = result.data ?? const []; - setState(() { - _loading = false; - _routes = routes; - _error = routes.isEmpty - ? (result.error ?? - AppLocalizations.of( - context, - ).translate('work_v2.route_lib.empty_site')) - : null; - }); } /// 路线类型代码 -> 当前语言文案 @@ -118,19 +182,20 @@ class _WorkRouteLibraryPageV2State extends State { const LatLng(31.083296, 120.840355); } - /// 按分栏过滤:返航为预留项(作业记录接口暂无返航类型数据,选中显示空态); - /// 覆盖/自定义模式过滤逻辑保留,恢复 _filterKeys 对应分栏即可重新生效 + /// 普通路线仍按覆盖/自定义模式筛选;返航分栏由独立方案组件展示。 List get _visible { if (_filter == 0) return _routes; final String kind = _filterKeys[_filter]; - if (kind == 'return') return const []; + if (kind == 'return') return _routes; final bool wantCoverage = kind == 'coverage'; return _routes.where((r) => r.coverageMode == wantCoverage).toList(); } /// 进入横屏「地图与区域编辑」画路线;返回后把方向还给竖屏并刷新列表 Future _openEditor() async { - await Navigator.of(context).push(RouteEditorPageV2.route(deviceSn: '')); + await Navigator.of( + context, + ).push(RouteEditorPageV2.route(deviceSn: '', startReturnEditor: _isReturn)); await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); if (mounted) _load(); @@ -178,7 +243,11 @@ class _WorkRouteLibraryPageV2State extends State { onBack: () => Navigator.of(context).maybePop(), trailing: WorkSquareButton( icon: Icons.add_rounded, - label: l10n.translate('work_v2.route_lib.new'), + label: l10n.translate( + _isReturn + ? 'work_v2.route_lib.return_manage' + : 'work_v2.route_lib.new', + ), primary: true, onTap: _openEditor, ), @@ -186,13 +255,21 @@ class _WorkRouteLibraryPageV2State extends State { const SizedBox(height: 12), WorkPageHeading( title: l10n.translate('work_v2.route_lib.title'), - subtitle: l10n.translate('work_v2.route_lib.page_subtitle'), + subtitle: l10n.translate( + _isReturn + ? 'work_v2.route_lib.return_subtitle' + : 'work_v2.route_lib.page_subtitle', + ), ), const SizedBox(height: 12), WorkFilterRow( items: _filterKeys.map((k) => _kindLabel(l10n, k)).toList(), index: _filter, - onChanged: (i) => setState(() => _filter = i), + onChanged: (i) { + if (_filter == i) return; + setState(() => _filter = i); + unawaited(_load()); + }, ), const SizedBox(height: 12), Expanded(child: _buildBody(l10n, routes)), @@ -202,6 +279,13 @@ class _WorkRouteLibraryPageV2State extends State { } Widget _buildBody(AppLocalizations l10n, List routes) { + if (_isReturn) { + return ReturnPlanLibrarySection( + cubit: _returnPlans, + onReload: _load, + onEdit: _openEditor, + ); + } if (_loading) { return const Center(child: CircularProgressIndicator(strokeWidth: 2)); } @@ -270,10 +354,7 @@ class _WorkRouteLibraryPageV2State extends State { Widget _buildRouteCard(AppLocalizations l10n, WorkRouteOption r) { final bool coverage = r.coverageMode; final Color kindColor = coverage ? _cyan : kWtBlue; - final String kindLabel = _kindLabel( - l10n, - coverage ? 'coverage' : 'custom', - ); + final String kindLabel = _kindLabel(l10n, coverage ? 'coverage' : 'custom'); final subtitle = r.metaText ?? r.planModeLabel ?? '路线 #${r.id}'; final imageUrl = r.imageUrl; final String enterLabel = l10n.translate('work_v2.enter_work_center'); @@ -303,8 +384,8 @@ class _WorkRouteLibraryPageV2State extends State { height: 96, fit: BoxFit.cover, width: double.infinity, - errorBuilder: - (context, error, stackTrace) => _mapThumb(), + errorBuilder: (context, error, stackTrace) => + _mapThumb(), ), ) else @@ -401,11 +482,7 @@ class _WorkRouteLibraryPageV2State extends State { showRobot: false, ); - Widget _smallAction( - String text, - VoidCallback onTap, { - bool primary = false, - }) { + Widget _smallAction(String text, VoidCallback onTap, {bool primary = false}) { return GestureDetector( onTap: onTap, behavior: HitTestBehavior.opaque, diff --git a/lib/features/v2/work/presentation/widgets/work_phone_ui.dart b/lib/features/v2/work/presentation/widgets/work_phone_ui.dart index bf5a0f63..3dd52889 100644 --- a/lib/features/v2/work/presentation/widgets/work_phone_ui.dart +++ b/lib/features/v2/work/presentation/widgets/work_phone_ui.dart @@ -98,7 +98,7 @@ class WorkSquareButton extends StatelessWidget { }); final IconData icon; - final VoidCallback onTap; + final VoidCallback? onTap; final double size; /// 有文字时变成胶囊按钮(如「+ 新建」) @@ -110,6 +110,10 @@ class WorkSquareButton extends StatelessWidget { @override Widget build(BuildContext context) { final bool pill = label != null; + final bool filled = primary && onTap != null; + final foreground = onTap == null + ? kWtHint + : (filled ? Colors.white : kWtNavy); return GestureDetector( onTap: onTap, behavior: HitTestBehavior.opaque, @@ -120,15 +124,15 @@ class WorkSquareButton extends StatelessWidget { ? const EdgeInsets.symmetric(horizontal: 12) : EdgeInsets.zero, decoration: BoxDecoration( - color: primary ? kWtBlue : Colors.white, + color: filled ? kWtBlue : Colors.white, borderRadius: BorderRadius.circular(12), - border: Border.all(color: primary ? Colors.transparent : kWtBorder), + border: Border.all(color: filled ? Colors.transparent : kWtBorder), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - Icon(icon, size: size, color: primary ? Colors.white : kWtNavy), + Icon(icon, size: size, color: foreground), if (pill) ...[ const SizedBox(width: 3), Text( @@ -136,7 +140,7 @@ class WorkSquareButton extends StatelessWidget { style: TextStyle( fontSize: 12.5, fontWeight: FontWeight.w700, - color: primary ? Colors.white : kWtNavy, + color: foreground, ), ), ], diff --git a/lib/features/work_history/domain/usecases/load_site_work_history_usecase.dart b/lib/features/work_history/domain/usecases/load_site_work_history_usecase.dart new file mode 100644 index 00000000..290772db --- /dev/null +++ b/lib/features/work_history/domain/usecases/load_site_work_history_usecase.dart @@ -0,0 +1,25 @@ +import 'package:fpdart/fpdart.dart'; +import '../../../../core/error/failure.dart'; +import '../entities/work_history_record.dart'; +import '../repositories/work_history_repository.dart'; + +class LoadSiteWorkHistoryUseCase { + LoadSiteWorkHistoryUseCase(this.repository); + final WorkHistoryRepository repository; + + Future> call({ + required int siteId, + required int orgId, + int pageNum = 1, + int pageSize = 99999999, + }) async { + if (siteId <= 0 || orgId <= 0) return Left(Failure('请先选择有效场站和组织')); + if (pageNum <= 0 || pageSize <= 0) return Left(Failure('分页参数无效')); + return repository.load( + siteId: siteId, + orgId: orgId, + pageNum: pageNum, + pageSize: pageSize, + ); + } +} diff --git a/lib/main.dart b/lib/main.dart index 3599e62e..ecac996c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -133,7 +133,10 @@ class MyApp extends StatelessWidget { value: sl(), ), BlocProvider( - create: (_) => UpdateCubit(VersionCheckService()), + create: (context) => UpdateCubit( + VersionCheckService(), + context.read(), + ), ), BlocProvider.value( value: sl(), @@ -147,9 +150,9 @@ class MyApp extends StatelessWidget { bloc: themeCubit, builder: (context, themeMode) { return MaterialApp.router( - title: 'Maibu Satabot', + title: '飒沓·星枢', locale: locale, - supportedLocales: const [Locale('zh', 'CN'), Locale('en', 'US')], + supportedLocales: AppLocalizations.supportedLocales, localizationsDelegates: const [ AppLocalizations.delegate, GlobalMaterialLocalizations.delegate, @@ -306,9 +309,13 @@ class _UpdateCheckerState extends State<_UpdateChecker> { @override Widget build(BuildContext context) { + final isAdmin = context.select( + (cubit) => cubit.state.user?.isAdmin == true, + ); return BlocConsumer( listener: (context, state) { - if (state is UpdateFailure) { + final user = context.read().state.user; + if (user?.isAdmin == true && state is UpdateFailure) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text('更新失败: ${state.error}'), @@ -317,7 +324,8 @@ class _UpdateCheckerState extends State<_UpdateChecker> { ); } }, - builder: (context, state) { + builder: (context, updateState) { + final state = isAdmin ? updateState : const UpdateInitial(); return Stack( children: [ widget.child, diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index f408089d..001d94ed 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -4,7 +4,7 @@ project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. -set(BINARY_NAME "飒沓机器人") +set(BINARY_NAME "飒沓·星枢") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.maibu.maibu_satabot_v2") diff --git a/linux/runner/my_application.cc b/linux/runner/my_application.cc index b75859db..78356ce8 100644 --- a/linux/runner/my_application.cc +++ b/linux/runner/my_application.cc @@ -45,11 +45,11 @@ static void my_application_activate(GApplication* application) { if (use_header_bar) { GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); gtk_widget_show(GTK_WIDGET(header_bar)); - gtk_header_bar_set_title(header_bar, "maibu_satabot_v2"); + gtk_header_bar_set_title(header_bar, "飒沓·星枢"); gtk_header_bar_set_show_close_button(header_bar, TRUE); gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); } else { - gtk_window_set_title(window, "maibu_satabot_v2"); + gtk_window_set_title(window, "飒沓·星枢"); } gtk_window_set_default_size(window, 1280, 720); diff --git a/macos/Runner/Configs/AppInfo.xcconfig b/macos/Runner/Configs/AppInfo.xcconfig index 2e379f43..ea100cb7 100644 --- a/macos/Runner/Configs/AppInfo.xcconfig +++ b/macos/Runner/Configs/AppInfo.xcconfig @@ -5,7 +5,7 @@ // 'flutter create' template. // The application's name. By default this is also the title of the Flutter window. -PRODUCT_NAME = 飒沓机器人 +PRODUCT_NAME = 飒沓·星枢 // The application's bundle identifier PRODUCT_BUNDLE_IDENTIFIER = com.maibu.maibuSatabotV2 diff --git a/pubspec.yaml b/pubspec.yaml index c7a04062..1927bc21 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,13 +18,14 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # of the product and file versions while build-number is used as the build suffix. version: 1.0.0+1 -flutter_icons: +flutter_launcher_icons: android: "launcher_icon" ios: true - image_path: "assets/images/app_logo_gray.png" + image_path: "assets/images/app_logo.png" + remove_alpha_ios: true # 适配安卓图标 - adaptive_icon_background: "#2e2e2e" - adaptive_icon_foreground: "assets/images/app_logo_gray.png" + adaptive_icon_background: "#FF8500" + adaptive_icon_foreground: "assets/images/app_logo.png" environment: sdk: ^3.10.0 diff --git a/test/region_editor_test.dart b/test/region_editor_test.dart index 653731c2..c57ce270 100644 --- a/test/region_editor_test.dart +++ b/test/region_editor_test.dart @@ -2,9 +2,11 @@ import 'dart:async'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:latlong2/latlong.dart'; +import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; import 'package:maibu_satabot_v2/core/logging/i_logger_service.dart'; import 'package:maibu_satabot_v2/features/autonomous_work/domain/entities/work_session_models.dart'; import 'package:maibu_satabot_v2/features/autonomous_work/domain/repositories/autonomous_work_gateway.dart'; @@ -16,6 +18,8 @@ import 'package:maibu_satabot_v2/features/regions/presentation/cubit/region_edit import 'package:maibu_satabot_v2/features/regions/presentation/widgets/region_boundary_layer.dart'; import 'package:maibu_satabot_v2/features/regions/presentation/widgets/region_form_dialog.dart'; +import 'support/region_test_localizations.dart'; + const points = [ RegionPoint(lat: 31.08333536934687, lng: 120.84125702784672), RegionPoint(lat: 31.083297377312423, lng: 120.84137894536802), @@ -117,6 +121,7 @@ class _Harness { void main() { TestWidgetsFlutterBinding.ensureInitialized(); + setUpAll(RegionTestLocalizations.loadAssets); test('新建完整链路按用户示例发送 JSON,编码保持 0090,scope 只传四点', () async { final h = _Harness(sample()); @@ -244,9 +249,18 @@ void main() { WidgetTester tester, _Harness h, { bool Function()? isCurrent, + Locale locale = AppLocalizations.chinese, }) async { await tester.pumpWidget( MaterialApp( + locale: locale, + supportedLocales: AppLocalizations.supportedLocales, + localizationsDelegates: const [ + RegionTestLocalizations(), + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], home: Builder( builder: (context) => Scaffold( body: TextButton( @@ -268,6 +282,15 @@ void main() { }); } + testWidgets('English region editor localizes its form and boundary count', (tester) async { + final h = _Harness(sample(id: 14)); + addTearDown(h.close); + await open(tester, h, locale: AppLocalizations.english); + expect(find.text('Edit region'), findsOneWidget); + expect(find.text('Region name *'), findsOneWidget); + expect(find.text('Boundary points: 4/4'), findsOneWidget); + }); + testWidgets('表单回填截图字段,使用真实路线选项、多选绑定并携带 ID 修改', (tester) async { final h = _Harness(sample(id: 14)); addTearDown(h.close); @@ -376,6 +399,14 @@ void main() { final geometry = [for (final p in points) LatLng(p.lat, p.lng)]; await tester.pumpWidget( MaterialApp( + locale: AppLocalizations.chinese, + supportedLocales: AppLocalizations.supportedLocales, + localizationsDelegates: const [ + RegionTestLocalizations(), + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], home: Scaffold( body: FlutterMap( options: MapOptions(initialCenter: geometry.first, initialZoom: 19), diff --git a/test/region_list_test.dart b/test/region_list_test.dart index 1793d77d..91812b7b 100644 --- a/test/region_list_test.dart +++ b/test/region_list_test.dart @@ -1,7 +1,9 @@ import 'dart:async'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:maibu_satabot_v2/core/localization/app_localizations.dart'; import 'package:maibu_satabot_v2/core/logging/i_logger_service.dart'; import 'package:maibu_satabot_v2/features/autonomous_work/domain/repositories/autonomous_work_gateway.dart'; import 'package:maibu_satabot_v2/features/regions/data/datasources/region_remote_datasource.dart'; @@ -12,6 +14,8 @@ import 'package:maibu_satabot_v2/features/regions/presentation/cubit/region_list import 'package:maibu_satabot_v2/features/regions/presentation/widgets/region_list_panel.dart'; import 'package:maibu_satabot_v2/features/regions/presentation/widgets/no_device_crosshair_hint.dart'; +import 'support/region_test_localizations.dart'; + Map row({int id = 16, int site = 18}) => { 'id': id, 'regionName': '测试分区', @@ -97,9 +101,18 @@ Future _mount( VoidCallback? create, ValueChanged? edit, Object? Function()? currentScope, + Locale locale = AppLocalizations.chinese, }) async { await tester.pumpWidget( MaterialApp( + locale: locale, + supportedLocales: AppLocalizations.supportedLocales, + localizationsDelegates: const [ + RegionTestLocalizations(), + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], home: Scaffold( body: Center( child: SizedBox( @@ -122,6 +135,7 @@ Future _mount( void main() { TestWidgetsFlutterBinding.ensureInitialized(); + setUpAll(RegionTestLocalizations.loadAssets); test('GET 按场站查询,字符串 siteId/空字段正常解析,编辑数据完整', () async { final h = _Harness(); addTearDown(h.close); @@ -246,6 +260,18 @@ void main() { await old; expect(h.cubit.state.regions.single.id, 20); }); + testWidgets('English region list localizes the count and deletion prompt', (tester) async { + final h = _Harness(); + addTearDown(h.close); + await tester.runAsync(h.load); + await _mount(tester, h, locale: AppLocalizations.english); + expect(find.text('Regions (1)'), findsOneWidget); + await tester.tap(find.byKey(const ValueKey('region_delete_16'))); + await tester.pumpAndSettle(); + expect(find.text('Delete region'), findsOneWidget); + expect(find.text('Delete “测试分区”? This cannot be undone.'), findsOneWidget); + }); + testWidgets('共享列表:选中高亮、修改传完整对象、新增独立入口', (tester) async { final h = _Harness(); addTearDown(h.close); @@ -289,6 +315,14 @@ void main() { RegionDraft? deleted; await tester.pumpWidget( MaterialApp( + locale: AppLocalizations.chinese, + supportedLocales: AppLocalizations.supportedLocales, + localizationsDelegates: const [ + RegionTestLocalizations(), + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], home: Scaffold( body: SizedBox( width: 320, @@ -339,6 +373,14 @@ void main() { testWidgets('无设备提示可关闭,选择/取消选择设备后保持关闭状态', (tester) async { Future show(bool hasDevice) => tester.pumpWidget( MaterialApp( + locale: AppLocalizations.chinese, + supportedLocales: AppLocalizations.supportedLocales, + localizationsDelegates: const [ + RegionTestLocalizations(), + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], home: Scaffold( body: SizedBox( width: 280, diff --git a/web/favicon.png b/web/favicon.png index 8aaa46ac..f63e02a0 100644 Binary files a/web/favicon.png and b/web/favicon.png differ diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png index b749bfef..c4bf2dbe 100644 Binary files a/web/icons/Icon-192.png and b/web/icons/Icon-192.png differ diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png index 88cfd48d..13ec31bd 100644 Binary files a/web/icons/Icon-512.png and b/web/icons/Icon-512.png differ diff --git a/web/icons/Icon-maskable-192.png b/web/icons/Icon-maskable-192.png index eb9b4d76..3f6541ea 100644 Binary files a/web/icons/Icon-maskable-192.png and b/web/icons/Icon-maskable-192.png differ diff --git a/web/icons/Icon-maskable-512.png b/web/icons/Icon-maskable-512.png index d69c5669..f5c12140 100644 Binary files a/web/icons/Icon-maskable-512.png and b/web/icons/Icon-maskable-512.png differ diff --git a/web/index.html b/web/index.html index db84ac8b..8d20bc9f 100644 --- a/web/index.html +++ b/web/index.html @@ -23,13 +23,13 @@ - + - 飒沓机器人 + 飒沓·星枢 diff --git a/web/manifest.json b/web/manifest.json index 6b1aba60..ddf4bcbd 100644 --- a/web/manifest.json +++ b/web/manifest.json @@ -1,6 +1,6 @@ { - "name": "maibu_satabot_v2", - "short_name": "maibu_satabot_v2", + "name": "飒沓·星枢", + "short_name": "飒沓·星枢", "start_url": ".", "display": "standalone", "background_color": "#0175C2", diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc index b799f3bb..0c06c20c 100644 --- a/windows/runner/Runner.rc +++ b/windows/runner/Runner.rc @@ -90,12 +90,12 @@ BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "com.maibu" "\0" - VALUE "FileDescription", "maibu_satabot_v2" "\0" + VALUE "FileDescription", "飒沓·星枢" "\0" VALUE "FileVersion", VERSION_AS_STRING "\0" VALUE "InternalName", "maibu_satabot_v2" "\0" VALUE "LegalCopyright", "Copyright (C) 2026 com.maibu. All rights reserved." "\0" VALUE "OriginalFilename", "maibu_satabot_v2.exe" "\0" - VALUE "ProductName", "maibu_satabot_v2" "\0" + VALUE "ProductName", "飒沓·星枢" "\0" VALUE "ProductVersion", VERSION_AS_STRING "\0" END END diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp index 0bbc4076..807f9a53 100644 --- a/windows/runner/main.cpp +++ b/windows/runner/main.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, FlutterWindow window(project); Win32Window::Point origin(10, 10); Win32Window::Size size(1280, 720); - if (!window.Create(L"飒沓机器人", origin, size)) { + if (!window.Create(L"飒沓·星枢", origin, size)) { return EXIT_FAILURE; } window.SetQuitOnClose(true);