机器人的列表接口

This commit is contained in:
2026-06-01 17:33:16 +08:00
parent 9154174614
commit 93e69a5e4b
23 changed files with 1312 additions and 269 deletions

View File

@@ -32,7 +32,7 @@ class RobotChecklist extends StatelessWidget {
color: Color(0xFF1D2129),
),
),
const SizedBox(height: 8),
const SizedBox(height: 6),
_buildCheckItem('逆变器', true),
_buildCheckItem('汇流箱', true),
_buildCheckItem('支架结构', true),
@@ -45,7 +45,7 @@ class RobotChecklist extends StatelessWidget {
Widget _buildCheckItem(String label, bool isDone, {bool isWarning = false}) {
return Padding(
padding: const EdgeInsets.only(bottom: 8),
padding: const EdgeInsets.only(bottom: 6),
child: Row(
children: [
Expanded(

View File

@@ -1,4 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../../../../core/di/injection.dart';
import '../../../../devices/presentation/bloc/devices_cubit.dart';
import '../../../../devices/domain/entities/device_entity.dart';
import '../../../../remote_control/presentation/bloc/remote_control_cubit.dart';
import '../../../../remote_control/presentation/pages/remote_control_page.dart';
/// 机器人控制面板
class RobotControlPanel extends StatelessWidget {
@@ -8,7 +14,46 @@ class RobotControlPanel extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
return GestureDetector(
onTap: () {
debugPrint('👆 控制面板被点击');
debugPrint('📋 robot 数据: $robot');
// 1. 将当前机器人设置为全局选中设备
final device = DeviceEntity(
deviceName: robot['name']?.toString() ?? '',
productId: int.tryParse(robot['id']?.toString() ?? '-1') ?? -1,
productName: '割草机产品MC700',
tenantId: 0,
tenantName: '',
status: robot['status'] == '在线' ? 1 : 0,
onlineStatus: robot['status'] == '在线' ? 1 : 0,
);
debugPrint('✅ 设置选中设备: ${device.deviceName}');
context.read<DevicesCubit>().selectDevice(device);
// 打印当前选中的设备信息
final selectedDevice = context.read<DevicesCubit>().state.selectedDevice;
debugPrint('📱 当前选中设备信息:');
debugPrint(' - deviceName: ${selectedDevice?.deviceName}');
debugPrint(' - productName: ${selectedDevice?.productName}');
debugPrint(' - status: ${selectedDevice?.status}');
debugPrint(' - onlineStatus: ${selectedDevice?.onlineStatus}');
// 2. 跳转到远程遥控页面
debugPrint('🚀 准备跳转...');
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BlocProvider(
create: (_) => sl<RemoteControlCubit>()..startControlLoop(),
child: const RemoteControlPage(),
),
),
);
},
child: Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.white,
@@ -124,6 +169,7 @@ class RobotControlPanel extends StatelessWidget {
),
],
),
),
);
}

View File

@@ -26,31 +26,30 @@ class RobotHeaderCard extends StatelessWidget {
children: [
Row(
children: [
Text(
robot['name'] as String,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Color(0xFF1D2129),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
robot['name'] as String,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Color(0xFF1D2129),
),
),
const SizedBox(height: 4),
Text(
'ID: ${robot['id']}',
style: const TextStyle(
fontSize: 12,
color: Color(0xFF86909C),
),
),
],
),
),
const SizedBox(width: 8),
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: const Color(0xFF00B42A).withOpacity(0.1),
borderRadius: BorderRadius.circular(4),
),
child: const Text(
'在线',
style: TextStyle(
fontSize: 12,
color: Color(0xFF00B42A),
fontWeight: FontWeight.w500,
),
),
),
const Spacer(),
// 信号强度
Row(
children: [
@@ -71,6 +70,23 @@ class RobotHeaderCard extends StatelessWidget {
],
),
const SizedBox(width: 12),
// 在线状态
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: const Color(0xFF00B42A).withOpacity(0.1),
borderRadius: BorderRadius.circular(4),
),
child: const Text(
'在线',
style: TextStyle(
fontSize: 12,
color: Color(0xFF00B42A),
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(width: 12),
// 设置图标
const Icon(Icons.settings, size: 20, color: Color(0xFF86909C)),
],

View File

@@ -72,10 +72,12 @@ class RobotItemCard extends StatelessWidget {
Text(
name,
style: const TextStyle(
fontSize: 16,
fontSize: 14,
fontWeight: FontWeight.bold,
color: Color(0xFF1D2129),
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 4),
Text(

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import '../../../../home/presentation/pages/running_status_page.dart';
/// 机器人状态栏
class RobotStatusBar extends StatelessWidget {
@@ -8,47 +9,69 @@ class RobotStatusBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: const [
BoxShadow(
color: Color(0x0D000000),
blurRadius: 8,
offset: Offset(0, 2),
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const RunningStatusPage(),
),
],
),
child: Row(
children: [
_buildStatusItem(
label: '速度',
value: '1.2',
unit: 'm/s',
),
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
_buildStatusItem(
label: '里程',
value: '2.36',
unit: 'km',
),
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
_buildStatusItem(
label: '电量',
value: '82',
unit: '%',
valueColor: const Color(0xFF00B42A),
),
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
_buildStatusItem(
label: '信号',
value: '强',
unit: '',
valueColor: const Color(0xFF00B42A),
),
],
);
},
child: Container(
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: const [
BoxShadow(
color: Color(0x0D000000),
blurRadius: 8,
offset: Offset(0, 2),
),
],
),
child: Row(
children: [
Expanded(
child: Row(
children: [
_buildStatusItem(
label: '速度',
value: '1.2',
unit: 'm/s',
),
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
_buildStatusItem(
label: '里程',
value: '2.36',
unit: 'km',
),
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
_buildStatusItem(
label: '电量',
value: '82',
unit: '%',
valueColor: const Color(0xFF00B42A),
),
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
_buildStatusItem(
label: '信号',
value: '强',
unit: '',
valueColor: const Color(0xFF00B42A),
),
],
),
),
const SizedBox(width: 8),
const Icon(
Icons.arrow_forward_ios,
size: 16,
color: Color(0xFF86909C),
),
],
),
),
);
}