作业首页和机器状态的数据
This commit is contained in:
@@ -381,11 +381,11 @@ class _LoginPageV2State extends State<LoginPageV2>
|
||||
const SizedBox(height: 12),
|
||||
_buildProtocolSection(),
|
||||
const SizedBox(height: 4),
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 32),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 32),
|
||||
child: Text(
|
||||
'新账户注册前须主动勾选确认',
|
||||
style: TextStyle(fontSize: 12, color: _grayText),
|
||||
AppLocalizations.of(context).translate('register.agree_hint'),
|
||||
style: const TextStyle(fontSize: 12, color: _grayText),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
import '../../domain/entities/work_session_models.dart';
|
||||
import '../../domain/entities/return_plan_models.dart';
|
||||
import '../../domain/repositories/autonomous_work_gateway.dart';
|
||||
|
||||
/// B 环境示例实现:完全本地内存,不依赖任何后端。
|
||||
@@ -105,6 +106,8 @@ class LocalDemoWorkGateway implements AutonomousWorkGateway {
|
||||
required List<LatLng> path,
|
||||
required List<LatLng> outer,
|
||||
required int planModel,
|
||||
// 本地演示无后端校验,只为与线上接口保持同一份签名
|
||||
required String routeType,
|
||||
String? imageBase64,
|
||||
}) async {
|
||||
_savedRoutes.add(
|
||||
@@ -120,6 +123,21 @@ class LocalDemoWorkGateway implements AutonomousWorkGateway {
|
||||
return const WorkResult<bool>.ok(true);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WorkResult<int?>> saveReturnPlan(ReturnPlanDraft draft) async {
|
||||
// B 环境演示:无后端,仅校验后本地确认,返回一个假主键占位
|
||||
if (draft.isEmpty) return const WorkResult.fail('没有可保存的返航点或障碍');
|
||||
return WorkResult<int?>.ok(++_routeSeq);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WorkResult<ReturnPlanDraft?>> fetchReturnPlanBySiteId({
|
||||
required int siteId,
|
||||
}) async {
|
||||
// 本地演示:无后端,始终返回「暂无方案」→ 进入空白新建态
|
||||
return WorkResult<ReturnPlanDraft?>.ok(null);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WorkResult<List<WorkTaskSnapshot>>> loadTasks({
|
||||
required String deviceId,
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:dio/dio.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import '../../../../core/consts/http_api_consts.dart';
|
||||
import '../../../../core/logging/i_logger_service.dart';
|
||||
import '../../domain/entities/device_schedule_plan_entity.dart';
|
||||
import '../models/device_task_model.dart';
|
||||
|
||||
abstract class DeviceTaskDatasource {
|
||||
@@ -35,6 +36,10 @@ abstract class DeviceTaskDatasource {
|
||||
required int orgId,
|
||||
required int siteId,
|
||||
});
|
||||
|
||||
/// 创建设备定时任务(定时作业计划)POST /iot/deviceTask/save
|
||||
/// 周期规则报文组装封在实现内,调用方只交业务实体
|
||||
Future<bool> saveDeviceSchedulePlan({required DeviceSchedulePlanEntity plan});
|
||||
}
|
||||
|
||||
class DeviceTaskDatasourceImpl implements DeviceTaskDatasource {
|
||||
@@ -53,8 +58,8 @@ class DeviceTaskDatasourceImpl implements DeviceTaskDatasource {
|
||||
}) async {
|
||||
try {
|
||||
final url = '${HttpApiConsts.baseUrl}/iot/deviceTask/deviceTaskPool';
|
||||
_logger.logWithLevel('[getDeviceTaskPool] 请求: POST $url');
|
||||
_logger.logWithLevel('[getDeviceTaskPool] 参数: userId=$userId, siteId=$siteId, orgId=$orgId');
|
||||
_logger.logWithLevel('[getDeviceTaskPool] 请求: POST $url', shouldLog: true);
|
||||
_logger.logWithLevel('[getDeviceTaskPool] 参数: userId=$userId, siteId=$siteId, orgId=$orgId, pageNum=$pageNum, pageSize=$pageSize', shouldLog: true);
|
||||
final response = await dio.post(
|
||||
url,
|
||||
data: {
|
||||
@@ -70,6 +75,7 @@ class DeviceTaskDatasourceImpl implements DeviceTaskDatasource {
|
||||
final data = response.data as Map<String, dynamic>;
|
||||
if (data['code'] == 200) {
|
||||
final rows = data['rows'] as List? ?? [];
|
||||
_logger.logWithLevel('[getDeviceTaskPool] 返回任务 ${rows.length} 条', shouldLog: true);
|
||||
return rows
|
||||
.map((item) => DeviceTaskModel.fromJson(item as Map<String, dynamic>))
|
||||
.toList();
|
||||
@@ -199,4 +205,84 @@ class DeviceTaskDatasourceImpl implements DeviceTaskDatasource {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> saveDeviceSchedulePlan({
|
||||
required DeviceSchedulePlanEntity plan,
|
||||
}) async {
|
||||
final url = '${HttpApiConsts.baseUrl}/iot/deviceTask/save';
|
||||
final body = _schedulePlanBody(plan);
|
||||
_logger.logWithLevel('[saveDeviceSchedulePlan] 请求: POST $url', shouldLog: true);
|
||||
_logger.logWithLevel('[saveDeviceSchedulePlan] 参数: ${jsonEncode(body)}', shouldLog: true);
|
||||
try {
|
||||
final response = await dio.post(url, data: body);
|
||||
_logger.logWithLevel('[saveDeviceSchedulePlan] 响应: statusCode=${response.statusCode}, body=${jsonEncode(response.data)}', shouldLog: true);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = response.data as Map<String, dynamic>;
|
||||
if (data['code'] == 200) {
|
||||
// 保存接口返回数量(如 data: 1),同时兼容布尔值及无 data 的成功响应。
|
||||
final saved = switch (data['data']) {
|
||||
bool value => value,
|
||||
num value => value > 0,
|
||||
_ => true,
|
||||
};
|
||||
_logger.logWithLevel(
|
||||
'[saveDeviceSchedulePlan] 结果: ${saved ? '成功' : '未保存'}',
|
||||
shouldLog: true,
|
||||
);
|
||||
return saved;
|
||||
} else {
|
||||
_logger.logWithLevel('[saveDeviceSchedulePlan] 业务失败: code=${data['code']}, msg=${data['msg']}', shouldLog: true);
|
||||
throw Exception(data['msg'] ?? '创建定时计划失败');
|
||||
}
|
||||
} else {
|
||||
throw Exception('HTTP ${response.statusCode}');
|
||||
}
|
||||
} catch (e) {
|
||||
_logger.logWithLevel('[saveDeviceSchedulePlan] 异常: $e', shouldLog: true);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
/// 业务实体 → 后端报文:字段名 / DAY・WEEK・MONTH 枚举字面量 /
|
||||
/// days・dates 条件结构 / 时间格式,全部封在数据层,不外泄到 domain。
|
||||
static Map<String, dynamic> _schedulePlanBody(DeviceSchedulePlanEntity p) {
|
||||
// 下标 = weekday.value - 1(周一~周日)
|
||||
const List<String> weekdayWire = <String>[
|
||||
'MONDAY',
|
||||
'TUESDAY',
|
||||
'WEDNESDAY',
|
||||
'THURSDAY',
|
||||
'FRIDAY',
|
||||
'SATURDAY',
|
||||
'SUNDAY',
|
||||
];
|
||||
String pad(int value) => value.toString().padLeft(2, '0');
|
||||
String dateText(DateTime d) =>
|
||||
'${d.year}-${pad(d.month)}-${pad(d.day)}';
|
||||
|
||||
return <String, dynamic>{
|
||||
'deviceId': p.deviceId,
|
||||
'orgId': p.orgId,
|
||||
'planName': p.planName.trim(),
|
||||
'routeId': p.routeId,
|
||||
'siteId': p.siteId,
|
||||
'deviceTaskPlanRules': <String, dynamic>{
|
||||
'type': switch (p.type) {
|
||||
WorkScheduleType.day => 'DAY',
|
||||
WorkScheduleType.week => 'WEEK',
|
||||
WorkScheduleType.month => 'MONTH',
|
||||
},
|
||||
if (p.type == WorkScheduleType.week)
|
||||
'days': <String>[
|
||||
for (final Weekday w in p.days) weekdayWire[w.value - 1],
|
||||
],
|
||||
if (p.type == WorkScheduleType.month) 'dates': p.dates,
|
||||
'dayTime': '${pad(p.dayHour)}:${pad(p.dayMinute)}:00',
|
||||
},
|
||||
'startTime': '${dateText(p.startDate)} 00:00:00',
|
||||
'finishTime': '${dateText(p.endDate)} 23:59:59',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,11 @@ class DeviceTaskModel extends DeviceTaskEntity {
|
||||
return DeviceTaskModel(
|
||||
id: json['id'] as int,
|
||||
deviceId: json['deviceId'] as String? ?? '',
|
||||
taskStatus: json['taskStaus'] as String? ?? '',
|
||||
taskStatusTranslate: json['taskStausTranslate'] as String? ?? '',
|
||||
taskStatus: (json['taskStaus'] ?? json['taskStatus']) as String? ?? '',
|
||||
taskStatusTranslate:
|
||||
(json['taskStausTranslate'] ?? json['taskStatusTranslate'])
|
||||
as String? ??
|
||||
'',
|
||||
routeId: json['routeId'] as int?,
|
||||
siteId: json['siteId'] as int?,
|
||||
orgId: json['orgId'] as int?,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import '../../../../core/error/failure.dart';
|
||||
import '../../domain/entities/device_schedule_plan_entity.dart';
|
||||
import '../../domain/entities/device_task_entity.dart';
|
||||
import '../../domain/repositories/device_task_repository.dart';
|
||||
import '../datasources/device_task_datasource.dart';
|
||||
@@ -92,4 +93,16 @@ class DeviceTaskRepositoryImpl implements DeviceTaskRepository {
|
||||
return Left(Failure(e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Either<Failure, bool>> saveDeviceSchedulePlan({
|
||||
required DeviceSchedulePlanEntity plan,
|
||||
}) async {
|
||||
try {
|
||||
final result = await datasource.saveDeviceSchedulePlan(plan: plan);
|
||||
return Right(result);
|
||||
} catch (e) {
|
||||
return Left(Failure(e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/// 定时作业计划(设备定时任务)业务实体。
|
||||
///
|
||||
/// 只表达业务概念(设备/路线/周期规则/生效区间),不含任何后端字段名与
|
||||
/// 报文格式;entity → JSON 的组装封在 data 层(DeviceTaskDatasource)。
|
||||
/// 对应接口:POST /iot/deviceTask/save(按天/周/月循环策略)。
|
||||
library;
|
||||
|
||||
/// 循环策略:每天 / 每周指定星期 / 每月指定几号
|
||||
enum WorkScheduleType { day, week, month }
|
||||
|
||||
/// 星期几(domain 自定义,不绑定 intl;value 与 DateTime.weekday 同口径 1-7)
|
||||
enum Weekday { monday, tuesday, wednesday, thursday, friday, saturday, sunday }
|
||||
|
||||
extension WeekdayX on Weekday {
|
||||
/// 1-7,周一=1,与 [DateTime.weekday] 对齐
|
||||
int get value => index + 1;
|
||||
}
|
||||
|
||||
/// 星期选择项(周一~周日),提交时由数据层映射为后端枚举字面量
|
||||
const List<Weekday> kWorkScheduleWeekdays = <Weekday>[
|
||||
Weekday.monday,
|
||||
Weekday.tuesday,
|
||||
Weekday.wednesday,
|
||||
Weekday.thursday,
|
||||
Weekday.friday,
|
||||
Weekday.saturday,
|
||||
Weekday.sunday,
|
||||
];
|
||||
|
||||
/// 一条待创建的定时作业计划。
|
||||
///
|
||||
/// 时间拆成「日期 + 时分」:
|
||||
/// - [startDate] / [endDate]:方案生效区间(仅日期部分有效,
|
||||
/// 提交时格式化为开始日 00:00:00 ~ 结束日 23:59:59)
|
||||
/// - [dayHour] / [dayMinute]:每日执行时刻
|
||||
class DeviceSchedulePlanEntity {
|
||||
const DeviceSchedulePlanEntity({
|
||||
required this.deviceId,
|
||||
required this.orgId,
|
||||
required this.planName,
|
||||
required this.routeId,
|
||||
required this.siteId,
|
||||
required this.type,
|
||||
this.days = const <Weekday>[],
|
||||
this.dates = const <int>[],
|
||||
this.dayHour = 8,
|
||||
this.dayMinute = 0,
|
||||
required this.startDate,
|
||||
required this.endDate,
|
||||
});
|
||||
|
||||
/// 设备 SN(如 MC700-xxx,与任务下发接口同一口径)
|
||||
final String deviceId;
|
||||
|
||||
/// 所属组织 ID(与场站同源,取自 SiteCubit 选中场站的 orgId)
|
||||
final int orgId;
|
||||
|
||||
/// 定时任务方案名称
|
||||
final String planName;
|
||||
|
||||
/// 作业路线 ID(路线库一条作业记录的主键,A 环境 = workRecord.id)
|
||||
final int routeId;
|
||||
|
||||
/// 站点 ID(当前选中场站)
|
||||
final int siteId;
|
||||
|
||||
final WorkScheduleType type;
|
||||
|
||||
/// type=week:选中星期集合(不能为空)
|
||||
final List<Weekday> days;
|
||||
|
||||
/// type=month:每月执行日期集合,取值 1-31(不能为空;小月缺该日则当月跳过)
|
||||
final List<int> dates;
|
||||
|
||||
/// 每日执行时刻
|
||||
final int dayHour;
|
||||
final int dayMinute;
|
||||
|
||||
/// 生效区间(仅日期部分有效)
|
||||
final DateTime startDate;
|
||||
final DateTime endDate;
|
||||
|
||||
/// 提交前的完整校验,返回 null = 通过。
|
||||
///
|
||||
/// 与后端入参校验规则逐条对齐,本地能拦的先拦(省一次失败往返):
|
||||
/// 1. 必填项(设备/名称/路线/场站/组织);
|
||||
/// 2. days / dates 数组非空(按周期类型);
|
||||
/// 3. 结束时间必须晚于开始时间;
|
||||
/// 4. 业务强校验:生效区间内必须存在至少一个满足周期规则、
|
||||
/// 且执行时刻落在区间内的可执行日期;否则后端拒绝保存。
|
||||
String? getValidationError() {
|
||||
if (deviceId.isEmpty) return '请选择执行设备';
|
||||
if (planName.trim().isEmpty) return '请填写方案名称';
|
||||
if (routeId <= 0) return '请选择作业路线';
|
||||
if (siteId <= 0 || orgId <= 0) return '请先在首页选择场站';
|
||||
if (type == WorkScheduleType.week && days.isEmpty) {
|
||||
return '按周执行需至少选择一个星期';
|
||||
}
|
||||
if (type == WorkScheduleType.month && dates.isEmpty) {
|
||||
return '按月执行需至少选择一个日期';
|
||||
}
|
||||
if (dates.any((d) => d < 1 || d > 31)) {
|
||||
return '每月执行日期取值范围为 1-31';
|
||||
}
|
||||
if (dayHour < 0 || dayHour > 23 || dayMinute < 0 || dayMinute > 59) {
|
||||
return '执行时刻不合法';
|
||||
}
|
||||
if (_dayOf(endDate).isBefore(_dayOf(startDate))) {
|
||||
return '结束日期必须晚于开始日期';
|
||||
}
|
||||
if (!hasExecutableTime) {
|
||||
return '生效区间内没有满足周期规则的可执行日期,任务不会触发';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// 业务强校验:逐天扫描 [startDate, endDate],
|
||||
/// 存在「命中周期规则 且 执行时刻落在 [开始日 00:00, 结束日 24:00) 内」的一天即可执行。
|
||||
/// 示例:有效期 11-19 ~ 11-20、week · days=[monday],区间内没有周一 → false。
|
||||
bool get hasExecutableTime {
|
||||
DateTime day = _dayOf(startDate);
|
||||
final DateTime last = _dayOf(endDate);
|
||||
while (!day.isAfter(last)) {
|
||||
if (_matches(day)) {
|
||||
// startTime 固定当天 00:00:00、finishTime 当天 23:59:59,
|
||||
// 任意时刻的执行点在区间内等价于「日期落在 [start, end] 闭区间」
|
||||
return true;
|
||||
}
|
||||
day = day.add(const Duration(days: 1));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _matches(DateTime day) => switch (type) {
|
||||
WorkScheduleType.day => true,
|
||||
WorkScheduleType.week => days.contains(
|
||||
kWorkScheduleWeekdays[day.weekday - 1],
|
||||
),
|
||||
WorkScheduleType.month => dates.contains(day.day),
|
||||
};
|
||||
|
||||
static DateTime _dayOf(DateTime d) => DateTime(d.year, d.month, d.day);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import '../../../../core/error/failure.dart';
|
||||
import '../entities/device_schedule_plan_entity.dart';
|
||||
import '../entities/device_task_entity.dart';
|
||||
|
||||
abstract class DeviceTaskRepository {
|
||||
@@ -36,4 +37,9 @@ abstract class DeviceTaskRepository {
|
||||
required int orgId,
|
||||
required int siteId,
|
||||
});
|
||||
|
||||
/// 创建设备定时任务(定时作业计划,按天/周/月循环)
|
||||
Future<Either<Failure, bool>> saveDeviceSchedulePlan({
|
||||
required DeviceSchedulePlanEntity plan,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -57,6 +57,9 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
|
||||
// 🔥 当前 MQTT 机器状态监听的设备 SN(用于换设备时清空旧缓存)
|
||||
String? _currentListeningSn;
|
||||
|
||||
/// 当前实时快照的设备身份,供入口模式确认使用(只读)。
|
||||
String? get listeningDeviceSn => _currentListeningSn;
|
||||
|
||||
// 🔥 MQTT机器状态收帧计数(用于链路日志)
|
||||
int _mqttVehicleFrameCount = 0;
|
||||
int _mqttLocationFrameCount = 0;
|
||||
@@ -322,8 +325,12 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
|
||||
rightTargetSpeed: host.rightTargetRpm,
|
||||
leftMeasureSpeed: host.leftMeasuredRpm,
|
||||
rightMeasureSpeed: host.rightMeasuredRpm,
|
||||
controlMode:
|
||||
host.controlMode.isNotEmpty ? host.controlMode : base.controlMode,
|
||||
// 严格按后端本帧给的值写:没带 control_mode 就置空(显示「未知」)。
|
||||
// 以前写的是 host.controlMode.isNotEmpty ? ... : base.controlMode,
|
||||
// 导致“后端已经不发控制模式了”界面仍永远停在第一次收到的值上。
|
||||
// 代价:若 host 帧偶发漏带该字段,此栏会在真值与「未知」间跳动;
|
||||
// 现场若出现闪烁,说明 host 帧字段不稳定,应从后端侧解决而非在此兜底。
|
||||
controlMode: host.controlMode,
|
||||
workingArea: host.totalWorkArea.toString(),
|
||||
// 🔥 供全功能模式(pv_control)展示:累计作业里程 + host 已推数据标记
|
||||
totalWorkDistance: host.totalWorkDistance,
|
||||
@@ -486,7 +493,11 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
|
||||
if (_cachedStatus != null && !isClosed) {
|
||||
final gps = _cachedGps ??
|
||||
GPSEntity(_cachedStatus!.latitude, _cachedStatus!.longitude);
|
||||
debugPrint('📤 [节流发射] 电压=${_cachedStatus!.voltage}V 电量=${_cachedStatus!.battery}% 经纬度=(${gps.latitude}, ${gps.longitude}) yaw=${_cachedStatus!.yaw} 控制模式=${_cachedStatus!.controlMode} | ${DateTime.now().toString().substring(11, 19)}');
|
||||
// 控制模式为空串 = 后端从未给过,日志里显式标出来,免得和 0 混看
|
||||
final controlModeLog = _cachedStatus!.controlMode.isEmpty
|
||||
? '--(未收到)'
|
||||
: _cachedStatus!.controlMode;
|
||||
debugPrint('📤 [节流发射] 电压=${_cachedStatus!.voltage}V 电量=${_cachedStatus!.battery}% 经纬度=(${gps.latitude}, ${gps.longitude}) yaw=${_cachedStatus!.yaw} 控制模式=$controlModeLog | ${DateTime.now().toString().substring(11, 19)}');
|
||||
emit(DeviceStatusUpdated(_cachedStatus!, gps));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,13 @@ import 'package:maibu_satabot_v2/core/router/route_paths.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
class DjPage extends StatefulWidget {
|
||||
const DjPage({super.key});
|
||||
/// 从横屏页(如「地图与区域编辑」)push 进来时为 true:
|
||||
/// 退出统一用 pop 回来源页。若用 context.go() 整栈替换,
|
||||
/// 来源页 await push 的 Future 永不完成,横屏恢复不会执行,
|
||||
/// 页面会被锁死在竖屏。首页进入时保持原 go() 行为。
|
||||
final bool exitToPop;
|
||||
|
||||
const DjPage({super.key, this.exitToPop = false});
|
||||
|
||||
@override
|
||||
State<DjPage> createState() => _DjPageState();
|
||||
@@ -41,6 +47,11 @@ class _DjPageState extends State<DjPage> {
|
||||
final page = data["page"];
|
||||
|
||||
if (action == "navigate") {
|
||||
// 编辑器入口:H5 发出任何跳转都视为「场站已选好」,pop 回横屏编辑页
|
||||
if (widget.exitToPop) {
|
||||
if (context.canPop()) context.pop();
|
||||
return;
|
||||
}
|
||||
if (page == "gaode") {
|
||||
_openGaode();
|
||||
}
|
||||
@@ -66,7 +77,12 @@ class _DjPageState extends State<DjPage> {
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
||||
onPressed: () {
|
||||
context.go(RoutePaths.home);
|
||||
// 编辑器入口:pop 回来源页(触发对方 await 完成→恢复横屏)
|
||||
if (widget.exitToPop && context.canPop()) {
|
||||
context.pop();
|
||||
} else {
|
||||
context.go(RoutePaths.home);
|
||||
}
|
||||
},
|
||||
),
|
||||
title: Text(AppLocalizations.of(context).translate('route_planning.title'), style: const TextStyle(color: Colors.white)),
|
||||
|
||||
@@ -20,14 +20,29 @@ class HomeRoutes {
|
||||
static List<RouteBase> get routes => [
|
||||
GoRoute(
|
||||
path: RoutePaths.remoteControl,
|
||||
builder: (context, state) => BlocProvider(
|
||||
// 每次进入该路由,都会创建一个全新的 Cubit 并开启循环
|
||||
create: (context) => sl<RemoteControlCubit>()..startControlLoop(),
|
||||
// 🔥 必须用 .value:RemoteControlCubit 是 GetIt 的 registerLazySingleton
|
||||
// (injection.dart:540),不是本路由创建的。BlocProvider(create:) 的所有权
|
||||
// 语义是“我创建我销毁”,离开路由时它会对这个实例调用 close(),等于把
|
||||
// 全局单例关掉:
|
||||
// · 关掉后 startControlLoop 的 isClosed 守卫直接 return、所有 emit 被忽略,
|
||||
// 旧遥控页与新版 pv_control HUD 一起静默失灵(推杆不动 / 权限不刷新 /
|
||||
// 弹窗不弹),而 LazySingleton 不会重建,只能杀进程恢复;
|
||||
// · 护栏加之前更狠:每个迟到回调都抛 StateError(“Cannot emit new states
|
||||
// after calling close”)。
|
||||
// 下方 DeviceStatusBloc 用的就是 .value(“使用全局单例,确保数据流不中断”),
|
||||
// 遥控保持一致。原来的注释“每次进入都会创建一个全新的 Cubit”是错的。
|
||||
builder: (context, state) => BlocProvider.value(
|
||||
value: sl<RemoteControlCubit>(),
|
||||
child: const RemoteControlPage(),
|
||||
),
|
||||
),
|
||||
GoRoute(path: RoutePaths.routePlan, builder: (context, state) => const RoutePlanPage()),
|
||||
GoRoute(path: RoutePaths.djMap, builder: (context, state) => const DjPage()),
|
||||
// 场站 H5:从横屏「地图与区域编辑」进入时传 extra=true,退出用 pop 回来源页;
|
||||
// 从首页进入保持原来 go() 换栈行为不变。
|
||||
GoRoute(
|
||||
path: RoutePaths.djMap,
|
||||
builder: (context, state) => DjPage(exitToPop: state.extra == true),
|
||||
),
|
||||
GoRoute(path: RoutePaths.productDesc, builder: (context, state) => const ProductPage()),
|
||||
GoRoute(path: RoutePaths.usage, builder: (context, state) => const ManualPage()),
|
||||
GoRoute(
|
||||
|
||||
@@ -19,3 +19,17 @@ enum WorkStatus {
|
||||
working, // 作业中
|
||||
paused, // 暂停中
|
||||
}
|
||||
|
||||
/// 后端 workRecord.routeType(Java 枚举 RouteType):规划类型,保存打点时必填。
|
||||
/// 缺失时后端返回「未选择规划类型」;code 必须与后端枚举 name() 完全一致。
|
||||
/// 新版「地图与区域编辑」与旧版路径规划共用 /iot/workRecord/add,因此共用这一个定义。
|
||||
enum RouteType {
|
||||
mowingTask('MOWING_TASK', '割草任务'),
|
||||
inspectionTask('INSPECTION_TASK', '巡检任务'),
|
||||
// backToRestPoint('BACK_TO_REST_POINT', '返航任务'), // 暂不展示
|
||||
other('OTHER', '其他类型');
|
||||
|
||||
final String code;
|
||||
final String label;
|
||||
const RouteType(this.code, this.label);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/components/control_mode_text.dart';
|
||||
import 'package:maibu_satabot_v2/core/consts/tcp_consts.dart';
|
||||
import 'package:maibu_satabot_v2/core/router/route_paths.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.dart';
|
||||
@@ -286,9 +287,12 @@ class _MachineDetailsPageState extends State<MachineDetailsPage> {
|
||||
|
||||
if (blocState is DeviceStatusUpdated) {
|
||||
debugPrint('✅ [MachineDetails] 有实时数据 - 电压:${blocState.status.voltage}, 电量:${blocState.status.battery}');
|
||||
controlMode = blocState.status.controlMode == '3'
|
||||
? AppLocalizations.of(context).translate('machine_details.remote_mode')
|
||||
: AppLocalizations.of(context).translate('machine_details.local_mode');
|
||||
// 统一映射(与「设备数据监控」同一口径):后端没给控制模式时显示「未知」,
|
||||
// 不能再一律兜成「本地模式」(协议:0=未知 1=本地 2=自主任务 3=远程遥控)
|
||||
controlMode = controlModeDisplayText(
|
||||
AppLocalizations.of(context),
|
||||
blocState.status.controlMode,
|
||||
);
|
||||
voltage = '${blocState.status.voltage}V';
|
||||
battery = '${blocState.status.battery}%';
|
||||
} else {
|
||||
|
||||
@@ -111,6 +111,7 @@ class _MainWrapperState extends State<MainWrapper> {
|
||||
// 作业首页(W01):返回键切回「设备」tab
|
||||
case 'work':
|
||||
return WorkHomePageV2(
|
||||
isActive: enabledItems[_currentIndex].id == tab.id,
|
||||
onBack: () {
|
||||
final int deviceIndex = enabledItems.indexWhere(
|
||||
(item) => item.id == 'device',
|
||||
|
||||
@@ -6,12 +6,15 @@ import 'package:flutter/foundation.dart';
|
||||
@immutable
|
||||
class PvTelemetry {
|
||||
const PvTelemetry({
|
||||
this.deviceName = '光伏巡检机器人',
|
||||
// 设备名占位留空:实际名称由页面注入(见 PvControlPage._resolveTelemetry),
|
||||
// 避免写死中文在英文环境下露出来
|
||||
this.deviceName = '',
|
||||
this.serialNumber = 'PV-RB-001',
|
||||
this.isOnline = true,
|
||||
this.battery,
|
||||
this.isAutoDriving = true,
|
||||
this.taskStatus = '巡检任务进行中',
|
||||
// 默认留空:具体文案由 UI 层按当前语言兜底(见 PvInfoColumn)
|
||||
this.taskStatus = '',
|
||||
this.speed = 0.3,
|
||||
this.mileage,
|
||||
this.networkNormal = true,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'package:maibu_satabot_v2/features/device_control_mode/domain/entities/device_control_mode.dart';
|
||||
import 'package:maibu_satabot_v2/features/device_control_mode/presentation/widgets/control_mode_entry_gate.dart';
|
||||
import 'dart:io';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
@@ -21,6 +23,7 @@ import 'package:maibu_satabot_v2/features/remote_control/presentation/bloc/remot
|
||||
import 'package:maibu_satabot_v2/features/v2/local_camera/presentation/cubit/local_camera_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/usb_camera/data/uvc_camera_service.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/usb_camera/presentation/cubit/usb_camera_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/domain/usecases/search_device_usecase.dart';
|
||||
|
||||
import '../models/pv_telemetry.dart';
|
||||
import '../channel/pv_robot_command_channel.dart';
|
||||
@@ -48,6 +51,7 @@ class PvControlPage extends StatefulWidget {
|
||||
required this.deviceId,
|
||||
this.deviceName,
|
||||
this.initialMode = PvViewMode.normal,
|
||||
this.initialShowJoysticks = true,
|
||||
});
|
||||
|
||||
final String deviceId;
|
||||
@@ -57,6 +61,11 @@ class PvControlPage extends StatefulWidget {
|
||||
/// [PvViewMode.manualControl],进页直接是手动控制 HUD(不再经过大屏)。
|
||||
final PvViewMode initialMode;
|
||||
|
||||
/// 进页时是否显示全屏 HUD 的两侧方向摇杆(默认显示)。
|
||||
/// 从「进入实时视频」那条链路(先看画面再转遥控)进来时传 false,
|
||||
/// 摇杆默认收起,用户在设置里需要时再手动打开。
|
||||
final bool initialShowJoysticks;
|
||||
|
||||
@override
|
||||
State<PvControlPage> createState() => _PvControlPageState();
|
||||
}
|
||||
@@ -75,6 +84,15 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
/// 控制态是否已激活:进入「手动控制」才 activate,退出 / 页面销毁 deactivate。
|
||||
bool _controlActive = false;
|
||||
|
||||
/// deactivate 是否正在进行中(内部含 await 归零全停 + HTTP 释放,约 0.5~1s)。
|
||||
/// 🔥 这段时间里若用户立刻重新点「手动控制」,不能马上 activate:
|
||||
/// 尾部那次 stopControlLoop() 会把刚起来的循环又关掉,HUD 就变成
|
||||
/// “摇杆推了没反应”。故延后到 deactivate 收尾再起循环。
|
||||
bool _deactivating = false;
|
||||
|
||||
/// deactivate 期间收到过重新进入控制态的请求。
|
||||
bool _restartAfterDeactivate = false;
|
||||
|
||||
/// 急停开关态:HUD 急停钮每点一次翻转,经通道下发 updateEmergency。
|
||||
bool _emergencyOn = false;
|
||||
|
||||
@@ -107,12 +125,32 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
|
||||
/// 模拟开关(真实推送未接入前在设置面板手动触发)。
|
||||
bool _simObstacle = false;
|
||||
bool _simReverse = false;
|
||||
|
||||
/// 「倒车影像」:控制手动控制主画面中间那组导向路径 + 黄色/绿色车道线
|
||||
/// (带流动箭头)的显隐,同时决定左下后视卡是否叠倒车引导线。
|
||||
/// 默认开启 = 保持原有视觉;关掉后画面回到干净视频。
|
||||
bool _simReverse = true;
|
||||
|
||||
/// 是否显示手动控制 HUD 的左右两个方向摇杆(设置面板可关掉):
|
||||
/// 关掉后摇杆与回中按钮一起隐藏,底部操作条自动向两侧展开。
|
||||
/// 初始值由入口决定([PvControlPage.initialShowJoysticks])。
|
||||
late bool _showJoysticks = widget.initialShowJoysticks;
|
||||
|
||||
/// 当前控制设备名:优先用页面入参(就是入口点选的那台,带别名),
|
||||
/// 缺失时回退 RemoteControlCubit 的 targetDevice,都没有则显示占位。
|
||||
String _resolveDeviceName(RemoteControlState? remote) {
|
||||
final passed = (widget.deviceName ?? '').trim();
|
||||
if (passed.isNotEmpty) return passed;
|
||||
final target = (remote?.targetDevice?.deviceName ?? '').trim();
|
||||
return target.isNotEmpty
|
||||
? target
|
||||
: AppLocalizations.of(context).translate('pv_control.no_device');
|
||||
}
|
||||
|
||||
/// 实际下发的遥测:真实字段来自全局 [DeviceStatusBloc] 的 host 实时数据
|
||||
/// (电量/巡检里程/设备温度),未收到时置 null 由 UI 显示"未知";
|
||||
/// 开启「模拟障碍物信息」相当于收到机器告警推送,叠加 obstacleAlert。
|
||||
PvTelemetry _resolveTelemetry(DeviceStatusState dsState) {
|
||||
PvTelemetry _resolveTelemetry(DeviceStatusState dsState, String deviceName) {
|
||||
double? battery;
|
||||
double? mileage;
|
||||
double? temp;
|
||||
@@ -135,6 +173,8 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
}
|
||||
}
|
||||
return _telemetry.copyWith(
|
||||
// 设备名用真实选中的设备,不再用 PvTelemetry 里写死的占位名
|
||||
deviceName: deviceName,
|
||||
obstacleAlert: _simObstacle,
|
||||
battery: battery,
|
||||
mileage: mileage,
|
||||
@@ -155,8 +195,7 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
sl<AuthCubit>().enterSafeMode();
|
||||
// 监听「权限交接」:其它端请求控制权时弹确认框,整页生命周期常驻。
|
||||
_initPermissionHandoverListener();
|
||||
// 进页面即建立控制会话:查询权限 + 启动控制循环(等价远程遥控页进页行为)。
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => _startControl());
|
||||
// 控制会话由模式确认完成后的回调建立。
|
||||
}
|
||||
|
||||
/// 本页的视频、地图、遥测都是围绕 `deviceId` 这一台设备,所以进页时确保
|
||||
@@ -219,12 +258,51 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
|
||||
void _onManualControl() {
|
||||
setState(() => _mode = PvViewMode.manualControl);
|
||||
// 🔥 折叠会退出控制态(见 _onCollapseManual),重新进 HUD 必须重新进入:
|
||||
// _startControl 有 _controlActive 幂等保护,首次进页(initState)重复调也不会起两份循环。
|
||||
_startControl();
|
||||
}
|
||||
|
||||
void _onCollapseManual() {
|
||||
// 🔥 折叠 = 退出控制态,不只是一次归零:大屏上没有摇杆,却留着
|
||||
// activate() 起着的 200ms 循环与控制权,既持续向设备发零速帧、又挤占
|
||||
// 同一条 TCP 上的业务指令;而 HUD 被卸载那一瞬,摇杆的 onPanEnd /
|
||||
// Listener.onPointerUp 三重兜底会随 State 一起消失,若另一只手仍按着
|
||||
// 摇杆,轴值就残留在非零 —— 大屏上没东西可归零,相当于“一直走”。
|
||||
// deactivate() 内部顺序已是:解除急停 → await 归零+全停 → 停循环 → 释放权限。
|
||||
// 不弹 toast:折叠是常规视图切换,不是“退出遥控”,每次弹释放提示很噪。
|
||||
_stopControl(notify: false);
|
||||
setState(() => _mode = PvViewMode.normal);
|
||||
}
|
||||
|
||||
/// 一键寻车:视频区 person_search 按钮,直连后端 searchDevice 接口。
|
||||
///
|
||||
/// deviceId 用 widget.deviceId(即设备编码 deviceName,MC700- 开头),
|
||||
/// 不是 getSiteList 的数字主键;下发结果以胶囊 Toast 反馈。
|
||||
Future<void> _onLocate() async {
|
||||
final code = widget.deviceId.trim();
|
||||
final tr = AppLocalizations.of(context);
|
||||
if (code.isEmpty) {
|
||||
CapsuleToast.show(
|
||||
tr.translate('device_list_v2.fr_toast_start_failed'),
|
||||
showCheck: false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
final result = await sl<SearchDeviceUseCase>().execute(deviceCode: code);
|
||||
if (!mounted) return;
|
||||
result.fold(
|
||||
(failure) => CapsuleToast.show(
|
||||
failure.message.isEmpty
|
||||
? tr.translate('device_list_v2.fr_toast_start_failed')
|
||||
: failure.message,
|
||||
showCheck: false,
|
||||
),
|
||||
(_) =>
|
||||
CapsuleToast.show(tr.translate('device_list_v2.fr_toast_start_sent')),
|
||||
);
|
||||
}
|
||||
|
||||
void _onPauseTask() {
|
||||
CapsuleToast.show(
|
||||
AppLocalizations.of(context).translate('pv_control.toast_paused'),
|
||||
@@ -248,10 +326,17 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
/// 进入控制态:查询权限 + 启动控制循环(与远程遥控页生命周期一致)。
|
||||
void _startControl() {
|
||||
if (_controlActive) return;
|
||||
if (_cubit.state.targetDevice == null) {
|
||||
if (_cubit.state.targetDevice?.deviceName != widget.deviceId) {
|
||||
debugPrint('❌ [PV遥控] targetDevice 为空,跳过控制循环与权限查询');
|
||||
return;
|
||||
}
|
||||
// 🔥 上一轮折叠的 deactivate 还在收尾:先记需求,等它结束后再起循环,
|
||||
// 否则会被它尾部的 stopControlLoop() 把新循环一并关掉。
|
||||
if (_deactivating) {
|
||||
_restartAfterDeactivate = true;
|
||||
debugPrint('⚠️ [PV遥控] 退出控制态尚未完成,推迟进入控制态');
|
||||
return;
|
||||
}
|
||||
_controlActive = true;
|
||||
// deactivate 会清除急停态,重新进入从“未急停”开始,与通道保持同步。
|
||||
_emergencyOn = false;
|
||||
@@ -259,13 +344,25 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
}
|
||||
|
||||
/// 退出控制态:归零、停循环、释放权限(通道内部完成,不阻塞 UI)。
|
||||
void _stopControl() {
|
||||
///
|
||||
/// [notify] 是否弹“释放控制权”结果提示:退页(dispose)需要,
|
||||
/// HUD 折叠回大屏属常规视图切换,不打扰。
|
||||
void _stopControl({bool notify = true}) {
|
||||
if (!_controlActive) return;
|
||||
_controlActive = false;
|
||||
_deactivating = true;
|
||||
_restartAfterDeactivate = false;
|
||||
// dispose 不能 await,fire-and-forget;拿到释放结果后弹与远程遥控页一致的提示
|
||||
//(CapsuleToast 走根 Overlay,页面销毁瞬间也能显示);无设备未发起释放则不弹。
|
||||
_channel.deactivate().then((released) {
|
||||
if (released == null || !mounted) return;
|
||||
// 🔥 收尾:先解除“正在退出”标记,若期间用户已重新进入 HUD 就补起一次控制态。
|
||||
_deactivating = false;
|
||||
if (_restartAfterDeactivate) {
|
||||
_restartAfterDeactivate = false;
|
||||
// 页面已销毁(退页与折叠竞态)时绝不能再起循环:那会留下一个无主的控制循环。
|
||||
if (mounted) _startControl();
|
||||
}
|
||||
if (released == null || !mounted || !notify) return;
|
||||
final tr = AppLocalizations.of(context);
|
||||
CapsuleToast.show(
|
||||
released
|
||||
@@ -321,11 +418,10 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
final requestingPlatform =
|
||||
state.requestingPlatform ??
|
||||
tr.translate('pv_control.perm_unknown_platform');
|
||||
final dialogContent =
|
||||
tr
|
||||
.translate('pv_control.perm_request_body')
|
||||
.replaceAll('{platform}', requestingPlatform)
|
||||
.replaceAll('{deviceId}', requestingDeviceId);
|
||||
final dialogContent = tr
|
||||
.translate('pv_control.perm_request_body')
|
||||
.replaceAll('{platform}', requestingPlatform)
|
||||
.replaceAll('{deviceId}', requestingDeviceId);
|
||||
final cubit = _cubit;
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
@@ -451,6 +547,8 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
backgroundColor: Colors.transparent,
|
||||
// 面板内部自带 maxHeight + 滚动,这里放开模态默认高度限制
|
||||
isScrollControlled: true,
|
||||
// 横屏底部有手势条 / 虚拟键:避开安全区,否则最后一行会被压住
|
||||
useSafeArea: true,
|
||||
// 薄遮罩:能看见底下视频与告警/倒车效果的变化
|
||||
barrierColor: Colors.black.withValues(alpha: 0.35),
|
||||
builder: (_) {
|
||||
@@ -470,10 +568,16 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
videoFit: _videoFit,
|
||||
simObstacle: _simObstacle,
|
||||
simReverse: _simReverse,
|
||||
showJoysticks: _showJoysticks,
|
||||
onVideoSourceChanged: (v) => update(() => _videoSource = v),
|
||||
onVideoFitChanged: (v) => update(() => _videoFit = v),
|
||||
onSimObstacleChanged: (v) => update(() => _simObstacle = v),
|
||||
onSimReverseChanged: (v) => update(() => _simReverse = v),
|
||||
// 倒车影像:不靠面板回传的 value 取反(面板是独立 Route,
|
||||
// value 可能是上一帧的旧值,会导致点了“关”实际又传回 true),
|
||||
// 直接按页面当前状态取反,保证每次点击一定翻转。
|
||||
onSimReverseChanged: (_) =>
|
||||
update(() => _simReverse = !_simReverse),
|
||||
onShowJoysticksChanged: (v) => update(() => _showJoysticks = v),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -498,7 +602,9 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
if (!mounted) return;
|
||||
if (path != null) {
|
||||
CapsuleToast.show(
|
||||
AppLocalizations.of(context).translate('pv_control.toast_screenshot_saved'),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('pv_control.toast_screenshot_saved'),
|
||||
);
|
||||
}
|
||||
// 截图后弹出预览
|
||||
@@ -567,7 +673,16 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget build(BuildContext context) => ControlModeEntryGate(
|
||||
key: ValueKey('remote-mode/${widget.deviceId}'),
|
||||
deviceId: widget.deviceId,
|
||||
deviceName: widget.deviceName,
|
||||
target: ControlModeTarget.remote,
|
||||
onReady: _startControl,
|
||||
child: _buildPage(context),
|
||||
);
|
||||
|
||||
Widget _buildPage(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: PvColors.bgDeepest,
|
||||
body: DecoratedBox(
|
||||
@@ -578,23 +693,33 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
left: false,
|
||||
right: false,
|
||||
child: _wrapVideoProvider(
|
||||
BlocBuilder<DeviceStatusBloc, DeviceStatusState>(
|
||||
builder: (context, dsState) {
|
||||
final telemetry = _resolveTelemetry(dsState);
|
||||
return _mode == PvViewMode.manualControl
|
||||
? PvManualControlView(
|
||||
streamUrl: _streamUrl,
|
||||
telemetry: telemetry,
|
||||
onCollapse: _onCollapseManual,
|
||||
onEmergencyStop: _onEmergencyStop,
|
||||
videoSource: _videoSource,
|
||||
videoFit: _videoFit,
|
||||
simReverse: _simReverse,
|
||||
deviceSn: widget.deviceId,
|
||||
onSettings: _openSettings,
|
||||
channel: _channel,
|
||||
)
|
||||
: _buildNormalLayout(telemetry);
|
||||
StreamBuilder<RemoteControlState>(
|
||||
initialData: _cubit.state,
|
||||
stream: _cubit.stream,
|
||||
builder: (context, remoteSnap) {
|
||||
// 当前选中的设备名(顶栏 / 信息卡 / HUD 同源)
|
||||
final deviceName = _resolveDeviceName(remoteSnap.data);
|
||||
return BlocBuilder<DeviceStatusBloc, DeviceStatusState>(
|
||||
builder: (context, dsState) {
|
||||
final telemetry = _resolveTelemetry(dsState, deviceName);
|
||||
return _mode == PvViewMode.manualControl
|
||||
? PvManualControlView(
|
||||
streamUrl: _streamUrl,
|
||||
telemetry: telemetry,
|
||||
onCollapse: _onCollapseManual,
|
||||
onEmergencyStop: _onEmergencyStop,
|
||||
videoSource: _videoSource,
|
||||
videoFit: _videoFit,
|
||||
simReverse: _simReverse,
|
||||
showJoysticks: _showJoysticks,
|
||||
deviceSn: widget.deviceId,
|
||||
deviceName: deviceName,
|
||||
onSettings: _openSettings,
|
||||
channel: _channel,
|
||||
)
|
||||
: _buildNormalLayout(telemetry, deviceName);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -603,7 +728,7 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNormalLayout(PvTelemetry telemetry) {
|
||||
Widget _buildNormalLayout(PvTelemetry telemetry, String deviceName) {
|
||||
// ===== 三行高度比例:顶部导航 : 第一行(视频+右列) : 第二行(控制栏) =====
|
||||
// 三行高度比例:顶部导航 : 第一行 : 第二行。Expanded 的 flex 只能是整数,
|
||||
// 这里写成 2 : 14 : 6(即 1 : 7 : 3)。第二行比 2.5 份再多一点,
|
||||
@@ -618,6 +743,7 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
Expanded(
|
||||
flex: navFlex,
|
||||
child: _PvTopNav(
|
||||
deviceName: deviceName,
|
||||
onBack: () => Navigator.of(context).pop(),
|
||||
onSettings: _openSettings,
|
||||
),
|
||||
@@ -646,6 +772,7 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
telemetry: telemetry,
|
||||
onScreenshot: _onScreenshot,
|
||||
onFullscreen: _onManualControl,
|
||||
onLocate: _onLocate,
|
||||
videoSource: _videoSource,
|
||||
videoFit: _videoFit,
|
||||
),
|
||||
@@ -687,7 +814,14 @@ class _PvControlPageState extends State<PvControlPage> {
|
||||
|
||||
/// 顶部导航栏:左侧返回、中间标题/副标题、右侧设置与更多
|
||||
class _PvTopNav extends StatelessWidget {
|
||||
const _PvTopNav({required this.onBack, required this.onSettings});
|
||||
const _PvTopNav({
|
||||
required this.deviceName,
|
||||
required this.onBack,
|
||||
required this.onSettings,
|
||||
});
|
||||
|
||||
/// 当前选中的设备名(副标题位置展示)
|
||||
final String deviceName;
|
||||
final VoidCallback onBack;
|
||||
final VoidCallback onSettings;
|
||||
|
||||
@@ -719,9 +853,10 @@ class _PvTopNav extends StatelessWidget {
|
||||
style: PvType.navTitle,
|
||||
),
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('pv_control.pv_robot_remote_control'),
|
||||
// 当前控制的是哪台设备(原先这里是写死的“光伏电站机器人远程遥控”)
|
||||
deviceName,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: PvType.navSubtitle,
|
||||
),
|
||||
],
|
||||
@@ -779,12 +914,9 @@ class _ScreenshotPreviewDialog extends StatelessWidget {
|
||||
if (path != null) ...[
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('pv_control.screenshot_saved_path').replaceAll(
|
||||
'{path}',
|
||||
path!,
|
||||
),
|
||||
AppLocalizations.of(context)
|
||||
.translate('pv_control.screenshot_saved_path')
|
||||
.replaceAll('{path}', path!),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: PvType.label,
|
||||
@@ -797,9 +929,7 @@ class _ScreenshotPreviewDialog extends StatelessWidget {
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('pv_control.close'),
|
||||
AppLocalizations.of(context).translate('pv_control.close'),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -253,7 +253,12 @@ class _DriveModeCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 1),
|
||||
Text(
|
||||
telemetry.taskStatus,
|
||||
// 遥测未带任务状态时,UI 层用当前语言兜底
|
||||
telemetry.taskStatus.isEmpty
|
||||
? AppLocalizations.of(
|
||||
context,
|
||||
).translate('pv_control.task_patrol_running')
|
||||
: telemetry.taskStatus,
|
||||
style: const TextStyle(
|
||||
color: PvColors.textSecondary,
|
||||
fontSize: 10,
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
import 'package:maibu_satabot_v2/components/control_mode_text.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/remote_control/domain/entities/reverse_camera_data.dart';
|
||||
@@ -64,7 +65,9 @@ class PvManualControlView extends StatefulWidget {
|
||||
this.videoSource = PvVideoSource.webrtc,
|
||||
this.videoFit = PvVideoFit.contain,
|
||||
this.simReverse = false,
|
||||
this.showJoysticks = true,
|
||||
this.deviceSn = '',
|
||||
this.deviceName = '',
|
||||
this.onSettings,
|
||||
this.channel,
|
||||
});
|
||||
@@ -81,12 +84,20 @@ class PvManualControlView extends StatefulWidget {
|
||||
/// 视频展示方式(设置面板可改):contain 完整显示 / cover 等比铺满(裁边)。
|
||||
final PvVideoFit videoFit;
|
||||
|
||||
/// 倒车影像模拟开关(设置面板控制):开启后左栏后视卡叠加倒车引导线。
|
||||
/// 「倒车影像」开关(设置面板控制):控制**主画面中间那组外黄内绿的车道线
|
||||
/// 与流动导向箭头**([_buildArOverlay])的显隐,不控制左下角后视卡。
|
||||
final bool simReverse;
|
||||
|
||||
/// 是否显示左右两个方向摇杆(设置面板控制):关闭后摇杆与回中按钮一起隐藏,
|
||||
/// 底部操作条自动向两侧摊开,把画面完整让给视频。
|
||||
final bool showJoysticks;
|
||||
|
||||
/// 设备 SN:HUD 地图按它过滤后端推送的规划路线(订阅切换由页面层负责)。
|
||||
final String deviceSn;
|
||||
|
||||
/// 当前选中的设备名(顶栏展示,看清控制的是哪台设备)
|
||||
final String deviceName;
|
||||
|
||||
/// 顶栏「设置」按钮回调(弹出设置面板)。
|
||||
final VoidCallback? onSettings;
|
||||
|
||||
@@ -163,6 +174,13 @@ class _PvManualControlViewState extends State<PvManualControlView>
|
||||
Offset? _leftPipPos;
|
||||
Offset? _rightPipPos;
|
||||
|
||||
/// 上一次真正下发出去的双轴值:与旧版摇杆的 `_lastSentY` / `_lastX` 同一意图,
|
||||
/// 值没变化就不重发。摇杆每移动一个 pointer 事件就回调一次,不去重会让
|
||||
/// updateOriginX/Y 里的 emit 高频重建整棵 HUD(本页挂的是 StreamBuilder,
|
||||
/// 没有旧版 BlocBuilder buildWhen 那层隔离,只能从源头少发)。
|
||||
int _lastDriveY = 0;
|
||||
int _lastDriveX = 0;
|
||||
|
||||
/// 折叠动画时长与曲线(两侧共用,保证节奏一致)。
|
||||
static const Duration _foldDur = Duration(milliseconds: 280);
|
||||
static const Curve _foldCurve = Curves.easeInOutCubic;
|
||||
@@ -195,6 +213,20 @@ class _PvManualControlViewState extends State<PvManualControlView>
|
||||
return '${two(n.hour)}:${two(n.minute)}:${two(n.second)}';
|
||||
}
|
||||
|
||||
/// 摇杆被关掉的那一帧立刻停车:隐藏只是不画了,手指原来的按压/下发的
|
||||
/// 方向指令不会自动停,必须显式发一次全停(同时把倒车引导线回正)。
|
||||
@override
|
||||
void didUpdateWidget(covariant PvManualControlView oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.showJoysticks && !widget.showJoysticks) {
|
||||
// 归零后清掉去重基准:否则下次推到同一个值会被当成“没变化”吞掉。
|
||||
_lastDriveY = 0;
|
||||
_lastDriveX = 0;
|
||||
unawaited(widget.channel?.stopAllMovement());
|
||||
_steerDeg.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// 定位质量枚举→文案(与设备监控弹窗/蓝牙协议同一套 fix_status 语义)。
|
||||
static String _qualText(int? q) => switch (q) {
|
||||
null => 'pv_control.unknown',
|
||||
@@ -209,12 +241,11 @@ class _PvManualControlViewState extends State<PvManualControlView>
|
||||
_ => 'pv_control.unknown',
|
||||
};
|
||||
|
||||
/// 控制模式→文案(与“设备数据监控” _getControlModeKey 同口径:3=远程,其余=本地)。
|
||||
/// 控制模式→文案 key(统一走 lib/components/control_mode_text.dart)。
|
||||
/// 此处原本已经能分辨「空 = 未知」,但数据层把「没给」的默认值写成了 '0',
|
||||
/// 于是它永远拿不到空串;现在 0~4 按协议展开,非协议值一律未知。
|
||||
static String _controlModeText(String? mode) {
|
||||
if (mode == null || mode.isEmpty) return 'pv_control.unknown';
|
||||
return int.tryParse(mode.trim()) == 3
|
||||
? 'pv_control.mode_remote'
|
||||
: 'pv_control.mode_local';
|
||||
return controlModeKey(mode) ?? 'pv_control.unknown';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -317,15 +348,18 @@ class _PvManualControlViewState extends State<PvManualControlView>
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
// 导向路径 + 车道线(箭头随 _flow 递进流动;整条脊柱随右摇杆转向弯曲)
|
||||
ValueListenableBuilder<double>(
|
||||
valueListenable: _steerDeg,
|
||||
builder: (context, deg, _) => AnimatedBuilder(
|
||||
animation: _flow,
|
||||
builder: (context, _) => CustomPaint(
|
||||
painter: _PvArPainter(progress: _flow.value, steering: deg),
|
||||
// 由设置面板「倒车影像」开关控制:关掉后主画面中间这组黄色/绿色
|
||||
// 引导线与流动箭头一起隐藏,画面回到干净的视频。
|
||||
if (widget.simReverse)
|
||||
ValueListenableBuilder<double>(
|
||||
valueListenable: _steerDeg,
|
||||
builder: (context, deg, _) => AnimatedBuilder(
|
||||
animation: _flow,
|
||||
builder: (context, _) => CustomPaint(
|
||||
painter: _PvArPainter(progress: _flow.value, steering: deg),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 障碍物告警成套效果:收到机器推送(或设置面板模拟开启)时,
|
||||
// 屏幕泛红呼吸 + 障碍框×2 + 预警横幅**同时**出现,同一 obstacleAlert 驱动。
|
||||
if (widget.telemetry.obstacleAlert) ...[
|
||||
@@ -560,6 +594,22 @@ class _PvManualControlViewState extends State<PvManualControlView>
|
||||
18,
|
||||
).copyWith(color: PvHudColors.textPrimary),
|
||||
),
|
||||
if (widget.deviceName.isNotEmpty) ...[
|
||||
SizedBox(width: d(8)),
|
||||
// 当前控制设备名:只展示不参与操作,过长省略不挤占其他胶囊
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: d(160)),
|
||||
child: Text(
|
||||
widget.deviceName,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: s(
|
||||
PvHudType.value,
|
||||
12,
|
||||
).copyWith(color: PvHudColors.textSecondary),
|
||||
),
|
||||
),
|
||||
],
|
||||
SizedBox(width: d(8)),
|
||||
_onlineBadge(),
|
||||
SizedBox(width: d(8)),
|
||||
@@ -1094,29 +1144,29 @@ class _PvManualControlViewState extends State<PvManualControlView>
|
||||
}
|
||||
|
||||
/// 左下后视图卡:标题与全屏按钮都浮在画面之上;高度由左栏列表项给定。
|
||||
///
|
||||
/// 注意:设置面板里的「倒车影像」开关**不控制这张卡**,它管的是主画面中间
|
||||
/// 那组黄/绿车道线与流动箭头(见 [_buildArOverlay])。后视卡保持稳定的
|
||||
/// 后视形态常驻,避免一次点击同时改两处、看起来像“开关失灵”。
|
||||
Widget _rearCard() {
|
||||
final tr = AppLocalizations.of(context);
|
||||
return PvRearViewCard(
|
||||
scale: _sc,
|
||||
// 倒车影像:设置面板开启后叠加引导线;弯曲实时跟右摇杆转向。
|
||||
// 后视引导线弯曲实时跟右摇杆转向。
|
||||
// 未来接入下位机后,ReverseCameraData 的 gear/steeringAngle/
|
||||
// rearDistanceCm 全部改成读回传数据即可,本组件不改。
|
||||
title: widget.simReverse
|
||||
? tr.translate('pv_control.reverse_camera')
|
||||
: tr.translate('pv_control.rear_view'),
|
||||
overlay: widget.simReverse
|
||||
? ValueListenableBuilder<double>(
|
||||
valueListenable: _steerDeg,
|
||||
builder: (context, deg, _) => ReverseGuideOverlay(
|
||||
data: ReverseCameraData(
|
||||
gear: 2,
|
||||
steeringAngle: deg,
|
||||
speed: 0.4,
|
||||
rearDistanceCm: 120,
|
||||
),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
title: tr.translate('pv_control.reverse_camera'),
|
||||
overlay: ValueListenableBuilder<double>(
|
||||
valueListenable: _steerDeg,
|
||||
builder: (context, deg, _) => ReverseGuideOverlay(
|
||||
data: ReverseCameraData(
|
||||
gear: 2,
|
||||
steeringAngle: deg,
|
||||
speed: 0.4,
|
||||
rearDistanceCm: 120,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1617,6 +1667,8 @@ class _PvManualControlViewState extends State<PvManualControlView>
|
||||
}
|
||||
|
||||
Widget _buildJoysticks(double w, double h) {
|
||||
// 设置里关掉「遥控摇杆」:整块(含回中按钮)不渲染,画面全留给视频
|
||||
if (!widget.showJoysticks) return const SizedBox.shrink();
|
||||
final radius = _joyRadius(w, h);
|
||||
final size = radius * 2;
|
||||
// 折叠时摇杆向外侧滑动,展开时向内收,避免与两侧面板挤压
|
||||
@@ -1633,8 +1685,16 @@ class _PvManualControlViewState extends State<PvManualControlView>
|
||||
radius: radius,
|
||||
axisHint: AxisHint.forwardBackward,
|
||||
skin: _joystickSkin(),
|
||||
onValueChanged: (v) => widget.channel?.sendDriveY(v.y.toInt()),
|
||||
onPanEnd: () async => widget.channel?.stopAllMovement(),
|
||||
onValueChanged: (v) {
|
||||
final int y = v.y.toInt();
|
||||
if (y == _lastDriveY) return;
|
||||
_lastDriveY = y;
|
||||
widget.channel?.sendDriveY(y);
|
||||
},
|
||||
onPanEnd: () async {
|
||||
_lastDriveY = 0;
|
||||
await widget.channel?.stopAllMovement();
|
||||
},
|
||||
),
|
||||
),
|
||||
AnimatedPositioned(
|
||||
@@ -1648,11 +1708,14 @@ class _PvManualControlViewState extends State<PvManualControlView>
|
||||
skin: _joystickSkin(),
|
||||
onValueChanged: (v) {
|
||||
final int x = v.x.toInt().abs() < 1 ? 0 : v.x.toInt();
|
||||
if (x == _lastDriveX) return;
|
||||
_lastDriveX = x;
|
||||
widget.channel?.sendDriveX(x);
|
||||
// 右摇杆(-100~100) → 转向角(-45°~45°),驱动引导线左右弯曲
|
||||
_steerDeg.value = (x * 0.45).clamp(-45.0, 45.0);
|
||||
},
|
||||
onPanEnd: () async {
|
||||
_lastDriveX = 0;
|
||||
_steerDeg.value = 0; // 松手回正,引导线恢复直线
|
||||
await widget.channel?.stopAllMovement();
|
||||
},
|
||||
@@ -1665,7 +1728,12 @@ class _PvManualControlViewState extends State<PvManualControlView>
|
||||
left: leftJL + size + d(6),
|
||||
bottom: d(64),
|
||||
child: GestureDetector(
|
||||
onTap: () => widget.channel?.stopAllMovement(),
|
||||
onTap: () {
|
||||
// 回中同样要清掉去重基准:不然摇杆球停在原处再推相同值会被吞掉。
|
||||
_lastDriveY = 0;
|
||||
_lastDriveX = 0;
|
||||
widget.channel?.stopAllMovement();
|
||||
},
|
||||
child: Container(
|
||||
width: d(40),
|
||||
height: d(40),
|
||||
@@ -1689,13 +1757,15 @@ class _PvManualControlViewState extends State<PvManualControlView>
|
||||
final size = radius * 2;
|
||||
final leftJL = _leftCollapsed ? d(24) : w * 0.22;
|
||||
final rightJR = _rightCollapsed ? d(24) : w * 0.16;
|
||||
// 摇杆隐藏后不再需要给两侧让位:底部条直接向两侧摊开,重心回到屏幕中心
|
||||
final showJoy = widget.showJoysticks;
|
||||
return AnimatedPositioned(
|
||||
duration: _foldDur,
|
||||
curve: _foldCurve,
|
||||
bottom: d(14),
|
||||
// 在两个摇杆内侧之间动态居中:折叠腾出空间后自动放宽、回正
|
||||
left: leftJL + size + d(8),
|
||||
right: rightJR + size + d(8),
|
||||
left: showJoy ? leftJL + size + d(8) : d(12),
|
||||
right: showJoy ? rightJR + size + d(8) : d(12),
|
||||
child: Center(
|
||||
// 窄屏(手机横屏)两摇杆之间的空间不够时整体等比缩小,不让四个按钮溢出
|
||||
child: FittedBox(
|
||||
|
||||
@@ -9,12 +9,13 @@ import '../theme/pv_hud_theme.dart';
|
||||
|
||||
/// 页面设置面板(底部弹出,遮罩半透明可透视下方视频,边调边看效果)。
|
||||
///
|
||||
/// 纯展示 + 回调:所有设置状态由 PvControlPage 持有。当前四项:
|
||||
/// 纯展示 + 回调:所有设置状态由 PvControlPage 持有。当前五项:
|
||||
/// - 视频源:以太网 RTSP / HDMI(USB 采集卡) / WebRTC,切换即重建对应链路 cubit;
|
||||
/// - 视频展示:完整显示(不裁画面、可能留黑边)/ 铺满屏幕(无黑边、裁掉边缘);
|
||||
/// - 模拟障碍物信息:真实推送未接入前手动触发,开启 = 相当于收到机器告警推送,
|
||||
/// 预警横幅 + AR 障碍框 + 屏幕四周泛红**同时**显示;
|
||||
/// - 倒车影像:开启后左栏后视卡叠加倒车引导线效果(模拟倒车挡)。
|
||||
/// - 倒车影像:开启后左栏后视卡叠加倒车引导线效果(模拟倒车挡);
|
||||
/// - 遥控摇杆(仅手动控制 HUD 显示):关闭后隐藏左右两个方向摇杆与回中按钮。
|
||||
///
|
||||
/// 皮肤两套(由 [light] 选择):普通态大屏沿用原深蓝面板;手动控制全屏视图
|
||||
/// (HUD)用近白玻璃卡,与其上的顶栏 / 侧栏 / 底部条保持同一视觉体系。
|
||||
@@ -25,10 +26,12 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
required this.videoFit,
|
||||
required this.simObstacle,
|
||||
required this.simReverse,
|
||||
required this.showJoysticks,
|
||||
required this.onVideoSourceChanged,
|
||||
required this.onVideoFitChanged,
|
||||
required this.onSimObstacleChanged,
|
||||
required this.onSimReverseChanged,
|
||||
required this.onShowJoysticksChanged,
|
||||
this.light = false,
|
||||
});
|
||||
|
||||
@@ -36,10 +39,15 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
final PvVideoFit videoFit;
|
||||
final bool simObstacle;
|
||||
final bool simReverse;
|
||||
|
||||
/// 是否显示左右两个方向摇杆(仅手动控制 HUD 有摇杆,设置面板可关掉)。
|
||||
final bool showJoysticks;
|
||||
|
||||
final ValueChanged<PvVideoSource> onVideoSourceChanged;
|
||||
final ValueChanged<PvVideoFit> onVideoFitChanged;
|
||||
final ValueChanged<bool> onSimObstacleChanged;
|
||||
final ValueChanged<bool> onSimReverseChanged;
|
||||
final ValueChanged<bool> onShowJoysticksChanged;
|
||||
|
||||
/// 是否套用 HUD 浅色玻璃皮肤(默认 false = 普通态大屏的深色皮肤,与改造前一致)。
|
||||
final bool light;
|
||||
@@ -65,14 +73,16 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
final skin = _skin;
|
||||
// 横屏可用高度有限:最大高度限幅 + 可滚动防底部裁切;
|
||||
// 视频源行用 Wrap,窄屏 / 大字体下药丸自动换行不溢出。
|
||||
final maxH = MediaQuery.sizeOf(context).height * 0.72;
|
||||
// 限幅放宽到 0.86:多一行开关后旧值会把最后一行压到手势条下面。
|
||||
final maxH = MediaQuery.sizeOf(context).height * 0.86;
|
||||
return ConstrainedBox(
|
||||
constraints: BoxConstraints(maxHeight: maxH),
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(18, 0, 18, 12),
|
||||
// 底部留白加大:面板整体往上抬,不贴着屏幕底边
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 18),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(14, 4, 10, 8),
|
||||
padding: const EdgeInsets.fromLTRB(12, 2, 8, 6),
|
||||
decoration: BoxDecoration(
|
||||
color: skin.panel,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
@@ -83,11 +93,11 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 标题行 + 关闭
|
||||
// 标题行 + 关闭(比原尺寸小一号,给下面的开关行腾高度)
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.settings_outlined, color: skin.accent, size: 18),
|
||||
const SizedBox(width: 8),
|
||||
Icon(Icons.settings_outlined, color: skin.accent, size: 16),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
tr.translate('pv_control.nav_settings'),
|
||||
style: PvType.cardTitle.copyWith(
|
||||
@@ -99,19 +109,19 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: skin.textSecondary,
|
||||
size: 20,
|
||||
size: 18,
|
||||
),
|
||||
visualDensity: VisualDensity.compact,
|
||||
padding: EdgeInsets.zero,
|
||||
constraints:
|
||||
const BoxConstraints(minWidth: 32, minHeight: 32),
|
||||
const BoxConstraints(minWidth: 28, minHeight: 28),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
],
|
||||
),
|
||||
// 视频源(Wrap:空间不够自动换第二行)
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
spacing: 6,
|
||||
runSpacing: 2,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
@@ -128,9 +138,9 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
// 视频展示(适配方式)+ 一句取舍说明
|
||||
const SizedBox(height: 6),
|
||||
const SizedBox(height: 4),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
spacing: 6,
|
||||
runSpacing: 2,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
@@ -152,7 +162,7 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
const SizedBox(height: 2),
|
||||
_switchTile(
|
||||
icon: Icons.warning_amber_rounded,
|
||||
iconColor: simObstacle ? skin.danger : skin.textTertiary,
|
||||
@@ -169,6 +179,17 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
value: simReverse,
|
||||
onChanged: onSimReverseChanged,
|
||||
),
|
||||
// 摇杆开关:新版远程遥控的设置面板里始终可见。
|
||||
// 大屏页本身没有摇杆,这个开关预设的是「全屏手动控制」里的显示与否,
|
||||
// 进 HUD 后立即生效(淡出淡入不需要重启页面)。
|
||||
_switchTile(
|
||||
icon: Icons.gamepad_outlined,
|
||||
iconColor: showJoysticks ? skin.accent : skin.textTertiary,
|
||||
title: tr.translate('pv_control.set_show_joysticks'),
|
||||
subtitle: tr.translate('pv_control.set_show_joysticks_sub'),
|
||||
value: showJoysticks,
|
||||
onChanged: onShowJoysticksChanged,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -190,10 +211,10 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 180),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: selected ? skin.accentSoft : skin.inner,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: selected ? skin.accent : skin.border,
|
||||
),
|
||||
@@ -222,11 +243,11 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
return InkWell(
|
||||
onTap: () => onChanged(!value),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
padding: const EdgeInsets.symmetric(vertical: 2),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, size: 20, color: iconColor),
|
||||
const SizedBox(width: 10),
|
||||
Icon(icon, size: 18, color: iconColor),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -245,11 +266,13 @@ class PvSettingsSheet extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
// Switch 自身禁用手势,统一走整行 onTap,避免两套状态
|
||||
// Switch 自身禁用手势,统一走整行 onTap,避免两套状态;
|
||||
// shrinkWrap 去掉默认 48dp 点按区,视觉上跟着整体缩一号
|
||||
IgnorePointer(
|
||||
child: Switch(
|
||||
value: value,
|
||||
onChanged: (_) {},
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
activeThumbColor: skin.switchActiveThumb,
|
||||
activeTrackColor: skin.switchActiveTrack,
|
||||
inactiveThumbColor: skin.switchInactiveThumb,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/remote_control/presentation/widgets/webrtc/webrtc_local_player.dart';
|
||||
|
||||
import '../models/pv_telemetry.dart';
|
||||
@@ -64,14 +65,14 @@ class PvVideoArea extends StatelessWidget {
|
||||
),
|
||||
|
||||
// ② 顶部左侧:实时视频 + 分辨率/帧率
|
||||
Positioned(left: 14, top: 12, child: _buildTopLeftBadge()),
|
||||
Positioned(left: 14, top: 12, child: _buildTopLeftBadge(context)),
|
||||
|
||||
// ③ 顶部中间:障碍物预警
|
||||
if (telemetry.obstacleAlert)
|
||||
Positioned(left: 0, right: 0, top: 10, child: _buildObstacleBanner()),
|
||||
|
||||
// ④ 顶部右侧:网络状态
|
||||
Positioned(right: 14, top: 12, child: _buildNetworkBadge()),
|
||||
Positioned(right: 14, top: 12, child: _buildNetworkBadge(context)),
|
||||
|
||||
// ⑤ 右侧工具按钮列
|
||||
if (showSideTools)
|
||||
@@ -112,7 +113,7 @@ class PvVideoArea extends StatelessWidget {
|
||||
return _VideoPlaceholder();
|
||||
}
|
||||
|
||||
Widget _buildTopLeftBadge() {
|
||||
Widget _buildTopLeftBadge(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -120,9 +121,11 @@ class PvVideoArea extends StatelessWidget {
|
||||
children: [
|
||||
const Icon(Icons.circle, size: 8, color: PvColors.danger),
|
||||
const SizedBox(width: 5),
|
||||
const Text(
|
||||
'实时视频',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('pv_control.realtime_video'),
|
||||
style: const TextStyle(
|
||||
color: PvColors.textPrimary,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
@@ -146,8 +149,9 @@ class PvVideoArea extends StatelessWidget {
|
||||
|
||||
Widget _buildObstacleBanner() => const _ObstacleBannerPill();
|
||||
|
||||
Widget _buildNetworkBadge() {
|
||||
Widget _buildNetworkBadge(BuildContext context) {
|
||||
final ok = telemetry.networkNormal;
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
@@ -163,7 +167,9 @@ class PvVideoArea extends StatelessWidget {
|
||||
Icon(Icons.wifi, size: 14, color: ok ? PvColors.online : PvColors.warning),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
ok ? '网络良好' : '网络异常',
|
||||
ok
|
||||
? l10n.translate('pv_control.network_good')
|
||||
: l10n.translate('pv_control.network_bad'),
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -202,13 +208,18 @@ class _VideoPlaceholder extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Colors.black87,
|
||||
child: const Center(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.videocam_off, size: 48, color: Colors.white38),
|
||||
SizedBox(height: 8),
|
||||
Text('视频未加载', style: TextStyle(color: Colors.white54, fontSize: 12)),
|
||||
const Icon(Icons.videocam_off, size: 48, color: Colors.white38),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('pv_control.video_not_loaded'),
|
||||
style: const TextStyle(color: Colors.white54, fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -276,9 +287,11 @@ class _ObstacleBannerPillState extends State<_ObstacleBannerPill>
|
||||
const SizedBox(width: 7),
|
||||
const Icon(Icons.warning_rounded, color: Colors.white, size: 16),
|
||||
const SizedBox(width: 5),
|
||||
const Text(
|
||||
'障碍物预警',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('pv_control.obstacle_alert'),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w800,
|
||||
|
||||
@@ -6,16 +6,19 @@ import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/core/logging/work_trace_diagnostics.dart';
|
||||
import 'package:maibu_satabot_v2/core/network/mqtt/domain/entities/route_status_entity.dart';
|
||||
import 'package:maibu_satabot_v2/core/network/mqtt/domain/repositories/mower_realtime_repository.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/presentation/bloc/device_status_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/presentation/bloc/device_status_state.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/map/HeadingPointer.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/map/geoserver_suzhou_layer.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/map/app_base_map_layer.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/site/presentation/cubit/site_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
|
||||
import '../theme/pv_colors.dart';
|
||||
import '../models/work_trace_recorder.dart';
|
||||
|
||||
/// HUD 作业地图:与「路径规划」同源、同图层、同样式的**只读**实时地图。
|
||||
///
|
||||
@@ -50,11 +53,22 @@ class PvWorkMap extends StatefulWidget {
|
||||
this.draftCompleted = false,
|
||||
this.draftObstacle = false,
|
||||
this.draftCrosshair = false,
|
||||
this.returnPoints = const <LatLng>[],
|
||||
this.followDevice = true,
|
||||
this.recenterSignal = 0,
|
||||
this.clearTraceSignal = 0,
|
||||
this.onCenterChanged,
|
||||
this.onDevicePosition,
|
||||
this.recordLocationTrace = true,
|
||||
this.workTrace,
|
||||
this.taskTrace,
|
||||
this.expectedTaskId,
|
||||
this.traceDiagnosticsEnabled = false,
|
||||
this.showDevice = true,
|
||||
this.extraMapLayers = const <Widget>[],
|
||||
this.focusPoints = const <LatLng>[],
|
||||
this.focusSignal = 0,
|
||||
this.focusPadding = const EdgeInsets.all(40),
|
||||
});
|
||||
|
||||
/// 设备 SN:用于过滤路线推送(deviceId 不匹配的消息直接丢弃)。
|
||||
@@ -115,6 +129,12 @@ class PvWorkMap extends StatefulWidget {
|
||||
/// 是否准星打点模式:画「中心 → 末点」蓝色连线、距离文字、草稿多边形。
|
||||
final bool draftCrosshair;
|
||||
|
||||
// ===== 一键返航图层(独立于圈地草稿层,默认空=不绘制)=====
|
||||
|
||||
/// 一键返航点:紫色虚线串联 + 紫色编号徽标(首点显示「H」)。
|
||||
/// 与作业区橙色打点、禁行区红色框配色区分,互不影响。
|
||||
final List<LatLng> returnPoints;
|
||||
|
||||
/// 是否让地图随设备位置自动居中。区域编辑时传 false:
|
||||
/// 否则每次定位推送都会把地图挪走,正在打的位置就跑了。
|
||||
final bool followDevice;
|
||||
@@ -133,18 +153,107 @@ class PvWorkMap extends StatefulWidget {
|
||||
/// 设备实时位置变化(无效/清空时回调 null),供「设备位置打点」取当前坐标。
|
||||
final ValueChanged<LatLng?>? onDevicePosition;
|
||||
|
||||
/// 普通地图的定位轨迹;作业中心的组合轨迹由 taskTrace 独立控制。
|
||||
final bool recordLocationTrace;
|
||||
final List<LatLng>? workTrace;
|
||||
final WorkTraceInput? taskTrace;
|
||||
final String? expectedTaskId;
|
||||
final bool traceDiagnosticsEnabled;
|
||||
final bool showDevice;
|
||||
|
||||
/// 业务页面提供独立叠加层,共享地图无需依赖具体分区业务。
|
||||
final List<Widget> extraMapLayers;
|
||||
final List<LatLng> focusPoints;
|
||||
final int focusSignal;
|
||||
final EdgeInsets focusPadding;
|
||||
|
||||
@override
|
||||
State<PvWorkMap> createState() => _PvWorkMapState();
|
||||
}
|
||||
|
||||
class _PvWorkMapState extends State<PvWorkMap> {
|
||||
final _traceDiagnostics = WorkTraceDiagnostics();
|
||||
final _taskTraceRecorder = WorkTraceRecorder();
|
||||
Object? _lastTraceRender;
|
||||
List<LatLng> get _visibleTracePoints => widget.taskTrace != null
|
||||
? _taskTraceRecorder.points
|
||||
: widget.workTrace ?? _trace;
|
||||
|
||||
void _synchronizeTaskTrace() {
|
||||
final input = widget.taskTrace;
|
||||
if (input == null) {
|
||||
_taskTraceRecorder.reset();
|
||||
return;
|
||||
}
|
||||
_taskTraceRecorder.synchronize(deviceId: widget.deviceSn, input: input);
|
||||
if (_pos != null) _taskTraceRecorder.addPosition(_pos!);
|
||||
}
|
||||
|
||||
void _logTraceRender(List<LatLng> points) {
|
||||
if (!widget.traceDiagnosticsEnabled) return;
|
||||
final signature = (
|
||||
widget.deviceSn,
|
||||
widget.expectedTaskId,
|
||||
widget.recordLocationTrace,
|
||||
widget.workTrace != null,
|
||||
widget.taskTrace?.recording,
|
||||
widget.taskTrace?.visible,
|
||||
widget.taskTrace?.completedPoints.length,
|
||||
points.length,
|
||||
points.isEmpty ? null : points.last,
|
||||
widget.previewRoute.length,
|
||||
_routeTaskId,
|
||||
_route.length,
|
||||
_ready,
|
||||
);
|
||||
if (_lastTraceRender == signature) return;
|
||||
_lastTraceRender = signature;
|
||||
_traceDiagnostics.log(
|
||||
'地图画线',
|
||||
{
|
||||
'deviceId': widget.deviceSn,
|
||||
'taskId': widget.expectedTaskId,
|
||||
'source': widget.taskTrace != null
|
||||
? (_taskTraceRecorder.hasCompletedPoints ? '到达点+实时定位' : '开始后定位轨迹')
|
||||
: widget.workTrace != null
|
||||
? '任务completedPoints'
|
||||
: '定位累计轨迹',
|
||||
'taskTraceRecording': widget.taskTrace?.recording,
|
||||
'taskTraceVisible': widget.taskTrace?.visible,
|
||||
'completedPoints': widget.taskTrace?.completedPoints.length,
|
||||
'recordLocationTrace': widget.recordLocationTrace,
|
||||
'mapReady': _ready,
|
||||
'mapCenter': !_ready
|
||||
? null
|
||||
: {
|
||||
'lat': _map.camera.center.latitude,
|
||||
'lng': _map.camera.center.longitude,
|
||||
},
|
||||
'mapZoom': !_ready ? null : _map.camera.zoom,
|
||||
'points': points.length,
|
||||
'previewRoutePoints': widget.previewRoute.length,
|
||||
'realtimeRoutePoints': _route.length,
|
||||
'greenPolyline': points.length >= 2,
|
||||
'lastPoint': points.isEmpty
|
||||
? null
|
||||
: {'lat': points.last.latitude, 'lng': points.last.longitude},
|
||||
'reason': points.isEmpty
|
||||
? '没有轨迹点'
|
||||
: points.length == 1
|
||||
? '只有一个点,需至少两个点才能画线'
|
||||
: '满足绿色Polyline绘制条件',
|
||||
},
|
||||
sampleKey:
|
||||
'map/${widget.deviceSn}/${widget.expectedTaskId}/${points.length < 2 ? points.length : "2+"}/$_ready',
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 与路径规划一致的常量 =====
|
||||
static const _esriUrl =
|
||||
'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}';
|
||||
static const _centerZoom = 18.0; // 路径规划回中/跟随都用 18 级
|
||||
static const _previewZoom = 21.0; // 与路径规划选中路线后的定位级别一致
|
||||
static const _maxTrace = 600; // 绿线最多保留的点数(约 5 分钟推送)
|
||||
static const _minTraceStep = 0.3; // 米:小于此间距的点丢弃(抖动过滤)
|
||||
static const _returnColor = Color(0xFF7B61FF); // 返航点配色(紫)
|
||||
|
||||
final MapController _map = MapController();
|
||||
final Distance _dist = const Distance();
|
||||
@@ -167,6 +276,7 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_synchronizeTaskTrace();
|
||||
// 图层范围仓库:与路径规划同一套用法(动态刷新 + 变更通知,失败自动回退内置兜底)
|
||||
StationLayerRepo.instance.addListener(_onStationLayersUpdated);
|
||||
StationLayerRepo.instance.refresh();
|
||||
@@ -208,14 +318,32 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
// 页面点了「刷新」:已走轨迹作废(同路径规划 traceManager.reset())
|
||||
if (oldWidget.clearTraceSignal != widget.clearTraceSignal) {
|
||||
_trace.clear();
|
||||
_taskTraceRecorder.reset();
|
||||
}
|
||||
_synchronizeTaskTrace();
|
||||
if (oldWidget.focusSignal != widget.focusSignal) _fitFocusGeometry();
|
||||
}
|
||||
|
||||
/// 预览的全部几何(轨迹 + 边界框):视野与定位都以它为准
|
||||
List<LatLng> get _previewPoints => <LatLng>[
|
||||
...widget.previewOuter,
|
||||
...widget.previewRoute,
|
||||
];
|
||||
...widget.previewOuter,
|
||||
...widget.previewRoute,
|
||||
];
|
||||
|
||||
void _fitFocusGeometry() {
|
||||
if (widget.focusPoints.isEmpty) return;
|
||||
_follow = false;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted || !_ready || widget.focusPoints.isEmpty) return;
|
||||
_map.fitCamera(
|
||||
CameraFit.bounds(
|
||||
bounds: LatLngBounds.fromPoints(widget.focusPoints),
|
||||
padding: widget.focusPadding,
|
||||
maxZoom: _previewZoom,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/// 把视野移到预览几何中心。刻意不用 CameraFit:
|
||||
/// 只要 center + 固定 zoom,跟 flutter_map 版本差异无关。
|
||||
@@ -254,6 +382,11 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
/// 多一道过滤反而会因为 payload 字段格式不同把运行中的路线丢掉。
|
||||
void _onRouteMessage(RouteStatusEntity msg) {
|
||||
if (msg.data.isEmpty || !mounted) return;
|
||||
if (widget.expectedTaskId != null &&
|
||||
msg.taskId > 0 &&
|
||||
'${msg.taskId}' != widget.expectedTaskId) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
// 新任务 = 上一段的行走轨迹作废(路径规划选中任务时同样会 reset 轨迹)
|
||||
if (msg.taskId != _routeTaskId) {
|
||||
@@ -266,12 +399,47 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
|
||||
/// 定位推送来了:攒轨迹 + 按需把机器移到正中间
|
||||
void _onLocation(DeviceStatusUpdated state) {
|
||||
if (!widget.showDevice) return;
|
||||
final p = _validLatLng(state.status.latitude, state.status.longitude);
|
||||
if (p == null) return; // 无效坐标不画点、不追(与路径规划一致)
|
||||
if (widget.traceDiagnosticsEnabled) {
|
||||
_traceDiagnostics.log(
|
||||
'定位收到',
|
||||
{
|
||||
'deviceId': widget.deviceSn,
|
||||
'taskId': widget.expectedTaskId,
|
||||
'lat': state.status.latitude,
|
||||
'lng': state.status.longitude,
|
||||
'valid': p != null,
|
||||
'recordLocationTrace': widget.recordLocationTrace,
|
||||
'displayPoints': _visibleTracePoints.length,
|
||||
'taskTraceRecording': widget.taskTrace?.recording,
|
||||
'note': widget.taskTrace != null
|
||||
? (widget.taskTrace!.recording
|
||||
? '按作业轨迹规则接入实时车位'
|
||||
: '任务未开始、暂停或结束,定位不追加到轨迹')
|
||||
: widget.recordLocationTrace
|
||||
? '定位可累计本地轨迹'
|
||||
: '定位只更新车标;本页绿色轨迹需要任务arrive到达点',
|
||||
},
|
||||
sampleKey: 'location/${widget.deviceSn}/${widget.expectedTaskId}',
|
||||
interval: const Duration(seconds: 5),
|
||||
);
|
||||
}
|
||||
if (p == null) {
|
||||
if (widget.onDevicePosition != null) {
|
||||
_pos = null;
|
||||
widget.onDevicePosition?.call(null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (p == _pos) return;
|
||||
_pos = p;
|
||||
widget.onDevicePosition?.call(p);
|
||||
_appendTrace(p);
|
||||
if (widget.taskTrace != null) {
|
||||
_taskTraceRecorder.addPosition(p);
|
||||
} else if (widget.recordLocationTrace) {
|
||||
_appendTrace(p);
|
||||
}
|
||||
if (_follow && widget.followDevice) _scheduleMove(p);
|
||||
}
|
||||
|
||||
@@ -328,11 +496,11 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
}
|
||||
|
||||
/// 中心到末点的距离文本(与路径规划同一套显示:1 公里内用米)
|
||||
String _distanceText(LatLng a, LatLng b) {
|
||||
String _distanceText(LatLng a, LatLng b, AppLocalizations l10n) {
|
||||
final d = _dist(a, b);
|
||||
return d < 1000
|
||||
? '${d.toStringAsFixed(1)} 米'
|
||||
: '${(d / 1000).toStringAsFixed(2)} 千米';
|
||||
? '${d.toStringAsFixed(1)} ${l10n.translate('pv_control.unit_m')}'
|
||||
: '${(d / 1000).toStringAsFixed(2)} ${l10n.translate('pv_control.unit_km')}';
|
||||
}
|
||||
|
||||
/// 进场中心:优先当前选中场站高清图层中心,无有效场站兜底到苏州地块(同路径规划)
|
||||
@@ -351,15 +519,27 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocListener<DeviceStatusBloc, DeviceStatusState>(
|
||||
listenWhen: (prev, cur) => cur is DeviceStatusUpdated,
|
||||
listener: (context, state) => _onLocation(state as DeviceStatusUpdated),
|
||||
listenWhen: (prev, cur) =>
|
||||
cur is DeviceStatusUpdated || widget.onDevicePosition != null,
|
||||
listener: (context, state) {
|
||||
if (state is DeviceStatusUpdated) {
|
||||
_onLocation(state);
|
||||
} else {
|
||||
_pos = null;
|
||||
widget.onDevicePosition?.call(null);
|
||||
}
|
||||
},
|
||||
child: BlocBuilder<DeviceStatusBloc, DeviceStatusState>(
|
||||
buildWhen: (prev, cur) => cur is DeviceStatusUpdated,
|
||||
builder: (context, state) {
|
||||
final status = state is DeviceStatusUpdated ? state.status : null;
|
||||
final status = widget.showDevice && state is DeviceStatusUpdated
|
||||
? state.status
|
||||
: null;
|
||||
final marker = status == null
|
||||
? null
|
||||
: _validLatLng(status.latitude, status.longitude);
|
||||
final tracePoints = _visibleTracePoints;
|
||||
_logTraceRender(tracePoints);
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
@@ -378,26 +558,34 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
),
|
||||
onMapReady: () {
|
||||
_ready = true;
|
||||
_fitPreviewRoute();
|
||||
if (widget.onDevicePosition != null && widget.showDevice) {
|
||||
final current = context.read<DeviceStatusBloc>().state;
|
||||
if (current is DeviceStatusUpdated) _onLocation(current);
|
||||
}
|
||||
if (widget.focusPoints.isNotEmpty) {
|
||||
_fitFocusGeometry();
|
||||
} else {
|
||||
_fitPreviewRoute();
|
||||
}
|
||||
// 进场先把当前中心告诉页面:准星还没动过时也能取到中心
|
||||
widget.onCenterChanged?.call(LatLng(_map.camera.center.latitude,
|
||||
_map.camera.center.longitude));
|
||||
widget.onCenterChanged?.call(
|
||||
LatLng(
|
||||
_map.camera.center.latitude,
|
||||
_map.camera.center.longitude,
|
||||
),
|
||||
);
|
||||
},
|
||||
onPositionChanged: _notifyCenter,
|
||||
onMapEvent: _onMapEvent,
|
||||
onTap: (_, _) {}, // 空实现:地图本身不响应点击
|
||||
),
|
||||
children: [
|
||||
/// ESRI World Imagery(WGS84,全球高清卫星图,无需坐标转换)
|
||||
TileLayer(
|
||||
urlTemplate: _esriUrl,
|
||||
userAgentPackageName: 'com.example.app',
|
||||
minZoom: 0,
|
||||
maxZoom: 19,
|
||||
),
|
||||
/// 底图:中文=ESRI,非中文=Google(不可达自动回退 ESRI)
|
||||
const AppBaseMapLayer(maxZoom: 22),
|
||||
|
||||
/// 场站无人机高清影像:滑到哪个场站区域(zoom>=16)就叠哪个
|
||||
if (_showStation) ..._stationLayers,
|
||||
...widget.extraMapLayers,
|
||||
|
||||
/// ① 作业区域边界框(与路径规划同一套画法):
|
||||
/// 覆盖模式 = 灰色半透明多边形;自定义模式 = 绿色边界线。
|
||||
@@ -465,9 +653,7 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
PolylineLayer(
|
||||
key: const ValueKey('pv_draft_points'),
|
||||
polylines: [
|
||||
for (var i = 0;
|
||||
i < widget.draftPoints.length - 1;
|
||||
i++)
|
||||
for (var i = 0; i < widget.draftPoints.length - 1; i++)
|
||||
Polyline(
|
||||
points: [
|
||||
widget.draftPoints[i],
|
||||
@@ -522,6 +708,7 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
_distanceText(
|
||||
widget.draftCenter!,
|
||||
widget.draftPoints.last,
|
||||
AppLocalizations.of(context),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
@@ -574,9 +761,11 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
PolylineLayer(
|
||||
key: const ValueKey('pv_draft_hole_points'),
|
||||
polylines: [
|
||||
for (var i = 0;
|
||||
i < widget.draftHolePoints.length - 1;
|
||||
i++)
|
||||
for (
|
||||
var i = 0;
|
||||
i < widget.draftHolePoints.length - 1;
|
||||
i++
|
||||
)
|
||||
Polyline(
|
||||
points: [
|
||||
widget.draftHolePoints[i],
|
||||
@@ -599,13 +788,13 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
],
|
||||
),
|
||||
|
||||
/// 已走轨迹(绿色实线,本地按定位推送累积)
|
||||
if (_trace.length >= 2)
|
||||
/// 已走轨迹(作业模式由到达点与实时车位组合)。
|
||||
if (tracePoints.length >= 2)
|
||||
PolylineLayer(
|
||||
key: const ValueKey('pv_trace'),
|
||||
polylines: [
|
||||
Polyline(
|
||||
points: List.of(_trace),
|
||||
points: List.of(tracePoints),
|
||||
color: const Color(0xFF00B42A),
|
||||
strokeWidth: 4,
|
||||
),
|
||||
@@ -629,18 +818,22 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
/// 禁行区打点编号(已完成:红底「组号-点号」;绘制中:橙底「点号」)
|
||||
if (widget.draftObstacle)
|
||||
MarkerLayer(
|
||||
key: const ValueKey('pv_draft_hole_markers'),
|
||||
markers: [
|
||||
for (var holeIndex = 0;
|
||||
holeIndex < widget.draftHoles.length;
|
||||
holeIndex++)
|
||||
for (var pointIndex = 0;
|
||||
pointIndex <
|
||||
widget.draftHoles[holeIndex].length;
|
||||
pointIndex++)
|
||||
for (
|
||||
var holeIndex = 0;
|
||||
holeIndex < widget.draftHoles.length;
|
||||
holeIndex++
|
||||
)
|
||||
for (
|
||||
var pointIndex = 0;
|
||||
pointIndex < widget.draftHoles[holeIndex].length;
|
||||
pointIndex++
|
||||
)
|
||||
Marker(
|
||||
point: widget.draftHoles[holeIndex][pointIndex],
|
||||
width: 80,
|
||||
@@ -651,9 +844,11 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
8,
|
||||
),
|
||||
),
|
||||
for (var pointIndex = 0;
|
||||
pointIndex < widget.draftHolePoints.length;
|
||||
pointIndex++)
|
||||
for (
|
||||
var pointIndex = 0;
|
||||
pointIndex < widget.draftHolePoints.length;
|
||||
pointIndex++
|
||||
)
|
||||
Marker(
|
||||
point: widget.draftHolePoints[pointIndex],
|
||||
width: 80,
|
||||
@@ -685,6 +880,53 @@ class _PvWorkMapState extends State<PvWorkMap> {
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
/// ===== 一键返航点:紫色虚线串联(末点连到准星)=====
|
||||
if (widget.returnPoints.isNotEmpty)
|
||||
PolylineLayer(
|
||||
key: const ValueKey('pv_return_points'),
|
||||
polylines: [
|
||||
for (var i = 0; i < widget.returnPoints.length - 1; i++)
|
||||
Polyline(
|
||||
points: [
|
||||
widget.returnPoints[i],
|
||||
widget.returnPoints[i + 1],
|
||||
],
|
||||
color: _returnColor.withValues(alpha: 0.85),
|
||||
strokeWidth: 2,
|
||||
isDotted: true,
|
||||
),
|
||||
if (widget.draftCrosshair && widget.draftCenter != null)
|
||||
Polyline(
|
||||
points: [
|
||||
widget.returnPoints.last,
|
||||
widget.draftCenter!,
|
||||
],
|
||||
color: _returnColor.withValues(alpha: 0.5),
|
||||
strokeWidth: 1.5,
|
||||
isDotted: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
/// 返航点编号:首点「H」,其余序号
|
||||
if (widget.returnPoints.isNotEmpty)
|
||||
MarkerLayer(
|
||||
key: const ValueKey('pv_return_point_markers'),
|
||||
markers: [
|
||||
for (var i = 0; i < widget.returnPoints.length; i++)
|
||||
Marker(
|
||||
point: widget.returnPoints[i],
|
||||
width: 80,
|
||||
height: 40,
|
||||
child: _draftBadge(
|
||||
i == 0 ? 'H' : '${i + 1}',
|
||||
_returnColor,
|
||||
10,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
// 还没收到定位推送时的提示(此时图面停在场站中心,机器不出现)
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class NoDeviceCrosshairHint extends StatefulWidget {
|
||||
const NoDeviceCrosshairHint({super.key, required this.hasDevice});
|
||||
final bool hasDevice;
|
||||
@override
|
||||
State<NoDeviceCrosshairHint> createState() => _NoDeviceCrosshairHintState();
|
||||
}
|
||||
|
||||
class _NoDeviceCrosshairHintState extends State<NoDeviceCrosshairHint> {
|
||||
bool _dismissed = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.hasDevice || _dismissed) return const SizedBox.shrink();
|
||||
return Material(
|
||||
color: const Color(0xFFFFF6E5),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(10, 8, 4, 8),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.my_location_rounded,
|
||||
size: 17,
|
||||
color: Color(0xFF9B6500),
|
||||
),
|
||||
const SizedBox(width: 7),
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'未选择设备,请使用「准星打点」:移动地图,将准星对准目标位置后点「+」。',
|
||||
style: TextStyle(
|
||||
fontSize: 11.5,
|
||||
color: Color(0xFF9B6500),
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
key: const ValueKey('dismiss_crosshair_hint'),
|
||||
onTap: () => setState(() => _dismissed = true),
|
||||
child: const Tooltip(
|
||||
message: '关闭提示',
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(3),
|
||||
child: Icon(
|
||||
Icons.close_rounded,
|
||||
size: 17,
|
||||
color: Color(0xFF9B6500),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,10 @@ class _LeftJoystickAreaState extends State<LeftJoystickArea> {
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
'暂未收到该机器的推送,不能控制',
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('remote_control.joystick_no_data'),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
|
||||
@@ -17,6 +17,17 @@ abstract class DeviceRemoteDataSource {
|
||||
|
||||
/// 根据拆分码(蓝牙设备名/时间戳)精确查询设备,未查到时返回 null
|
||||
Future<DeviceDataModel?> getDeviceBySpiltCode(String code);
|
||||
|
||||
/// 修改设备别名(只写 deviceAlias,deviceName 保持不变)
|
||||
Future<bool> updateDeviceAlias({
|
||||
required String deviceId,
|
||||
required String deviceAlias,
|
||||
});
|
||||
|
||||
/// 一键寻车(GET /iot/host/searchDevice)
|
||||
///
|
||||
/// [deviceCode] 是设备编码(deviceName,MC700- 开头),不是 getSiteList 的数字主键 id。
|
||||
Future<bool> searchDevice({required String deviceCode});
|
||||
}
|
||||
|
||||
/// 设备远程数据源实现类 - 从真实 API 获取数据
|
||||
@@ -93,6 +104,8 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
for (int i = 0; i < rows.length && i < 10; i++) {
|
||||
debugPrint('>>> [DeviceRemoteDataSource] rows[$i]: ${rows[i]}');
|
||||
}
|
||||
// 同样核查一下 getAllDevices 是否下发归属字段(负责人是谁)
|
||||
_logOwnershipFields(rows, source: 'getDeviceList');
|
||||
return rows.map((item) => _parseDeviceFromJson(item)).toList();
|
||||
} catch (e) {
|
||||
debugPrint('>>> [DeviceRemoteDataSource] getAllDevices error: $e');
|
||||
@@ -138,6 +151,61 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> updateDeviceAlias({
|
||||
required String deviceId,
|
||||
required String deviceAlias,
|
||||
}) async {
|
||||
final response = await dio.post(
|
||||
HttpApiConsts.updateDeviceAlias,
|
||||
data: {'deviceId': deviceId, 'deviceAlias': deviceAlias},
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('网络请求失败: ${response.statusCode}');
|
||||
}
|
||||
|
||||
final responseData = response.data;
|
||||
if (responseData['code'] != 200) {
|
||||
throw Exception(responseData['msg'] ?? '业务异常');
|
||||
}
|
||||
|
||||
// 后端 data 为布尔值: true 表示别名已更新
|
||||
final updated = responseData['data'] == true;
|
||||
debugPrint(
|
||||
'>>> [DeviceRemoteDataSource] updateDeviceAlias deviceId=$deviceId '
|
||||
'deviceAlias=$deviceAlias updated=$updated',
|
||||
);
|
||||
return updated;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> searchDevice({required String deviceCode}) async {
|
||||
final response = await dio.get(
|
||||
HttpApiConsts.hostSearchDevice,
|
||||
queryParameters: {'deviceId': deviceCode},
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('网络请求失败: ${response.statusCode}');
|
||||
}
|
||||
|
||||
final responseData = response.data;
|
||||
// 兼容 int / String 类型的 code(与 createDeviceTask 同样口径)
|
||||
final code = responseData['code'];
|
||||
final codeValue = code is int
|
||||
? code
|
||||
: int.tryParse(code?.toString() ?? '');
|
||||
if (codeValue != 200) {
|
||||
throw Exception(responseData['msg'] ?? '一键寻车指令下发失败');
|
||||
}
|
||||
|
||||
debugPrint(
|
||||
'>>> [DeviceRemoteDataSource] searchDevice 已下发 deviceId=$deviceCode',
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<List<DeviceDataModel>> _fetchDevicesFromAPI(int siteId) async {
|
||||
final response = await dio.get(
|
||||
HttpApiConsts.getSiteDeviceList,
|
||||
@@ -155,9 +223,144 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
}
|
||||
|
||||
final List<dynamic> rows = responseData['rows'] ?? [];
|
||||
_logProductModel(rows, siteId: siteId);
|
||||
_logOwnershipFields(rows, source: 'getSiteList');
|
||||
return rows.map((item) => _parseDeviceFromJson(item)).toList();
|
||||
}
|
||||
|
||||
/// 🔍 一次性核查:设备列表 row 里到底带不带归属字段
|
||||
/// (组织 / 场站 / 负责人),用于确认能否展示真实归属链路。
|
||||
/// 归属页靠这些字段展示真实值,拿不到就显示「未知」,不编造。
|
||||
/// 目前接入两个列表接口:getSiteList、getDeviceList。
|
||||
void _logOwnershipFields(List<dynamic> rows, {String source = ''}) {
|
||||
if (rows.isEmpty) return;
|
||||
final row = rows.first;
|
||||
if (row is! Map) return;
|
||||
|
||||
// 1) 先把顶层字段名全部列出:即使后端换了叫法(responsible / charge / principal)
|
||||
// 也能一眼看出到底有没有「负责人」这个字段
|
||||
_printChunked(
|
||||
'>>> [$source/归属字段] 顶层字段(${row.length}): ',
|
||||
row.keys.join('|'),
|
||||
);
|
||||
|
||||
// 2) 再按关键字把归属相关字段的“键=值”摘出来
|
||||
const keywords = [
|
||||
'org',
|
||||
'site',
|
||||
'user',
|
||||
'owner',
|
||||
'manager',
|
||||
'responsible',
|
||||
'charge',
|
||||
'principal',
|
||||
'contact',
|
||||
'bind',
|
||||
'head',
|
||||
];
|
||||
final hits = <String>[];
|
||||
for (final entry in row.entries) {
|
||||
final k = entry.key.toString().toLowerCase();
|
||||
if (keywords.any((word) => k.contains(word))) {
|
||||
hits.add('${entry.key}=${entry.value}');
|
||||
}
|
||||
}
|
||||
debugPrint(
|
||||
'>>> [$source/归属字段] 命中 ${hits.length} 个: '
|
||||
'${hits.isEmpty ? '无(该接口不下发归属信息)' : hits.join(', ')}',
|
||||
);
|
||||
}
|
||||
|
||||
/// 🔍 专项日志:只核查 getSiteList 返回体里是否带 productModel 字段
|
||||
/// 整体打印 row 会被截断,这里只摘取关键字段 + 型号相关候选字段
|
||||
void _logProductModel(List<dynamic> rows, {required int siteId}) {
|
||||
debugPrint('>>> [getSiteList/datasource] siteId=$siteId 返回 ${rows.length} 条');
|
||||
if (rows.isEmpty) {
|
||||
debugPrint(
|
||||
'>>> [getSiteList/datasource] rows 为空,无法判断 productModel 是否存在',
|
||||
);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < rows.length; i++) {
|
||||
final row = rows[i];
|
||||
if (row is! Map) {
|
||||
debugPrint(
|
||||
'>>> [getSiteList/datasource] rows[$i] 非 Map 结构: ${row.runtimeType}',
|
||||
);
|
||||
continue;
|
||||
}
|
||||
final json = Map<String, dynamic>.from(row);
|
||||
final head =
|
||||
'deviceId=${json['deviceId']} name=${json['deviceName'] ?? json['name']}';
|
||||
if (json.containsKey('productModel')) {
|
||||
final value = json['productModel'];
|
||||
debugPrint(
|
||||
'>>> [getSiteList/datasource] rows[$i] $head 有 productModel=$value (${value.runtimeType})',
|
||||
);
|
||||
} else {
|
||||
final candidates = json.entries
|
||||
.where((e) => _isModelLikeKey(e.key))
|
||||
.map((e) => '${e.key}=${e.value}')
|
||||
.join(', ');
|
||||
debugPrint(
|
||||
'>>> [getSiteList/datasource] rows[$i] $head 无 productModel 字段;型号候选字段: '
|
||||
'${candidates.isEmpty ? '无' : candidates}',
|
||||
);
|
||||
// 彻底核实:打印顶层全部字段名,并递归扫描子对象/数组,
|
||||
// 确认后端是否在任意层级返回过 productModel
|
||||
_printChunked(
|
||||
'>>> [getSiteList/datasource] rows[$i] 全部顶层字段(${json.length}): ',
|
||||
json.keys.join('|'),
|
||||
);
|
||||
final nested = _findKeyPaths(json, 'productModel');
|
||||
debugPrint(
|
||||
'>>> [getSiteList/datasource] rows[$i] 嵌套层 productModel 命中: '
|
||||
'${nested.isEmpty ? '无(子对象/数组均未找到)' : nested.join(', ')}',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 递归查找指定 key(含子对象与数组),返回“路径=值”列表
|
||||
List<String> _findKeyPaths(dynamic node, String key, [String path = '']) {
|
||||
final hits = <String>[];
|
||||
if (node is Map) {
|
||||
node.forEach((k, v) {
|
||||
final p = path.isEmpty ? '$k' : '$path.$k';
|
||||
if (k.toString() == key) {
|
||||
hits.add('$p=$v');
|
||||
} else {
|
||||
hits.addAll(_findKeyPaths(v, key, p));
|
||||
}
|
||||
});
|
||||
} else if (node is List) {
|
||||
for (int i = 0; i < node.length; i++) {
|
||||
hits.addAll(_findKeyPaths(node[i], key, '$path[$i]'));
|
||||
}
|
||||
}
|
||||
return hits;
|
||||
}
|
||||
|
||||
/// 长文本分段打印,避免 debugPrint 单条过长被截断
|
||||
void _printChunked(String prefix, String content) {
|
||||
const chunk = 700;
|
||||
var head = prefix;
|
||||
for (int start = 0; start < content.length; start += chunk) {
|
||||
final end =
|
||||
start + chunk < content.length ? start + chunk : content.length;
|
||||
debugPrint('$head${content.substring(start, end)}');
|
||||
head = ' ↳ ';
|
||||
}
|
||||
}
|
||||
|
||||
bool _isModelLikeKey(String key) {
|
||||
final k = key.toLowerCase();
|
||||
return k.contains('model') ||
|
||||
k.contains('product') ||
|
||||
k.contains('type') ||
|
||||
k.contains('version');
|
||||
}
|
||||
|
||||
Future<List<DeviceDataModel>> _fetchUAVDevicesFromAPI(int siteId) async {
|
||||
final response = await dio.get(
|
||||
HttpApiConsts.getSiteUAVList,
|
||||
@@ -202,6 +405,11 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
voltage: (json['voltage'] as num?)?.toDouble(),
|
||||
radiation: (json['radiation'] as num?)?.toDouble(),
|
||||
isRobot: isRobot,
|
||||
// 型号:列表每一项都展示(productModel 优先,productName 兜底)
|
||||
productName: (json['productName'] ?? '').toString(),
|
||||
productModel: (json['productModel'] ?? '').toString().trim().isEmpty
|
||||
? null
|
||||
: json['productModel'].toString().trim(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -306,7 +514,7 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
status: '异常',
|
||||
power: 45.2,
|
||||
todayEnergy: 256.8,
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
if (typeFilter != null && typeFilter != 'all') {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:maibu_satabot_v2/core/error/failure.dart';
|
||||
|
||||
import '../../domain/entities/device_entity.dart';
|
||||
import '../../domain/entities/device_status_entity.dart';
|
||||
import '../../domain/repositories/device_repository.dart';
|
||||
@@ -32,4 +36,42 @@ class DeviceRepositoryImpl implements DeviceRepository {
|
||||
final dataModel = await remoteDataSource.getDeviceBySpiltCode(code);
|
||||
return dataModel?.toEntity();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Either<Failure, bool>> updateDeviceAlias({
|
||||
required String deviceId,
|
||||
required String deviceAlias,
|
||||
}) async {
|
||||
try {
|
||||
final updated = await remoteDataSource.updateDeviceAlias(
|
||||
deviceId: deviceId,
|
||||
deviceAlias: deviceAlias,
|
||||
);
|
||||
return Right(updated);
|
||||
} on DioException catch (e) {
|
||||
final serverMessage = e.response?.data is Map
|
||||
? (e.response?.data['msg'] ?? '网络连接异常')
|
||||
: '网络连接异常';
|
||||
return Left(Failure('$serverMessage'));
|
||||
} catch (e) {
|
||||
final cleanMessage = e.toString().replaceFirst('Exception: ', '');
|
||||
return Left(Failure(cleanMessage));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Either<Failure, bool>> searchDevice({required String deviceCode}) async {
|
||||
try {
|
||||
final sent = await remoteDataSource.searchDevice(deviceCode: deviceCode);
|
||||
return Right(sent);
|
||||
} on DioException catch (e) {
|
||||
final serverMessage = e.response?.data is Map
|
||||
? (e.response?.data['msg'] ?? '网络连接异常')
|
||||
: '网络连接异常';
|
||||
return Left(Failure('$serverMessage'));
|
||||
} catch (e) {
|
||||
final cleanMessage = e.toString().replaceFirst('Exception: ', '');
|
||||
return Left(Failure(cleanMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:maibu_satabot_v2/core/error/failure.dart';
|
||||
|
||||
import '../entities/device_entity.dart';
|
||||
import '../entities/device_status_entity.dart';
|
||||
|
||||
@@ -9,4 +12,19 @@ abstract class DeviceRepository {
|
||||
|
||||
/// 根据拆分码(蓝牙设备名/时间戳)精确查询设备,未查到时返回 null
|
||||
Future<DeviceEntity?> getDeviceBySpiltCode(String code);
|
||||
|
||||
/// 修改设备别名。
|
||||
///
|
||||
/// 后端只更新 deviceAlias,deviceName(出厂序列号)保持不变;
|
||||
/// 返回 true 表示别名已成功写库。
|
||||
Future<Either<Failure, bool>> updateDeviceAlias({
|
||||
required String deviceId,
|
||||
required String deviceAlias,
|
||||
});
|
||||
|
||||
/// 一键寻车:向后端下发寻车指令(GET /iot/host/searchDevice)。
|
||||
///
|
||||
/// [deviceCode] 是设备编码(MC700- 开头),不是数字主键;
|
||||
/// 返回 true 表示指令已成功下发。
|
||||
Future<Either<Failure, bool>> searchDevice({required String deviceCode});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../domain/usecases/search_device_usecase.dart';
|
||||
import 'find_robot_state.dart';
|
||||
|
||||
/// 一键寻车 Cubit
|
||||
///
|
||||
/// 调用链:UI → FindRobotCubit → SearchDeviceUseCase → Repository → DataSource,
|
||||
/// 弹窗不再直接依赖用例或数据源。
|
||||
///
|
||||
/// 下发口径:deviceId 传设备编码(deviceName,MC700- 开头),不是数字主键 id。
|
||||
class FindRobotCubit extends Cubit<FindRobotState> {
|
||||
final SearchDeviceUseCase _searchDevice;
|
||||
|
||||
FindRobotCubit(this._searchDevice) : super(const FindRobotState());
|
||||
|
||||
/// 下发一键寻车指令(GET /iot/host/searchDevice)
|
||||
///
|
||||
/// [deviceCode] 为空时直接判定失败,不发请求(避免后端把空串当全量)。
|
||||
Future<void> startFind({required String deviceCode}) async {
|
||||
if (state.isSubmitting) return;
|
||||
|
||||
final code = deviceCode.trim();
|
||||
if (code.isEmpty) {
|
||||
emit(const FindRobotState(errorMessage: ''));
|
||||
return;
|
||||
}
|
||||
|
||||
emit(FindRobotState(isSubmitting: true, deviceCode: code));
|
||||
|
||||
final result = await _searchDevice.execute(deviceCode: code);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(
|
||||
FindRobotState(errorMessage: failure.message, deviceCode: code),
|
||||
),
|
||||
(sent) => emit(
|
||||
FindRobotState(isSuccess: sent, deviceCode: code),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 结果已被界面消费,复位避免重复弹提示
|
||||
void reset() {
|
||||
if (state.isSubmitting) return;
|
||||
emit(const FindRobotState());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// 一键寻车指令下发状态
|
||||
///
|
||||
/// 一次性结果用 [isSuccess] / [errorMessage] 表达:
|
||||
/// [errorMessage] 非 null 即失败,空串表示只知失败、文案由 UI 套本地化提示。
|
||||
class FindRobotState extends Equatable {
|
||||
/// 请求进行中(用于拦截重复点击)
|
||||
final bool isSubmitting;
|
||||
|
||||
/// 后端已成功下发寻车指令
|
||||
final bool isSuccess;
|
||||
|
||||
/// 失败原因;null 表示尚无结果
|
||||
final String? errorMessage;
|
||||
|
||||
/// 本次操作的设备编码(MC700- 开头)
|
||||
final String? deviceCode;
|
||||
|
||||
const FindRobotState({
|
||||
this.isSubmitting = false,
|
||||
this.isSuccess = false,
|
||||
this.errorMessage,
|
||||
this.deviceCode,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [isSubmitting, isSuccess, errorMessage, deviceCode];
|
||||
}
|
||||
@@ -5,7 +5,10 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
/// 使用静态变量存储状态,确保全局同步
|
||||
class FloatBarSettingService {
|
||||
final SharedPreferences _prefs;
|
||||
static const String _key = 'float_bar_enabled';
|
||||
|
||||
/// key 升版:旧版(float_bar_enabled)可能残留 true,导致升级后悬浮条依然显示,
|
||||
/// 故换用新 key,保证首次启动一律回到默认关闭。
|
||||
static const String _key = 'float_bar_enabled_v2';
|
||||
|
||||
/// 🔥 静态实例引用
|
||||
static FloatBarSettingService? _instance;
|
||||
@@ -18,6 +21,7 @@ class FloatBarSettingService {
|
||||
|
||||
FloatBarSettingService(this._prefs) {
|
||||
_instance = this;
|
||||
// 默认关闭:未设置过时一律不显示悬浮条
|
||||
_isEnabled = _prefs.getBool(_key) ?? false;
|
||||
_settingNotifier.value = _isEnabled;
|
||||
debugPrint('✅ [FloatBarSettingService] 初始化完成,初始状态: $_isEnabled');
|
||||
|
||||
@@ -18,6 +18,7 @@ import '../../../../../../core/di/injection.dart';
|
||||
import '../../../../../../core/managers/drone_task_state_manager.dart';
|
||||
import '../../../../../../core/network/mqtt/domain/entities/drone_osd_entity.dart';
|
||||
import '../../../../../../core/network/mqtt/data/datasources/drone_osd_datasource.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/map/app_base_map_layer.dart';
|
||||
|
||||
/// 模拟轨迹模式枚举
|
||||
enum SimulationMode {
|
||||
@@ -1501,14 +1502,8 @@ class FloatBarWidgetState extends State<FloatBarWidget> {
|
||||
},
|
||||
),
|
||||
children: [
|
||||
// ESRI World Imagery(WGS84 坐标系,全球高清卫星图)
|
||||
// 替代高德地图(GCJ02),统一坐标系,无需坐标转换
|
||||
TileLayer(
|
||||
urlTemplate: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
|
||||
userAgentPackageName: 'com.example.app',
|
||||
minZoom: 0,
|
||||
maxZoom: 19,
|
||||
),
|
||||
// 底图:中文=ESRI,非中文=Google(不可达自动回退 ESRI)
|
||||
const AppBaseMapLayer(),
|
||||
|
||||
// 轨迹线(中间层)
|
||||
if (_trajectoryPoints.length >= 1)
|
||||
|
||||
@@ -781,31 +781,33 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
|
||||
'🔴🔴🔴 [全部-选中机器人] hasHost: ${robot.hasHost}',
|
||||
);
|
||||
|
||||
// 🔥 hasHost 字段判定:false → 蓝牙连接流程
|
||||
if (!robot.hasHost) {
|
||||
debugPrint('⚠️ [全部-EmbeddedRobotList] hasHost=false,进入蓝牙连接流程');
|
||||
|
||||
// 从设备名中提取时间戳(如 MC700PRO-CN-JS-1751525588120-0000000A-9527 → 1751525588120)
|
||||
final timestamp = _extractTimestamp(robot.name);
|
||||
if (timestamp == null || timestamp.isEmpty) {
|
||||
debugPrint('❌ [全部-EmbeddedRobotList] 未提取到时间戳');
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('设备名称异常,暂时无法连接'),
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
debugPrint('✅ [全部-EmbeddedRobotList] 提取到时间戳: $timestamp');
|
||||
|
||||
// 调用蓝牙连接流程
|
||||
_connectToDeviceViaBluetooth(context, robot.name, timestamp);
|
||||
return;
|
||||
}
|
||||
// ===== 【暂时停用】hasHost 分层判定 =====
|
||||
// 需求:暂时不管有无宿主,点卡片一律直接进控制页。
|
||||
// 恢复方式:取消下面整段注释即可(原逻辑:hasHost=false → 蓝牙连接流程)
|
||||
// if (!robot.hasHost) {
|
||||
// debugPrint('⚠️ [全部-EmbeddedRobotList] hasHost=false,进入蓝牙连接流程');
|
||||
//
|
||||
// // 从设备名中提取时间戳(如 MC700PRO-CN-JS-1751525588120-0000000A-9527 → 1751525588120)
|
||||
// final timestamp = _extractTimestamp(robot.name);
|
||||
// if (timestamp == null || timestamp.isEmpty) {
|
||||
// debugPrint('❌ [全部-EmbeddedRobotList] 未提取到时间戳');
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// const SnackBar(
|
||||
// content: Text('设备名称异常,暂时无法连接'),
|
||||
// duration: Duration(seconds: 2),
|
||||
// ),
|
||||
// );
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// debugPrint('✅ [全部-EmbeddedRobotList] 提取到时间戳: $timestamp');
|
||||
//
|
||||
// // 调用蓝牙连接流程
|
||||
// _connectToDeviceViaBluetooth(context, robot.name, timestamp);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// hasHost == true → 走原来的逻辑
|
||||
// 原 hasHost == true 分支(现在所有设备都走这里)
|
||||
debugPrint('✅ [全部-EmbeddedRobotList] hasHost=true,走正常控制流程');
|
||||
|
||||
// 1. 将当前机器人设置为全局待控制设备
|
||||
|
||||
@@ -47,7 +47,8 @@ import '../../../local_camera/presentation/pages/local_camera_page.dart';
|
||||
import '../../../usb_camera/presentation/pages/usb_camera_page.dart';
|
||||
import '../../../../remote_control/presentation/bloc/remote_control_cubit.dart';
|
||||
import '../../../../devices/domain/entities/device_entity.dart';
|
||||
import '../../../../devices/domain/usecases/update_devicename_usecase.dart';
|
||||
import '../cubit/rename_device_cubit.dart';
|
||||
import '../cubit/rename_device_state.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
||||
/// 设备状态页面 V2 —— 按「02_设备卡片总览」设计稿换皮。
|
||||
@@ -63,10 +64,16 @@ class DeviceStatusPageV2 extends StatelessWidget {
|
||||
final selectedSite = sl<SiteCubit>().state.selectedSite;
|
||||
final siteId = selectedSite?.id;
|
||||
|
||||
return BlocProvider(
|
||||
create: (_) =>
|
||||
sl<DeviceListBloc.DeviceStatusBloc>()
|
||||
..add(DeviceListEvent.DeviceStatusLoadData(siteId: siteId)),
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider(
|
||||
create: (_) =>
|
||||
sl<DeviceListBloc.DeviceStatusBloc>()
|
||||
..add(DeviceListEvent.DeviceStatusLoadData(siteId: siteId)),
|
||||
),
|
||||
// 设备改名:UI 只调 Cubit,不直接依赖 UseCase/DataSource
|
||||
BlocProvider(create: (_) => sl<RenameDeviceCubit>()),
|
||||
],
|
||||
child: const DeviceStatusViewV2(),
|
||||
);
|
||||
}
|
||||
@@ -355,7 +362,10 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
}
|
||||
},
|
||||
builder: (context, stationState) =>
|
||||
_buildV2Scaffold(context, robotState, stationState),
|
||||
BlocListener<RenameDeviceCubit, RenameDeviceState>(
|
||||
listener: _onRenameState,
|
||||
child: _buildV2Scaffold(context, robotState, stationState),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -408,8 +418,11 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
for (final r in robotState.robots) {
|
||||
items.add(
|
||||
_V2DeviceItem(
|
||||
// 展示口径:deviceAlias 为空(首次绑定必为 null)就回退 deviceName;
|
||||
// 后端改名接口只写 deviceAlias,deviceName 永远保持不变
|
||||
name: (r.alias != null && r.alias!.isNotEmpty) ? r.alias! : r.name,
|
||||
modelText: '${r.type} · ${DeviceV2Display.editionOf(r.id)}',
|
||||
// 型号 · 版本:由 getSiteList 的 productModel 解析(如 MC700 · PRO 旗舰版)
|
||||
modelText: r.modelLabelOf(AppLocalizations.of(context)),
|
||||
snKey: r.id,
|
||||
status: _robotV2Status(r),
|
||||
battery: r.isOnline ? r.battery.round() : null,
|
||||
@@ -424,7 +437,12 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
items.add(
|
||||
_V2DeviceItem(
|
||||
name: s.callsign.isNotEmpty ? s.callsign : sn,
|
||||
modelText: '无人机机场 · ${DeviceV2Display.editionOf(sn)}',
|
||||
modelText: AppLocalizations.of(context)
|
||||
.translate('device_list_v2.drone_station_model')
|
||||
.replaceAll(
|
||||
'%s',
|
||||
DeviceV2Display.editionOf(sn, AppLocalizations.of(context)),
|
||||
),
|
||||
snKey: sn,
|
||||
status: s.isOnline ? DeviceV2Status.online : DeviceV2Status.offline,
|
||||
battery: s.isOnline ? s.capacityPercent?.round() : null,
|
||||
@@ -536,13 +554,18 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
),
|
||||
)
|
||||
else if (visible.isEmpty)
|
||||
const SliverToBoxAdapter(
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(40),
|
||||
padding: const EdgeInsets.all(40),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'没有匹配的设备',
|
||||
style: TextStyle(fontSize: 13, color: _v2Gray),
|
||||
AppLocalizations.of(context).translate(
|
||||
'device_list_v2.no_matching_device',
|
||||
),
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: _v2Gray,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -591,25 +614,46 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
}
|
||||
|
||||
/// 卡片右上角「...」:进「设备归属与安全」页(仅机器人有归属关系;机场暂未开发)
|
||||
void _v2ItemMore(BuildContext context, _V2DeviceItem item) {
|
||||
Future<void> _v2ItemMore(BuildContext context, _V2DeviceItem item) async {
|
||||
final robot = item.robot;
|
||||
if (robot == null) {
|
||||
CapsuleToast.show('功能暂未开发', showCheck: false);
|
||||
CapsuleToast.show(
|
||||
AppLocalizations.of(context).translate('device_list_v2.feature_todo'),
|
||||
showCheck: false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
Navigator.push(
|
||||
// 归属页内完成解绑后会回传 true,此时卡片与统计卡都要重拉
|
||||
// 当前选中场站一并传过去:设备就是从这个场站查出来的,
|
||||
// 后端未下发设备归属时用于兜底展示真实场站与组织
|
||||
final site = sl<SiteCubit>().state.selectedSite;
|
||||
final unbound = await Navigator.push<bool>(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => RobotOwnershipPageV2(robot: robot),
|
||||
builder: (context) => RobotOwnershipPageV2(
|
||||
robot: robot,
|
||||
siteId: site?.id,
|
||||
siteName: site?.siteName,
|
||||
orgId: site?.orgId,
|
||||
),
|
||||
),
|
||||
);
|
||||
if (unbound == true && context.mounted) {
|
||||
context.read<RobotListBloc>().add(const RobotListRefresh());
|
||||
context.read<DeviceListBloc.DeviceStatusBloc>().add(
|
||||
const DeviceListEvent.DeviceStatusRefresh(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 卡片铅笔图标:修改设备名称(弹窗只负责输入,下发走真实 updateDeviceAlias)
|
||||
/// 卡片铅笔图标:只负责收集输入,下发交给 RenameDeviceCubit
|
||||
Future<void> _v2ItemRename(BuildContext context, _V2DeviceItem item) async {
|
||||
final robot = item.robot;
|
||||
if (robot == null) {
|
||||
CapsuleToast.show('功能暂未开发', showCheck: false);
|
||||
CapsuleToast.show(
|
||||
AppLocalizations.of(context).translate('device_list_v2.feature_todo'),
|
||||
showCheck: false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
final newName = await showRenameDeviceDialog(
|
||||
@@ -621,33 +665,51 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
// 取消 / 名称未变(与旧页一致:不调接口直接返回)
|
||||
if (newName == null || newName == item.name || !context.mounted) return;
|
||||
|
||||
final result = await sl<UpdateDevicenameUsecase>()(
|
||||
UpdateDevicenameParams(robot.id, newName),
|
||||
// 后端 updateDeviceAlias 的设备标识用设备编码(deviceName,MC700- 开头),
|
||||
// 不是 getSiteList 返回的数字主键 robot.id;deviceName 异常为空时回退 id 兜底
|
||||
final targetDeviceId = robot.name.isNotEmpty ? robot.name : robot.id;
|
||||
debugPrint(
|
||||
'>>> [V2-Rename] 下发 deviceId=$targetDeviceId alias=$newName (robot.id=${robot.id})',
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
|
||||
result.fold(
|
||||
(failure) => CapsuleToast.show(
|
||||
failure.message.isEmpty ? '修改设备名称失败' : failure.message,
|
||||
showCheck: false,
|
||||
),
|
||||
(code) {
|
||||
if (code != 1) {
|
||||
CapsuleToast.show('修改设备名称失败:状态码 $code', showCheck: false);
|
||||
return;
|
||||
}
|
||||
CapsuleToast.show('设备名称已更新为「$newName」');
|
||||
// 刷新卡片列表(别名优先展示,重拉后即可看到新名称)
|
||||
context.read<RobotListBloc>().add(const RobotListRefresh());
|
||||
context.read<DeviceListBloc.DeviceStatusBloc>().add(
|
||||
const DeviceListEvent.DeviceStatusRefresh(),
|
||||
);
|
||||
},
|
||||
context.read<RenameDeviceCubit>().rename(
|
||||
deviceId: targetDeviceId,
|
||||
alias: newName,
|
||||
);
|
||||
}
|
||||
|
||||
/// 改名结果回调:弹提示 + 重拉列表(deviceAlias 写入后卡片即显示新名称)
|
||||
void _onRenameState(BuildContext context, RenameDeviceState state) {
|
||||
// 提交中无 toast 需求
|
||||
if (state.isSubmitting) return;
|
||||
|
||||
final l10n = AppLocalizations.of(context);
|
||||
|
||||
if (state.isSuccess) {
|
||||
CapsuleToast.show(
|
||||
l10n
|
||||
.translate('device_list_v2.rename_success')
|
||||
.replaceAll('%s', state.alias ?? ''),
|
||||
);
|
||||
// 卡片列表与统计卡是两套数据源,都要重拉
|
||||
context.read<RobotListBloc>().add(const RobotListRefresh());
|
||||
context.read<DeviceListBloc.DeviceStatusBloc>().add(
|
||||
const DeviceListEvent.DeviceStatusRefresh(),
|
||||
);
|
||||
context.read<RenameDeviceCubit>().reset();
|
||||
return;
|
||||
}
|
||||
|
||||
final message = state.errorMessage;
|
||||
if (message == null) return;
|
||||
CapsuleToast.show(
|
||||
message.isEmpty ? l10n.translate('device_list_v2.rename_failed') : message,
|
||||
showCheck: false,
|
||||
);
|
||||
context.read<RenameDeviceCubit>().reset();
|
||||
}
|
||||
|
||||
/// 卡片点击分发:与旧列表 onTap 逐行一致(机器人→hasHost 流程,机场→详情页)
|
||||
void _v2ItemTap(BuildContext context, _V2DeviceItem item) {
|
||||
Future<void> _v2ItemTap(BuildContext context, _V2DeviceItem item) async {
|
||||
final robot = item.robot;
|
||||
if (robot != null) {
|
||||
debugPrint(
|
||||
@@ -655,29 +717,31 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
);
|
||||
debugPrint('🔴🔴🔴 [V2-选中机器人] hasHost: ${robot.hasHost}');
|
||||
|
||||
// 🔥 hasHost 字段判定:false → 蓝牙连接流程
|
||||
if (!robot.hasHost) {
|
||||
debugPrint('⚠️ [V2] hasHost=false,进入蓝牙连接流程');
|
||||
// ===== 【暂时停用】hasHost 分层判定 =====
|
||||
// 需求:暂时不管有无宿主,点卡片一律直接进设备详情页。
|
||||
// 恢复方式:取消下面整段注释即可(原逻辑:hasHost=false → 蓝牙连接流程)
|
||||
// if (!robot.hasHost) {
|
||||
// debugPrint('⚠️ [V2] hasHost=false,进入蓝牙连接流程');
|
||||
//
|
||||
// // 从设备名中提取时间戳
|
||||
// final timestamp = _extractTimestamp(robot.name);
|
||||
// if (timestamp == null || timestamp.isEmpty) {
|
||||
// debugPrint('❌ [V2] 未提取到时间戳');
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// const SnackBar(
|
||||
// content: Text('设备名称异常,暂时无法连接'),
|
||||
// duration: Duration(seconds: 2),
|
||||
// ),
|
||||
// );
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// debugPrint('✅ [V2] 提取到时间戳: $timestamp');
|
||||
// _connectToDeviceViaBluetooth(context, robot.name, timestamp);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// 从设备名中提取时间戳
|
||||
final timestamp = _extractTimestamp(robot.name);
|
||||
if (timestamp == null || timestamp.isEmpty) {
|
||||
debugPrint('❌ [V2] 未提取到时间戳');
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('设备名称异常,暂时无法连接'),
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
debugPrint('✅ [V2] 提取到时间戳: $timestamp');
|
||||
_connectToDeviceViaBluetooth(context, robot.name, timestamp);
|
||||
return;
|
||||
}
|
||||
|
||||
// hasHost == true → 走原来的逻辑:前置(setTargetDevice)不变,
|
||||
// 原 hasHost == true 分支(现在所有设备都走这里):前置(setTargetDevice)不变,
|
||||
// 跳转目标换成新设备详情页(V2 概览设计稿);
|
||||
// 页内铃铛/远程遥控再回旧 RobotControlPage,方便新旧对照。
|
||||
debugPrint('✅ [V2] hasHost=true,走正常控制流程');
|
||||
@@ -695,12 +759,19 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
final remoteCubit = GetIt.I<RemoteControlCubit>();
|
||||
remoteCubit.setTargetDevice(device);
|
||||
|
||||
Navigator.push(
|
||||
final renamed = await Navigator.push<bool>(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DeviceDetailPageV2(robot: robot),
|
||||
),
|
||||
);
|
||||
// 详情页改过名:卡片与统计卡都要重拉,否则列表还显示旧名字
|
||||
if (renamed == true && context.mounted) {
|
||||
context.read<RobotListBloc>().add(const RobotListRefresh());
|
||||
context.read<DeviceListBloc.DeviceStatusBloc>().add(
|
||||
const DeviceListEvent.DeviceStatusRefresh(),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -777,7 +848,10 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
}
|
||||
|
||||
void _v2Todo() {
|
||||
CapsuleToast.show('功能暂未开发', showCheck: false);
|
||||
CapsuleToast.show(
|
||||
AppLocalizations.of(context).translate('device_list_v2.feature_todo'),
|
||||
showCheck: false,
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 切换场站入口:右上角按钮下方小字(场站名) =====
|
||||
@@ -788,7 +862,10 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
return BlocBuilder<SiteCubit, SiteState>(
|
||||
bloc: sl<SiteCubit>(),
|
||||
builder: (context, siteState) {
|
||||
final name = siteState.selectedSite?.siteName ?? '未选择场站';
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final name =
|
||||
siteState.selectedSite?.siteName ??
|
||||
l10n.translate('device_list_v2.no_site_selected');
|
||||
return Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: GestureDetector(
|
||||
@@ -800,7 +877,13 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
isPersonal ? '($name)· 个人账号' : '($name)',
|
||||
isPersonal
|
||||
? l10n
|
||||
.translate('device_list_v2.site_suffix_personal')
|
||||
.replaceAll('%s', name)
|
||||
: l10n
|
||||
.translate('device_list_v2.site_suffix')
|
||||
.replaceAll('%s', name),
|
||||
style: const TextStyle(fontSize: 12, color: _v2Gray),
|
||||
),
|
||||
if (!isPersonal)
|
||||
@@ -823,12 +906,19 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
SiteState siteState,
|
||||
bool isPersonal,
|
||||
) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
if (isPersonal) {
|
||||
CapsuleToast.show('个人账号仅绑定一个场站', showCheck: false);
|
||||
CapsuleToast.show(
|
||||
l10n.translate('device_list_v2.personal_single_site'),
|
||||
showCheck: false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (siteState.sites.isEmpty) {
|
||||
CapsuleToast.show('暂无场站数据', showCheck: false);
|
||||
CapsuleToast.show(
|
||||
l10n.translate('device_list_v2.no_site_data'),
|
||||
showCheck: false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
final siteCubit = sl<SiteCubit>();
|
||||
@@ -843,15 +933,19 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 14),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'选择场站',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _v2Navy,
|
||||
Builder(
|
||||
builder: (sheetCtx) => Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
child: Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(
|
||||
sheetCtx,
|
||||
).translate('device_list_v2.select_site'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _v2Navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -897,6 +991,7 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
|
||||
// ===== 标题区 =====
|
||||
Widget _buildV2Header() {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
// SizedBox 撑满宽:否则 Column 会收缩到文本宽并被外层 Column 居中,
|
||||
@@ -905,19 +1000,19 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: const [
|
||||
children: [
|
||||
Text(
|
||||
'我的机器人',
|
||||
style: TextStyle(
|
||||
l10n.translate('device_list_v2.my_robots'),
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _v2Navy,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 6),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'多机型统一管理 · 按设备 SN 动态加载功能',
|
||||
style: TextStyle(fontSize: 13, color: _v2Gray),
|
||||
l10n.translate('device_list_v2.my_robots_desc'),
|
||||
style: const TextStyle(fontSize: 13, color: _v2Gray),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -928,6 +1023,7 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
// ===== 卡片视图 / 集中概览 切换(03 设计稿:浅蓝轨道 + 白色选中胶囊) =====
|
||||
Widget _buildViewToggle() {
|
||||
final isCard = _viewMode == 'card';
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: Container(
|
||||
@@ -941,7 +1037,7 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildToggleSegment(
|
||||
'卡片视图',
|
||||
l10n.translate('device_list_v2.view_card'),
|
||||
Icons.grid_view_rounded,
|
||||
isCard,
|
||||
() => setState(() => _viewMode = 'card'),
|
||||
@@ -949,7 +1045,7 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
),
|
||||
Expanded(
|
||||
child: _buildToggleSegment(
|
||||
'集中概览',
|
||||
l10n.translate('device_list_v2.view_overview'),
|
||||
Icons.bar_chart_rounded,
|
||||
!isCard,
|
||||
() => setState(() => _viewMode = 'overview'),
|
||||
@@ -1018,14 +1114,19 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: _v2Border),
|
||||
),
|
||||
child: const Row(
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 14),
|
||||
Icon(Icons.search, size: 20, color: Color(0xFFC9CDD4)),
|
||||
SizedBox(width: 10),
|
||||
const SizedBox(width: 14),
|
||||
const Icon(Icons.search, size: 20, color: Color(0xFFC9CDD4)),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
'搜索设备名称、型号或 SN',
|
||||
style: TextStyle(fontSize: 14, color: Color(0xFFB9C2CF)),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.search_hint_full'),
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFFB9C2CF),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -1036,11 +1137,12 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
|
||||
// ===== 状态过滤药丸:真实生效 =====
|
||||
Widget _buildStatusPills(int all, int online, int working, int offline) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final pills = [
|
||||
('all', '全部', all),
|
||||
('online', '在线', online),
|
||||
('working', '作业中', working),
|
||||
('offline', '离线', offline),
|
||||
('all', l10n.translate('device_list_v2.all'), all),
|
||||
('online', l10n.translate('device_list_v2.online'), online),
|
||||
('working', l10n.translate('device_list_v2.stat_working'), working),
|
||||
('offline', l10n.translate('device_list_v2.offline'), offline),
|
||||
];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 10, 0, 2),
|
||||
@@ -1181,9 +1283,11 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'设备集中概览',
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.overview_title'),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _v2Navy,
|
||||
@@ -1197,25 +1301,26 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
}
|
||||
|
||||
Widget _buildOverviewHeader() {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 4, 16, 0),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: const [
|
||||
children: [
|
||||
Text(
|
||||
'设备集中概览',
|
||||
style: TextStyle(
|
||||
l10n.translate('device_list_v2.overview_title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _v2Navy,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 6),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'适合企业多机器人集中管理',
|
||||
style: TextStyle(fontSize: 13, color: _v2Gray),
|
||||
l10n.translate('device_list_v2.overview_desc'),
|
||||
style: const TextStyle(fontSize: 13, color: _v2Gray),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -1225,11 +1330,27 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
|
||||
/// 四张统计卡:设备总数 / 在线设备 / 作业中 / 告警离线
|
||||
Widget _buildStatCards(int all, int online, int working, int offline) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final stats = [
|
||||
(Icons.smart_toy_rounded, _v2Blue, all, '设备总数'),
|
||||
(Icons.wifi_rounded, _v2Blue, online, '在线设备'),
|
||||
(Icons.play_circle_fill_rounded, const Color(0xFF2FBF6B), working, '作业中'),
|
||||
(Icons.warning_amber_rounded, const Color(0xFFE5484D), offline, '告警/离线'),
|
||||
(Icons.smart_toy_rounded, _v2Blue, all, l10n.translate('device_list_v2.stat_total')),
|
||||
(
|
||||
Icons.wifi_rounded,
|
||||
_v2Blue,
|
||||
online,
|
||||
l10n.translate('device_list_v2.stat_online_devices'),
|
||||
),
|
||||
(
|
||||
Icons.play_circle_fill_rounded,
|
||||
const Color(0xFF2FBF6B),
|
||||
working,
|
||||
l10n.translate('device_list_v2.stat_working'),
|
||||
),
|
||||
(
|
||||
Icons.warning_amber_rounded,
|
||||
const Color(0xFFE5484D),
|
||||
offline,
|
||||
l10n.translate('device_list_v2.stat_alarm_offline'),
|
||||
),
|
||||
];
|
||||
return Row(
|
||||
children: [
|
||||
@@ -1285,9 +1406,11 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
padding: const EdgeInsets.fromLTRB(14, 12, 14, 10),
|
||||
child: Row(
|
||||
children: [
|
||||
const Text(
|
||||
'设备分布',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.device_distribution'),
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _v2Navy,
|
||||
@@ -1300,7 +1423,11 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'共 $all 台设备',
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
)
|
||||
.translate('device_list_v2.total_devices_count')
|
||||
.replaceAll('%s', '$all'),
|
||||
style: const TextStyle(fontSize: 12, color: _v2Blue),
|
||||
),
|
||||
const Icon(Icons.chevron_right, size: 16, color: _v2Blue),
|
||||
@@ -1331,48 +1458,58 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(14, 12, 14, 8),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(14, 12, 14, 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Text(
|
||||
'设备信息',
|
||||
style: TextStyle(fontSize: 12, color: _v2Gray),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.th_device_info'),
|
||||
style: const TextStyle(fontSize: 12, color: _v2Gray),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
'状态',
|
||||
style: TextStyle(fontSize: 12, color: _v2Gray),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.th_status'),
|
||||
style: const TextStyle(fontSize: 12, color: _v2Gray),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
'电量',
|
||||
style: TextStyle(fontSize: 12, color: _v2Gray),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.battery_level'),
|
||||
style: const TextStyle(fontSize: 12, color: _v2Gray),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Text(
|
||||
'位置/当前任务',
|
||||
style: TextStyle(fontSize: 12, color: _v2Gray),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.th_location_task'),
|
||||
style: const TextStyle(fontSize: 12, color: _v2Gray),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 16),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (visible.isEmpty)
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(32),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
child: Text(
|
||||
'没有匹配的设备',
|
||||
style: TextStyle(fontSize: 13, color: _v2Gray),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.no_matching_device'),
|
||||
style: const TextStyle(fontSize: 13, color: _v2Gray),
|
||||
),
|
||||
)
|
||||
else
|
||||
@@ -1417,7 +1554,8 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'${DeviceV2Display.versionOf(e.snKey)} SN: ${DeviceV2Display.maskedSn(e.snKey)}',
|
||||
// 概览表第二行:型号 · 版本 + SN
|
||||
'${e.modelText} SN: ${DeviceV2Display.maskedSn(e.snKey)}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 10, color: _v2Gray),
|
||||
@@ -1444,8 +1582,11 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
flex: 4,
|
||||
child: Text(
|
||||
e.robot != null
|
||||
? '${DeviceV2Display.locationOf(e.snKey)} · ${e.robot!.task}'
|
||||
: DeviceV2Display.locationOf(e.snKey),
|
||||
? '${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),
|
||||
@@ -1459,21 +1600,22 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
}
|
||||
|
||||
Widget _buildOverviewBadge(DeviceV2Status status) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final (label, fg, bg, icon) = switch (status) {
|
||||
DeviceV2Status.working => (
|
||||
'作业中',
|
||||
l10n.translate('device_list_v2.stat_working'),
|
||||
const Color(0xFF2FBF6B),
|
||||
const Color(0xFFE5F8EC),
|
||||
Icons.play_arrow_rounded,
|
||||
),
|
||||
DeviceV2Status.online => (
|
||||
'在线',
|
||||
l10n.translate('device_list_v2.online'),
|
||||
_v2Blue,
|
||||
const Color(0xFFE7F3FE),
|
||||
Icons.wifi_rounded,
|
||||
),
|
||||
DeviceV2Status.offline => (
|
||||
'离线',
|
||||
l10n.translate('device_list_v2.offline'),
|
||||
const Color(0xFF6B7280),
|
||||
const Color(0xFFF0F2F5),
|
||||
Icons.pause_rounded,
|
||||
@@ -1548,11 +1690,13 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
padding: const EdgeInsets.fromLTRB(16, 14, 8, 4),
|
||||
child: Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'添加机器人',
|
||||
style: TextStyle(
|
||||
AppLocalizations.of(
|
||||
sheetCtx,
|
||||
).translate('device_list_v2.add_robot'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _v2Navy,
|
||||
@@ -1569,7 +1713,9 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
),
|
||||
_v2SheetItem(
|
||||
icon: Icons.qr_code_scanner,
|
||||
label: '扫一扫',
|
||||
label: AppLocalizations.of(
|
||||
sheetCtx,
|
||||
).translate('device_list_v2.scan_action'),
|
||||
onTap: () async {
|
||||
Navigator.pop(sheetCtx);
|
||||
final result = await Navigator.of(context).push<String>(
|
||||
@@ -1594,7 +1740,9 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
const Divider(height: 1, indent: 20, color: Color(0xFFF0F4FA)),
|
||||
_v2SheetItem(
|
||||
icon: Icons.add_circle_outline,
|
||||
label: '添加设备',
|
||||
label: AppLocalizations.of(
|
||||
sheetCtx,
|
||||
).translate('device_list_v2.add_device'),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetCtx);
|
||||
// 原菜单该项即为 TODO,保持不跳转
|
||||
@@ -1604,7 +1752,9 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
const Divider(height: 1, indent: 20, color: Color(0xFFF0F4FA)),
|
||||
_v2SheetItem(
|
||||
icon: Icons.videocam_outlined,
|
||||
label: '本地视频',
|
||||
label: AppLocalizations.of(
|
||||
sheetCtx,
|
||||
).translate('device_list_v2.local_video'),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetCtx);
|
||||
Navigator.of(context).push(
|
||||
@@ -1615,7 +1765,9 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
const Divider(height: 1, indent: 20, color: Color(0xFFF0F4FA)),
|
||||
_v2SheetItem(
|
||||
icon: Icons.usb,
|
||||
label: 'USB 摄像头',
|
||||
label: AppLocalizations.of(
|
||||
sheetCtx,
|
||||
).translate('device_list_v2.usb_camera'),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetCtx);
|
||||
Navigator.of(context).push(
|
||||
@@ -2168,6 +2320,7 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
id: robot.id,
|
||||
alias: robot.alias,
|
||||
type: robot.type,
|
||||
modelText: robot.modelLabelOf(AppLocalizations.of(context)),
|
||||
status: robot.status,
|
||||
battery: robot.battery,
|
||||
task: robot.task,
|
||||
@@ -2177,39 +2330,41 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
);
|
||||
debugPrint('🔴🔴🔴 [全部-选中机器人] hasHost: ${robot.hasHost}');
|
||||
|
||||
// 🔥 hasHost 字段判定:false → 蓝牙连接流程
|
||||
if (!robot.hasHost) {
|
||||
debugPrint(
|
||||
'⚠️ [全部-EmbeddedRobotList] hasHost=false,进入蓝牙连接流程',
|
||||
);
|
||||
// ===== 【暂时停用】hasHost 分层判定 =====
|
||||
// 需求:暂时不管有无宿主,点卡片一律直接进设备详情页。
|
||||
// 恢复方式:取消下面整段注释即可(原逻辑:hasHost=false → 蓝牙连接流程)
|
||||
// if (!robot.hasHost) {
|
||||
// debugPrint(
|
||||
// '⚠️ [全部-EmbeddedRobotList] hasHost=false,进入蓝牙连接流程',
|
||||
// );
|
||||
//
|
||||
// // 从设备名中提取时间戳(如 MC700PRO-CN-JS-1751525588120-0000000A-9527 → 1751525588120)
|
||||
// final timestamp = _extractTimestamp(robot.name);
|
||||
// if (timestamp == null || timestamp.isEmpty) {
|
||||
// debugPrint('❌ [全部-EmbeddedRobotList] 未提取到时间戳');
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// const SnackBar(
|
||||
// content: Text('设备名称异常,暂时无法连接'),
|
||||
// duration: Duration(seconds: 2),
|
||||
// ),
|
||||
// );
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// debugPrint(
|
||||
// '✅ [全部-EmbeddedRobotList] 提取到时间戳: $timestamp',
|
||||
// );
|
||||
//
|
||||
// // 调用蓝牙连接流程
|
||||
// _connectToDeviceViaBluetooth(
|
||||
// context,
|
||||
// robot.name,
|
||||
// timestamp,
|
||||
// );
|
||||
// return;
|
||||
// }
|
||||
|
||||
// 从设备名中提取时间戳(如 MC700PRO-CN-JS-1751525588120-0000000A-9527 → 1751525588120)
|
||||
final timestamp = _extractTimestamp(robot.name);
|
||||
if (timestamp == null || timestamp.isEmpty) {
|
||||
debugPrint('❌ [全部-EmbeddedRobotList] 未提取到时间戳');
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('设备名称异常,暂时无法连接'),
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
debugPrint(
|
||||
'✅ [全部-EmbeddedRobotList] 提取到时间戳: $timestamp',
|
||||
);
|
||||
|
||||
// 调用蓝牙连接流程
|
||||
_connectToDeviceViaBluetooth(
|
||||
context,
|
||||
robot.name,
|
||||
timestamp,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// hasHost == true → 走原来的逻辑:前置(setTargetDevice)不变,
|
||||
// 原 hasHost == true 分支(现在所有设备都走这里):前置(setTargetDevice)不变,
|
||||
// 跳转目标换成新设备详情页(V2 概览设计稿);
|
||||
// 页内铃铛/远程遥控再回旧 RobotControlPage,方便新旧对照。
|
||||
debugPrint(
|
||||
@@ -2531,7 +2686,9 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
_buildMenuOption(
|
||||
ctx,
|
||||
icon: Icons.qr_code_scanner,
|
||||
label: '扫一扫',
|
||||
label: AppLocalizations.of(
|
||||
ctx,
|
||||
).translate('device_list_v2.scan_action'),
|
||||
onTap: () async {
|
||||
Navigator.pop(ctx);
|
||||
final result = await Navigator.of(context).push<String>(
|
||||
@@ -2553,7 +2710,9 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
_buildMenuOption(
|
||||
ctx,
|
||||
icon: Icons.add_circle_outline,
|
||||
label: '添加设备',
|
||||
label: AppLocalizations.of(
|
||||
ctx,
|
||||
).translate('device_list_v2.add_device'),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
// TODO: 添加设备功能
|
||||
@@ -2563,7 +2722,9 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
_buildMenuOption(
|
||||
ctx,
|
||||
icon: Icons.videocam_outlined,
|
||||
label: '本地视频',
|
||||
label: AppLocalizations.of(
|
||||
ctx,
|
||||
).translate('device_list_v2.local_video'),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
Navigator.of(context).push(
|
||||
@@ -2577,7 +2738,9 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
_buildMenuOption(
|
||||
ctx,
|
||||
icon: Icons.usb,
|
||||
label: 'USB 摄像头',
|
||||
label: AppLocalizations.of(
|
||||
ctx,
|
||||
).translate('device_list_v2.usb_camera'),
|
||||
onTap: () {
|
||||
Navigator.pop(ctx);
|
||||
Navigator.of(context).push(
|
||||
@@ -2766,16 +2929,29 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
);
|
||||
} else {
|
||||
debugPrint('⚠️ 未找到匹配的机场,请从无人机机场标签页进入');
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('请从"无人机机场"标签页查看详情')));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.view_details_from_tab'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// 其他设备类型,显示提示
|
||||
debugPrint('⚠️ [DeviceStatusPage] 未知设备类型: $deviceType');
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('该设备类型暂不支持查看详情: $deviceType'),
|
||||
content: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.device_type_not_supported').replaceAll(
|
||||
'%s',
|
||||
deviceType,
|
||||
),
|
||||
),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
@@ -2821,9 +2997,13 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
final isBluetoothOn = await bleManager.checkBluetooth();
|
||||
if (!isBluetoothOn) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('请先打开手机蓝牙'),
|
||||
duration: Duration(seconds: 2),
|
||||
SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.open_bluetooth_first'),
|
||||
),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
return;
|
||||
@@ -2833,13 +3013,18 @@ class _DeviceStatusViewV2State extends State<DeviceStatusViewV2> {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => const Center(
|
||||
builder: (_) => Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(height: 16),
|
||||
Text('正在搜索蓝牙设备...', style: TextStyle(color: Colors.white)),
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.searching_bluetooth'),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -19,6 +19,7 @@ import '../../domain/entities/drone_station_entity.dart';
|
||||
import '../bloc/drone_station_bloc.dart';
|
||||
import '../bloc/drone_station_event.dart';
|
||||
import '../bloc/drone_station_state.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/map/app_base_map_layer.dart';
|
||||
|
||||
/// 无人机视频回传/远程控制页面
|
||||
class DroneVideoControlPage extends StatefulWidget {
|
||||
@@ -1293,14 +1294,8 @@ class _DroneVideoControlPageState extends State<DroneVideoControlPage> {
|
||||
),
|
||||
),
|
||||
children: [
|
||||
// ESRI World Imagery(WGS84 坐标系,全球高清卫星图)
|
||||
// 替代高德地图(GCJ02),统一坐标系,无需坐标转换
|
||||
TileLayer(
|
||||
urlTemplate: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
|
||||
userAgentPackageName: 'com.example.app',
|
||||
minZoom: 0,
|
||||
maxZoom: 19,
|
||||
),
|
||||
// 底图:中文=ESRI,非中文=Google(不可达自动回退 ESRI)
|
||||
const AppBaseMapLayer(),
|
||||
|
||||
// 🔥 轨迹线(中间层)
|
||||
if (_trajectoryPoints.length >= 1)
|
||||
@@ -1567,14 +1562,8 @@ class _DroneVideoControlPageState extends State<DroneVideoControlPage> {
|
||||
),
|
||||
),
|
||||
children: [
|
||||
// ESRI World Imagery(WGS84 坐标系,全球高清卫星图)
|
||||
// 替代高德地图(GCJ02),统一坐标系,无需坐标转换
|
||||
TileLayer(
|
||||
urlTemplate: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
|
||||
userAgentPackageName: 'com.example.app',
|
||||
minZoom: 0,
|
||||
maxZoom: 19,
|
||||
),
|
||||
// 底图:中文=ESRI,非中文=Google(不可达自动回退 ESRI)
|
||||
const AppBaseMapLayer(),
|
||||
|
||||
// 🔥 轨迹线(中间层)
|
||||
if (_trajectoryPoints.length >= 1)
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.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';
|
||||
import 'package:maibu_satabot_v2/features/main_container/domain/tab_config.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/local_camera/presentation/pages/local_camera_page.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/site/presentation/cubit/site_cubit.dart';
|
||||
@@ -40,12 +41,16 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
stops: [0.0, 0.5, 1.0],
|
||||
);
|
||||
|
||||
static void _todoTap() {
|
||||
CapsuleToast.show('功能暂未开发', showCheck: false);
|
||||
void _todoTap(BuildContext context) {
|
||||
CapsuleToast.show(
|
||||
AppLocalizations.of(context).translate('device_list_v2.feature_todo'),
|
||||
showCheck: false,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Scaffold(
|
||||
backgroundColor: _bgTop,
|
||||
body: Stack(
|
||||
@@ -72,10 +77,10 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
const SizedBox(height: 18),
|
||||
_buildHeroCard(context),
|
||||
const SizedBox(height: 26),
|
||||
const Center(
|
||||
Center(
|
||||
child: Text(
|
||||
'还没有添加机器人',
|
||||
style: TextStyle(
|
||||
l10n.translate('device_list_v2.no_device_title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
@@ -83,11 +88,11 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Center(
|
||||
Center(
|
||||
child: Text(
|
||||
'您可以先了解 APP 的功能,\n收到机器人后随时绑定使用。',
|
||||
l10n.translate('device_list_v2.no_device_desc'),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: _grayText,
|
||||
height: 1.6,
|
||||
@@ -97,9 +102,9 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
const SizedBox(height: 20),
|
||||
_buildAddButton(context),
|
||||
const SizedBox(height: 30),
|
||||
const Text(
|
||||
'新手入门',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
l10n.translate('device_list_v2.guide_title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
@@ -107,21 +112,24 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildGuideCard(
|
||||
context: context,
|
||||
icon: Icons.list_alt,
|
||||
title: '产品操作指南',
|
||||
subtitle: '了解机器人基础功能和使用流程',
|
||||
title: l10n.translate('device_list_v2.guide1_title'),
|
||||
subtitle: l10n.translate('device_list_v2.guide1_desc'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildGuideCard(
|
||||
context: context,
|
||||
icon: Icons.videocam_outlined,
|
||||
title: '观看产品视频',
|
||||
subtitle: '快速上手遥控、图传及作业功能',
|
||||
title: l10n.translate('device_list_v2.guide2_title'),
|
||||
subtitle: l10n.translate('device_list_v2.guide2_desc'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildGuideCard(
|
||||
context: context,
|
||||
icon: Icons.help_outline,
|
||||
title: '帮助与售后服务',
|
||||
subtitle: '常见问题、报修及客服支持',
|
||||
title: l10n.translate('device_list_v2.guide3_title'),
|
||||
subtitle: l10n.translate('device_list_v2.guide3_desc'),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
@@ -145,7 +153,10 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
_buildTopIconButton(Icons.notifications_none, onTap: _todoTap),
|
||||
_buildTopIconButton(
|
||||
Icons.notifications_none,
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
// 设计稿:右上角 ⊕ 是蓝底白号主色按钮,与铃铛的白底按钮区分
|
||||
_buildTopIconButton(
|
||||
@@ -201,7 +212,10 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
return BlocBuilder<SiteCubit, SiteState>(
|
||||
bloc: GetIt.I<SiteCubit>(),
|
||||
builder: (context, siteState) {
|
||||
final name = siteState.selectedSite?.siteName ?? '未选择场站';
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final name =
|
||||
siteState.selectedSite?.siteName ??
|
||||
l10n.translate('device_list_v2.no_site_selected');
|
||||
return Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: GestureDetector(
|
||||
@@ -213,7 +227,13 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
isPersonal ? '($name)· 个人账号' : '($name)',
|
||||
isPersonal
|
||||
? l10n
|
||||
.translate('device_list_v2.site_suffix_personal')
|
||||
.replaceAll('%s', name)
|
||||
: l10n
|
||||
.translate('device_list_v2.site_suffix')
|
||||
.replaceAll('%s', name),
|
||||
style: const TextStyle(fontSize: 12, color: _grayText),
|
||||
),
|
||||
if (!isPersonal)
|
||||
@@ -232,12 +252,19 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
}
|
||||
|
||||
void _onSiteTap(BuildContext context, SiteState siteState, bool isPersonal) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
if (isPersonal) {
|
||||
CapsuleToast.show('个人账号仅绑定一个场站', showCheck: false);
|
||||
CapsuleToast.show(
|
||||
l10n.translate('device_list_v2.personal_single_site'),
|
||||
showCheck: false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (siteState.sites.isEmpty) {
|
||||
CapsuleToast.show('暂无场站数据', showCheck: false);
|
||||
CapsuleToast.show(
|
||||
l10n.translate('device_list_v2.no_site_data'),
|
||||
showCheck: false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
final siteCubit = GetIt.I<SiteCubit>();
|
||||
@@ -252,12 +279,12 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 14),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'选择场站',
|
||||
style: TextStyle(
|
||||
l10n.translate('device_list_v2.select_site'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
@@ -374,14 +401,16 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Row(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.add, color: Colors.white, size: 20),
|
||||
SizedBox(width: 8),
|
||||
const Icon(Icons.add, color: Colors.white, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'添加机器人',
|
||||
style: TextStyle(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.add_robot'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
@@ -410,11 +439,13 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
padding: const EdgeInsets.fromLTRB(16, 14, 8, 4),
|
||||
child: Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'添加机器人',
|
||||
style: TextStyle(
|
||||
AppLocalizations.of(
|
||||
sheetCtx,
|
||||
).translate('device_list_v2.add_robot'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
@@ -435,7 +466,9 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
),
|
||||
_sheetItem(
|
||||
icon: Icons.qr_code_scanner,
|
||||
label: '扫一扫',
|
||||
label: AppLocalizations.of(
|
||||
sheetCtx,
|
||||
).translate('device_list_v2.scan_action'),
|
||||
onTap: () async {
|
||||
Navigator.pop(sheetCtx);
|
||||
final result = await Navigator.of(context).push<String>(
|
||||
@@ -459,17 +492,21 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
_sheetDivider(),
|
||||
_sheetItem(
|
||||
icon: Icons.add_circle_outline,
|
||||
label: '添加设备',
|
||||
label: AppLocalizations.of(
|
||||
sheetCtx,
|
||||
).translate('device_list_v2.add_device'),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetCtx);
|
||||
// 原菜单该项即为 TODO,保持不跳转
|
||||
_todoTap();
|
||||
_todoTap(context);
|
||||
},
|
||||
),
|
||||
_sheetDivider(),
|
||||
_sheetItem(
|
||||
icon: Icons.videocam_outlined,
|
||||
label: '本地视频',
|
||||
label: AppLocalizations.of(
|
||||
sheetCtx,
|
||||
).translate('device_list_v2.local_video'),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetCtx);
|
||||
Navigator.of(context).push(
|
||||
@@ -480,7 +517,9 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
_sheetDivider(),
|
||||
_sheetItem(
|
||||
icon: Icons.usb,
|
||||
label: 'USB 摄像头',
|
||||
label: AppLocalizations.of(
|
||||
sheetCtx,
|
||||
).translate('device_list_v2.usb_camera'),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetCtx);
|
||||
Navigator.of(context).push(
|
||||
@@ -525,12 +564,13 @@ class NoDevicePageV2 extends StatelessWidget {
|
||||
|
||||
// ===== 新手入门卡片:二级未开发,统一提示 =====
|
||||
Widget _buildGuideCard({
|
||||
required BuildContext context,
|
||||
required IconData icon,
|
||||
required String title,
|
||||
required String subtitle,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: _todoTap,
|
||||
onTap: () => _todoTap(context),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
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/capsule_toast.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
|
||||
import '../../data/models/robot_data_model.dart';
|
||||
import '../cubit/find_robot_cubit.dart';
|
||||
import '../cubit/find_robot_state.dart';
|
||||
import 'robot_summary_card_v2.dart';
|
||||
|
||||
/// 一键寻车底部弹窗(设计稿:设备控制 → 一键寻车)
|
||||
///
|
||||
/// 多处复用:全部功能中心、设备详情页、控制页都可以直接调用。
|
||||
/// 寻车指令下发通道尚未接入,未注入回调时统一给出明确提示,不假装成功。
|
||||
/// 启动寻车已接入真实接口(GET /iot/host/searchDevice,deviceId=设备编码),
|
||||
/// 走 FindRobotCubit → UseCase → Repository → DataSource;停止/地图入口仍为占位。
|
||||
Future<void> showFindRobotSheet(
|
||||
BuildContext context, {
|
||||
required RobotDataModel robot,
|
||||
@@ -22,12 +28,15 @@ Future<void> showFindRobotSheet(
|
||||
backgroundColor: Colors.transparent,
|
||||
isScrollControlled: true,
|
||||
barrierColor: const Color(0x8C0B1B2B),
|
||||
builder: (_) => _FindRobotSheet(
|
||||
robot: robot,
|
||||
gnssValid: gnssValid ?? robot.isOnline,
|
||||
onOpenMap: onOpenMap,
|
||||
onStartFind: onStartFind,
|
||||
onStopFind: onStopFind,
|
||||
builder: (_) => BlocProvider(
|
||||
create: (_) => GetIt.I<FindRobotCubit>(),
|
||||
child: _FindRobotSheet(
|
||||
robot: robot,
|
||||
gnssValid: gnssValid ?? robot.isOnline,
|
||||
onOpenMap: onOpenMap,
|
||||
onStartFind: onStartFind,
|
||||
onStopFind: onStopFind,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -61,39 +70,81 @@ class _FindRobotSheet extends StatelessWidget {
|
||||
bool get _online => robot.isOnline;
|
||||
|
||||
void _handleStart(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
if (!_online) {
|
||||
CapsuleToast.show('设备离线,无法触发声光寻车', showCheck: false);
|
||||
CapsuleToast.show(
|
||||
l10n.translate('device_list_v2.fr_toast_offline'),
|
||||
showCheck: false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
// 外部显式注入回调时优先使用(保留自定义下发通道的能力)
|
||||
if (onStartFind != null) {
|
||||
onStartFind!();
|
||||
return;
|
||||
}
|
||||
CapsuleToast.show('声光寻车指令下发未接入', showCheck: false);
|
||||
// 一键寻车:deviceId 传设备编码(deviceName,MC700- 开头),
|
||||
// 不是 getSiteList 的数字主键 robot.id;deviceName 异常为空时回退 id 兜底。
|
||||
final deviceCode = robot.name.isNotEmpty ? robot.name : robot.id;
|
||||
context.read<FindRobotCubit>().startFind(deviceCode: deviceCode);
|
||||
}
|
||||
|
||||
void _handleStop() {
|
||||
if (onStopFind != null) {
|
||||
onStopFind!();
|
||||
/// 寻车下发结果:成功/失败均弹提示并复位,避免重复触发
|
||||
void _handleFindState(BuildContext context, FindRobotState state) {
|
||||
if (state.isSubmitting) return;
|
||||
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final cubit = context.read<FindRobotCubit>();
|
||||
|
||||
if (state.isSuccess) {
|
||||
CapsuleToast.show(l10n.translate('device_list_v2.fr_toast_start_sent'));
|
||||
cubit.reset();
|
||||
return;
|
||||
}
|
||||
CapsuleToast.show('停止寻车指令下发未接入', showCheck: false);
|
||||
|
||||
final message = state.errorMessage;
|
||||
if (message == null) return;
|
||||
CapsuleToast.show(
|
||||
message.isEmpty
|
||||
? l10n.translate('device_list_v2.fr_toast_start_failed')
|
||||
: message,
|
||||
showCheck: false,
|
||||
);
|
||||
cubit.reset();
|
||||
}
|
||||
|
||||
// 一键寻车为一次性下发,无「停止」语义,停止按钮已按需求注释掉(方法一并保留注释备恢复)。
|
||||
// void _handleStop(BuildContext context) {
|
||||
// if (onStopFind != null) {
|
||||
// onStopFind!();
|
||||
// return;
|
||||
// }
|
||||
// CapsuleToast.show(
|
||||
// AppLocalizations.of(context).translate('device_list_v2.fr_toast_stop_todo'),
|
||||
// showCheck: false,
|
||||
// );
|
||||
// }
|
||||
|
||||
void _handleOpenMap(BuildContext context) {
|
||||
if (onOpenMap != null) {
|
||||
onOpenMap!();
|
||||
return;
|
||||
}
|
||||
CapsuleToast.show('地图定位入口暂未接入', showCheck: false);
|
||||
CapsuleToast.show(
|
||||
AppLocalizations.of(context).translate('device_list_v2.fr_toast_map_todo'),
|
||||
showCheck: false,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final model = RobotSummaryCardV2.modelOf(robot);
|
||||
return SafeArea(
|
||||
top: false,
|
||||
child: Container(
|
||||
return BlocListener<FindRobotCubit, FindRobotState>(
|
||||
listener: _handleFindState,
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
|
||||
@@ -107,10 +158,10 @@ class _FindRobotSheet extends StatelessWidget {
|
||||
// 标题行
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
Expanded(
|
||||
child: Text(
|
||||
'一键寻车',
|
||||
style: TextStyle(
|
||||
l10n.translate('device_list_v2.fr_title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
@@ -163,7 +214,7 @@ class _FindRobotSheet extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
'${gnssValid ? 'GNSS定位有效' : 'GNSS定位无效'} · $model 标准版',
|
||||
'${gnssValid ? l10n.translate('device_list_v2.fr_gnss_valid') : l10n.translate('device_list_v2.fr_gnss_invalid')} · ${l10n.translate('device_list_v2.fr_model_std').replaceAll('%s', model)}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontSize: 12, color: _gray),
|
||||
@@ -181,7 +232,9 @@ class _FindRobotSheet extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(9),
|
||||
),
|
||||
child: Text(
|
||||
_online ? '在线' : '离线',
|
||||
_online
|
||||
? l10n.translate('device_list_v2.online')
|
||||
: l10n.translate('device_list_v2.offline'),
|
||||
style: TextStyle(
|
||||
fontSize: 10.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -219,22 +272,25 @@ class _FindRobotSheet extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const Expanded(
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'在地图中查看机器人',
|
||||
style: TextStyle(
|
||||
l10n.translate('device_list_v2.fr_map_entry'),
|
||||
style: const TextStyle(
|
||||
fontSize: 14.5,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'定位位置与最后更新时间',
|
||||
style: TextStyle(fontSize: 12, color: _gray),
|
||||
l10n.translate('device_list_v2.fr_map_entry_sub'),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: _gray,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -260,25 +316,32 @@ class _FindRobotSheet extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'声光寻车',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
l10n.translate('device_list_v2.fr_sound_title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'触发蜂鸣与指示灯,帮助现场人员找到设备;默认自动停止。',
|
||||
style: TextStyle(fontSize: 12, height: 1.5, color: _gray),
|
||||
Text(
|
||||
l10n.translate('device_list_v2.fr_sound_desc'),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
height: 1.5,
|
||||
color: _gray,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
'自动结束',
|
||||
style: TextStyle(fontSize: 12.5, color: _gray),
|
||||
Text(
|
||||
l10n.translate('device_list_v2.fr_auto_stop'),
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5,
|
||||
color: _gray,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Container(
|
||||
@@ -290,9 +353,9 @@ class _FindRobotSheet extends StatelessWidget {
|
||||
color: _softBlue,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Text(
|
||||
'10秒(示例)',
|
||||
style: TextStyle(
|
||||
child: Text(
|
||||
l10n.translate('device_list_v2.fr_auto_stop_value'),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _blue,
|
||||
@@ -324,18 +387,18 @@ class _FindRobotSheet extends StatelessWidget {
|
||||
]
|
||||
: null,
|
||||
),
|
||||
child: const Row(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
const Icon(
|
||||
Icons.volume_up_rounded,
|
||||
size: 19,
|
||||
color: Colors.white,
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'启动寻车提示',
|
||||
style: TextStyle(
|
||||
l10n.translate('device_list_v2.fr_start'),
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
@@ -345,38 +408,43 @@ class _FindRobotSheet extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// 停止寻车
|
||||
GestureDetector(
|
||||
onTap: _handleStop,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
height: 48,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: _blue, width: 1.2),
|
||||
),
|
||||
child: const Text(
|
||||
'停止寻车',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _blue,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 停止寻车:一次性下发无停止语义,按需求注释掉该按钮。
|
||||
// const SizedBox(height: 10),
|
||||
// GestureDetector(
|
||||
// onTap: () => _handleStop(context),
|
||||
// behavior: HitTestBehavior.opaque,
|
||||
// child: Container(
|
||||
// height: 48,
|
||||
// alignment: Alignment.center,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// borderRadius: BorderRadius.circular(12),
|
||||
// border: Border.all(color: _blue, width: 1.2),
|
||||
// ),
|
||||
// child: Text(
|
||||
// l10n.translate('device_list_v2.fr_stop'),
|
||||
// style: const TextStyle(
|
||||
// fontSize: 15,
|
||||
// fontWeight: FontWeight.w700,
|
||||
// color: _blue,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
const SizedBox(height: 12),
|
||||
const Text(
|
||||
'设备离线时不可触发声光寻车,只能查看最后已知位置。',
|
||||
style: TextStyle(fontSize: 11.5, height: 1.5, color: _hint),
|
||||
Text(
|
||||
l10n.translate('device_list_v2.fr_note'),
|
||||
style: const TextStyle(
|
||||
fontSize: 11.5,
|
||||
height: 1.5,
|
||||
color: _hint,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ 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/my/presentation/pages/help_feedback_page.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/profile_detail_page.dart';
|
||||
@@ -41,14 +42,20 @@ class MyPageV2 extends StatelessWidget {
|
||||
static const _cardBorder = Color(0xFFE9F1FA);
|
||||
|
||||
/// 未实现入口的统一提示
|
||||
static void _todoTap() {
|
||||
CapsuleToast.show('功能暂未开发', showCheck: false);
|
||||
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<AppUserCubit>().state.user;
|
||||
final userName = user?.nickname ?? user?.username ?? 'SATA用户';
|
||||
final userName =
|
||||
user?.nickname ??
|
||||
user?.username ??
|
||||
AppLocalizations.of(context).translate('my_v2.default_user_name');
|
||||
final userContact = user?.email ?? user?.phone;
|
||||
|
||||
return Scaffold(
|
||||
@@ -100,21 +107,25 @@ class MyPageV2 extends StatelessWidget {
|
||||
const SizedBox(height: 14),
|
||||
_buildStatsRow(context),
|
||||
const SizedBox(height: 22),
|
||||
_buildSectionTitle('服务支持'),
|
||||
_buildSectionTitle(
|
||||
AppLocalizations.of(context).translate('my_v2.service_support'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildServiceGroup(context),
|
||||
const SizedBox(height: 22),
|
||||
_buildSectionTitle('账户与设置'),
|
||||
_buildSectionTitle(
|
||||
AppLocalizations.of(context).translate('my_v2.account_settings'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildAccountGroup(context),
|
||||
const SizedBox(height: 16),
|
||||
_buildNoteCard(),
|
||||
_buildNoteCard(context),
|
||||
const SizedBox(height: 14),
|
||||
// 页脚灰字(设计稿)
|
||||
const Center(
|
||||
Center(
|
||||
child: Text(
|
||||
'设计原型 · 数据仅供演示 · 不连接真实设备或账号',
|
||||
style: TextStyle(fontSize: 11, color: _grayText),
|
||||
AppLocalizations.of(context).translate('my_v2.footer_note'),
|
||||
style: const TextStyle(fontSize: 11, color: _grayText),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
@@ -142,7 +153,10 @@ class MyPageV2 extends StatelessWidget {
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
_buildTopIconButton(Icons.notifications_none, onTap: _todoTap),
|
||||
_buildTopIconButton(
|
||||
Icons.notifications_none,
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
_buildTopIconButton(
|
||||
Icons.settings_outlined,
|
||||
@@ -184,6 +198,7 @@ class MyPageV2 extends StatelessWidget {
|
||||
String? userContact,
|
||||
String? avatarUrl,
|
||||
) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return GestureDetector(
|
||||
onTap: () => _push(context, const ProfileDetailPage()),
|
||||
// 切图自身已烘进圆角、细描边与透明留白:不能再套 ClipRRect+cover,
|
||||
@@ -228,24 +243,24 @@ class MyPageV2 extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
'个人账号 · ${userContact ?? '未设置联系方式'}',
|
||||
'${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),
|
||||
const Row(
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'编辑个人资料',
|
||||
style: TextStyle(
|
||||
l10n.translate('my_v2.edit_profile'),
|
||||
style: const TextStyle(
|
||||
fontSize: 13.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _primaryBlue,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
const Icon(
|
||||
Icons.chevron_right,
|
||||
size: 16,
|
||||
color: _primaryBlue,
|
||||
@@ -288,15 +303,16 @@ class MyPageV2 extends StatelessWidget {
|
||||
|
||||
// ===== 三个数据卡 =====
|
||||
Widget _buildStatsRow(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildStatCard(
|
||||
icon: Icons.assignment_outlined,
|
||||
iconColor: _primaryBlue,
|
||||
value: '未知',
|
||||
label: '处理中工单',
|
||||
onTap: _todoTap,
|
||||
value: l10n.translate('my_v2.unknown'),
|
||||
label: l10n.translate('my_v2.stat_processing_order'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
@@ -304,9 +320,9 @@ class MyPageV2 extends StatelessWidget {
|
||||
child: _buildStatCard(
|
||||
icon: Icons.build_outlined,
|
||||
iconColor: _orange,
|
||||
value: '未知',
|
||||
label: '保养提醒',
|
||||
onTap: _todoTap,
|
||||
value: l10n.translate('my_v2.unknown'),
|
||||
label: l10n.translate('my_v2.stat_maintenance_reminder'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
@@ -314,8 +330,8 @@ class MyPageV2 extends StatelessWidget {
|
||||
child: _buildStatCard(
|
||||
icon: Icons.article_outlined,
|
||||
iconColor: _primaryBlue,
|
||||
value: '教程',
|
||||
label: '使用与帮助',
|
||||
value: l10n.translate('my_v2.stat_tutorial'),
|
||||
label: l10n.translate('my_v2.stat_usage_help'),
|
||||
onTap: () => _push(context, const HelpFeedbackPage()),
|
||||
),
|
||||
),
|
||||
@@ -399,64 +415,66 @@ class MyPageV2 extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildServiceGroup(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return _buildGroupCard([
|
||||
_buildMenuRow(
|
||||
icon: Icons.headset_mic_outlined,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: '售后服务中心',
|
||||
subtitle: '报修、工单、保修查询',
|
||||
onTap: _todoTap,
|
||||
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: '维修保养',
|
||||
subtitle: '保养计划、提醒与维护记录',
|
||||
onTap: _todoTap,
|
||||
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: '帮助与操作指南',
|
||||
subtitle: '产品说明书、教程及常见问题',
|
||||
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: '账号与安全',
|
||||
subtitle: '邮箱/手机、密码及登录设备',
|
||||
onTap: _todoTap,
|
||||
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: '消息通知',
|
||||
subtitle: '设备、作业、服务及授权消息',
|
||||
title: l10n.translate('my_v2.message_notice'),
|
||||
subtitle: l10n.translate('my_v2.message_notice_desc'),
|
||||
// 未读接口暂无,按约定显示「未知」
|
||||
trailingText: '未读未知',
|
||||
onTap: _todoTap,
|
||||
trailingText: l10n.translate('my_v2.unread_unknown'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.settings_outlined,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: '通用设置',
|
||||
subtitle: '语言、单位、地区及APP偏好',
|
||||
title: l10n.translate('my_v2.general_settings'),
|
||||
subtitle: l10n.translate('my_v2.general_settings_desc'),
|
||||
onTap: () => _push(context, const SystemSettingsPage()),
|
||||
),
|
||||
_buildRowDivider(),
|
||||
@@ -464,9 +482,9 @@ class MyPageV2 extends StatelessWidget {
|
||||
icon: Icons.info_outline,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: '关于与法律协议',
|
||||
subtitle: 'APP版本、协议和隐私政策',
|
||||
onTap: _todoTap,
|
||||
title: l10n.translate('my_v2.about_legal'),
|
||||
subtitle: l10n.translate('my_v2.about_legal_desc'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
]);
|
||||
}
|
||||
@@ -535,7 +553,7 @@ class MyPageV2 extends StatelessWidget {
|
||||
}
|
||||
|
||||
// ===== 底部说明卡(设计稿原文) =====
|
||||
Widget _buildNoteCard() {
|
||||
Widget _buildNoteCard(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(14),
|
||||
@@ -543,9 +561,9 @@ class MyPageV2 extends StatelessWidget {
|
||||
color: _noteBg,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Text(
|
||||
'设备共享、成员授权、管理员移交与解绑转让沿用「设备」模块已有流程,本模块不重复开发。',
|
||||
style: TextStyle(fontSize: 12.5, color: _subText, height: 1.6),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('my_v2.note_card'),
|
||||
style: const TextStyle(fontSize: 12.5, color: _subText, height: 1.6),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -555,13 +573,13 @@ class MyPageV2 extends StatelessWidget {
|
||||
return GestureDetector(
|
||||
onTap: () => _showLogoutDialog(context),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: const SizedBox(
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
height: 44,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'退出登录',
|
||||
style: TextStyle(
|
||||
AppLocalizations.of(context).translate('my_v2.logout'),
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFFF53F3F),
|
||||
@@ -573,15 +591,16 @@ class MyPageV2 extends StatelessWidget {
|
||||
}
|
||||
|
||||
void _showLogoutDialog(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: const Text('退出登录'),
|
||||
content: const Text('确定要退出登录吗?'),
|
||||
title: Text(l10n.translate('my_v2.logout')),
|
||||
content: Text(l10n.translate('my_v2.logout_confirm')),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: const Text('取消'),
|
||||
child: Text(l10n.translate('my_v2.cancel')),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
@@ -595,7 +614,7 @@ class MyPageV2 extends StatelessWidget {
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: const Color(0xFFF53F3F),
|
||||
),
|
||||
child: const Text('确定'),
|
||||
child: Text(l10n.translate('my_v2.confirm')),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user