1.优化补足了首页下拉刷新中对获取场站接口的加入,确保能够实时获取数据并渲染。
2.优化修改了tcp重连机制,具体操作:断开重连时候不再建立新链接 而是将旧链接重置,并重新发送数据。 3.大面积的给项目中的各个页面 手动接入了多语言的支持。同时也调整了相应带来的问题英文长度较大影响原有的样式的问题,已解决了对应的样式不和谐问题。保证了外观的统一性。 4.给项目中的主要操作加了几个核心的操作比如远程遥控和路径规划添加了双层的保护,设置里安全模式,即在此期间对服务器推送的重复登录操作后的自动退出登录做一个拦截 保证操作的安全性。
This commit is contained in:
@@ -54,7 +54,7 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
allDevices.addAll(result);
|
||||
}
|
||||
|
||||
if (typeFilter != null && typeFilter != '全部') {
|
||||
if (typeFilter != null && typeFilter != 'all') {
|
||||
return allDevices.where((device) => device.type == typeFilter).toList();
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
return DeviceDataModel(
|
||||
deviceId: json['device_sn']?.toString() ?? '',
|
||||
name: json['callsign'] ?? '无人机机场',
|
||||
type: '无人机机场',
|
||||
type: 'drone_station',
|
||||
status: onlineStatus == 1 ? '在线' : '离线',
|
||||
power: (json['capacity_percent'] as num?)?.toDouble() ?? 0,
|
||||
todayEnergy: 0,
|
||||
@@ -150,7 +150,7 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
const DeviceDataModel(
|
||||
deviceId: '10001',
|
||||
name: '逆变器 INV-001',
|
||||
type: '逆变器',
|
||||
type: 'inverter',
|
||||
status: '在线',
|
||||
power: 125.8,
|
||||
todayEnergy: 752.6,
|
||||
@@ -158,7 +158,7 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
const DeviceDataModel(
|
||||
deviceId: '10002',
|
||||
name: '逆变器 INV-002',
|
||||
type: '逆变器',
|
||||
type: 'inverter',
|
||||
status: '在线',
|
||||
power: 118.6,
|
||||
todayEnergy: 698.2,
|
||||
@@ -166,7 +166,7 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
const DeviceDataModel(
|
||||
deviceId: '10003',
|
||||
name: '汇流箱 SCB-001',
|
||||
type: '汇流箱',
|
||||
type: 'combiner_box',
|
||||
status: '在线',
|
||||
power: 0,
|
||||
todayEnergy: 0,
|
||||
@@ -176,7 +176,7 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
const DeviceDataModel(
|
||||
deviceId: '10004',
|
||||
name: '组件组串 STR-001',
|
||||
type: '组件',
|
||||
type: 'module',
|
||||
status: '在线',
|
||||
power: 85.3,
|
||||
todayEnergy: 0,
|
||||
@@ -185,7 +185,7 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
const DeviceDataModel(
|
||||
deviceId: '10005',
|
||||
name: '监控 MON-001',
|
||||
type: '监控',
|
||||
type: 'monitor',
|
||||
status: '离线',
|
||||
power: 0,
|
||||
todayEnergy: 0,
|
||||
@@ -193,14 +193,14 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
const DeviceDataModel(
|
||||
deviceId: '10006',
|
||||
name: '逆变器 INV-003',
|
||||
type: '逆变器',
|
||||
type: 'inverter',
|
||||
status: '异常',
|
||||
power: 45.2,
|
||||
todayEnergy: 256.8,
|
||||
),
|
||||
];
|
||||
|
||||
if (typeFilter != null && typeFilter != '全部') {
|
||||
if (typeFilter != null && typeFilter != 'all') {
|
||||
return allDevices.where((device) => device.type == typeFilter).toList();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,14 +20,16 @@ class RobotDataModel {
|
||||
|
||||
/// 从 JSON 创建数据模型
|
||||
factory RobotDataModel.fromJson(Map<String, dynamic> json) {
|
||||
final batteryValue = (json['battery'] as num?)?.toDouble() ??
|
||||
(json['capacity_percent'] as num?)?.toDouble() ?? 100.0;
|
||||
|
||||
final batteryValue =
|
||||
(json['battery'] as num?)?.toDouble() ??
|
||||
(json['capacity_percent'] as num?)?.toDouble() ??
|
||||
100.0;
|
||||
|
||||
return RobotDataModel(
|
||||
name: json['deviceName'] ?? json['name'] ?? '',
|
||||
id: json['deviceId']?.toString() ?? json['id']?.toString() ?? '',
|
||||
alias: json['deviceAlias'] as String?, // 获取别名字段
|
||||
type: json['deviceTypeName'] ?? json['type'] ?? '未知类型',
|
||||
type: _convertType(json['deviceTypeName'] ?? json['type'] ?? '未知类型'),
|
||||
status: _getStatusText(json['status'] ?? 0),
|
||||
battery: batteryValue,
|
||||
task: json['task'] ?? json['currentTask'] ?? '待机中',
|
||||
@@ -60,4 +62,15 @@ class RobotDataModel {
|
||||
return '未知';
|
||||
}
|
||||
}
|
||||
|
||||
static String _convertType(String type) {
|
||||
if (type.contains('巡检')) {
|
||||
return 'inspection';
|
||||
} else if (type.contains('清洗')) {
|
||||
return 'cleaning';
|
||||
} else if (type.contains('除草')) {
|
||||
return 'weeding';
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
|
||||
try {
|
||||
final response = await getDeviceStatusDataUseCase.execute(
|
||||
siteId: currentState.siteId,
|
||||
typeFilter: currentState.selectedType == '全部'
|
||||
typeFilter: currentState.selectedType == 'all'
|
||||
? null
|
||||
: currentState.selectedType,
|
||||
);
|
||||
|
||||
@@ -27,7 +27,7 @@ class DeviceStatusLoaded extends DeviceStatusState {
|
||||
const DeviceStatusLoaded({
|
||||
required this.deviceStatus,
|
||||
required this.devices,
|
||||
this.selectedType = '全部',
|
||||
this.selectedType = 'all',
|
||||
this.searchKeyword = '',
|
||||
this.siteId,
|
||||
});
|
||||
|
||||
@@ -34,10 +34,12 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
final result = await getDroneStationListUseCase(event.siteId);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(DroneStationError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(failure) => emit(
|
||||
DroneStationError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
),
|
||||
),
|
||||
(stations) => emit(DroneStationLoaded(stations)),
|
||||
);
|
||||
}
|
||||
@@ -50,10 +52,12 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
final result = await getDroneStationListUseCase(event.siteId);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(DroneStationError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(failure) => emit(
|
||||
DroneStationError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
),
|
||||
),
|
||||
(stations) => emit(DroneStationLoaded(stations)),
|
||||
);
|
||||
}
|
||||
@@ -68,10 +72,12 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
final result = await getUAVDetailUseCase(event.gatewaySn, event.deviceSn);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(UAVDetailError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(failure) => emit(
|
||||
UAVDetailError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
),
|
||||
),
|
||||
(detail) => emit(UAVDetailLoaded(detail)),
|
||||
);
|
||||
}
|
||||
@@ -89,11 +95,14 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(VideoStreamError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(videoStream) => emit(VideoStreamLoaded(videoStream, event.cameraPosition)),
|
||||
(failure) => emit(
|
||||
VideoStreamError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
),
|
||||
),
|
||||
(videoStream) =>
|
||||
emit(VideoStreamLoaded(videoStream, event.cameraPosition)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -113,15 +122,19 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(UavVideoStreamError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(videoStream) => emit(UavVideoStreamLoaded(
|
||||
videoStream: videoStream,
|
||||
cameraIndex: event.cameraIndex,
|
||||
lensType: event.lensType,
|
||||
)),
|
||||
(failure) => emit(
|
||||
UavVideoStreamError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
),
|
||||
),
|
||||
(videoStream) => emit(
|
||||
UavVideoStreamLoaded(
|
||||
videoStream: videoStream,
|
||||
cameraIndex: event.cameraIndex,
|
||||
lensType: event.lensType,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,44 +18,30 @@ class FloatBarSettingService {
|
||||
|
||||
FloatBarSettingService(this._prefs) {
|
||||
_instance = this;
|
||||
// 从持久化读取初始状态
|
||||
_isEnabled = _prefs.getBool(_key) ?? true;
|
||||
_settingNotifier.value = _isEnabled;
|
||||
print('✅ [FloatBarSettingService] 初始化完成,初始状态: $_isEnabled');
|
||||
debugPrint('✅ [FloatBarSettingService] 初始化完成,初始状态: $_isEnabled');
|
||||
}
|
||||
|
||||
/// 获取静态实例
|
||||
static FloatBarSettingService? get instance => _instance;
|
||||
|
||||
/// 获取 ValueNotifier
|
||||
static ValueNotifier<bool> get settingNotifier => _settingNotifier;
|
||||
|
||||
/// 获取当前是否启用(直接从静态变量读取)
|
||||
static bool get isEnabled => _isEnabled;
|
||||
|
||||
/// 设置是否启用
|
||||
static Future<void> setEnabled(bool enabled) async {
|
||||
print('🔍 [FloatBarSettingService] setEnabled 被调用,新值: $enabled');
|
||||
|
||||
// 1. 更新静态变量
|
||||
debugPrint('🔍 [FloatBarSettingService] setEnabled 被调用,新值: $enabled');
|
||||
_isEnabled = enabled;
|
||||
print('🔍 [FloatBarSettingService] 静态变量已更新: $_isEnabled');
|
||||
|
||||
// 2. 更新 ValueNotifier(通知所有监听者)
|
||||
_settingNotifier.value = enabled;
|
||||
print(
|
||||
'🔍 [FloatBarSettingService] ValueNotifier 已更新: ${_settingNotifier.value}',
|
||||
);
|
||||
|
||||
// 3. 持久化到 SharedPreferences
|
||||
final instance = _instance;
|
||||
if (instance != null) {
|
||||
await instance._prefs.setBool(_key, enabled);
|
||||
print('🔍 [FloatBarSettingService] 已保存到 SharedPreferences');
|
||||
debugPrint('🔍 [FloatBarSettingService] 已保存到 SharedPreferences');
|
||||
}
|
||||
}
|
||||
|
||||
/// 切换开关
|
||||
static Future<void> toggle() async {
|
||||
await setEnabled(!_isEnabled);
|
||||
}
|
||||
|
||||
@@ -37,9 +37,7 @@ class FloatBarManager {
|
||||
hide();
|
||||
}
|
||||
|
||||
_overlayEntry = OverlayEntry(
|
||||
builder: (context) => const FloatBarWidget(),
|
||||
);
|
||||
_overlayEntry = OverlayEntry(builder: (context) => const FloatBarWidget());
|
||||
|
||||
Overlay.of(_globalContext!)?.insert(_overlayEntry!);
|
||||
}
|
||||
@@ -66,4 +64,4 @@ class FloatBarManager {
|
||||
_globalContext = null;
|
||||
_isInitialized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
|
||||
/// 清洗/除草机器人任务详情页
|
||||
class CleaningWeedingRobotTaskPage extends StatelessWidget {
|
||||
@@ -8,8 +9,10 @@ class CleaningWeedingRobotTaskPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isCleaning = robot['type'] == '清洗机器人';
|
||||
final title = isCleaning ? '清洗机器人任务' : '除草机器人任务';
|
||||
final isCleaning = robot['type'] == 'cleaning';
|
||||
final title = isCleaning
|
||||
? AppLocalizations.of(context).translate('device_list_v2.cleaning_robot') + ' ' + AppLocalizations.of(context).translate('device_list_v2.task')
|
||||
: AppLocalizations.of(context).translate('device_list_v2.weeding_robot') + ' ' + AppLocalizations.of(context).translate('device_list_v2.task');
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F6F8),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../../../../../core/di/injection.dart';
|
||||
import '../../../../../core/app/app_user_cubit.dart';
|
||||
import '../../../../../components/tcp_status_indicator.dart';
|
||||
@@ -47,6 +48,16 @@ class DeviceStatusPage extends StatelessWidget {
|
||||
class DeviceStatusView extends StatelessWidget {
|
||||
const DeviceStatusView({super.key});
|
||||
|
||||
/// 🔥 机器人设备名称前缀,用于从通用设备列表中过滤掉机器人
|
||||
static const _robotPrefixes = [
|
||||
'RCHETD-CN',
|
||||
'MC700PLUS-CN',
|
||||
'MC700-CN',
|
||||
'MC700PRO-CN',
|
||||
'RCETD-CN',
|
||||
'MC700AIR-CN',
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
@@ -98,9 +109,9 @@ class DeviceStatusView extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
const Text(
|
||||
'设备状态',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('device_list_v2.title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
@@ -137,7 +148,9 @@ class DeviceStatusView extends StatelessWidget {
|
||||
padding: const EdgeInsets.fromLTRB(16.0, 8, 16.0, 8),
|
||||
child: TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: '搜索设备名称/编号',
|
||||
hintText: AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.search_hint'),
|
||||
hintStyle: const TextStyle(color: Color(0xFF86909C), fontSize: 14),
|
||||
prefixIcon: const Icon(
|
||||
Icons.search,
|
||||
@@ -148,9 +161,9 @@ class DeviceStatusView extends StatelessWidget {
|
||||
onPressed: () {
|
||||
// TODO: 触发搜索
|
||||
},
|
||||
child: const Text(
|
||||
'搜索',
|
||||
style: TextStyle(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('device_list_v2.search'),
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF165DFF),
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -188,14 +201,31 @@ class DeviceStatusView extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildTypeFilterBar(BuildContext context) {
|
||||
final types = ['全部', '机器人', '无人机机场', '逆变器', '汇流箱', '组件', '监控'];
|
||||
final typeCodes = [
|
||||
'all',
|
||||
'robot',
|
||||
'drone_station',
|
||||
'inverter',
|
||||
'combiner_box',
|
||||
'module',
|
||||
'monitor',
|
||||
];
|
||||
final typeLabels = [
|
||||
AppLocalizations.of(context).translate('device_list_v2.all'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.robot'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.drone_station'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.inverter'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.combiner_box'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.module'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.monitor'),
|
||||
];
|
||||
|
||||
return BlocBuilder<
|
||||
DeviceListBloc.DeviceStatusBloc,
|
||||
DeviceListState.DeviceStatusState
|
||||
>(
|
||||
builder: (context, state) {
|
||||
String selectedType = '全部';
|
||||
String selectedType = 'all';
|
||||
if (state is DeviceListState.DeviceStatusLoaded) {
|
||||
selectedType = state.selectedType;
|
||||
}
|
||||
@@ -206,16 +236,17 @@ class DeviceStatusView extends StatelessWidget {
|
||||
scrollDirection: Axis.horizontal,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
itemCount: types.length,
|
||||
itemCount: typeCodes.length,
|
||||
separatorBuilder: (context, index) => const SizedBox(width: 24.0),
|
||||
itemBuilder: (context, index) {
|
||||
final type = types[index];
|
||||
final isSelected = selectedType == type;
|
||||
final typeCode = typeCodes[index];
|
||||
final typeLabel = typeLabels[index];
|
||||
final isSelected = selectedType == typeCode;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
context.read<DeviceListBloc.DeviceStatusBloc>().add(
|
||||
DeviceListEvent.DeviceStatusChangeType(type),
|
||||
DeviceListEvent.DeviceStatusChangeType(typeCode),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
@@ -223,7 +254,7 @@ class DeviceStatusView extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
type,
|
||||
typeLabel,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: isSelected
|
||||
@@ -259,19 +290,16 @@ class DeviceStatusView extends StatelessWidget {
|
||||
BuildContext context,
|
||||
DeviceListState.DeviceStatusState state,
|
||||
) {
|
||||
// 如果选择的是"机器人",显示机器人专属页面
|
||||
if (state is DeviceListState.DeviceStatusLoaded &&
|
||||
state.selectedType == '机器人') {
|
||||
state.selectedType == 'robot') {
|
||||
return const RobotListPage();
|
||||
}
|
||||
|
||||
// 如果选择的是"无人机机场",显示机场列表
|
||||
if (state is DeviceListState.DeviceStatusLoaded &&
|
||||
state.selectedType == '无人机机场') {
|
||||
state.selectedType == 'drone_station') {
|
||||
return _buildDroneStationList(context);
|
||||
}
|
||||
|
||||
// 其他类型显示原有设备列表
|
||||
return _buildDeviceList(context, state);
|
||||
}
|
||||
|
||||
@@ -293,12 +321,24 @@ class DeviceStatusView extends StatelessWidget {
|
||||
}
|
||||
|
||||
if (state is DeviceListState.DeviceStatusLoaded) {
|
||||
// 🔥 先根据类型过滤
|
||||
List filteredByType = state.devices;
|
||||
if (state.selectedType != '全部') {
|
||||
if (state.selectedType != 'all') {
|
||||
filteredByType = state.devices.where((device) {
|
||||
return device.type == state.selectedType;
|
||||
}).toList();
|
||||
} else {
|
||||
// 🔥 "全部"模式下,排除已由专用组件渲染的类型,避免重复展示
|
||||
// drone_station 已通过 _buildDroneStationList 渲染
|
||||
// 机器人(通过名称前缀识别)已通过 _buildEmbeddedRobotList 渲染
|
||||
filteredByType = state.devices.where((device) {
|
||||
if (device.type == 'drone_station') return false;
|
||||
final isRobot = _robotPrefixes.any(
|
||||
(prefix) =>
|
||||
device.name.startsWith(prefix) ||
|
||||
device.deviceId.startsWith(prefix),
|
||||
);
|
||||
return !isRobot;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
// 🔥 再根据搜索关键词过滤
|
||||
@@ -322,19 +362,32 @@ class DeviceStatusView extends StatelessWidget {
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
children: [
|
||||
_buildStatusCard(state),
|
||||
_buildStatusCard(context, state),
|
||||
const SizedBox(height: 20.0),
|
||||
// 🔥 机器人列表(直接复用 RobotListPage 的布局)
|
||||
if (state.selectedType == '全部') _buildEmbeddedRobotList(context),
|
||||
if (state.selectedType == 'all') _buildEmbeddedRobotList(context),
|
||||
// 🔥 无人机机场列表(直接复用 _buildDroneStationList 的布局)
|
||||
if (state.selectedType == '全部')
|
||||
if (state.selectedType == 'all')
|
||||
_buildDroneStationList(context, embedded: true),
|
||||
// 🔥 普通设备列表
|
||||
...filteredDevices
|
||||
.map(
|
||||
(device) => DeviceItemWidget(
|
||||
device: device,
|
||||
onTap: () => _navigateToDeviceDetail(context, device),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return const Center(child: Text('暂无数据'));
|
||||
return Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('device_list_v2.no_data'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 🔥 嵌入式机器人列表(直接复用 RobotListPage 的布局)
|
||||
@@ -428,9 +481,11 @@ class DeviceStatusView extends StatelessWidget {
|
||||
children: [
|
||||
const Icon(Icons.location_off, size: 48, color: Color(0xFF86909C)),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'请先选择场站',
|
||||
style: TextStyle(fontSize: 14, color: Color(0xFF4E5969)),
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.select_site_first'),
|
||||
style: const TextStyle(fontSize: 14, color: Color(0xFF4E5969)),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -471,10 +526,15 @@ class DeviceStatusView extends StatelessWidget {
|
||||
final stations = state.stations;
|
||||
|
||||
if (stations.isEmpty) {
|
||||
return const Center(
|
||||
return Center(
|
||||
child: Text(
|
||||
'该场站暂无无人机机场',
|
||||
style: TextStyle(fontSize: 14, color: Color(0xFF4E5969)),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.no_drone_stations'),
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFF4E5969),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -512,13 +572,20 @@ class DeviceStatusView extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
return const Center(child: Text('暂无数据'));
|
||||
return Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('device_list_v2.no_data'),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusCard(DeviceListState.DeviceStatusLoaded state) {
|
||||
Widget _buildStatusCard(
|
||||
BuildContext context,
|
||||
DeviceListState.DeviceStatusLoaded state,
|
||||
) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -537,28 +604,36 @@ class DeviceStatusView extends StatelessWidget {
|
||||
children: [
|
||||
_buildStatItem(
|
||||
value: state.deviceStatus.total.toString(),
|
||||
label: '全部设备',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.total_devices'),
|
||||
dotColor: const Color(0xFF86909C),
|
||||
textColor: const Color(0xFF86909C), // 新增字体颜色
|
||||
textColor: const Color(0xFF86909C),
|
||||
),
|
||||
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
|
||||
_buildStatItem(
|
||||
value: state.deviceStatus.online.toString(),
|
||||
label: '在线',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.online'),
|
||||
dotColor: const Color(0xFF00B42A),
|
||||
textColor: const Color(0xFF00B42A),
|
||||
),
|
||||
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
|
||||
_buildStatItem(
|
||||
value: state.deviceStatus.exception.toString(),
|
||||
label: '告警',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.alarm'),
|
||||
dotColor: const Color(0xFFFF7D00),
|
||||
textColor: const Color(0xFFFF7D00),
|
||||
),
|
||||
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
|
||||
_buildStatItem(
|
||||
value: state.deviceStatus.offline.toString(),
|
||||
label: '离线',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.offline'),
|
||||
dotColor: const Color(0xFFF53F3F),
|
||||
textColor: const Color(0xFFF53F3F),
|
||||
),
|
||||
@@ -597,11 +672,16 @@ class DeviceStatusView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: textColor ?? const Color(0xFF4E5969),
|
||||
Flexible(
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: textColor ?? const Color(0xFF4E5969),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -646,14 +726,7 @@ class DeviceStatusView extends StatelessWidget {
|
||||
debugPrint('🔍 [DeviceStatusPage] 设备类型: $deviceType');
|
||||
|
||||
// 🔥 判断是否为机器人(根据设备类型前缀)
|
||||
final robotPrefixes = [
|
||||
'RCHETD-CN',
|
||||
'MC700PLUS-CN',
|
||||
'MC700-CN',
|
||||
'MC700PRO-CN',
|
||||
'RCETD-CN',
|
||||
'MC700AIR-CN',
|
||||
];
|
||||
final robotPrefixes = _robotPrefixes;
|
||||
bool isRobot = robotPrefixes.any((prefix) => deviceType.startsWith(prefix));
|
||||
|
||||
// 🔥 判断是否为无人机机场(根据设备类型包含关键字)
|
||||
|
||||
@@ -4,9 +4,13 @@ import 'package:dio/dio.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import '../../../../../core/consts/http_api_consts.dart';
|
||||
import '../../../../../core/di/injection.dart';
|
||||
import '../../../../../core/managers/drone_task_state_manager.dart';
|
||||
import '../../domain/entities/flight_task_entity.dart';
|
||||
import '../../domain/entities/flight_task_detail_entity.dart';
|
||||
import '../../domain/entities/drone_station_entity.dart';
|
||||
import '../../domain/usecases/update_flight_task_status_usecase.dart';
|
||||
import '../bloc/drone_station_bloc.dart';
|
||||
import '../float_bar/view/float_bar_widget.dart';
|
||||
|
||||
/// 无人机任务与航线控制页面
|
||||
class DroneMissionControlPage extends StatefulWidget {
|
||||
@@ -120,11 +124,14 @@ class _DroneMissionControlPageState extends State<DroneMissionControlPage> {
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(failure.message)));
|
||||
},
|
||||
(data) {
|
||||
(data) async {
|
||||
print('✅ [DroneMissionControl] 任务执行成功: $data');
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('任务执行成功')));
|
||||
|
||||
// 🔥 获取无人机详情并设置给 FloatBarWidget
|
||||
await _loadDroneDetailAndSetToFloatBar();
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
@@ -135,6 +142,65 @@ class _DroneMissionControlPageState extends State<DroneMissionControlPage> {
|
||||
}
|
||||
}
|
||||
|
||||
/// 加载无人机详情并设置给 FloatBarWidget
|
||||
Future<void> _loadDroneDetailAndSetToFloatBar() async {
|
||||
if (_detailTask == null || _detailTask!.sn.isEmpty) {
|
||||
print('⚠️ [DroneMissionControl] 任务 SN 为空,无法获取无人机详情');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
print('🔍 [DroneMissionControl] 开始获取无人机详情, sn: ${_detailTask!.sn}');
|
||||
|
||||
final response = await Dio().get(
|
||||
HttpApiConsts.getUAVDetail,
|
||||
queryParameters: {
|
||||
'gatewaySn': _detailTask!.sn, // 机场 SN
|
||||
'deviceSn': '', // 无人机 SN(可选)
|
||||
},
|
||||
);
|
||||
|
||||
print('📡 [DroneMissionControl] 响应状态码: ${response.statusCode}');
|
||||
print('📦 [DroneMissionControl] 响应数据: ${response.data}');
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final Map<String, dynamic> jsonData = (response.data is String)
|
||||
? json.decode(response.data)
|
||||
: Map<String, dynamic>.from(response.data);
|
||||
|
||||
if (jsonData['code'] == 0 || jsonData['code'] == 200) {
|
||||
final detailData = jsonData['data'];
|
||||
final Map<String, dynamic> detailMap = (detailData is Map)
|
||||
? Map<String, dynamic>.from(detailData)
|
||||
: <String, dynamic>{};
|
||||
|
||||
final droneDetail = UAVDetailEntity.fromJson(detailMap);
|
||||
|
||||
print('✅ [DroneMissionControl] 获取无人机详情成功');
|
||||
print(' droneSn: ${droneDetail.deviceSn}');
|
||||
print(' gatewaySn: ${droneDetail.gatewaySn}');
|
||||
print(' cameraList: ${droneDetail.droneCameraList?.length ?? 0}');
|
||||
|
||||
// 创建无人机任务信息
|
||||
final droneTaskInfo = DroneTaskInfo(
|
||||
droneSn: droneDetail.deviceSn,
|
||||
gatewaySn: droneDetail.gatewaySn,
|
||||
cameraList: droneDetail.droneCameraList,
|
||||
);
|
||||
|
||||
// 设置给 FloatBarWidget
|
||||
droneTaskStateManager.setDroneTaskInfo(droneTaskInfo);
|
||||
|
||||
print('✅ [DroneMissionControl] 已设置无人机任务信息到 FloatBarWidget');
|
||||
} else {
|
||||
print('❌ [DroneMissionControl] 获取无人机详情失败: ${jsonData['message']}');
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('❌ [DroneMissionControl] 获取无人机详情异常: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../../../../core/di/injection.dart';
|
||||
import '../../../../../core/managers/drone_task_state_manager.dart';
|
||||
import '../../domain/entities/drone_station_entity.dart';
|
||||
import '../bloc/drone_station_bloc.dart';
|
||||
import '../bloc/drone_station_event.dart';
|
||||
@@ -402,18 +403,36 @@ class _DroneStationDetailPageState extends State<DroneStationDetailPage> {
|
||||
}
|
||||
|
||||
Widget _buildDroneStatusCard(UAVDetailEntity detail) {
|
||||
// 检查无人机是否在线
|
||||
final bool isOnline = detail.droneOnlineStatus == 1;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 扩展功能:无论在线还是离线,都同步到悬浮弹窗
|
||||
debugPrint('👆 [DroneStationDetailPage] 点击无人机状态卡片,同步到悬浮弹窗');
|
||||
debugPrint(' droneSn: ${detail.deviceSn}');
|
||||
debugPrint(' gatewaySn: ${detail.gatewaySn}');
|
||||
debugPrint(' 是否在线: ${isOnline ? '在线' : '离线'}');
|
||||
|
||||
final droneTaskInfo = DroneTaskInfo(
|
||||
droneSn: detail.deviceSn,
|
||||
gatewaySn: detail.gatewaySn,
|
||||
cameraList: detail.droneCameraList,
|
||||
isOnline: isOnline,
|
||||
stationName: detail.callsign,
|
||||
droneName: detail.droneCallsign,
|
||||
);
|
||||
droneTaskStateManager.setDroneTaskInfo(droneTaskInfo);
|
||||
|
||||
// 原有逻辑:跳转到无人机视频控制页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DroneVideoControlPage(
|
||||
droneSn: detail.deviceSn,
|
||||
gatewaySn: detail.gatewaySn,
|
||||
// 使用无人机摄像头列表,如果为null则传空列表
|
||||
cameraList: detail.droneCameraList ?? [],
|
||||
// 传入网关摄像头列表作为备选视频源
|
||||
gatewayCameraList: detail.gatewayCameraList ?? [],
|
||||
cameraList: detail.droneCameraList,
|
||||
gatewayCameraList: detail.gatewayCameraList,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,65 +1,193 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../../../../core/di/injection.dart';
|
||||
import '../../../../../core/managers/drone_task_state_manager.dart';
|
||||
import '../bloc/drone_station_bloc.dart';
|
||||
import '../bloc/drone_station_event.dart';
|
||||
import '../bloc/drone_station_state.dart';
|
||||
import '../../domain/entities/drone_station_entity.dart';
|
||||
import 'drone_video_control_page.dart';
|
||||
|
||||
/// 无人机机场与设备状态页面
|
||||
class DroneStationStatusPage extends StatelessWidget {
|
||||
const DroneStationStatusPage({super.key});
|
||||
/// 支持从机场详情页进入,点击无人机卡片同步视频和轨迹到悬浮弹窗
|
||||
class DroneStationStatusPage extends StatefulWidget {
|
||||
final String? gatewaySn;
|
||||
final String? deviceSn;
|
||||
|
||||
const DroneStationStatusPage({super.key, this.gatewaySn, this.deviceSn});
|
||||
|
||||
@override
|
||||
State<DroneStationStatusPage> createState() => _DroneStationStatusPageState();
|
||||
}
|
||||
|
||||
class _DroneStationStatusPageState extends State<DroneStationStatusPage> {
|
||||
late final DroneStationBloc _bloc;
|
||||
UAVDetailEntity? _uavDetail;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_bloc = sl<DroneStationBloc>();
|
||||
_loadUAVDetail();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_bloc.close();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// 加载无人机详情
|
||||
void _loadUAVDetail() {
|
||||
if (widget.gatewaySn != null && widget.gatewaySn!.isNotEmpty) {
|
||||
_bloc.add(
|
||||
UAVDetailLoad(
|
||||
gatewaySn: widget.gatewaySn!,
|
||||
deviceSn: widget.deviceSn ?? '',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 检查无人机是否在线
|
||||
bool _isDroneOnline() {
|
||||
return _uavDetail != null && _uavDetail!.droneOnlineStatus == 1;
|
||||
}
|
||||
|
||||
/// 点击无人机卡片处理
|
||||
/// 无论在线还是离线,都同步到悬浮弹窗,同时跳转到视频控制页面
|
||||
void _onDroneCardTap() {
|
||||
debugPrint('👆 [DroneStationStatusPage] 点击无人机卡片');
|
||||
|
||||
if (_uavDetail == null) {
|
||||
debugPrint('⚠️ [DroneStationStatusPage] 无人机详情为空');
|
||||
return;
|
||||
}
|
||||
|
||||
// 扩展功能:无论在线还是离线,都同步到悬浮弹窗
|
||||
debugPrint('🛸 [DroneStationStatusPage] 同步无人机信息到悬浮弹窗');
|
||||
debugPrint(' droneSn: ${_uavDetail!.deviceSn}');
|
||||
debugPrint(' gatewaySn: ${_uavDetail!.gatewaySn}');
|
||||
debugPrint(' 是否在线: ${_isDroneOnline() ? '在线' : '离线'}');
|
||||
|
||||
final droneTaskInfo = DroneTaskInfo(
|
||||
droneSn: _uavDetail!.deviceSn,
|
||||
gatewaySn: _uavDetail!.gatewaySn,
|
||||
cameraList: _uavDetail!.droneCameraList,
|
||||
isOnline: _isDroneOnline(),
|
||||
stationName: _uavDetail!.callsign,
|
||||
droneName: _uavDetail!.droneCallsign,
|
||||
);
|
||||
|
||||
debugPrint(' cameraList: ${droneTaskInfo.cameraList?.length ?? 0}');
|
||||
droneTaskStateManager.setDroneTaskInfo(droneTaskInfo);
|
||||
|
||||
// 原有逻辑:跳转到无人机视频控制页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DroneVideoControlPage(
|
||||
droneSn: _uavDetail!.deviceSn,
|
||||
gatewaySn: _uavDetail!.gatewaySn,
|
||||
cameraList: _uavDetail!.droneCameraList,
|
||||
gatewayCameraList: _uavDetail!.gatewayCameraList,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示无人机不在线提示
|
||||
void _showOfflineToast() {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('无人机不在线,无法查看实时视频和轨迹'),
|
||||
duration: Duration(seconds: 2),
|
||||
backgroundColor: Color(0xFFFF7D00),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F6F8),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
// 顶部导航栏
|
||||
SliverAppBar(
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
pinned: true,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Color(0xFF1D2129)),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: const Text(
|
||||
'无人机机场与设备状态',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
return BlocProvider.value(
|
||||
value: _bloc,
|
||||
child: BlocListener<DroneStationBloc, DroneStationState>(
|
||||
listener: (context, state) {
|
||||
if (state is UAVDetailLoaded) {
|
||||
setState(() {
|
||||
_uavDetail = state.detail;
|
||||
});
|
||||
debugPrint('✅ [DroneStationStatusPage] 无人机详情加载成功');
|
||||
debugPrint(
|
||||
' droneOnlineStatus: ${state.detail.droneOnlineStatus}',
|
||||
);
|
||||
debugPrint(' deviceSn: ${state.detail.deviceSn}');
|
||||
debugPrint(' gatewaySn: ${state.detail.gatewaySn}');
|
||||
} else if (state is UAVDetailError) {
|
||||
debugPrint(
|
||||
'❌ [DroneStationStatusPage] 无人机详情加载失败: ${state.message}',
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F6F8),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
// 顶部导航栏
|
||||
SliverAppBar(
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
pinned: true,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Color(0xFF1D2129)),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: const Text(
|
||||
'无人机机场与设备状态',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.notifications_none,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.notifications_none, color: Color(0xFF1D2129)),
|
||||
onPressed: () {},
|
||||
// 内容区域
|
||||
SliverToBoxAdapter(
|
||||
child: Column(
|
||||
children: [
|
||||
ListView(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
// 机场状态卡片
|
||||
_buildAirportStatusCard(),
|
||||
const SizedBox(height: 12),
|
||||
// 无人机状态卡片
|
||||
_buildDroneStatusCard(),
|
||||
const SizedBox(height: 12),
|
||||
// 快捷操作
|
||||
_buildQuickActions(),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 80), // 为底部 Tab 栏留出空间
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// 内容区域
|
||||
SliverToBoxAdapter(
|
||||
child: Column(
|
||||
children: [
|
||||
ListView(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
// 机场状态卡片
|
||||
_buildAirportStatusCard(),
|
||||
const SizedBox(height: 12),
|
||||
// 无人机状态卡片
|
||||
_buildDroneStatusCard(),
|
||||
const SizedBox(height: 12),
|
||||
// 快捷操作
|
||||
_buildQuickActions(),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 80), // 为底部 Tab 栏留出空间
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -91,7 +219,11 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildStatusRow('机场编号', 'AIRPORT-01', status: '正常'),
|
||||
_buildStatusRow(
|
||||
'机场编号',
|
||||
_uavDetail?.gatewaySn ?? 'AIRPORT-01',
|
||||
status: '正常',
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildStatusRow('位置', '升压站旁 - 无人机机场'),
|
||||
const SizedBox(height: 12),
|
||||
@@ -108,87 +240,116 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// 无人机状态卡片
|
||||
/// 点击卡片时只有无人机在线才会同步到悬浮弹窗
|
||||
Widget _buildDroneStatusCard() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
'无人机状态',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF00B42A).withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Text(
|
||||
'在线',
|
||||
final isOnline = _isDroneOnline();
|
||||
|
||||
return GestureDetector(
|
||||
onTap: _onDroneCardTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
'无人机状态',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF00B42A),
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/xunjian.png',
|
||||
width: 60,
|
||||
height: 60,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'无人机 - 01',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
const Spacer(),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: isOnline
|
||||
? const Color(0xFF00B42A).withOpacity(0.1)
|
||||
: const Color(0xFFFF7D00).withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
isOnline ? '在线' : '离线',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isOnline
|
||||
? const Color(0xFF00B42A)
|
||||
: const Color(0xFFFF7D00),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildDroneBatteryRow(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// const SizedBox(height: 12),
|
||||
// _buildStatusRow('飞行模式', '待命'),
|
||||
// const SizedBox(height: 12),
|
||||
// _buildStatusRow('机身状态', '正常'),
|
||||
// const SizedBox(height: 12),
|
||||
// _buildStatusRow('上次任务', '逆变器区巡检(05-20 10:30)'),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/xunjian.png',
|
||||
width: 60,
|
||||
height: 60,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_uavDetail?.droneCallsign ?? '无人机 - 01',
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildDroneBatteryRow(),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
size: 16,
|
||||
color: isOnline
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFFC9CDD4),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
isOnline ? '点击查看实时视频和轨迹' : '无人机离线,无法查看视频和轨迹',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isOnline
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF86909C),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -282,19 +443,12 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: color,
|
||||
size: 24,
|
||||
),
|
||||
child: Icon(icon, color: color, size: 24),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF4E5969),
|
||||
),
|
||||
style: const TextStyle(fontSize: 12, color: Color(0xFF4E5969)),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -307,10 +461,7 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
style: const TextStyle(fontSize: 13, color: Color(0xFF86909C)),
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
@@ -344,15 +495,16 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// 带进度条的状态行
|
||||
Widget _buildStatusRowWithProgress(String label, String value, String progress) {
|
||||
Widget _buildStatusRowWithProgress(
|
||||
String label,
|
||||
String value,
|
||||
String progress,
|
||||
) {
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
style: const TextStyle(fontSize: 13, color: Color(0xFF86909C)),
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
@@ -373,11 +525,7 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 12,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
const Icon(Icons.arrow_forward_ios, size: 12, color: Color(0xFF86909C)),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -388,17 +536,14 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
children: [
|
||||
const Text(
|
||||
'气象条件',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
style: TextStyle(fontSize: 13, color: Color(0xFF86909C)),
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.wb_sunny, size: 16, color: Color(0xFFFF7D00)),
|
||||
const SizedBox(width: 4),
|
||||
const Text(
|
||||
children: const [
|
||||
Icon(Icons.wb_sunny, size: 16, color: Color(0xFFFF7D00)),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
'晴',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
@@ -406,21 +551,15 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
'25°C',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
style: TextStyle(fontSize: 13, color: Color(0xFF1D2129)),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
'东南风 2级',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
style: TextStyle(fontSize: 13, color: Color(0xFF1D2129)),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -430,33 +569,38 @@ class DroneStationStatusPage extends StatelessWidget {
|
||||
|
||||
/// 无人机电量行
|
||||
Widget _buildDroneBatteryRow() {
|
||||
final capacity = _uavDetail?.liveCapacity ?? 78;
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
const Text(
|
||||
'电量',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
style: TextStyle(fontSize: 13, color: Color(0xFF86909C)),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: LinearProgressIndicator(
|
||||
value: 0.78,
|
||||
value: capacity / 100,
|
||||
backgroundColor: const Color(0xFFF2F3F5),
|
||||
valueColor: const AlwaysStoppedAnimation<Color>(Color(0xFF00B42A)),
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
capacity > 20
|
||||
? const Color(0xFF00B42A)
|
||||
: const Color(0xFFFF7D00),
|
||||
),
|
||||
minHeight: 6,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
'78%',
|
||||
Text(
|
||||
'${capacity.toInt()}%',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF00B42A),
|
||||
color: capacity > 20
|
||||
? const Color(0xFF00B42A)
|
||||
: const Color(0xFFFF7D00),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -158,8 +158,10 @@ class _DroneVideoControlPageState extends State<DroneVideoControlPage> {
|
||||
|
||||
// 根据是否使用备选视频源决定使用哪个 SN
|
||||
final effectiveSn = _useBackupSource ? widget.gatewaySn : widget.droneSn;
|
||||
|
||||
debugPrint('📤 请求视频流 - SN: $effectiveSn, 摄像头: ${_currentCamera!.cameraIndex}');
|
||||
|
||||
debugPrint(
|
||||
'📤 请求视频流 - SN: $effectiveSn, 摄像头: ${_currentCamera!.cameraIndex}',
|
||||
);
|
||||
|
||||
_bloc.add(
|
||||
UavVideoStreamLoad(
|
||||
@@ -190,20 +192,22 @@ class _DroneVideoControlPageState extends State<DroneVideoControlPage> {
|
||||
void _toggleBackupSource(bool useBackup) {
|
||||
debugPrint('=== 🔄 切换视频源 ===');
|
||||
debugPrint('切换到: ${useBackup ? "备选(网关)" : "主视频源(无人机)"}');
|
||||
|
||||
|
||||
setState(() {
|
||||
_useBackupSource = useBackup;
|
||||
// 更新实际使用的摄像头列表
|
||||
_effectiveCameraList = useBackup
|
||||
_effectiveCameraList = useBackup
|
||||
? (_backupCameraList ?? [])
|
||||
: (widget.cameraList ?? []);
|
||||
// 选择新列表的第一个摄像头
|
||||
_currentCamera = _effectiveCameraList.isNotEmpty ? _effectiveCameraList.first : null;
|
||||
_currentCamera = _effectiveCameraList.isNotEmpty
|
||||
? _effectiveCameraList.first
|
||||
: null;
|
||||
});
|
||||
|
||||
|
||||
debugPrint('新摄像头列表长度: ${_effectiveCameraList.length}');
|
||||
debugPrint('选中的摄像头: ${_currentCamera?.cameraIndex}');
|
||||
|
||||
|
||||
// 重新加载视频流
|
||||
if (_currentCamera != null) {
|
||||
_loadVideoStream(_currentLensType ?? UavLensType.wide);
|
||||
@@ -372,7 +376,8 @@ class _DroneVideoControlPageState extends State<DroneVideoControlPage> {
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
if (_effectiveCameraList.isNotEmpty || _backupCameraList?.isNotEmpty == true)
|
||||
if (_effectiveCameraList.isNotEmpty ||
|
||||
_backupCameraList?.isNotEmpty == true)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Row(
|
||||
@@ -391,9 +396,16 @@ class _DroneVideoControlPageState extends State<DroneVideoControlPage> {
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: const [
|
||||
Icon(Icons.flight, size: 16, color: Color(0xFF165DFF)),
|
||||
Icon(
|
||||
Icons.flight,
|
||||
size: 16,
|
||||
color: Color(0xFF165DFF),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Text('无人机', style: TextStyle(fontSize: 12)),
|
||||
Text(
|
||||
'无人机',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -402,15 +414,23 @@ class _DroneVideoControlPageState extends State<DroneVideoControlPage> {
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: const [
|
||||
Icon(Icons.home_work, size: 16, color: Color(0xFFFF7D00)),
|
||||
Icon(
|
||||
Icons.home_work,
|
||||
size: 16,
|
||||
color: Color(0xFFFF7D00),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Text('备选', style: TextStyle(fontSize: 12)),
|
||||
Text(
|
||||
'备选',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
onChanged: (bool? useBackup) {
|
||||
if (useBackup != null && useBackup != _useBackupSource) {
|
||||
if (useBackup != null &&
|
||||
useBackup != _useBackupSource) {
|
||||
_toggleBackupSource(useBackup);
|
||||
}
|
||||
},
|
||||
@@ -440,9 +460,13 @@ class _DroneVideoControlPageState extends State<DroneVideoControlPage> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
_useBackupSource ? Icons.home_work : Icons.videocam,
|
||||
_useBackupSource
|
||||
? Icons.home_work
|
||||
: Icons.videocam,
|
||||
size: 16,
|
||||
color: _useBackupSource ? const Color(0xFFFF7D00) : const Color(0xFF165DFF),
|
||||
color: _useBackupSource
|
||||
? const Color(0xFFFF7D00)
|
||||
: const Color(0xFF165DFF),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../../../../../core/di/injection.dart';
|
||||
import '../../../../../core/logging/i_logger_service.dart';
|
||||
import '../../../../devices/presentation/bloc/devices_cubit.dart';
|
||||
@@ -25,7 +26,8 @@ class RobotListPage extends StatelessWidget {
|
||||
final siteId = selectedSite?.id;
|
||||
|
||||
return BlocProvider(
|
||||
create: (_) => sl<RobotListBloc>()..add(RobotListLoadData(siteId: siteId)),
|
||||
create: (_) =>
|
||||
sl<RobotListBloc>()..add(RobotListLoadData(siteId: siteId)),
|
||||
child: RobotListView(siteId: siteId),
|
||||
);
|
||||
}
|
||||
@@ -63,9 +65,7 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
builder: (context, state) {
|
||||
if (state is RobotListLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Color(0xFF165DFF),
|
||||
),
|
||||
child: CircularProgressIndicator(color: Color(0xFF165DFF)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -99,13 +99,18 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
}
|
||||
|
||||
Widget _buildStatsCard(RobotListLoaded state) {
|
||||
// 计算各类型机器人数量
|
||||
final allRobots = state.robots;
|
||||
final inspectionRobots = allRobots.where((r) => r.type.contains('巡检')).toList();
|
||||
final cleaningRobots = allRobots.where((r) => r.type.contains('清洗')).toList();
|
||||
final weedingRobots = allRobots.where((r) => r.type.contains('除草')).toList();
|
||||
|
||||
final onlineInspection = inspectionRobots.where((r) => r.status == '在线').length;
|
||||
final inspectionRobots = allRobots
|
||||
.where((r) => r.type == 'inspection')
|
||||
.toList();
|
||||
final cleaningRobots = allRobots
|
||||
.where((r) => r.type == 'cleaning')
|
||||
.toList();
|
||||
final weedingRobots = allRobots.where((r) => r.type == 'weeding').toList();
|
||||
|
||||
final onlineInspection = inspectionRobots
|
||||
.where((r) => r.status == '在线')
|
||||
.length;
|
||||
final onlineCleaning = cleaningRobots.where((r) => r.status == '在线').length;
|
||||
final onlineWeeding = weedingRobots.where((r) => r.status == '在线').length;
|
||||
return Container(
|
||||
@@ -129,37 +134,43 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
onTap: () {
|
||||
context.read<RobotListBloc>().add(
|
||||
RobotListChangeType(
|
||||
_selectedType == '巡检机器人' ? null : '巡检机器人',
|
||||
_selectedType == 'inspection' ? null : 'inspection',
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
_selectedType = _selectedType == '巡检机器人' ? null : '巡检机器人';
|
||||
_selectedType = _selectedType == 'inspection'
|
||||
? null
|
||||
: 'inspection';
|
||||
});
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: _selectedType == '巡检机器人'
|
||||
gradient: _selectedType == 'inspection'
|
||||
? const LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Color(0xFFE8F4FF),
|
||||
Color(0xFFFFFFFF),
|
||||
],
|
||||
colors: [Color(0xFFE8F4FF), Color(0xFFFFFFFF)],
|
||||
)
|
||||
: null,
|
||||
color: _selectedType != '巡检机器人' ? Colors.transparent : null,
|
||||
color: _selectedType != 'inspection'
|
||||
? Colors.transparent
|
||||
: null,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
'巡检机器人',
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.inspection_robot'),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: _selectedType == '巡检机器人'
|
||||
color: _selectedType == 'inspection'
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF1D2129),
|
||||
),
|
||||
@@ -169,21 +180,29 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset('assets/images/xunjian.png', width: 48, height: 48),
|
||||
Image.asset(
|
||||
'assets/images/xunjian.png',
|
||||
width: 48,
|
||||
height: 48,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'${inspectionRobots.length}',
|
||||
style: const TextStyle(fontSize: 28, fontWeight: FontWeight.bold, color: Color(0xFF165DFF)),
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF165DFF),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'在线$onlineInspection台',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.online')}$onlineInspection台',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: _selectedType == '巡检机器人'
|
||||
color: _selectedType == 'inspection'
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF00B42A),
|
||||
),
|
||||
@@ -198,37 +217,43 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
onTap: () {
|
||||
context.read<RobotListBloc>().add(
|
||||
RobotListChangeType(
|
||||
_selectedType == '清洗机器人' ? null : '清洗机器人',
|
||||
_selectedType == 'cleaning' ? null : 'cleaning',
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
_selectedType = _selectedType == '清洗机器人' ? null : '清洗机器人';
|
||||
_selectedType = _selectedType == 'cleaning'
|
||||
? null
|
||||
: 'cleaning';
|
||||
});
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: _selectedType == '清洗机器人'
|
||||
gradient: _selectedType == 'cleaning'
|
||||
? const LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Color(0xFFE8F4FF),
|
||||
Color(0xFFFFFFFF),
|
||||
],
|
||||
colors: [Color(0xFFE8F4FF), Color(0xFFFFFFFF)],
|
||||
)
|
||||
: null,
|
||||
color: _selectedType != '清洗机器人' ? Colors.transparent : null,
|
||||
color: _selectedType != 'cleaning'
|
||||
? Colors.transparent
|
||||
: null,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
'清洗机器人',
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.cleaning_robot'),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: _selectedType == '清洗机器人'
|
||||
color: _selectedType == 'cleaning'
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF1D2129),
|
||||
),
|
||||
@@ -238,21 +263,29 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset('assets/images/qinxi.png', width: 48, height: 48),
|
||||
Image.asset(
|
||||
'assets/images/qinxi.png',
|
||||
width: 48,
|
||||
height: 48,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'${cleaningRobots.length}',
|
||||
style: const TextStyle(fontSize: 28, fontWeight: FontWeight.bold, color: Color(0xFF165DFF)),
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF165DFF),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'在线$onlineCleaning台',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.online')}$onlineCleaning台',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: _selectedType == '清洗机器人'
|
||||
color: _selectedType == 'cleaning'
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF00B42A),
|
||||
),
|
||||
@@ -267,37 +300,41 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
onTap: () {
|
||||
context.read<RobotListBloc>().add(
|
||||
RobotListChangeType(
|
||||
_selectedType == '除草机器人' ? null : '除草机器人',
|
||||
_selectedType == 'weeding' ? null : 'weeding',
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
_selectedType = _selectedType == '除草机器人' ? null : '除草机器人';
|
||||
_selectedType = _selectedType == 'weeding' ? null : 'weeding';
|
||||
});
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: _selectedType == '除草机器人'
|
||||
gradient: _selectedType == 'weeding'
|
||||
? const LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Color(0xFFE8F4FF),
|
||||
Color(0xFFFFFFFF),
|
||||
],
|
||||
colors: [Color(0xFFE8F4FF), Color(0xFFFFFFFF)],
|
||||
)
|
||||
: null,
|
||||
color: _selectedType != '除草机器人' ? Colors.transparent : null,
|
||||
color: _selectedType != 'weeding'
|
||||
? Colors.transparent
|
||||
: null,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
'除草机器人',
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.weeding_robot'),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: _selectedType == '除草机器人'
|
||||
color: _selectedType == 'weeding'
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF1D2129),
|
||||
),
|
||||
@@ -307,14 +344,18 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset('assets/images/chucao.png', width: 48, height: 48),
|
||||
Image.asset(
|
||||
'assets/images/chucao.png',
|
||||
width: 48,
|
||||
height: 48,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'${weedingRobots.length}',
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _selectedType == '除草机器人'
|
||||
color: _selectedType == 'weeding'
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF00B42A),
|
||||
),
|
||||
@@ -323,11 +364,11 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'在线$onlineWeeding台',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.online')}$onlineWeeding台',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: _selectedType == '除草机器人'
|
||||
color: _selectedType == 'weeding'
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF00B42A),
|
||||
),
|
||||
@@ -344,38 +385,78 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
Widget _buildQuickActions(RobotListLoaded state) {
|
||||
// 计算统计数据
|
||||
final onlineCount = state.robots.where((r) => r.status == '在线').length;
|
||||
final workingCount = state.robots.where((r) => r.task != '待机中' && r.task != '充电中').length;
|
||||
final workingCount = state.robots
|
||||
.where((r) => r.task != '待机中' && r.task != '充电中')
|
||||
.length;
|
||||
final standbyCount = state.robots.where((r) => r.task == '待机中').length;
|
||||
final faultCount = state.robots.where((r) => r.status == '异常' || r.status == '离线').length;
|
||||
final faultCount = state.robots
|
||||
.where((r) => r.status == '异常' || r.status == '离线')
|
||||
.length;
|
||||
return Container(
|
||||
margin: const EdgeInsets.fromLTRB(16, 0, 16, 12),
|
||||
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))],
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildStatusItem(value: '$onlineCount', label: '在线设备', valueColor: const Color(0xFF165DFF)),
|
||||
_buildStatusItem(
|
||||
value: '$onlineCount',
|
||||
label: '在线设备',
|
||||
valueColor: const Color(0xFF165DFF),
|
||||
),
|
||||
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
|
||||
_buildStatusItem(value: '$workingCount', label: '作业中', valueColor: const Color(0xFF00B42A)),
|
||||
_buildStatusItem(
|
||||
value: '$workingCount',
|
||||
label: '作业中',
|
||||
valueColor: const Color(0xFF00B42A),
|
||||
),
|
||||
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
|
||||
_buildStatusItem(value: '$standbyCount', label: '待命', valueColor: const Color(0xFFFF7D00)),
|
||||
_buildStatusItem(
|
||||
value: '$standbyCount',
|
||||
label: '待命',
|
||||
valueColor: const Color(0xFFFF7D00),
|
||||
),
|
||||
Container(width: 1, height: 40, color: const Color(0xFFE5E6EB)),
|
||||
_buildStatusItem(value: '$faultCount', label: '故障数', valueColor: const Color(0xFFF53F3F)),
|
||||
_buildStatusItem(
|
||||
value: '$faultCount',
|
||||
label: '故障数',
|
||||
valueColor: const Color(0xFFF53F3F),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusItem({required String value, required String label, required Color valueColor}) {
|
||||
Widget _buildStatusItem({
|
||||
required String value,
|
||||
required String label,
|
||||
required Color valueColor,
|
||||
}) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(value, style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold, color: valueColor)),
|
||||
Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: valueColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(label, style: const TextStyle(fontSize: 13, color: Color(0xFF4E5969))),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(fontSize: 13, color: Color(0xFF4E5969)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -385,14 +466,16 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
// 获取第一个正在执行任务的机器人
|
||||
final workingRobot = state.robots.firstWhere(
|
||||
(r) => r.task != '待机中' && r.task != '充电中',
|
||||
orElse: () => state.robots.isNotEmpty ? state.robots.first : RobotDataModel(
|
||||
name: '',
|
||||
id: '',
|
||||
type: '',
|
||||
status: '',
|
||||
battery: 0,
|
||||
task: '无任务',
|
||||
),
|
||||
orElse: () => state.robots.isNotEmpty
|
||||
? state.robots.first
|
||||
: RobotDataModel(
|
||||
name: '',
|
||||
id: '',
|
||||
type: '',
|
||||
status: '',
|
||||
battery: 0,
|
||||
task: '无任务',
|
||||
),
|
||||
);
|
||||
return Container(
|
||||
margin: const EdgeInsets.fromLTRB(16, 0, 16, 12),
|
||||
@@ -400,18 +483,36 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: const [BoxShadow(color: Color(0x0D000000), blurRadius: 8, offset: Offset(0, 2))],
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('当前任务', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Color(0xFF1D2129))),
|
||||
const Text(
|
||||
'当前任务',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Image.asset('assets/images/xunjian.png', width: 80, height: 80, fit: BoxFit.cover),
|
||||
child: Image.asset(
|
||||
'assets/images/xunjian.png',
|
||||
width: 80,
|
||||
height: 80,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
@@ -420,16 +521,41 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(child: Text('巡检任务-逆变器区巡检', style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: Color(0xFF1D2129)))),
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'巡检任务-逆变器区巡检',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(color: const Color(0xFF165DFF).withOpacity(0.1), borderRadius: BorderRadius.circular(4)),
|
||||
child: const Text('进行中', style: TextStyle(fontSize: 11, color: Color(0xFF165DFF), fontWeight: FontWeight.w500)),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF165DFF).withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Text(
|
||||
'进行中',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Color(0xFF165DFF),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildTaskInfo('机器人:', workingRobot.name.isNotEmpty ? workingRobot.name : '无'),
|
||||
_buildTaskInfo(
|
||||
'机器人:',
|
||||
workingRobot.name.isNotEmpty ? workingRobot.name : '无',
|
||||
),
|
||||
_buildTaskInfo('区域:', '逆变器区A区'),
|
||||
_buildTaskInfo('进度:', '62%'),
|
||||
_buildTaskInfo('预计完成:', '12:30'),
|
||||
@@ -449,8 +575,14 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(text: label, style: const TextStyle(fontSize: 13, color: Color(0xFF86909C))),
|
||||
TextSpan(text: value, style: const TextStyle(fontSize: 13, color: Color(0xFF1D2129))),
|
||||
TextSpan(
|
||||
text: label,
|
||||
style: const TextStyle(fontSize: 13, color: Color(0xFF86909C)),
|
||||
),
|
||||
TextSpan(
|
||||
text: value,
|
||||
style: const TextStyle(fontSize: 13, color: Color(0xFF1D2129)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -461,64 +593,84 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
final allRobots = state.robots;
|
||||
|
||||
// 根据选中的类型过滤
|
||||
final filteredRobots = state.selectedType == null
|
||||
? allRobots
|
||||
: allRobots.where((robot) => robot.type.contains(state.selectedType!)).toList();
|
||||
final filteredRobots = state.selectedType == null
|
||||
? allRobots
|
||||
: allRobots
|
||||
.where((robot) => robot.type.contains(state.selectedType!))
|
||||
.toList();
|
||||
|
||||
if (filteredRobots.isEmpty) {
|
||||
return [const Center(child: Padding(padding: EdgeInsets.all(32), child: Text('暂无机器人数据', style: TextStyle(fontSize: 14, color: Color(0xFF86909C)))))];
|
||||
return [
|
||||
const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(32),
|
||||
child: Text(
|
||||
'暂无机器人数据',
|
||||
style: TextStyle(fontSize: 14, color: Color(0xFF86909C)),
|
||||
),
|
||||
),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
return filteredRobots.map((robot) => RobotItemCard(
|
||||
name: robot.name,
|
||||
id: robot.id,
|
||||
alias: robot.alias, // 传递别名
|
||||
type: robot.type,
|
||||
status: robot.status,
|
||||
battery: robot.battery,
|
||||
task: robot.task,
|
||||
onTap: () async {
|
||||
// final logger = sl<ILoggerService>();
|
||||
debugPrint('🔴🔴🔴 [选中机器人] ========== 点击事件触发 ==========');
|
||||
debugPrint('🔴🔴🔴 [选中机器人] name: ${robot.name}, id: ${robot.id}, type: ${robot.type}');
|
||||
debugPrint('🔴🔴🔴 [选中机器人] status: ${robot.status}, battery: ${robot.battery}, task: ${robot.task}');
|
||||
|
||||
// 1. 将当前机器人设置为全局待控制设备(用 robot.name 作为 deviceName)
|
||||
final device = DeviceEntity(
|
||||
deviceName: robot.name, // ✅ 修正: 用 name 而不是 id
|
||||
productId: -1,
|
||||
productName: robot.type,
|
||||
tenantId: 0,
|
||||
tenantName: '',
|
||||
status: robot.status == '在线' ? 1 : 0,
|
||||
onlineStatus: robot.status == '在线' ? 1 : 0,
|
||||
);
|
||||
|
||||
debugPrint('🎯 [RobotListPage] 准备调用 setTargetDevice...');
|
||||
// 🔥 使用 GetIt 直接获取 RemoteControlCubit 单例
|
||||
final remoteCubit = GetIt.I<RemoteControlCubit>();
|
||||
remoteCubit.setTargetDevice(device); // 🔥 TCP连接在后台异步执行
|
||||
debugPrint('✅ [RobotListPage] setTargetDevice 已调用(TCP连接中)');
|
||||
|
||||
// 2. 跳转到机器人控制页面
|
||||
final robotMap = {
|
||||
'name': robot.name,
|
||||
'id': robot.id,
|
||||
'alias': robot.alias, // 传递别名
|
||||
'type': robot.type,
|
||||
'status': robot.status,
|
||||
'battery': robot.battery,
|
||||
'task': robot.task,
|
||||
};
|
||||
|
||||
debugPrint('🚀 [RobotListPage] 准备跳转页面...');
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => RobotControlPage(robot: robotMap),
|
||||
return filteredRobots
|
||||
.map(
|
||||
(robot) => RobotItemCard(
|
||||
name: robot.name,
|
||||
id: robot.id,
|
||||
alias: robot.alias, // 传递别名
|
||||
type: robot.type,
|
||||
status: robot.status,
|
||||
battery: robot.battery,
|
||||
task: robot.task,
|
||||
onTap: () async {
|
||||
// final logger = sl<ILoggerService>();
|
||||
debugPrint('🔴🔴🔴 [选中机器人] ========== 点击事件触发 ==========');
|
||||
debugPrint(
|
||||
'🔴🔴🔴 [选中机器人] name: ${robot.name}, id: ${robot.id}, type: ${robot.type}',
|
||||
);
|
||||
debugPrint(
|
||||
'🔴🔴🔴 [选中机器人] status: ${robot.status}, battery: ${robot.battery}, task: ${robot.task}',
|
||||
);
|
||||
|
||||
// 1. 将当前机器人设置为全局待控制设备(用 robot.name 作为 deviceName)
|
||||
final device = DeviceEntity(
|
||||
deviceName: robot.name, // ✅ 修正: 用 name 而不是 id
|
||||
productId: -1,
|
||||
productName: robot.type,
|
||||
tenantId: 0,
|
||||
tenantName: '',
|
||||
status: robot.status == '在线' ? 1 : 0,
|
||||
onlineStatus: robot.status == '在线' ? 1 : 0,
|
||||
);
|
||||
|
||||
debugPrint('🎯 [RobotListPage] 准备调用 setTargetDevice...');
|
||||
// 🔥 使用 GetIt 直接获取 RemoteControlCubit 单例
|
||||
final remoteCubit = GetIt.I<RemoteControlCubit>();
|
||||
remoteCubit.setTargetDevice(device); // 🔥 TCP连接在后台异步执行
|
||||
debugPrint('✅ [RobotListPage] setTargetDevice 已调用(TCP连接中)');
|
||||
|
||||
// 2. 跳转到机器人控制页面
|
||||
final robotMap = {
|
||||
'name': robot.name,
|
||||
'id': robot.id,
|
||||
'alias': robot.alias, // 传递别名
|
||||
'type': robot.type,
|
||||
'status': robot.status,
|
||||
'battery': robot.battery,
|
||||
'task': robot.task,
|
||||
};
|
||||
|
||||
debugPrint('🚀 [RobotListPage] 准备跳转页面...');
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => RobotControlPage(robot: robotMap),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
)).toList();
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,7 @@ class DeviceBottomNavBar extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: const Color(0xFFF2F3F5),
|
||||
width: 0.5,
|
||||
),
|
||||
top: BorderSide(color: const Color(0xFFF2F3F5), width: 0.5),
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
@@ -79,7 +76,9 @@ class DeviceBottomNavBar extends StatelessWidget {
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
color: isSelected ? const Color(0xFF004CFD) : const Color(0xFF86909C),
|
||||
color: isSelected
|
||||
? const Color(0xFF004CFD)
|
||||
: const Color(0xFF86909C),
|
||||
size: 24,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
@@ -87,7 +86,9 @@ class DeviceBottomNavBar extends StatelessWidget {
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: isSelected ? const Color(0xFF004FFF) : const Color(0xFF86909C),
|
||||
color: isSelected
|
||||
? const Color(0xFF004FFF)
|
||||
: const Color(0xFF86909C),
|
||||
fontWeight: isSelected ? FontWeight.w500 : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../domain/entities/device_entity.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
|
||||
/// 设备列表项 Widget
|
||||
class DeviceItemWidget extends StatelessWidget {
|
||||
@@ -68,7 +69,7 @@ class DeviceItemWidget extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// 第二行:设备数据
|
||||
_buildDeviceData(device),
|
||||
_buildDeviceData(context, device),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -112,11 +113,7 @@ class DeviceItemWidget extends StatelessWidget {
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: color,
|
||||
size: 28,
|
||||
),
|
||||
child: Icon(icon, color: color, size: 28),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -148,46 +145,71 @@ class DeviceItemWidget extends StatelessWidget {
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
child: Text(
|
||||
status,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: textColor,
|
||||
),
|
||||
),
|
||||
child: Text(status, style: TextStyle(fontSize: 12, color: textColor)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDeviceData(DeviceEntity device) {
|
||||
Widget _buildDeviceData(BuildContext context, DeviceEntity device) {
|
||||
final dataItems = <Widget>[];
|
||||
|
||||
// 根据设备类型显示不同的数据
|
||||
if (device.type == '逆变器') {
|
||||
dataItems.add(_buildDataItem('${device.power}', 'kW | 功率'));
|
||||
if (device.type == 'inverter') {
|
||||
dataItems.add(
|
||||
_buildDataItem(
|
||||
'${device.power}',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.inverter')} | ${AppLocalizations.of(context).translate('device_list_v2.power')}',
|
||||
),
|
||||
);
|
||||
dataItems.add(const SizedBox(width: 16));
|
||||
dataItems.add(_buildDataItem('${device.todayEnergy}', 'kWh | 今日发电'));
|
||||
} else if (device.type == '汇流箱') {
|
||||
dataItems.add(
|
||||
_buildDataItem(
|
||||
'${device.todayEnergy}',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.today_energy')}',
|
||||
),
|
||||
);
|
||||
} else if (device.type == 'combiner_box') {
|
||||
if (device.current != null) {
|
||||
dataItems.add(_buildDataItem('${device.current}', 'A | 电流'));
|
||||
dataItems.add(
|
||||
_buildDataItem(
|
||||
'${device.current}',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.current')}',
|
||||
),
|
||||
);
|
||||
dataItems.add(const SizedBox(width: 16));
|
||||
}
|
||||
if (device.temperature != null) {
|
||||
dataItems.add(_buildDataItem('${device.temperature}', '℃ | 温度'));
|
||||
dataItems.add(
|
||||
_buildDataItem(
|
||||
'${device.temperature}',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.temperature')}',
|
||||
),
|
||||
);
|
||||
}
|
||||
} else if (device.type == '组件') {
|
||||
dataItems.add(_buildDataItem('${device.power}', 'kW | 功率'));
|
||||
} else if (device.type == 'module') {
|
||||
dataItems.add(
|
||||
_buildDataItem(
|
||||
'${device.power}',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.power')}',
|
||||
),
|
||||
);
|
||||
dataItems.add(const SizedBox(width: 16));
|
||||
if (device.radiation != null) {
|
||||
dataItems.add(_buildDataItem('${device.radiation}', 'W/m² | 辐照度'));
|
||||
dataItems.add(
|
||||
_buildDataItem(
|
||||
'${device.radiation}',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.radiation')}',
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// 监控等其他类型
|
||||
dataItems.add(_buildDataItem('--', '数据'));
|
||||
dataItems.add(
|
||||
_buildDataItem(
|
||||
'--',
|
||||
'${AppLocalizations.of(context).translate('device_list_v2.data')}',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
children: dataItems,
|
||||
);
|
||||
return Row(children: dataItems);
|
||||
}
|
||||
|
||||
Widget _buildDataItem(String value, String unit) {
|
||||
@@ -205,10 +227,7 @@ class DeviceItemWidget extends StatelessWidget {
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
unit,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF4E5969),
|
||||
),
|
||||
style: const TextStyle(fontSize: 12, color: Color(0xFF4E5969)),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
|
||||
/// 机器人卡片组件
|
||||
class RobotItemCard extends StatelessWidget {
|
||||
@@ -83,7 +84,9 @@ class RobotItemCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
alias != null && alias!.isNotEmpty ? '别名: $alias' : 'ID: $id',
|
||||
alias != null && alias!.isNotEmpty
|
||||
? '别名: $alias'
|
||||
: 'ID: $id',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF86909C),
|
||||
@@ -111,14 +114,14 @@ class RobotItemCard extends StatelessWidget {
|
||||
battery > 50
|
||||
? Icons.battery_full
|
||||
: battery > 20
|
||||
? Icons.battery_std
|
||||
: Icons.battery_alert,
|
||||
? Icons.battery_std
|
||||
: Icons.battery_alert,
|
||||
size: 16,
|
||||
color: battery > 50
|
||||
? const Color(0xFF00B42A)
|
||||
: battery > 20
|
||||
? const Color(0xFFFF7D00)
|
||||
: const Color(0xFFF53F3F),
|
||||
? const Color(0xFFFF7D00)
|
||||
: const Color(0xFFF53F3F),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
@@ -129,15 +132,17 @@ class RobotItemCard extends StatelessWidget {
|
||||
color: battery > 50
|
||||
? const Color(0xFF00B42A)
|
||||
: battery > 20
|
||||
? const Color(0xFFFF7D00)
|
||||
: const Color(0xFFF53F3F),
|
||||
? const Color(0xFFFF7D00)
|
||||
: const Color(0xFFF53F3F),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
const Text(
|
||||
'电量',
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.battery_level'),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF4E5969),
|
||||
@@ -162,8 +167,10 @@ class RobotItemCard extends StatelessWidget {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
const Text(
|
||||
'当前任务',
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.current_task'),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF4E5969),
|
||||
@@ -208,23 +215,17 @@ class RobotItemCard extends StatelessWidget {
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
status,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: textColor,
|
||||
),
|
||||
),
|
||||
child: Text(status, style: TextStyle(fontSize: 12, color: textColor)),
|
||||
);
|
||||
}
|
||||
|
||||
String _getRobotImage() {
|
||||
switch (type) {
|
||||
case '巡检机器人':
|
||||
case 'inspection':
|
||||
return 'assets/images/xunjian.png';
|
||||
case '清洗机器人':
|
||||
case 'cleaning':
|
||||
return 'assets/images/qinxi.png';
|
||||
case '除草机器人':
|
||||
case 'weeding':
|
||||
return 'assets/images/chucao.png';
|
||||
default:
|
||||
return 'assets/images/xunjian.png';
|
||||
|
||||
@@ -64,6 +64,12 @@ class SiteDataSourceImpl implements SiteDataSource {
|
||||
}
|
||||
|
||||
final List<dynamic> rows = responseData['rows'] ?? [];
|
||||
|
||||
print('📤 [SiteDataSource] 接口返回原始数据:');
|
||||
for (var i = 0; i < rows.length && i < 3; i++) {
|
||||
print(' 场站$i: ${rows[i]}');
|
||||
}
|
||||
|
||||
return rows.map((item) => SiteEntity.fromJson(item)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class SiteEntity extends Equatable {
|
||||
factory SiteEntity.fromJson(Map<String, dynamic> json) {
|
||||
return SiteEntity(
|
||||
id: json['id'] as int,
|
||||
siteName: json['siteName'] as String? ?? '',
|
||||
siteName: json['name'] as String? ?? json['siteName'] as String? ?? '',
|
||||
siteCode: json['siteCode'] as String?,
|
||||
orgId: json['orgId'] as int? ?? 0,
|
||||
longitude: (json['longitude'] as num?)?.toDouble(),
|
||||
|
||||
@@ -91,7 +91,18 @@ class HomeV2Bloc extends Bloc<HomeV2Event, HomeV2State> {
|
||||
if (state is HomeV2Loaded) {
|
||||
final currentState = state as HomeV2Loaded;
|
||||
|
||||
final user = appUserCubit.state.user;
|
||||
if (user == null) {
|
||||
emit(const HomeV2Error(
|
||||
message: '用户未登录',
|
||||
shouldShowError: true,
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
// 并行刷新首页数据和电站列表
|
||||
final homeResult = await getHomeDataUseCase(const NoParams());
|
||||
final siteResult = await getSiteListUseCase(user.orgId);
|
||||
|
||||
homeResult.fold(
|
||||
(failure) => emit(HomeV2Error(
|
||||
@@ -99,11 +110,38 @@ class HomeV2Bloc extends Bloc<HomeV2Event, HomeV2State> {
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(homeData) {
|
||||
List<SiteEntity> sites = currentState.sites;
|
||||
SiteEntity? selectedSite = currentState.selectedSite;
|
||||
|
||||
siteResult.fold(
|
||||
(failure) {
|
||||
print('刷新场站列表失败: ${failure.message}');
|
||||
},
|
||||
(siteList) {
|
||||
sites = siteList;
|
||||
// 保持当前选中的场站
|
||||
final savedSelectedSite = siteCubit.state.selectedSite;
|
||||
if (savedSelectedSite != null && siteList.isNotEmpty) {
|
||||
selectedSite = siteList.firstWhere(
|
||||
(site) => site.id == savedSelectedSite.id,
|
||||
orElse: () => siteList.first,
|
||||
);
|
||||
} else if (siteList.isNotEmpty) {
|
||||
selectedSite = siteList.first;
|
||||
}
|
||||
|
||||
// 更新全局 SiteCubit 的选中状态
|
||||
if (selectedSite != null) {
|
||||
siteCubit.selectSite(selectedSite!);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
emit(HomeV2Loaded(
|
||||
homeData: homeData,
|
||||
trendType: currentState.trendType,
|
||||
sites: currentState.sites,
|
||||
selectedSite: currentState.selectedSite,
|
||||
sites: sites,
|
||||
selectedSite: selectedSite,
|
||||
));
|
||||
},
|
||||
);
|
||||
|
||||
@@ -25,7 +25,7 @@ class HomeV2Loaded extends HomeV2State {
|
||||
|
||||
const HomeV2Loaded({
|
||||
required this.homeData,
|
||||
this.trendType = 'kW',
|
||||
this.trendType = 'day',
|
||||
this.sites = const [],
|
||||
this.selectedSite,
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/presentation/bloc/home_v2_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/presentation/bloc/home_v2_event.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/presentation/bloc/home_v2_state.dart';
|
||||
@@ -53,10 +54,23 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
// 🔥 错误状态不再显示全屏错误页面,而是通过 listener 显示 SnackBar
|
||||
// 🔥 错误状态显示重试按钮
|
||||
if (state is HomeV2Error) {
|
||||
// 返回空容器保持页面
|
||||
return const SizedBox.shrink();
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.error_outline, size: 48, color: Colors.orange),
|
||||
const SizedBox(height: 12),
|
||||
Text(state.message, style: const TextStyle(fontSize: 14, color: Colors.grey)),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () => _bloc.add(const HomeV2LoadData()),
|
||||
child: const Text('重试'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (state is HomeV2Loaded) {
|
||||
@@ -92,7 +106,11 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
sl<SiteCubit>().state;
|
||||
return Text(
|
||||
siteState.selectedSite?.siteName ??
|
||||
'选择电站',
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate(
|
||||
'home_v2.select_site',
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
@@ -149,9 +167,11 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
color: Color(0xFF165DFF),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
const Text(
|
||||
'多云 28°C',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.weather'),
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF4E5969),
|
||||
),
|
||||
@@ -180,10 +200,12 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
color: Color(0xFFF53F3F),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
const Expanded(
|
||||
Expanded(
|
||||
child: Text(
|
||||
'紧急告警',
|
||||
style: TextStyle(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.emergency_alarm'),
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFFF53F3F),
|
||||
),
|
||||
@@ -229,7 +251,8 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
);
|
||||
}
|
||||
|
||||
return const SizedBox();
|
||||
// 🔥 Initial/Loading 状态显示加载指示器
|
||||
return const Center(child: CircularProgressIndicator(color: Color(0xFF165DFF)));
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -256,9 +279,13 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
final sites = currentState.sites;
|
||||
|
||||
if (sites.isEmpty) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('暂无可用电站')));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(context).translate('home_v2.no_sites'),
|
||||
),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -282,9 +309,11 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
'选择电站',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.select_site'),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
@@ -303,7 +332,11 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
title: Text(site.siteName),
|
||||
subtitle:
|
||||
site.siteCode != null && site.siteCode!.isNotEmpty
|
||||
? Text('编号: ${site.siteCode}')
|
||||
? Text(
|
||||
AppLocalizations.of(context)
|
||||
.translate('home_v2.site_code')
|
||||
.replaceAll('%s', site.siteCode!),
|
||||
)
|
||||
: null,
|
||||
trailing: isSelected
|
||||
? const Icon(
|
||||
@@ -347,11 +380,9 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
builder: (BuildContext context) {
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider.value(value: context.read<DeviceStatusBloc>()),
|
||||
BlocProvider.value(
|
||||
value: context.read<DeviceStatusBloc>(),
|
||||
),
|
||||
BlocProvider.value(
|
||||
value: GetIt.I<RemoteControlCubit>(), // 🔥 注入 RemoteControlCubit
|
||||
value: GetIt.I<RemoteControlCubit>(), // 🔥 注入 RemoteControlCubit
|
||||
),
|
||||
],
|
||||
child: const DeviceStatusModal(),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/domain/entities/home_entity.dart';
|
||||
|
||||
class PlantOverviewCard extends StatelessWidget {
|
||||
@@ -11,9 +12,9 @@ class PlantOverviewCard extends StatelessWidget {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'电站概况',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('home_v2.plant_overview'),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
@@ -42,10 +43,7 @@ class PlantOverviewCard extends StatelessWidget {
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.transparent,
|
||||
Colors.black.withOpacity(0.6),
|
||||
],
|
||||
colors: [Colors.transparent, Colors.black.withOpacity(0.6)],
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
@@ -57,47 +55,66 @@ class PlantOverviewCard extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'装机容量',
|
||||
style: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 12,
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.installed_capacity'),
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 12,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'${overview.installedCapacity} MWp',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'${overview.installedCapacity} MWp',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
const Text(
|
||||
'投运日期',
|
||||
style: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 12,
|
||||
const SizedBox(width: 16),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.commission_date'),
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 12,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
overview.commissionDate,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
overview.commissionDate,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/domain/entities/home_entity.dart';
|
||||
|
||||
class PowerCard extends StatelessWidget {
|
||||
@@ -40,12 +41,11 @@ class PowerCard extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'实时发电功率',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
),
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.real_time_power'),
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
@@ -68,10 +68,7 @@ class PowerCard extends StatelessWidget {
|
||||
padding: EdgeInsets.only(bottom: 4),
|
||||
child: Text(
|
||||
'kW',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
),
|
||||
style: TextStyle(color: Colors.white, fontSize: 14),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -86,7 +83,11 @@ class PowerCard extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.more_horiz, size: 20, color: Colors.white),
|
||||
icon: const Icon(
|
||||
Icons.more_horiz,
|
||||
size: 20,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () => print('点击更多'),
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/domain/entities/home_entity.dart';
|
||||
|
||||
class PowerTrendChart extends StatelessWidget {
|
||||
@@ -22,9 +23,9 @@ class PowerTrendChart extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'发电趋势(今日)',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('home_v2.power_trend'),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
@@ -38,8 +39,14 @@ class PowerTrendChart extends StatelessWidget {
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildTypeButton('kW'),
|
||||
_buildTypeButton('周'),
|
||||
_buildTypeButton(
|
||||
'day',
|
||||
AppLocalizations.of(context).translate('home_v2.day'),
|
||||
),
|
||||
_buildTypeButton(
|
||||
'month',
|
||||
AppLocalizations.of(context).translate('home_v2.month'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -88,7 +95,11 @@ class PowerTrendChart extends StatelessWidget {
|
||||
interval: 6,
|
||||
getTitlesWidget: (value, meta) {
|
||||
final index = value.toInt();
|
||||
if (index == 0 || index == 6 || index == 12 || index == 18 || index == 23) {
|
||||
if (index == 0 ||
|
||||
index == 6 ||
|
||||
index == 12 ||
|
||||
index == 18 ||
|
||||
index == 23) {
|
||||
String time;
|
||||
if (index == 23) {
|
||||
time = '23:00';
|
||||
@@ -174,7 +185,7 @@ class PowerTrendChart extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTypeButton(String type) {
|
||||
Widget _buildTypeButton(String type, String label) {
|
||||
final isSelected = trendType == type;
|
||||
return GestureDetector(
|
||||
onTap: () => onToggleType(type),
|
||||
@@ -187,7 +198,7 @@ class PowerTrendChart extends StatelessWidget {
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
type,
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: isSelected ? Colors.white : const Color(0xFF86909C),
|
||||
fontSize: 14,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
|
||||
class QuickEntryCard extends StatelessWidget {
|
||||
const QuickEntryCard({super.key});
|
||||
@@ -11,9 +12,9 @@ class QuickEntryCard extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'快捷入口',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('home_v2.quick_entry'),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
@@ -36,32 +37,44 @@ class QuickEntryCard extends StatelessWidget {
|
||||
children: [
|
||||
_buildQuickEntryCard(
|
||||
icon: Icons.upload_file,
|
||||
label: '设备上报',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.device_report'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildQuickEntryCard(
|
||||
icon: Icons.qr_code_scanner,
|
||||
label: '扫一扫',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.scan_qr'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildQuickEntryCard(
|
||||
icon: Icons.assignment,
|
||||
label: '工单任务',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.work_order'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildQuickEntryCard(
|
||||
icon: Icons.notifications_active,
|
||||
label: '告警中心',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.alarm_center'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildQuickEntryCard(
|
||||
icon: Icons.map,
|
||||
label: '电厂地图',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.power_plant_map'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildQuickEntryCard(
|
||||
icon: Icons.devices,
|
||||
label: '设备列表',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.device_list'),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
@@ -71,10 +84,7 @@ class QuickEntryCard extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildQuickEntryCard({
|
||||
required IconData icon,
|
||||
required String label,
|
||||
}) {
|
||||
Widget _buildQuickEntryCard({required IconData icon, required String label}) {
|
||||
return InkWell(
|
||||
onTap: () => print('点击:$label'),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
@@ -97,11 +107,7 @@ class QuickEntryCard extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
color: const Color(0xFF165DFF),
|
||||
size: 26,
|
||||
),
|
||||
Icon(icon, color: const Color(0xFF165DFF), size: 26),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
label,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/domain/entities/home_entity.dart';
|
||||
|
||||
class StatsGrid extends StatelessWidget {
|
||||
@@ -18,21 +19,25 @@ class StatsGrid extends StatelessWidget {
|
||||
padding: EdgeInsets.zero,
|
||||
children: [
|
||||
_buildStatCard(
|
||||
title: '今日发电量',
|
||||
title: AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.today_generation'),
|
||||
value: _formatNumber(data.todayGeneration),
|
||||
unit: 'kWh',
|
||||
valueColor: const Color(0xFF00B42A),
|
||||
showArrow: false,
|
||||
),
|
||||
_buildStatCard(
|
||||
title: '等效小时数',
|
||||
title: AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.equivalent_hours'),
|
||||
value: data.equivalentHours.toStringAsFixed(1),
|
||||
unit: 'h',
|
||||
valueColor: const Color(0xFF165DFF),
|
||||
showArrow: false,
|
||||
),
|
||||
_buildAlarmCard(data.alarmCount),
|
||||
_buildWorkOrderCard(data.pendingWorkOrders),
|
||||
_buildAlarmCard(context, data.alarmCount),
|
||||
_buildWorkOrderCard(context, data.pendingWorkOrders),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -81,10 +86,7 @@ class StatsGrid extends StatelessWidget {
|
||||
else
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF4E5969),
|
||||
fontSize: 14,
|
||||
),
|
||||
style: const TextStyle(color: Color(0xFF4E5969), fontSize: 14),
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
@@ -101,10 +103,7 @@ class StatsGrid extends StatelessWidget {
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
unit,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF4E5969),
|
||||
fontSize: 14,
|
||||
),
|
||||
style: const TextStyle(color: Color(0xFF4E5969), fontSize: 14),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -113,7 +112,7 @@ class StatsGrid extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAlarmCard(int count) {
|
||||
Widget _buildAlarmCard(BuildContext context, int count) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 12, 12),
|
||||
decoration: BoxDecoration(
|
||||
@@ -134,12 +133,14 @@ class StatsGrid extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'告警数',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('home_v2.alarm_count'),
|
||||
style: const TextStyle(
|
||||
color: Color(0xFFF53F3F),
|
||||
fontSize: 13,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
@@ -171,7 +172,7 @@ class StatsGrid extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildWorkOrderCard(int count) {
|
||||
Widget _buildWorkOrderCard(BuildContext context, int count) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 12, 12),
|
||||
decoration: BoxDecoration(
|
||||
@@ -192,12 +193,16 @@ class StatsGrid extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'待办工单',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.pending_work_order'),
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF4E5969),
|
||||
fontSize: 13,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/domain/entities/home_entity.dart';
|
||||
|
||||
class WorkOrderCard extends StatelessWidget {
|
||||
@@ -14,9 +15,11 @@ class WorkOrderCard extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'待办工单',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.pending_work_order'),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
@@ -34,7 +37,9 @@ class WorkOrderCard extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildWorkOrderCard(
|
||||
title: '待处理',
|
||||
title: AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.work_order_pending'),
|
||||
count: stats.pending,
|
||||
color: const Color(0xFFF53F3F),
|
||||
bgColor: Colors.white,
|
||||
@@ -43,7 +48,9 @@ class WorkOrderCard extends StatelessWidget {
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: _buildWorkOrderCard(
|
||||
title: '处理中',
|
||||
title: AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.work_order_processing'),
|
||||
count: stats.processing,
|
||||
color: const Color(0xFFFF7D00),
|
||||
bgColor: const Color(0xFFFFF7E6),
|
||||
@@ -52,7 +59,9 @@ class WorkOrderCard extends StatelessWidget {
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: _buildWorkOrderCard(
|
||||
title: '待验收',
|
||||
title: AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.work_order_pending_acceptance'),
|
||||
count: stats.pendingAcceptance,
|
||||
color: const Color(0xFF1D2129),
|
||||
bgColor: Colors.white,
|
||||
@@ -70,36 +79,31 @@ class WorkOrderCard extends StatelessWidget {
|
||||
required Color color,
|
||||
required Color bgColor,
|
||||
}) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
// TODO: 点击跳转逻辑
|
||||
},
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 4,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 4,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: color,
|
||||
fontSize: 13,
|
||||
),
|
||||
style: TextStyle(color: color, fontSize: 13),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
@@ -112,13 +116,13 @@ class WorkOrderCard extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 14,
|
||||
color: color.withOpacity(0.5),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 14,
|
||||
color: color.withOpacity(0.5),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter/services.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/v2/my/presentation/cubit/my_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/states/my_state.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/di/my_di.dart';
|
||||
@@ -41,9 +42,9 @@ class _MyPageContent extends StatelessWidget {
|
||||
body: BlocConsumer<MyCubit, MyState>(
|
||||
listener: (context, state) {
|
||||
if (state is MyError) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(state.message)),
|
||||
);
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(state.message)));
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
@@ -57,11 +58,11 @@ class _MyPageContent extends StatelessWidget {
|
||||
final cubit = context.read<MyCubit>();
|
||||
final appUserState = context.watch<AppUserCubit>().state;
|
||||
final user = appUserState.user;
|
||||
|
||||
|
||||
// 获取用户信息(优先使用昵称,其次用户名)
|
||||
final userName = user?.nickname ?? user?.username ?? '未知用户';
|
||||
final userRole = user?.email ?? user?.phone ?? '未设置';
|
||||
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
// 用户信息卡片(延伸到状态栏)
|
||||
@@ -96,7 +97,12 @@ class _MyPageContent extends StatelessWidget {
|
||||
),
|
||||
// 菜单列表(白色卡片)
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 15, left: 16, right: 16, bottom: 16),
|
||||
margin: const EdgeInsets.only(
|
||||
top: 15,
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: 16,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
@@ -147,9 +153,7 @@ class _MyPageContent extends StatelessWidget {
|
||||
// 跳转到个人信息详情页
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ProfileDetailPage(),
|
||||
),
|
||||
MaterialPageRoute(builder: (context) => const ProfileDetailPage()),
|
||||
);
|
||||
debugPrint('✅ 已调用 Navigator.push');
|
||||
break;
|
||||
@@ -163,14 +167,12 @@ class _MyPageContent extends StatelessWidget {
|
||||
// 跳转到系统设置页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const SystemSettingsPage(),
|
||||
),
|
||||
MaterialPageRoute(builder: (context) => const SystemSettingsPage()),
|
||||
);
|
||||
break;
|
||||
default:
|
||||
debugPrint('点击菜单: ${item.title}');
|
||||
// TODO: 根据 ID 跳转到对应页面
|
||||
// TODO: 根据 ID 跳转到对应页面
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,19 +181,25 @@ class _MyPageContent extends StatelessWidget {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('清除缓存'),
|
||||
content: const Text('确定要清除所有缓存数据吗?'),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).translate('my_v2.clear_cache'),
|
||||
),
|
||||
content: Text(
|
||||
AppLocalizations.of(context).translate('my_v2.confirm_clear_cache'),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('取消'),
|
||||
child: Text(AppLocalizations.of(context).translate('my_v2.cancel')),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
cubit.clearCache();
|
||||
},
|
||||
child: const Text('确定'),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('my_v2.confirm'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -8,6 +8,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/features/auth/presentation/bloc/auth_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/main_container/presentation/cubit/tab_config_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/float_bar/cubit/float_bar_setting_cubit.dart';
|
||||
|
||||
/// 系统设置综合页面
|
||||
class SystemSettingsPage extends StatefulWidget {
|
||||
@@ -45,6 +46,9 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
// Tab 设置
|
||||
_buildTabSettingsSection(),
|
||||
const SizedBox(height: 12),
|
||||
// 悬浮条设置
|
||||
_buildFloatBarSection(),
|
||||
const SizedBox(height: 12),
|
||||
// 语言设置
|
||||
_buildLanguageSection(),
|
||||
const SizedBox(height: 12),
|
||||
@@ -56,6 +60,65 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 悬浮条设置
|
||||
Widget _buildFloatBarSection() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(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: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('my_v2.suspend_bar'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('my_v2.suspend_bar_desc'),
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
ValueListenableBuilder<bool>(
|
||||
valueListenable: FloatBarSettingService.settingNotifier,
|
||||
builder: (context, isEnabled, child) {
|
||||
return Switch(
|
||||
value: isEnabled,
|
||||
onChanged: (value) {
|
||||
FloatBarSettingService.setEnabled(value);
|
||||
},
|
||||
activeColor: const Color(0xFF165DFF),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Tab 设置
|
||||
Widget _buildTabSettingsSection() {
|
||||
return Container(
|
||||
@@ -74,9 +137,9 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Tab 设置',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('my_v2.tab_settings'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
@@ -88,9 +151,9 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
if (state.runtimeType.toString() != 'TabConfigLoaded') {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
|
||||
final tabs = state.config.items;
|
||||
|
||||
|
||||
return ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
@@ -164,14 +227,18 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
AppLocalizations.of(context).translate('my.chinese'),
|
||||
'zh',
|
||||
locale.languageCode == 'zh',
|
||||
() => context.read<LocaleCubit>().setLocale(const Locale('zh', 'CN')),
|
||||
() => context.read<LocaleCubit>().setLocale(
|
||||
const Locale('zh', 'CN'),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildLanguageOption(
|
||||
AppLocalizations.of(context).translate('my.english'),
|
||||
'en',
|
||||
locale.languageCode == 'en',
|
||||
() => context.read<LocaleCubit>().setLocale(const Locale('en', 'US')),
|
||||
() => context.read<LocaleCubit>().setLocale(
|
||||
const Locale('en', 'US'),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -182,16 +249,25 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLanguageOption(String label, String code, bool isSelected, VoidCallback onTap) {
|
||||
Widget _buildLanguageOption(
|
||||
String label,
|
||||
String code,
|
||||
bool isSelected,
|
||||
VoidCallback onTap,
|
||||
) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? const Color(0xFF165DFF).withOpacity(0.1) : Colors.transparent,
|
||||
color: isSelected
|
||||
? const Color(0xFF165DFF).withOpacity(0.1)
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: isSelected ? const Color(0xFF165DFF) : const Color(0xFFE5E6EB),
|
||||
color: isSelected
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFFE5E6EB),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
@@ -202,7 +278,9 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isSelected ? const Color(0xFF165DFF) : const Color(0xFF1D2129),
|
||||
color: isSelected
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF1D2129),
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
@@ -258,11 +336,13 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(AppLocalizations.of(context).translate('login.logout')),
|
||||
content: const Text('确定要退出登录吗?'),
|
||||
content: Text(
|
||||
AppLocalizations.of(context).translate('login.confirm_logout'),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('取消'),
|
||||
child: Text(AppLocalizations.of(context).translate('my_v2.cancel')),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
@@ -275,7 +355,9 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: const Color(0xFFF53F3F),
|
||||
),
|
||||
child: const Text('确定'),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('my_v2.confirm'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/domain/entities/my_entities.dart';
|
||||
|
||||
/// 菜单项卡片组件(100% 还原设计稿)
|
||||
@@ -24,9 +25,7 @@ class MenuItemCard extends StatelessWidget {
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
// 图标
|
||||
@@ -39,21 +38,27 @@ class MenuItemCard extends StatelessWidget {
|
||||
// 标题
|
||||
Expanded(
|
||||
child: Text(
|
||||
item.title,
|
||||
_getLocalizedTitle(context, item),
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
// 副标题或开关
|
||||
if (item.subTitle != null) ...[
|
||||
Text(
|
||||
item.subTitle!,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF86909C),
|
||||
Flexible(
|
||||
child: Text(
|
||||
item.subTitle!,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
@@ -65,7 +70,9 @@ class MenuItemCard extends StatelessWidget {
|
||||
value: item.switchValue,
|
||||
onChanged: onSwitchChanged,
|
||||
activeColor: const Color(0xFF165DFF),
|
||||
activeTrackColor: const Color(0xFF165DFF).withOpacity(0.3),
|
||||
activeTrackColor: const Color(
|
||||
0xFF165DFF,
|
||||
).withOpacity(0.3),
|
||||
inactiveThumbColor: const Color(0xFFC9CDD4),
|
||||
inactiveTrackColor: const Color(0xFFE5E6EB),
|
||||
),
|
||||
@@ -115,4 +122,25 @@ class MenuItemCard extends StatelessWidget {
|
||||
return Icons.label_outline;
|
||||
}
|
||||
}
|
||||
|
||||
String _getLocalizedTitle(BuildContext context, MenuItemEntity item) {
|
||||
switch (item.id) {
|
||||
case 'personal_info':
|
||||
return AppLocalizations.of(context).translate('my_v2.personal_info');
|
||||
case 'message_settings':
|
||||
return AppLocalizations.of(context).translate('my_v2.message_settings');
|
||||
case 'offline_cache':
|
||||
return AppLocalizations.of(context).translate('my_v2.offline_cache');
|
||||
case 'night_mode':
|
||||
return AppLocalizations.of(context).translate('my_v2.night_mode');
|
||||
case 'system_settings':
|
||||
return AppLocalizations.of(context).translate('my_v2.system_settings');
|
||||
case 'help_feedback':
|
||||
return AppLocalizations.of(context).translate('my_v2.help_feedback');
|
||||
case 'about_us':
|
||||
return AppLocalizations.of(context).translate('my_v2.about_us');
|
||||
default:
|
||||
return item.title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/constants/my_constants.dart';
|
||||
|
||||
/// 快捷入口卡片组件(我的消息、我的收藏、我的工单)
|
||||
@@ -36,32 +37,24 @@ class QuickActionCard extends StatelessWidget {
|
||||
// 我的消息
|
||||
_buildQuickActionItem(
|
||||
icon: Icons.notifications_outlined,
|
||||
label: '我的消息',
|
||||
label: AppLocalizations.of(context).translate('my_v2.message'),
|
||||
onTap: onMessageTap,
|
||||
showBadge: true,
|
||||
),
|
||||
// 分割线
|
||||
Container(
|
||||
width: 1,
|
||||
height: 40,
|
||||
color: const Color(0xFFF0F0F0),
|
||||
),
|
||||
Container(width: 1, height: 40, color: const Color(0xFFF0F0F0)),
|
||||
// 我的收藏
|
||||
_buildQuickActionItem(
|
||||
icon: Icons.favorite_border,
|
||||
label: '我的收藏',
|
||||
label: AppLocalizations.of(context).translate('my_v2.favorite'),
|
||||
onTap: onFavoriteTap,
|
||||
),
|
||||
// 分割线
|
||||
Container(
|
||||
width: 1,
|
||||
height: 40,
|
||||
color: const Color(0xFFF0F0F0),
|
||||
),
|
||||
Container(width: 1, height: 40, color: const Color(0xFFF0F0F0)),
|
||||
// 我的工单
|
||||
_buildQuickActionItem(
|
||||
icon: Icons.assignment_outlined,
|
||||
label: '我的工单',
|
||||
label: AppLocalizations.of(context).translate('my_v2.work_order'),
|
||||
onTap: onWorkOrderTap,
|
||||
),
|
||||
],
|
||||
@@ -79,18 +72,14 @@ class QuickActionCard extends StatelessWidget {
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: SizedBox(
|
||||
width: 80,
|
||||
width: 90,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 24,
|
||||
color: MyColors.primary,
|
||||
),
|
||||
Icon(icon, size: 24, color: MyColors.primary),
|
||||
if (showBadge)
|
||||
Positioned(
|
||||
right: -4,
|
||||
@@ -113,6 +102,9 @@ class QuickActionCard extends StatelessWidget {
|
||||
fontSize: 13,
|
||||
color: MyColors.textSecondary,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -27,26 +27,26 @@ class AppDimensions {
|
||||
|
||||
/// 上报类型枚举
|
||||
enum ReportType {
|
||||
deviceFault('设备故障', Icons.notifications_active),
|
||||
patrolRecord('巡检记录', Icons.description),
|
||||
hiddenDanger('隐患上报', Icons.shield),
|
||||
defectReport('缺陷上报', Icons.build);
|
||||
deviceFault('report.device_fault', Icons.notifications_active),
|
||||
patrolRecord('report.patrol_record', Icons.description),
|
||||
hiddenDanger('report.hidden_danger', Icons.shield),
|
||||
defectReport('report.defect_report', Icons.build);
|
||||
|
||||
final String label;
|
||||
final String labelKey;
|
||||
final IconData icon;
|
||||
|
||||
const ReportType(this.label, this.icon);
|
||||
const ReportType(this.labelKey, this.icon);
|
||||
}
|
||||
|
||||
/// 问题等级枚举
|
||||
enum ProblemLevel {
|
||||
normal('一般', Color(0xFF86909C), Color(0xFFE5E6EB)),
|
||||
important('重要', Color(0xFFFF7D00), Color(0xFFE5E6EB)),
|
||||
urgent('紧急', Color(0xFFF53F3F), Color(0xFFF53F3F));
|
||||
normal('report.normal', Color(0xFF86909C), Color(0xFFE5E6EB)),
|
||||
important('report.important', Color(0xFFFF7D00), Color(0xFFE5E6EB)),
|
||||
urgent('report.urgent', Color(0xFFF53F3F), Color(0xFFF53F3F));
|
||||
|
||||
final String label;
|
||||
final String labelKey;
|
||||
final Color textColor;
|
||||
final Color borderColor;
|
||||
|
||||
const ProblemLevel(this.label, this.textColor, this.borderColor);
|
||||
const ProblemLevel(this.labelKey, this.textColor, this.borderColor);
|
||||
}
|
||||
|
||||
@@ -9,18 +9,18 @@ class ReportCubit extends Cubit<ReportState> {
|
||||
final SubmitReportUseCase submitReportUseCase;
|
||||
|
||||
ReportCubit({required this.submitReportUseCase})
|
||||
: super(ReportFormState(report: ReportEntity()));
|
||||
: super(ReportFormState(report: ReportEntity()));
|
||||
|
||||
/// 选择上报类型
|
||||
void selectReportType(ReportType type) {
|
||||
if (state is ReportFormState) {
|
||||
final currentState = state as ReportFormState;
|
||||
emit(currentState.copyWith(
|
||||
selectedReportType: type,
|
||||
report: currentState.report.copyWith(
|
||||
reportType: type.label,
|
||||
emit(
|
||||
currentState.copyWith(
|
||||
selectedReportType: type,
|
||||
report: currentState.report.copyWith(reportType: type.labelKey),
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,10 +28,12 @@ class ReportCubit extends Cubit<ReportState> {
|
||||
void selectDevice(String device) {
|
||||
if (state is ReportFormState) {
|
||||
final currentState = state as ReportFormState;
|
||||
emit(currentState.copyWith(
|
||||
selectedDevice: device,
|
||||
report: currentState.report.copyWith(deviceId: device),
|
||||
));
|
||||
emit(
|
||||
currentState.copyWith(
|
||||
selectedDevice: device,
|
||||
report: currentState.report.copyWith(deviceId: device),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,10 +41,12 @@ class ReportCubit extends Cubit<ReportState> {
|
||||
void updateLocation(String location) {
|
||||
if (state is ReportFormState) {
|
||||
final currentState = state as ReportFormState;
|
||||
emit(currentState.copyWith(
|
||||
location: location,
|
||||
report: currentState.report.copyWith(location: location),
|
||||
));
|
||||
emit(
|
||||
currentState.copyWith(
|
||||
location: location,
|
||||
report: currentState.report.copyWith(location: location),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,9 +54,11 @@ class ReportCubit extends Cubit<ReportState> {
|
||||
void updateDescription(String description) {
|
||||
if (state is ReportFormState) {
|
||||
final currentState = state as ReportFormState;
|
||||
emit(currentState.copyWith(
|
||||
report: currentState.report.copyWith(description: description),
|
||||
));
|
||||
emit(
|
||||
currentState.copyWith(
|
||||
report: currentState.report.copyWith(description: description),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,12 +66,12 @@ class ReportCubit extends Cubit<ReportState> {
|
||||
void selectProblemLevel(ProblemLevel level) {
|
||||
if (state is ReportFormState) {
|
||||
final currentState = state as ReportFormState;
|
||||
emit(currentState.copyWith(
|
||||
selectedProblemLevel: level,
|
||||
report: currentState.report.copyWith(
|
||||
problemLevel: level.label,
|
||||
emit(
|
||||
currentState.copyWith(
|
||||
selectedProblemLevel: level,
|
||||
report: currentState.report.copyWith(problemLevel: level.labelKey),
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,10 +81,12 @@ class ReportCubit extends Cubit<ReportState> {
|
||||
final currentState = state as ReportFormState;
|
||||
final updatedFiles = List<String>.from(currentState.mediaFiles)
|
||||
..add(filePath);
|
||||
emit(currentState.copyWith(
|
||||
mediaFiles: updatedFiles,
|
||||
report: currentState.report.copyWith(mediaUrls: updatedFiles),
|
||||
));
|
||||
emit(
|
||||
currentState.copyWith(
|
||||
mediaFiles: updatedFiles,
|
||||
report: currentState.report.copyWith(mediaUrls: updatedFiles),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,10 +96,12 @@ class ReportCubit extends Cubit<ReportState> {
|
||||
final currentState = state as ReportFormState;
|
||||
final updatedFiles = List<String>.from(currentState.mediaFiles)
|
||||
..removeAt(index);
|
||||
emit(currentState.copyWith(
|
||||
mediaFiles: updatedFiles,
|
||||
report: currentState.report.copyWith(mediaUrls: updatedFiles),
|
||||
));
|
||||
emit(
|
||||
currentState.copyWith(
|
||||
mediaFiles: updatedFiles,
|
||||
report: currentState.report.copyWith(mediaUrls: updatedFiles),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../cubit/report_cubit.dart';
|
||||
import '../states/report_state.dart';
|
||||
import '../constants/report_constants.dart';
|
||||
@@ -46,9 +47,7 @@ class _ReportPageContent extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
if (state is ReportSubmitting) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColors.primary,
|
||||
),
|
||||
child: CircularProgressIndicator(color: AppColors.primary),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -57,9 +56,7 @@ class _ReportPageContent extends StatelessWidget {
|
||||
return Column(
|
||||
children: [
|
||||
_buildAppBar(context, state.location, cubit),
|
||||
Expanded(
|
||||
child: _buildFormContent(context, state),
|
||||
),
|
||||
Expanded(child: _buildFormContent(context, state)),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -72,7 +69,11 @@ class _ReportPageContent extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// 构建导航栏
|
||||
PreferredSizeWidget _buildAppBar(BuildContext context, String location, ReportCubit cubit) {
|
||||
PreferredSizeWidget _buildAppBar(
|
||||
BuildContext context,
|
||||
String location,
|
||||
ReportCubit cubit,
|
||||
) {
|
||||
return PreferredSize(
|
||||
preferredSize: const Size.fromHeight(100),
|
||||
child: Container(
|
||||
@@ -89,9 +90,9 @@ class _ReportPageContent extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'现场上报',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('report.title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColors.textPrimary,
|
||||
@@ -101,9 +102,9 @@ class _ReportPageContent extends StatelessWidget {
|
||||
onTap: () {
|
||||
context.read<ReportCubit>().submitReport();
|
||||
},
|
||||
child: const Text(
|
||||
'提交',
|
||||
style: TextStyle(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('report.submit'),
|
||||
style: const TextStyle(
|
||||
color: AppColors.primary,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -240,19 +241,12 @@ class _ReportPageContent extends StatelessWidget {
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.location_on,
|
||||
color: AppColors.primary,
|
||||
size: 20,
|
||||
),
|
||||
const Icon(Icons.location_on, color: AppColors.primary, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
location,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
style: TextStyle(fontSize: 16, color: AppColors.textPrimary),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -270,7 +264,7 @@ class _ReportPageContent extends StatelessWidget {
|
||||
maxHeight: 1080,
|
||||
imageQuality: 85,
|
||||
);
|
||||
|
||||
|
||||
if (image != null) {
|
||||
cubit.addMediaFile(image.path);
|
||||
}
|
||||
@@ -287,7 +281,7 @@ class _ReportPageContent extends StatelessWidget {
|
||||
source: ImageSource.camera,
|
||||
maxDuration: const Duration(minutes: 5),
|
||||
);
|
||||
|
||||
|
||||
if (video != null) {
|
||||
cubit.addMediaFile(video.path);
|
||||
}
|
||||
@@ -301,10 +295,8 @@ class _ReportPageContent extends StatelessWidget {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => MediaPreviewPage(
|
||||
mediaFiles: mediaFiles,
|
||||
initialIndex: index,
|
||||
),
|
||||
builder: (context) =>
|
||||
MediaPreviewPage(mediaFiles: mediaFiles, initialIndex: index),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -322,7 +314,9 @@ class _ReportPageContent extends StatelessWidget {
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.image),
|
||||
title: const Text('选择图片'),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).translate('report.select_image'),
|
||||
),
|
||||
onTap: () async {
|
||||
Navigator.pop(context);
|
||||
final XFile? image = await picker.pickImage(
|
||||
@@ -338,7 +332,9 @@ class _ReportPageContent extends StatelessWidget {
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.video_library),
|
||||
title: const Text('选择视频'),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).translate('report.select_video'),
|
||||
),
|
||||
onTap: () async {
|
||||
Navigator.pop(context);
|
||||
final XFile? video = await picker.pickVideo(
|
||||
@@ -360,19 +356,20 @@ class _ReportPageContent extends StatelessWidget {
|
||||
|
||||
/// 显示位置选择器
|
||||
void _showLocationPicker(BuildContext context, ReportCubit cubit) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
final locations = [
|
||||
'主厂房A区',
|
||||
'主厂房B区',
|
||||
'锅炉房',
|
||||
'汽机房',
|
||||
'控制室',
|
||||
'配电室',
|
||||
loc.translate('report.main_building_a'),
|
||||
loc.translate('report.main_building_b'),
|
||||
loc.translate('report.boiler_room'),
|
||||
loc.translate('report.turbine_room'),
|
||||
loc.translate('report.control_room'),
|
||||
loc.translate('report.power_distribution_room'),
|
||||
];
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('选择位置'),
|
||||
title: Text(loc.translate('report.select_location')),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -390,7 +387,7 @@ class _ReportPageContent extends StatelessWidget {
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('取消'),
|
||||
child: Text(loc.translate('report.cancel')),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -399,19 +396,20 @@ class _ReportPageContent extends StatelessWidget {
|
||||
|
||||
/// 显示设备选择器
|
||||
void _showDevicePicker(BuildContext context, ReportCubit cubit) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
final devices = [
|
||||
'锅炉1号',
|
||||
'锅炉2号',
|
||||
'汽轮机1号',
|
||||
'发电机1号',
|
||||
'变压器1号',
|
||||
'水泵1号',
|
||||
loc.translate('report.boiler_1'),
|
||||
loc.translate('report.boiler_2'),
|
||||
loc.translate('report.turbine_1'),
|
||||
loc.translate('report.generator_1'),
|
||||
loc.translate('report.transformer_1'),
|
||||
loc.translate('report.water_pump_1'),
|
||||
];
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('选择设备'),
|
||||
title: Text(loc.translate('report.select_device')),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -429,7 +427,7 @@ class _ReportPageContent extends StatelessWidget {
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('取消'),
|
||||
child: Text(loc.translate('report.cancel')),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -438,19 +436,20 @@ class _ReportPageContent extends StatelessWidget {
|
||||
|
||||
/// 显示成功对话框
|
||||
void _showSuccessDialog(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('提交成功'),
|
||||
content: const Text('您的上报已成功提交'),
|
||||
title: Text(loc.translate('report.submit_success')),
|
||||
content: Text(loc.translate('report.submit_success_message')),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context); // 返回上一页
|
||||
},
|
||||
child: const Text('确定'),
|
||||
child: Text(loc.translate('report.confirm')),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -459,15 +458,16 @@ class _ReportPageContent extends StatelessWidget {
|
||||
|
||||
/// 显示错误对话框
|
||||
void _showErrorDialog(BuildContext context, String message) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('提交失败'),
|
||||
title: Text(loc.translate('report.submit_failed')),
|
||||
content: Text(message),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('确定'),
|
||||
child: Text(loc.translate('report.confirm')),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../constants/report_constants.dart';
|
||||
|
||||
/// 问题描述输入模块
|
||||
@@ -14,6 +15,7 @@ class DescriptionInput extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: AppDimensions.horizontalPadding,
|
||||
@@ -34,8 +36,8 @@ class DescriptionInput extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'问题描述',
|
||||
style: TextStyle(
|
||||
loc.translate('report.problem_description'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.textPrimary,
|
||||
@@ -47,35 +49,38 @@ class DescriptionInput extends StatelessWidget {
|
||||
maxLength: 200,
|
||||
onChanged: onChanged,
|
||||
decoration: InputDecoration(
|
||||
hintText: '请详细描述问题现象...',
|
||||
hintStyle: TextStyle(color: AppColors.textHint),
|
||||
hintText: loc.translate('report.description_hint'),
|
||||
hintStyle: const TextStyle(color: AppColors.textHint),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppDimensions.borderRadiusSmall),
|
||||
borderSide: BorderSide(color: AppColors.borderColor),
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppDimensions.borderRadiusSmall,
|
||||
),
|
||||
borderSide: const BorderSide(color: AppColors.borderColor),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppDimensions.borderRadiusSmall),
|
||||
borderSide: BorderSide(color: AppColors.borderColor),
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppDimensions.borderRadiusSmall,
|
||||
),
|
||||
borderSide: const BorderSide(color: AppColors.borderColor),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppDimensions.borderRadiusSmall),
|
||||
borderSide: BorderSide(color: AppColors.primary, width: 2),
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppDimensions.borderRadiusSmall,
|
||||
),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.primary,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
counterText: '',
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
style: const TextStyle(fontSize: 14, color: AppColors.textPrimary),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text(
|
||||
'${description?.length ?? 0}/200',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColors.textHint,
|
||||
),
|
||||
style: const TextStyle(fontSize: 12, color: AppColors.textHint),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../constants/report_constants.dart';
|
||||
|
||||
/// 设备选择器
|
||||
@@ -6,11 +7,7 @@ class DeviceSelector extends StatelessWidget {
|
||||
final String? selectedDevice;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const DeviceSelector({
|
||||
super.key,
|
||||
this.selectedDevice,
|
||||
required this.onTap,
|
||||
});
|
||||
const DeviceSelector({super.key, this.selectedDevice, required this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -36,8 +33,8 @@ class DeviceSelector extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'设备选择',
|
||||
style: TextStyle(
|
||||
AppLocalizations.of(context).translate('report.select_device'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.textPrimary,
|
||||
@@ -46,7 +43,10 @@ class DeviceSelector extends StatelessWidget {
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
selectedDevice ?? '请选择设备',
|
||||
selectedDevice ??
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('report.please_select_device'),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: selectedDevice != null
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../constants/report_constants.dart';
|
||||
|
||||
/// 问题等级选择器
|
||||
@@ -14,6 +15,7 @@ class LevelSelector extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: AppDimensions.horizontalPadding,
|
||||
@@ -34,8 +36,8 @@ class LevelSelector extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'问题等级',
|
||||
style: TextStyle(
|
||||
loc.translate('report.problem_level'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.textPrimary,
|
||||
@@ -55,19 +57,27 @@ class LevelSelector extends StatelessWidget {
|
||||
color: isSelected && level == ProblemLevel.urgent
|
||||
? AppColors.danger.withOpacity(0.1)
|
||||
: AppColors.background,
|
||||
borderRadius: BorderRadius.circular(AppDimensions.borderRadiusSmall),
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppDimensions.borderRadiusSmall,
|
||||
),
|
||||
border: Border.all(
|
||||
color: isSelected ? level.borderColor : AppColors.borderColor,
|
||||
color: isSelected
|
||||
? level.borderColor
|
||||
: AppColors.borderColor,
|
||||
width: isSelected ? 2 : 1,
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
level.label,
|
||||
loc.translate(level.labelKey),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isSelected ? level.textColor : level.textColor.withOpacity(0.6),
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
color: isSelected
|
||||
? level.textColor
|
||||
: level.textColor.withOpacity(0.6),
|
||||
fontWeight: isSelected
|
||||
? FontWeight.w600
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../constants/report_constants.dart';
|
||||
|
||||
/// 媒体上传模块
|
||||
@@ -23,6 +24,7 @@ class MediaUploader extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: AppDimensions.horizontalPadding,
|
||||
@@ -43,8 +45,8 @@ class MediaUploader extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'上传图片/视频',
|
||||
style: TextStyle(
|
||||
loc.translate('report.upload_media'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.textPrimary,
|
||||
@@ -58,14 +60,14 @@ class MediaUploader extends StatelessWidget {
|
||||
// 拍照按钮
|
||||
_buildUploadButton(
|
||||
icon: Icons.camera_alt,
|
||||
label: '拍照',
|
||||
label: loc.translate('report.take_photo'),
|
||||
onTap: onCameraTap,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// 录像按钮
|
||||
_buildUploadButton(
|
||||
icon: Icons.videocam,
|
||||
label: '录像',
|
||||
label: loc.translate('report.record_video'),
|
||||
onTap: onVideoTap,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
@@ -74,84 +76,94 @@ class MediaUploader extends StatelessWidget {
|
||||
final String filePath = entry.value;
|
||||
final bool isNetworkImage = filePath.startsWith('http');
|
||||
final bool isVideo = _isVideoFile(filePath);
|
||||
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => onTap?.call(entry.key),
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
margin: const EdgeInsets.only(right: 8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(AppDimensions.borderRadiusSmall),
|
||||
color: AppColors.cardBackground,
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(AppDimensions.borderRadiusSmall),
|
||||
child: isVideo
|
||||
? _buildVideoThumbnail(filePath)
|
||||
: (isNetworkImage
|
||||
? Image.network(
|
||||
filePath,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return _buildPlaceholderIcon(Icons.broken_image);
|
||||
},
|
||||
)
|
||||
: Image.file(
|
||||
File(filePath),
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return _buildPlaceholderIcon(Icons.broken_image);
|
||||
},
|
||||
)),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 4,
|
||||
right: 12,
|
||||
child: GestureDetector(
|
||||
onTap: () => onRemove(entry.key),
|
||||
child: Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.black54,
|
||||
shape: BoxShape.circle,
|
||||
children: [
|
||||
Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
margin: const EdgeInsets.only(right: 8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppDimensions.borderRadiusSmall,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.close,
|
||||
size: 14,
|
||||
color: Colors.white,
|
||||
color: AppColors.cardBackground,
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppDimensions.borderRadiusSmall,
|
||||
),
|
||||
child: isVideo
|
||||
? _buildVideoThumbnail(filePath)
|
||||
: (isNetworkImage
|
||||
? Image.network(
|
||||
filePath,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder:
|
||||
(context, error, stackTrace) {
|
||||
return _buildPlaceholderIcon(
|
||||
Icons.broken_image,
|
||||
);
|
||||
},
|
||||
)
|
||||
: Image.file(
|
||||
File(filePath),
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder:
|
||||
(context, error, stackTrace) {
|
||||
return _buildPlaceholderIcon(
|
||||
Icons.broken_image,
|
||||
);
|
||||
},
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 视频播放图标
|
||||
if (isVideo)
|
||||
Positioned(
|
||||
child: Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
margin: const EdgeInsets.only(right: 8),
|
||||
alignment: Alignment.center,
|
||||
top: 4,
|
||||
right: 12,
|
||||
child: GestureDetector(
|
||||
onTap: () => onRemove(entry.key),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
width: 20,
|
||||
height: 20,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.black38,
|
||||
color: Colors.black54,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.play_arrow,
|
||||
Icons.close,
|
||||
size: 14,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// 视频播放图标
|
||||
if (isVideo)
|
||||
Positioned(
|
||||
child: Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
margin: const EdgeInsets.only(right: 8),
|
||||
alignment: Alignment.center,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.black38,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.play_arrow,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
// 添加按钮
|
||||
@@ -228,17 +240,9 @@ class MediaUploader extends StatelessWidget {
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
// 灰色背景
|
||||
Container(
|
||||
color: Colors.grey[300],
|
||||
),
|
||||
Container(color: Colors.grey[300]),
|
||||
// 视频图标
|
||||
const Center(
|
||||
child: Icon(
|
||||
Icons.videocam,
|
||||
color: Colors.grey,
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
const Center(child: Icon(Icons.videocam, color: Colors.grey, size: 32)),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -247,13 +251,7 @@ class MediaUploader extends StatelessWidget {
|
||||
Widget _buildPlaceholderIcon(IconData icon) {
|
||||
return Container(
|
||||
color: Colors.grey[300],
|
||||
child: Center(
|
||||
child: Icon(
|
||||
icon,
|
||||
color: Colors.grey,
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
child: Center(child: Icon(icon, color: Colors.grey, size: 32)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../constants/report_constants.dart';
|
||||
|
||||
/// 上报类型选择器
|
||||
@@ -15,21 +16,32 @@ class ReportTypeSelector extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppDimensions.horizontalPadding),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: AppDimensions.horizontalPadding,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: ReportType.values.map((type) {
|
||||
final isSelected = selectedType == type;
|
||||
return Expanded(
|
||||
return Flexible(
|
||||
flex: 1,
|
||||
child: GestureDetector(
|
||||
onTap: () => onSelected(type),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 3),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 14,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.background,
|
||||
borderRadius: BorderRadius.circular(AppDimensions.borderRadiusSmall),
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppDimensions.borderRadiusSmall,
|
||||
),
|
||||
border: Border.all(
|
||||
color: isSelected ? AppColors.primary : AppColors.borderColor,
|
||||
color: isSelected
|
||||
? AppColors.primary
|
||||
: AppColors.borderColor,
|
||||
width: isSelected ? 2 : 1,
|
||||
),
|
||||
boxShadow: [
|
||||
@@ -45,17 +57,27 @@ class ReportTypeSelector extends StatelessWidget {
|
||||
children: [
|
||||
Icon(
|
||||
type.icon,
|
||||
color: isSelected ? AppColors.primary : AppColors.textHint,
|
||||
size: 24,
|
||||
color: isSelected
|
||||
? AppColors.primary
|
||||
: AppColors.textHint,
|
||||
size: 26,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
type.label,
|
||||
AppLocalizations.of(context).translate(type.labelKey),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isSelected ? AppColors.primary : AppColors.textSecondary,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
fontSize: 11,
|
||||
height: 1.2,
|
||||
color: isSelected
|
||||
? AppColors.primary
|
||||
: AppColors.textSecondary,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.w600
|
||||
: FontWeight.normal,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/bloc/alarm_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/bloc/alarm_state.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/constants/alarm_constants.dart';
|
||||
@@ -44,9 +45,7 @@ class _AlarmCenterPageState extends State<AlarmCenterPage> {
|
||||
child: BlocBuilder<AlarmCubit, AlarmState>(
|
||||
builder: (context, state) {
|
||||
if (state is AlarmLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
if (state is AlarmError) {
|
||||
@@ -64,7 +63,11 @@ class _AlarmCenterPageState extends State<AlarmCenterPage> {
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () => _cubit.loadAlarms(),
|
||||
child: const Text('重试'),
|
||||
child: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.retry'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -96,22 +99,34 @@ class _AlarmCenterPageState extends State<AlarmCenterPage> {
|
||||
//const SizedBox(height: AlarmDimensions.moduleSpacing),
|
||||
// 告警统计卡片
|
||||
AlarmCountCard(count: state.count),
|
||||
const SizedBox(height: AlarmDimensions.moduleSpacing),
|
||||
const SizedBox(
|
||||
height: AlarmDimensions.moduleSpacing,
|
||||
),
|
||||
// 告警列表
|
||||
...state.alarms.map((alarm) {
|
||||
return AlarmItemCard(
|
||||
alarm: alarm,
|
||||
onTap: () {
|
||||
context.push('/alarm_center/detail/${alarm.id}');
|
||||
context.push(
|
||||
'/alarm_center/detail/${alarm.id}',
|
||||
);
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
const SizedBox(height: AlarmDimensions.moduleSpacing),
|
||||
const SizedBox(
|
||||
height: AlarmDimensions.moduleSpacing,
|
||||
),
|
||||
// AI 诊断建议(仅当有 AI 诊断内容时显示)
|
||||
if (state.alarms.any((alarm) => alarm.aiDiagnosis != null))
|
||||
if (state.alarms.any(
|
||||
(alarm) => alarm.aiDiagnosis != null,
|
||||
))
|
||||
AiDiagnosisCard(
|
||||
content: state.alarms
|
||||
.firstWhere((alarm) => alarm.aiDiagnosis != null)
|
||||
content:
|
||||
state.alarms
|
||||
.firstWhere(
|
||||
(alarm) =>
|
||||
alarm.aiDiagnosis != null,
|
||||
)
|
||||
.aiDiagnosis ??
|
||||
'',
|
||||
onViewDetails: () {
|
||||
@@ -153,20 +168,61 @@ class _AlarmCenterPageState extends State<AlarmCenterPage> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'筛选条件',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.filter_title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AlarmColors.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildFilterOption('告警等级', ['高危', '中危', '低危', '提示']),
|
||||
_buildFilterOption(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.alarm_level'),
|
||||
[
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.high_risk'),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.medium_risk'),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.low_risk'),
|
||||
AppLocalizations.of(context).translate('alarm_center.hint'),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildFilterOption('时间范围', ['今天', '本周', '本月', '全部']),
|
||||
_buildFilterOption(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.time_range'),
|
||||
[
|
||||
AppLocalizations.of(context).translate('alarm_center.today'),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.this_week'),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.this_month'),
|
||||
AppLocalizations.of(context).translate('alarm_center.all'),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildFilterOption('区域', ['A区', 'B区', 'C区', 'D区', '全部']),
|
||||
_buildFilterOption(
|
||||
AppLocalizations.of(context).translate('alarm_center.area'),
|
||||
[
|
||||
'A区',
|
||||
'B区',
|
||||
'C区',
|
||||
'D区',
|
||||
AppLocalizations.of(context).translate('alarm_center.all'),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
@@ -181,9 +237,11 @@ class _AlarmCenterPageState extends State<AlarmCenterPage> {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'应用筛选',
|
||||
style: TextStyle(
|
||||
child: Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.apply_filter'),
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
@@ -204,9 +262,9 @@ class _AlarmCenterPageState extends State<AlarmCenterPage> {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
const Text(
|
||||
'告警中心',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('alarm_center.title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/domain/entities/alarm_count_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/constants/alarm_constants.dart';
|
||||
|
||||
/// 告警统计卡片
|
||||
class AlarmCountCard extends StatelessWidget {
|
||||
const AlarmCountCard({
|
||||
super.key,
|
||||
required this.count,
|
||||
});
|
||||
const AlarmCountCard({super.key, required this.count});
|
||||
|
||||
final AlarmCountEntity count;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: AlarmDimensions.horizontalPadding),
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: AlarmDimensions.horizontalPadding,
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AlarmColors.background,
|
||||
@@ -25,7 +25,9 @@ class AlarmCountCard extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildCountItem(
|
||||
label: '未处理',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.unprocessed'),
|
||||
value: count.unprocessed,
|
||||
color: AlarmColors.danger,
|
||||
bgColor: AlarmColors.unprocessedBg,
|
||||
@@ -51,7 +53,9 @@ class AlarmCountCard extends StatelessWidget {
|
||||
_buildDivider(),
|
||||
Expanded(
|
||||
child: _buildCountItem(
|
||||
label: '今日新增',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.today_new'),
|
||||
value: count.todayNew,
|
||||
color: const Color(0xFF1D2129),
|
||||
),
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/domain/entities/alarm_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/constants/alarm_constants.dart';
|
||||
|
||||
/// 告警项卡片
|
||||
class AlarmItemCard extends StatelessWidget {
|
||||
const AlarmItemCard({
|
||||
super.key,
|
||||
required this.alarm,
|
||||
this.onTap,
|
||||
});
|
||||
const AlarmItemCard({super.key, required this.alarm, this.onTap});
|
||||
|
||||
final AlarmEntity alarm;
|
||||
final VoidCallback? onTap;
|
||||
@@ -34,11 +31,7 @@ class AlarmItemCard extends StatelessWidget {
|
||||
// 第一行:图标 + 标题 + 等级标签
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
alarm.level.icon,
|
||||
color: alarm.level.color,
|
||||
size: 20,
|
||||
),
|
||||
Icon(alarm.level.icon, color: alarm.level.color, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
@@ -51,13 +44,16 @@ class AlarmItemCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: alarm.level.color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
alarm.level.label,
|
||||
_getLevelLabel(context, alarm.level),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: alarm.level.color,
|
||||
@@ -70,7 +66,7 @@ class AlarmItemCard extends StatelessWidget {
|
||||
const SizedBox(height: 8),
|
||||
// 第二行:区域和设备
|
||||
Text(
|
||||
'区域:${alarm.area} / 设备:${alarm.device}',
|
||||
'${AppLocalizations.of(context).translate('alarm_center.area')}:${alarm.area} / ${AppLocalizations.of(context).translate('alarm_center.device')}:${alarm.device}',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: AlarmColors.textSecondary,
|
||||
@@ -89,7 +85,7 @@ class AlarmItemCard extends StatelessWidget {
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
alarm.status.label,
|
||||
_getStatusLabel(context, alarm.status),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: alarm.status == AlarmStatus.unconfirmed
|
||||
@@ -113,4 +109,32 @@ class AlarmItemCard extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _getLevelLabel(BuildContext context, AlarmLevel level) {
|
||||
switch (level) {
|
||||
case AlarmLevel.danger:
|
||||
return AppLocalizations.of(context).translate('alarm_center.high_risk');
|
||||
case AlarmLevel.warning:
|
||||
return AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.medium_risk');
|
||||
case AlarmLevel.low:
|
||||
return AppLocalizations.of(context).translate('alarm_center.low_risk');
|
||||
case AlarmLevel.info:
|
||||
return AppLocalizations.of(context).translate('alarm_center.hint');
|
||||
}
|
||||
}
|
||||
|
||||
String _getStatusLabel(BuildContext context, AlarmStatus status) {
|
||||
switch (status) {
|
||||
case AlarmStatus.unconfirmed:
|
||||
return AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.unconfirmed');
|
||||
case AlarmStatus.confirmed:
|
||||
return AppLocalizations.of(context).translate('alarm_center.confirmed');
|
||||
case AlarmStatus.recovered:
|
||||
return AppLocalizations.of(context).translate('alarm_center.recovered');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/constants/alarm_constants.dart';
|
||||
|
||||
/// 告警筛选标签栏
|
||||
@@ -35,11 +36,15 @@ class AlarmTabBar extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
filter.label,
|
||||
_getFilterLabel(context, filter),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
color: isSelected ? AlarmColors.primary : AlarmColors.textSecondary,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
color: isSelected
|
||||
? AlarmColors.primary
|
||||
: AlarmColors.textSecondary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
@@ -47,7 +52,9 @@ class AlarmTabBar extends StatelessWidget {
|
||||
height: 2,
|
||||
width: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? AlarmColors.primary : Colors.transparent,
|
||||
color: isSelected
|
||||
? AlarmColors.primary
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(1),
|
||||
),
|
||||
),
|
||||
@@ -59,4 +66,19 @@ class AlarmTabBar extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _getFilterLabel(BuildContext context, AlarmFilterTab filter) {
|
||||
switch (filter) {
|
||||
case AlarmFilterTab.all:
|
||||
return AppLocalizations.of(context).translate('alarm_center.all');
|
||||
case AlarmFilterTab.unprocessed:
|
||||
return AppLocalizations.of(
|
||||
context,
|
||||
).translate('alarm_center.unprocessed');
|
||||
case AlarmFilterTab.confirmed:
|
||||
return AppLocalizations.of(context).translate('alarm_center.confirmed');
|
||||
case AlarmFilterTab.recovered:
|
||||
return AppLocalizations.of(context).translate('alarm_center.recovered');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../../../../../core/consts/workorder_consts.dart';
|
||||
import '../cubit/workorder_cubit.dart';
|
||||
import '../widgets/workorder_tabbar.dart';
|
||||
@@ -18,9 +19,15 @@ class WorkOrderPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
// 创建 Repository 和 UseCases
|
||||
final remoteDataSource = WorkOrderRemoteDataSourceImpl();
|
||||
final repository = WorkOrderRepositoryImpl(remoteDataSource: remoteDataSource);
|
||||
final getWorkOrderListUseCase = GetWorkOrderListUseCase(repository: repository);
|
||||
final getWorkOrderCountUseCase = GetWorkOrderCountUseCase(repository: repository);
|
||||
final repository = WorkOrderRepositoryImpl(
|
||||
remoteDataSource: remoteDataSource,
|
||||
);
|
||||
final getWorkOrderListUseCase = GetWorkOrderListUseCase(
|
||||
repository: repository,
|
||||
);
|
||||
final getWorkOrderCountUseCase = GetWorkOrderCountUseCase(
|
||||
repository: repository,
|
||||
);
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) {
|
||||
@@ -87,7 +94,9 @@ class WorkOrderPage extends StatelessWidget {
|
||||
backgroundColor: AppConstants.primaryColor,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
child: const Text('重试'),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('work_order_v2.retry'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -99,10 +108,10 @@ class WorkOrderPage extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
// 导航栏
|
||||
_buildAppBar(),
|
||||
_buildAppBar(context),
|
||||
// 标签栏
|
||||
_buildTabBar(context, state),
|
||||
|
||||
|
||||
// 内容区域
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
@@ -114,16 +123,18 @@ class WorkOrderPage extends StatelessWidget {
|
||||
// 统计卡片
|
||||
if (state.count != null)
|
||||
WorkOrderCountCard(count: state.count!),
|
||||
|
||||
|
||||
// 工单列表
|
||||
...state.workOrders.map((workOrder) => WorkOrderItemCard(
|
||||
workOrder: workOrder,
|
||||
onTap: () {
|
||||
// TODO: 跳转到工单详情页
|
||||
debugPrint('点击工单: ${workOrder.title}');
|
||||
},
|
||||
)),
|
||||
|
||||
...state.workOrders.map(
|
||||
(workOrder) => WorkOrderItemCard(
|
||||
workOrder: workOrder,
|
||||
onTap: () {
|
||||
// TODO: 跳转到工单详情页
|
||||
debugPrint('点击工单: ${workOrder.title}');
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
@@ -134,26 +145,22 @@ class WorkOrderPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAppBar() {
|
||||
Widget _buildAppBar(BuildContext context) {
|
||||
return Container(
|
||||
height: 44.0,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: const Row(
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'工单任务',
|
||||
style: TextStyle(
|
||||
AppLocalizations.of(context).translate('work_order_v2.title'),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
Icon(
|
||||
Icons.add_circle_outline,
|
||||
size: 24,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
const Spacer(),
|
||||
Icon(Icons.add_circle_outline, size: 24, color: Color(0xFF1D2129)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../../../../../core/consts/workorder_consts.dart';
|
||||
import '../../domain/entities/workorder_entity.dart';
|
||||
|
||||
@@ -6,10 +7,7 @@ import '../../domain/entities/workorder_entity.dart';
|
||||
class WorkOrderCountCard extends StatelessWidget {
|
||||
final WorkOrderCountEntity count;
|
||||
|
||||
const WorkOrderCountCard({
|
||||
Key? key,
|
||||
required this.count,
|
||||
}) : super(key: key);
|
||||
const WorkOrderCountCard({Key? key, required this.count}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -27,19 +25,25 @@ class WorkOrderCountCard extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
_buildCountItem(
|
||||
label: '待处理',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.pending'),
|
||||
value: count.pendingCount.toString(),
|
||||
valueColor: WorkOrderColors.primaryText,
|
||||
),
|
||||
_buildDivider(),
|
||||
_buildCountItem(
|
||||
label: '执行中',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.executing'),
|
||||
value: count.executingCount.toString(),
|
||||
valueColor: WorkOrderColors.primaryText,
|
||||
),
|
||||
_buildDivider(),
|
||||
_buildCountItem(
|
||||
label: '今日完成',
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.today_completed'),
|
||||
value: count.todayCompletedCount.toString(),
|
||||
valueColor: WorkOrderColors.primary,
|
||||
),
|
||||
@@ -78,10 +82,6 @@ class WorkOrderCountCard extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildDivider() {
|
||||
return Container(
|
||||
width: 1,
|
||||
height: 40,
|
||||
color: const Color(0xFFF0F0F0),
|
||||
);
|
||||
return Container(width: 1, height: 40, color: const Color(0xFFF0F0F0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../../../../../core/consts/workorder_consts.dart';
|
||||
import '../../domain/entities/workorder_entity.dart';
|
||||
|
||||
@@ -7,11 +8,8 @@ class WorkOrderItemCard extends StatelessWidget {
|
||||
final WorkOrderEntity workOrder;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
const WorkOrderItemCard({
|
||||
Key? key,
|
||||
required this.workOrder,
|
||||
this.onTap,
|
||||
}) : super(key: key);
|
||||
const WorkOrderItemCard({Key? key, required this.workOrder, this.onTap})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -47,48 +45,79 @@ class WorkOrderItemCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildStatusTag(),
|
||||
_buildStatusTag(context),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
|
||||
// 详情信息
|
||||
_buildDetailRow('工单号', workOrder.orderNo),
|
||||
_buildDetailRow(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.order_no'),
|
||||
workOrder.orderNo,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
|
||||
|
||||
// 优先级
|
||||
_buildDetailRow(
|
||||
'优先级',
|
||||
_getPriorityText(workOrder.priority),
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.priority'),
|
||||
_getPriorityText(context, workOrder.priority),
|
||||
valueColor: _getPriorityColor(workOrder.priority),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
|
||||
|
||||
// 根据状态显示不同信息
|
||||
if (workOrder.status == WorkOrderStatus.pending) ...[
|
||||
_buildDetailRow(
|
||||
'创建时间',
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.create_time'),
|
||||
_formatDateTime(workOrder.createTime),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
_buildDetailRow('地点', workOrder.location),
|
||||
_buildDetailRow(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.location'),
|
||||
workOrder.location,
|
||||
),
|
||||
] else if (workOrder.status == WorkOrderStatus.executing) ...[
|
||||
_buildDetailRow('执行人', workOrder.executor ?? '-'),
|
||||
_buildDetailRow(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.executor'),
|
||||
workOrder.executor ?? '-',
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
_buildDetailRow('地点', workOrder.location),
|
||||
_buildDetailRow(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.location'),
|
||||
workOrder.location,
|
||||
),
|
||||
if (workOrder.progress != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
_buildProgressBar(),
|
||||
_buildProgressBar(context),
|
||||
],
|
||||
] else if (workOrder.status == WorkOrderStatus.completed) ...[
|
||||
_buildDetailRow(
|
||||
'完成时间',
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.complete_time'),
|
||||
workOrder.completeTime != null
|
||||
? _formatDateTime(workOrder.completeTime!)
|
||||
: '-',
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
_buildDetailRow('地点', workOrder.location),
|
||||
_buildDetailRow(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.location'),
|
||||
workOrder.location,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
@@ -113,26 +142,30 @@ class WorkOrderItemCard extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusTag() {
|
||||
Widget _buildStatusTag(BuildContext context) {
|
||||
Color color;
|
||||
String text;
|
||||
|
||||
switch (workOrder.status) {
|
||||
case WorkOrderStatus.pending:
|
||||
color = AppConstants.pendingColor;
|
||||
text = '待处理';
|
||||
text = AppLocalizations.of(context).translate('work_order_v2.pending');
|
||||
break;
|
||||
case WorkOrderStatus.executing:
|
||||
color = AppConstants.executingColor;
|
||||
text = '执行中';
|
||||
text = AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.executing');
|
||||
break;
|
||||
case WorkOrderStatus.completed:
|
||||
color = AppConstants.completedColor;
|
||||
text = '已完成';
|
||||
text = AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.completed');
|
||||
break;
|
||||
default:
|
||||
color = AppConstants.auxiliaryTextColor;
|
||||
text = '未知';
|
||||
text = AppLocalizations.of(context).translate('common.unknown');
|
||||
}
|
||||
|
||||
return Row(
|
||||
@@ -144,13 +177,7 @@ class WorkOrderItemCard extends StatelessWidget {
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
child: Text(text, style: TextStyle(fontSize: 12, color: color)),
|
||||
),
|
||||
if (workOrder.status == WorkOrderStatus.executing &&
|
||||
workOrder.progress != null)
|
||||
@@ -169,39 +196,43 @@ class WorkOrderItemCard extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDetailRow(
|
||||
String label,
|
||||
String value, {
|
||||
Color? valueColor,
|
||||
}) {
|
||||
Widget _buildDetailRow(String label, String value, {Color? valueColor}) {
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
'$label:',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppConstants.auxiliaryTextColor,
|
||||
Flexible(
|
||||
child: Text(
|
||||
'$label:',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppConstants.auxiliaryTextColor,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: valueColor ?? AppConstants.secondaryTextColor,
|
||||
Flexible(
|
||||
child: Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: valueColor ?? AppConstants.secondaryTextColor,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProgressBar() {
|
||||
Widget _buildProgressBar(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'进度:',
|
||||
'${AppLocalizations.of(context).translate('work_order_v2.progress')}:',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppConstants.auxiliaryTextColor,
|
||||
@@ -224,14 +255,14 @@ class WorkOrderItemCard extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
String _getPriorityText(WorkOrderPriority priority) {
|
||||
String _getPriorityText(BuildContext context, WorkOrderPriority priority) {
|
||||
switch (priority) {
|
||||
case WorkOrderPriority.high:
|
||||
return '高';
|
||||
return AppLocalizations.of(context).translate('work_order_v2.high');
|
||||
case WorkOrderPriority.medium:
|
||||
return '中';
|
||||
return AppLocalizations.of(context).translate('work_order_v2.medium');
|
||||
case WorkOrderPriority.low:
|
||||
return '低';
|
||||
return AppLocalizations.of(context).translate('work_order_v2.low');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../../../../../core/consts/workorder_consts.dart';
|
||||
|
||||
/// 工单标签栏组件
|
||||
@@ -15,10 +16,32 @@ class WorkOrderTabBar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tabs = [
|
||||
{'label': '待处理', 'status': WorkOrderStatus.pending, 'badge': false},
|
||||
{'label': '执行中', 'status': WorkOrderStatus.executing, 'badge': true},
|
||||
{'label': '已完成', 'status': WorkOrderStatus.completed, 'badge': false},
|
||||
{'label': '全部', 'status': WorkOrderStatus.all, 'badge': true},
|
||||
{
|
||||
'label': AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.pending'),
|
||||
'status': WorkOrderStatus.pending,
|
||||
'badge': false,
|
||||
},
|
||||
{
|
||||
'label': AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.executing'),
|
||||
'status': WorkOrderStatus.executing,
|
||||
'badge': true,
|
||||
},
|
||||
{
|
||||
'label': AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.completed'),
|
||||
'status': WorkOrderStatus.completed,
|
||||
'badge': false,
|
||||
},
|
||||
{
|
||||
'label': AppLocalizations.of(context).translate('work_order_v2.all'),
|
||||
'status': WorkOrderStatus.all,
|
||||
'badge': true,
|
||||
},
|
||||
];
|
||||
|
||||
return Container(
|
||||
@@ -44,7 +67,9 @@ class WorkOrderTabBar extends StatelessWidget {
|
||||
tab['label'] as String,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
color: isSelected
|
||||
? AppConstants.primaryColor
|
||||
: AppConstants.secondaryTextColor,
|
||||
|
||||
Reference in New Issue
Block a user