基本完成APP的所有页面中的语言切换支持的开发和设计
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
|
||||
class RouteDirectionPanel extends StatefulWidget {
|
||||
// 接收外部传入的初始值
|
||||
@@ -8,6 +9,10 @@ class RouteDirectionPanel extends StatefulWidget {
|
||||
final ValueChanged<Map<String, dynamic>>? onValueChanged;
|
||||
// 取消/关闭面板回调(保留)
|
||||
final VoidCallback? onCancel;
|
||||
// 多语言支持
|
||||
final String? titleText;
|
||||
final String? optimalHeadingText;
|
||||
final String? routeDirectionText;
|
||||
|
||||
const RouteDirectionPanel({
|
||||
super.key,
|
||||
@@ -15,6 +20,9 @@ class RouteDirectionPanel extends StatefulWidget {
|
||||
this.initialDirection = 0.0, // 默认方向0度
|
||||
this.onValueChanged, // 实时值变更回调
|
||||
this.onCancel,
|
||||
this.titleText,
|
||||
this.optimalHeadingText,
|
||||
this.routeDirectionText,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -65,9 +73,9 @@ class _RouteDirectionPanelState extends State<RouteDirectionPanel> {
|
||||
},
|
||||
child: const Icon(Icons.arrow_back_ios, color: Colors.black87, size: 20),
|
||||
),
|
||||
const Text(
|
||||
'航线方向',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: Colors.black87),
|
||||
Text(
|
||||
widget.titleText ?? '航线方向',
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: Colors.black87),
|
||||
),
|
||||
const SizedBox(width: 24), // 占位保持标题居中
|
||||
],
|
||||
@@ -78,7 +86,7 @@ class _RouteDirectionPanelState extends State<RouteDirectionPanel> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text('最优航向', style: TextStyle(fontSize: 16, color: Colors.black87)),
|
||||
Text(widget.optimalHeadingText ?? '最优航向', style: const TextStyle(fontSize: 16, color: Colors.black87)),
|
||||
Switch(
|
||||
value: _optimalHeading,
|
||||
activeColor: const Color(0xFF00C853),
|
||||
@@ -101,7 +109,7 @@ class _RouteDirectionPanelState extends State<RouteDirectionPanel> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text('航线方向', style: TextStyle(fontSize: 16, color: Colors.black87)),
|
||||
Text(widget.routeDirectionText ?? '航线方向', style: const TextStyle(fontSize: 16, color: Colors.black87)),
|
||||
Text(
|
||||
'${_direction.toStringAsFixed(0)}°',
|
||||
style: TextStyle(fontSize: 16, color: _optimalHeading ? Colors.grey : Colors.black87, fontWeight: FontWeight.w500),
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/common/commonFn.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -90,7 +91,7 @@ class ImmersionHeader extends StatelessWidget {
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// 3. 状态标签也紧跟其后
|
||||
_buildStatusTag(device.isOnline),
|
||||
_buildStatusTag(device.isOnline, context),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -121,7 +122,7 @@ class ImmersionHeader extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusTag(bool isOnline) {
|
||||
Widget _buildStatusTag(bool isOnline, BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
@@ -135,7 +136,11 @@ class ImmersionHeader extends StatelessWidget {
|
||||
children: [
|
||||
CircleAvatar(radius: 3, backgroundColor: isOnline ? Colors.green : Colors.grey),
|
||||
const SizedBox(width: 6),
|
||||
Text(isOnline ? "在线" : "离线", style: const TextStyle(fontSize: 12, color: Colors.black54)),
|
||||
Text(
|
||||
isOnline ? AppLocalizations.of(context).translate('home.device_online') : AppLocalizations.of(context).translate('home.device_offline'),
|
||||
style: const TextStyle(fontSize: 12, color: Colors.black54),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -199,7 +204,11 @@ class ImmersionHeader extends StatelessWidget {
|
||||
height: 5,
|
||||
decoration: BoxDecoration(color: Colors.grey[300], borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
const Text("切换设备", style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
Text(
|
||||
AppLocalizations.of(modalContext).translate('home.switch_device'),
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Container(height: 0.5, margin: const EdgeInsets.symmetric(horizontal: 20), color: Colors.grey.withOpacity(0.1)),
|
||||
|
||||
@@ -216,7 +225,7 @@ class ImmersionHeader extends StatelessWidget {
|
||||
children: [
|
||||
const CircularProgressIndicator(color: Colors.blue),
|
||||
const SizedBox(height: 16),
|
||||
Text("加载中...", style: TextStyle(color: Colors.grey[600])),
|
||||
Text(AppLocalizations.of(context).translate('home.loading'), style: TextStyle(color: Colors.grey[600])),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -224,13 +233,13 @@ class ImmersionHeader extends StatelessWidget {
|
||||
|
||||
// 2. 列表展示
|
||||
if (state.devices.isEmpty) {
|
||||
return const Center(
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.description_outlined, size: 60, color: Colors.grey),
|
||||
SizedBox(height: 16),
|
||||
Text('暂无设备', style: TextStyle(fontSize: 16, color: Colors.grey)),
|
||||
const Icon(Icons.description_outlined, size: 60, color: Colors.grey),
|
||||
const SizedBox(height: 16),
|
||||
Text(AppLocalizations.of(context).translate('home.no_devices'), style: const TextStyle(fontSize: 16, color: Colors.grey)),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -288,7 +297,7 @@ class ImmersionHeader extends StatelessWidget {
|
||||
const SizedBox(width: 4),
|
||||
Flexible(
|
||||
child: Text(
|
||||
(device.deviceAlias?.trim() ?? '').isEmpty ? '未知设备' : device.deviceAlias!,
|
||||
(device.deviceAlias?.trim() ?? '').isEmpty ? AppLocalizations.of(context).translate('home.unknown_device') : device.deviceAlias!,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
// 关键属性:处理文本溢出
|
||||
maxLines: 2, // 最多显示2行
|
||||
@@ -299,7 +308,11 @@ class ImmersionHeader extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
const Text("点击查看详情", style: TextStyle(color: Colors.grey, fontSize: 12)),
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('home.click_to_view'),
|
||||
style: const TextStyle(color: Colors.grey, fontSize: 12),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -319,8 +332,8 @@ class ImmersionHeader extends StatelessWidget {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
text: isSelected ? "使用中" : "切换",
|
||||
width: 80,
|
||||
text: isSelected ? AppLocalizations.of(context).translate('home.in_use') : AppLocalizations.of(context).translate('home.switch'),
|
||||
width: 90,
|
||||
height: 30,
|
||||
fontSize: 14,
|
||||
// 如果是当前设备,按钮颜色变灰
|
||||
@@ -333,8 +346,8 @@ class ImmersionHeader extends StatelessWidget {
|
||||
print("通过按钮进入详情,设备名称:$device");
|
||||
},
|
||||
|
||||
text: "详情",
|
||||
width: 80,
|
||||
text: AppLocalizations.of(context).translate('home.details'),
|
||||
width: 90,
|
||||
height: 30,
|
||||
fontSize: 14,
|
||||
backgroundColor: Colors.white,
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
|
||||
import 'CoordTransform/coord_transform.dart';
|
||||
|
||||
@@ -47,7 +48,7 @@ class _AmapFlutterMapPageState extends State<AmapFlutterMapPage> {
|
||||
if (status.isDenied) {
|
||||
if (!_isDisposed) { // 防护:页面没销毁才弹提示
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('定位权限被拒绝,无法获取当前位置')),
|
||||
SnackBar(content: Text(AppLocalizations.of(context).translate('route_planning.location_permission_denied'))),
|
||||
);
|
||||
setState(() { _isLoading = false; });
|
||||
}
|
||||
@@ -58,9 +59,9 @@ class _AmapFlutterMapPageState extends State<AmapFlutterMapPage> {
|
||||
if (status.isPermanentlyDenied) {
|
||||
if (!_isDisposed) { // 防护:页面没销毁才弹提示
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('定位权限被永久拒绝,请去设置开启'),
|
||||
action: SnackBarAction(label: '去设置', onPressed: openAppSettings),
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context).translate('route_planning.location_permanently_denied')),
|
||||
action: SnackBarAction(label: AppLocalizations.of(context).translate('route_planning.go_to_settings'), onPressed: openAppSettings),
|
||||
),
|
||||
);
|
||||
setState(() { _isLoading = false; });
|
||||
@@ -81,7 +82,7 @@ class _AmapFlutterMapPageState extends State<AmapFlutterMapPage> {
|
||||
if (!serviceEnabled) {
|
||||
if (!_isDisposed) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('定位服务未启用,请开启定位服务')),
|
||||
SnackBar(content: Text(AppLocalizations.of(context).translate('route_planning.location_service_disabled'))),
|
||||
);
|
||||
setState(() { _isLoading = false; });
|
||||
}
|
||||
@@ -118,9 +119,9 @@ class _AmapFlutterMapPageState extends State<AmapFlutterMapPage> {
|
||||
setState(() { _isLoading = false; });
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('定位失败: $e'),
|
||||
content: Text('${AppLocalizations.of(context).translate('route_planning.location_failed')}: $e'),
|
||||
action: SnackBarAction(
|
||||
label: '重试',
|
||||
label: AppLocalizations.of(context).translate('route_planning.retry'),
|
||||
onPressed: _checkAndGetLocation,
|
||||
),
|
||||
),
|
||||
@@ -134,12 +135,12 @@ class _AmapFlutterMapPageState extends State<AmapFlutterMapPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('路径规划'),
|
||||
title: Text(AppLocalizations.of(context).translate('route_planning.title')),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.my_location),
|
||||
onPressed: _checkAndGetLocation,
|
||||
tooltip: '定位到我的位置',
|
||||
tooltip: AppLocalizations.of(context).translate('route_planning.my_location'),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -18,6 +18,7 @@ import 'package:maibu_satabot_v2/components/toast.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/consts/tcp_consts.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/core/network/net_message_dispatcher.dart';
|
||||
import 'package:maibu_satabot_v2/core/network/protocol_decoder.dart';
|
||||
import 'package:maibu_satabot_v2/core/router/route_paths.dart';
|
||||
@@ -167,9 +168,9 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
|
||||
// 所有可用的场站列表(根据你的实际瓦片目录配置)
|
||||
final List<DJIStation> _stationList = [
|
||||
const DJIStation(name: 'liaoning', displayName: '一号场站'),
|
||||
const DJIStation(name: 'station_b', displayName: '二号场站'),
|
||||
const DJIStation(name: 'station_c', displayName: '三号场站'),
|
||||
const DJIStation(name: 'liaoning', displayName: 'station_1'),
|
||||
const DJIStation(name: 'station_b', displayName: 'station_2'),
|
||||
const DJIStation(name: 'station_c', displayName: 'station_3'),
|
||||
// 新增场站只需在这里添加,无需修改其他逻辑
|
||||
];
|
||||
|
||||
@@ -591,20 +592,21 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
}
|
||||
|
||||
void _showSavePlotDialog() {
|
||||
final loc = AppLocalizations.of(context);
|
||||
showInputConfirmDialog(
|
||||
context: context,
|
||||
title: '保存地块', // 自定义标题
|
||||
hintText: '请输入地块名称(如:北地块、一号田)', // 自定义输入提示
|
||||
labelText: '地块名称', // 自定义输入框标签
|
||||
confirmText: '保存', // 确认按钮文字
|
||||
cancelText: '取消', // 取消按钮文字
|
||||
title: loc.translate('route_planning.save_plot'), // 自定义标题
|
||||
hintText: loc.translate('route_planning.plot_name_hint'), // 自定义输入提示
|
||||
labelText: loc.translate('route_planning.plot_name_label'), // 自定义输入框标签
|
||||
confirmText: loc.translate('route_planning.save'), // 确认按钮文字
|
||||
cancelText: loc.translate('route_planning.cancel'), // 取消按钮文字
|
||||
// 输入校验器(可选)
|
||||
inputValidator: (inputText) {
|
||||
if (inputText.isEmpty) {
|
||||
return '地块名称不能为空!';
|
||||
return loc.translate('route_planning.plot_name_empty');
|
||||
}
|
||||
if (inputText.length > 20) {
|
||||
return '地块名称不能超过20个字符!';
|
||||
return loc.translate('route_planning.plot_name_too_long');
|
||||
}
|
||||
return null; // 校验通过
|
||||
},
|
||||
@@ -629,7 +631,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
} else {
|
||||
// 截图失败时,允许空图片保存(可根据业务调整为强制失败)
|
||||
_savePlotData(plotName, null);
|
||||
_showPageToast(message: "地块保存成功,但地图截图生成失败!", type: ToastType.warn);
|
||||
_showPageToast(message: loc.translate('route_planning.save_success') + "," + "但地图截图生成失败!", type: ToastType.warn);
|
||||
|
||||
//ToastUtils.showWarn(context, '地块保存成功,但地图截图生成失败!');
|
||||
//ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('地块保存成功,但地图截图生成失败!'), backgroundColor: Colors.amber));
|
||||
@@ -683,10 +685,11 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
}
|
||||
|
||||
Future<void> _savePlotData(String plotName, String? imgBase64) async {
|
||||
final loc = AppLocalizations.of(context);
|
||||
// 1. 获取用户ID
|
||||
final userId = context.read<AppUserCubit>().state.user?.userId ?? "";
|
||||
if (userId.isEmpty) {
|
||||
_showPageToast(message: "用户ID为空,无法保存!", type: ToastType.error);
|
||||
_showPageToast(message: loc.translate('route_planning.user_id_empty'), type: ToastType.error);
|
||||
|
||||
//ToastUtils.showError(context, '用户ID为空,无法保存!');
|
||||
return;
|
||||
@@ -756,7 +759,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
|
||||
// 7. 发送请求
|
||||
try {
|
||||
_showPageToast(message: "正在保存地块「$plotName」...", type: ToastType.loading);
|
||||
_showPageToast(message: loc.translate('route_planning.saving') + "「$plotName」...", type: ToastType.loading);
|
||||
|
||||
//ToastUtils.showLoading(context, '正在保存地块「$plotName」...');
|
||||
//ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('正在保存地块...'), backgroundColor: Colors.blue));
|
||||
@@ -765,7 +768,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
final String responseBody = await response.stream.bytesToString();
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
_showPageToast(message: "地块「$plotName」保存成功!", type: ToastType.success);
|
||||
_showPageToast(message: loc.translate('route_planning.save_success') + "「$plotName」", type: ToastType.success);
|
||||
|
||||
//ToastUtils.showSuccess(context, '地块「$plotName」保存成功!');
|
||||
_clearLocalData();
|
||||
@@ -787,7 +790,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('保存失败: $e');
|
||||
_showPageToast(message: "保存失败: ${e.toString()}", type: ToastType.error);
|
||||
_showPageToast(message: loc.translate('route_planning.save_failed') + ": ${e.toString()}", type: ToastType.error);
|
||||
|
||||
//ToastUtils.showError(context, '保存失败: ${e.toString()}');
|
||||
//ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('保存失败: ${e.toString()}'), backgroundColor: Colors.red));
|
||||
@@ -822,7 +825,8 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
}
|
||||
_showPageToast(message: "已撤回作业区域最后一个点,剩余${_markedPoints.length}个点", type: ToastType.info);
|
||||
} else {
|
||||
_showPageToast(message: "暂无作业区域点可撤回", type: ToastType.info);
|
||||
final loc = AppLocalizations.of(context);
|
||||
_showPageToast(message: loc.translate('route_planning.no_work_points'), type: ToastType.info);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -884,7 +888,8 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
_isWorkAreaCompleted = false;
|
||||
_saveBoxOpen = false;
|
||||
typedPathList.clear();
|
||||
_showPageToast(message: "已清空所有作业区域点和路径", type: ToastType.success);
|
||||
final loc = AppLocalizations.of(context);
|
||||
_showPageToast(message: loc.translate('route_planning.clear_work_area'), type: ToastType.success);
|
||||
//ToastUtils.showSuccess(context, '已清空所有作业区域点和路径');
|
||||
|
||||
//ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('已清空所有作业区域点和路径')));
|
||||
@@ -892,7 +897,8 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
// 2. 空洞模式:清空所有空洞 + 恢复UI + 重新生成路径
|
||||
else if (_currentAreaMode == AreaMode.obstacle) {
|
||||
if (_obstacleHoles.isEmpty && _currentObstaclePoints.isEmpty) {
|
||||
_showPageToast(message: "暂无障碍物可删除", type: ToastType.info);
|
||||
final loc = AppLocalizations.of(context);
|
||||
_showPageToast(message: loc.translate('route_planning.no_obstacles'), type: ToastType.info);
|
||||
|
||||
//ToastUtils.showInfo(context, '暂无障碍物可删除');
|
||||
return;
|
||||
@@ -905,7 +911,8 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
if (_isWorkAreaCompleted) {
|
||||
_generatePath(showTips: false);
|
||||
}
|
||||
_showPageToast(message: "已清空所有障碍物", type: ToastType.success);
|
||||
final loc = AppLocalizations.of(context);
|
||||
_showPageToast(message: loc.translate('route_planning.clear_obstacles'), type: ToastType.success);
|
||||
//ToastUtils.showSuccess(context, '已清空所有障碍物');
|
||||
}
|
||||
});
|
||||
@@ -1032,11 +1039,11 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
await _saveDataToLocal();
|
||||
|
||||
if (mounted) {
|
||||
_showPageToast(message: "已清除所有缓存,恢复初始状态", type: ToastType.success);
|
||||
_showPageToast(message: AppLocalizations.of(context).translate('route_planning.clear_cache_success'), type: ToastType.success);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
_showPageToast(message: "刷新失败:${e.toString().substring(0, 50)}", type: ToastType.error);
|
||||
_showPageToast(message: "${AppLocalizations.of(context).translate('route_planning.refresh_failed')}:${e.toString().substring(0, 50)}", type: ToastType.error);
|
||||
}
|
||||
} finally {
|
||||
if (mounted) {
|
||||
@@ -1861,7 +1868,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text('作业模式:$workMode', style: const TextStyle(fontSize: 14, color: Colors.grey)),
|
||||
Text('${AppLocalizations.of(context).translate('route_planning.work_mode')}:$workMode', style: const TextStyle(fontSize: 14, color: Colors.grey)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -1982,7 +1989,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
),
|
||||
child: state.isLoading
|
||||
? const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white))
|
||||
: const Text('开始作业', style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold)),
|
||||
: Text(AppLocalizations.of(context).translate('route_planning.start_work'), style: const TextStyle(fontSize: 14, fontWeight: FontWeight.bold)),
|
||||
),
|
||||
)
|
||||
: Row(
|
||||
@@ -2638,6 +2645,9 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
child: RouteDirectionPanel(
|
||||
initialOptimalHeading: true,
|
||||
initialDirection: 0.0,
|
||||
titleText: AppLocalizations.of(context).translate('route_planning.route_direction'),
|
||||
optimalHeadingText: AppLocalizations.of(context).translate('route_planning.optimal_heading'),
|
||||
routeDirectionText: AppLocalizations.of(context).translate('route_planning.route_direction'),
|
||||
onValueChanged: (result) {
|
||||
_angle = result['optimalHeading'] == true ? -1 : result['direction'];
|
||||
|
||||
@@ -2687,7 +2697,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'地块列表(共${plotList.length}条)',
|
||||
AppLocalizations.of(context).translate('route_planning.plot_list_title').replaceAll('%d', plotList.length.toString()),
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Colors.black87),
|
||||
),
|
||||
IconButton(
|
||||
@@ -2704,13 +2714,13 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
const Divider(height: 1, color: Colors.grey),
|
||||
Expanded(
|
||||
child: plotList.isEmpty
|
||||
? const Center(
|
||||
? Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.inbox_outlined, color: Colors.grey, size: 48),
|
||||
SizedBox(height: 16),
|
||||
Text('暂无地块数据', style: TextStyle(color: Colors.grey, fontSize: 16)),
|
||||
const Icon(Icons.inbox_outlined, color: Colors.grey, size: 48),
|
||||
const SizedBox(height: 16),
|
||||
Text(AppLocalizations.of(context).translate('route_planning.no_plot_data'), style: const TextStyle(color: Colors.grey, fontSize: 16)),
|
||||
],
|
||||
),
|
||||
)
|
||||
@@ -2750,12 +2760,12 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 4, offset: const Offset(0, 2))],
|
||||
),
|
||||
child: const Row(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.warning_amber_rounded, color: Colors.white, size: 20),
|
||||
SizedBox(width: 8),
|
||||
const Icon(Icons.warning_amber_rounded, color: Colors.white, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text('航向角未初始化,无法开始作业', style: TextStyle(color: Colors.white, fontSize: 14)),
|
||||
child: Text(AppLocalizations.of(context).translate('route_planning.heading_not_init'), style: const TextStyle(color: Colors.white, fontSize: 14)),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -2775,12 +2785,12 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 4, offset: const Offset(0, 2))],
|
||||
),
|
||||
child: const Row(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.error_rounded, color: Colors.white, size: 20),
|
||||
SizedBox(width: 8),
|
||||
const Icon(Icons.error_rounded, color: Colors.white, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text('请切换到远程模式后再开始作业', style: TextStyle(color: Colors.white, fontSize: 14)),
|
||||
child: Text(AppLocalizations.of(context).translate('route_planning.switch_remote_mode'), style: const TextStyle(color: Colors.white, fontSize: 14)),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/core/router/route_paths.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/common/enum.dart';
|
||||
|
||||
@@ -63,14 +64,23 @@ class _VerticalFloatMenuState extends State<VerticalFloatMenu> {
|
||||
_selectedWorkModeIn = widget.selectedWorkModeIn;
|
||||
}
|
||||
|
||||
final List<Map<String, dynamic>> _menuItems = const [
|
||||
{"icon": Icons.crop_free, "name": "圈地"},
|
||||
{"icon": Icons.format_list_bulleted, "name": "列表"},
|
||||
{"icon": Icons.train, "name": "场站"},
|
||||
{"icon": Icons.navigation, "name": "定位"},
|
||||
{"icon": Icons.refresh, "name": "刷新"},
|
||||
{"icon": Icons.videocam, "name": "监控"},
|
||||
];
|
||||
final List<Map<String, dynamic>> _menuItems = [];
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
// 在依赖变化时重新初始化菜单(支持语言切换)
|
||||
final loc = AppLocalizations.of(context);
|
||||
_menuItems.clear();
|
||||
_menuItems.addAll([
|
||||
{"icon": Icons.crop_free, "name": loc.translate('route_planning.mark_land')},
|
||||
{"icon": Icons.format_list_bulleted, "name": loc.translate('route_planning.list')},
|
||||
{"icon": Icons.train, "name": loc.translate('route_planning.station')},
|
||||
{"icon": Icons.navigation, "name": loc.translate('route_planning.location')},
|
||||
{"icon": Icons.refresh, "name": loc.translate('route_planning.refresh')},
|
||||
{"icon": Icons.videocam, "name": loc.translate('route_planning.monitoring')},
|
||||
]);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -168,37 +178,47 @@ class _VerticalFloatMenuState extends State<VerticalFloatMenu> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text("选择作业模式", style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 20),
|
||||
_modeItem(
|
||||
title: "弓字模式",
|
||||
subtitle: "标准全覆盖路径规划",
|
||||
isSelected: selectedMode == WorkMode.bow,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedMode = WorkMode.bow;
|
||||
});
|
||||
Builder(
|
||||
builder: (dialogContext) {
|
||||
final loc = AppLocalizations.of(dialogContext);
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(loc.translate('route_planning.select_work_mode'), style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 20),
|
||||
_modeItem(
|
||||
title: loc.translate('route_planning.bow_mode'),
|
||||
subtitle: loc.translate('route_planning.bow_mode_subtitle'),
|
||||
isSelected: selectedMode == WorkMode.bow,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedMode = WorkMode.bow;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_modeItem(
|
||||
title: loc.translate('route_planning.custom_mode'),
|
||||
subtitle: loc.translate('route_planning.custom_mode_subtitle'),
|
||||
isSelected: selectedMode == WorkMode.custom,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedMode = WorkMode.custom;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: Text(loc.translate('common.cancel'))),
|
||||
ElevatedButton(onPressed: () => Navigator.pop(context, selectedMode), child: Text(loc.translate('common.confirm'))),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_modeItem(
|
||||
title: "自定义模式",
|
||||
subtitle: "手动设定作业区域",
|
||||
isSelected: selectedMode == WorkMode.custom,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedMode = WorkMode.custom;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: const Text("取消")),
|
||||
ElevatedButton(onPressed: () => Navigator.pop(context, selectedMode), child: const Text("确定")),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/core/router/route_paths.dart';
|
||||
|
||||
class QuickActionsGrid extends StatelessWidget {
|
||||
@@ -12,20 +13,23 @@ class QuickActionsGrid extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
_buildActionItem(
|
||||
context: context,
|
||||
icon: Icons.videogame_asset_outlined,
|
||||
label: '远程遥控',
|
||||
labelKey: 'home.remote_control',
|
||||
iconColor: Colors.blue,
|
||||
onTap: () => context.push(RoutePaths.remoteControl),
|
||||
),
|
||||
_buildActionItem(
|
||||
context: context,
|
||||
icon: Icons.near_me_outlined,
|
||||
label: '路径规划',
|
||||
labelKey: 'home.route_plan',
|
||||
iconColor: Colors.purple,
|
||||
onTap: () => context.push(RoutePaths.routePlan),
|
||||
),
|
||||
_buildActionItem(
|
||||
context: context,
|
||||
icon: Icons.insights_rounded,
|
||||
label: '机器状态',
|
||||
labelKey: 'home.machine_status',
|
||||
iconColor: Colors.orange,
|
||||
onTap: () => context.push(RoutePaths.runningStatus),
|
||||
),
|
||||
@@ -36,8 +40,9 @@ class QuickActionsGrid extends StatelessWidget {
|
||||
|
||||
// 💡 改造后的构建函数,支持命名参数和点击事件
|
||||
Widget _buildActionItem({
|
||||
required BuildContext context,
|
||||
required IconData icon,
|
||||
required String label,
|
||||
required String labelKey,
|
||||
required Color iconColor,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
@@ -65,7 +70,7 @@ class QuickActionsGrid extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
label,
|
||||
AppLocalizations.of(context).translate(labelKey),
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/common/enum.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/map/testmap_pages.dart';
|
||||
|
||||
@@ -95,8 +96,9 @@ class _BottomOperationPanelState extends State<BottomOperationPanel> {
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
final loc = AppLocalizations.of(context);
|
||||
setState(() {
|
||||
_currentTab = '地块'; // 更新选中状态
|
||||
_currentTab = loc.translate('route_planning.land'); // 更新选中状态
|
||||
});
|
||||
debugPrint('切换到地块标签');
|
||||
widget.onLandTap?.call();
|
||||
@@ -104,9 +106,9 @@ class _BottomOperationPanelState extends State<BottomOperationPanel> {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
// 选中地块时背景为白色,否则透明
|
||||
decoration: BoxDecoration(color: _currentTab == '地块' ? Colors.white : Colors.transparent, borderRadius: BorderRadius.circular(8)),
|
||||
child: const Center(
|
||||
child: Text('地块', style: TextStyle(color: Colors.black87, fontSize: 16)),
|
||||
decoration: BoxDecoration(color: _currentTab == AppLocalizations.of(context).translate('route_planning.land') ? Colors.white : Colors.transparent, borderRadius: BorderRadius.circular(8)),
|
||||
child: Center(
|
||||
child: Text(AppLocalizations.of(context).translate('route_planning.land'), style: TextStyle(color: Colors.black87, fontSize: 16)),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -114,8 +116,9 @@ class _BottomOperationPanelState extends State<BottomOperationPanel> {
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
final loc = AppLocalizations.of(context);
|
||||
setState(() {
|
||||
_currentTab = '航线'; // 更新选中状态
|
||||
_currentTab = loc.translate('route_planning.route'); // 更新选中状态
|
||||
});
|
||||
debugPrint('切换到航线标签');
|
||||
widget.onRouteTap?.call();
|
||||
@@ -123,9 +126,9 @@ class _BottomOperationPanelState extends State<BottomOperationPanel> {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
// 选中航线时背景为白色,否则透明
|
||||
decoration: BoxDecoration(color: _currentTab == '航线' ? Colors.white : Colors.transparent, borderRadius: BorderRadius.circular(8)),
|
||||
child: const Center(
|
||||
child: Text('航线', style: TextStyle(color: Colors.black87, fontSize: 16)),
|
||||
decoration: BoxDecoration(color: _currentTab == AppLocalizations.of(context).translate('route_planning.route') ? Colors.white : Colors.transparent, borderRadius: BorderRadius.circular(8)),
|
||||
child: Center(
|
||||
child: Text(AppLocalizations.of(context).translate('route_planning.route'), style: TextStyle(color: Colors.black87, fontSize: 16)),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -151,9 +154,9 @@ class _BottomOperationPanelState extends State<BottomOperationPanel> {
|
||||
children: [
|
||||
DropdownButton<RobotMode>(
|
||||
value: _robotMode,
|
||||
items: const [
|
||||
DropdownMenuItem(value: RobotMode.point, child: Text("十字准星")),
|
||||
DropdownMenuItem(value: RobotMode.robot, child: Text("机器人模式")),
|
||||
items: [
|
||||
DropdownMenuItem(value: RobotMode.point, child: Text(AppLocalizations.of(context).translate('route_planning.crosshair'))),
|
||||
DropdownMenuItem(value: RobotMode.robot, child: Text(AppLocalizations.of(context).translate('route_planning.robot_mode'))),
|
||||
],
|
||||
onChanged: (v) {
|
||||
if (v != null) {
|
||||
@@ -187,9 +190,9 @@ class _BottomOperationPanelState extends State<BottomOperationPanel> {
|
||||
if (widget.initialWorkMode == WorkMode.bow)
|
||||
DropdownButton<AreaMode>(
|
||||
value: _areaMode,
|
||||
items: const [
|
||||
DropdownMenuItem(value: AreaMode.work, child: Text("作业区域")),
|
||||
DropdownMenuItem(value: AreaMode.obstacle, child: Text("障碍区域")),
|
||||
items: [
|
||||
DropdownMenuItem(value: AreaMode.work, child: Text(AppLocalizations.of(context).translate('route_planning.work_area'))),
|
||||
DropdownMenuItem(value: AreaMode.obstacle, child: Text(AppLocalizations.of(context).translate('route_planning.obstacle_area'))),
|
||||
],
|
||||
onChanged: (v) {
|
||||
if (v != null) {
|
||||
@@ -206,15 +209,15 @@ class _BottomOperationPanelState extends State<BottomOperationPanel> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildActionButton(Icons.delete_outline, '删除', true, () {
|
||||
_buildActionButton(Icons.delete_outline, AppLocalizations.of(context).translate('route_planning.delete'), true, () {
|
||||
debugPrint('点击了删除按钮,清空所有打点');
|
||||
widget.onDeleteTap?.call();
|
||||
}),
|
||||
_buildActionButton(Icons.undo_outlined, '撤回', widget.canUndo ?? true, () {
|
||||
_buildActionButton(Icons.undo_outlined, AppLocalizations.of(context).translate('route_planning.undo'), widget.canUndo ?? true, () {
|
||||
debugPrint('点击了撤回按钮,删除最后一个打点');
|
||||
widget.onUndoTap?.call();
|
||||
}),
|
||||
_buildActionButton(Icons.check_outlined, '完成', true, () {
|
||||
_buildActionButton(Icons.check_outlined, AppLocalizations.of(context).translate('route_planning.complete'), true, () {
|
||||
widget.onComplete.call();
|
||||
}),
|
||||
],
|
||||
@@ -226,7 +229,7 @@ class _BottomOperationPanelState extends State<BottomOperationPanel> {
|
||||
|
||||
// 标签内容切换方法(地块/航线)
|
||||
Widget _buildTabContent() {
|
||||
if (_currentTab == '地块') {
|
||||
if (_currentTab == AppLocalizations.of(context).translate('route_planning.land')) {
|
||||
// 地块模式:显示机器人/区域选择+操作按钮
|
||||
return _buildLandContent();
|
||||
} else {
|
||||
@@ -237,7 +240,7 @@ class _BottomOperationPanelState extends State<BottomOperationPanel> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text('作业行距(米)', style: TextStyle(fontSize: 16, color: Colors.black87)),
|
||||
Text(AppLocalizations.of(context).translate('route_planning.work_distance'), style: const TextStyle(fontSize: 16, color: Colors.black87)),
|
||||
Row(
|
||||
children: [
|
||||
// 减号按钮
|
||||
@@ -285,7 +288,7 @@ class _BottomOperationPanelState extends State<BottomOperationPanel> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text('航线方向', style: TextStyle(fontSize: 16, color: Colors.black87)),
|
||||
Text(AppLocalizations.of(context).translate('route_planning.route_direction'), style: const TextStyle(fontSize: 16, color: Colors.black87)),
|
||||
// 设置按钮
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
@@ -298,7 +301,7 @@ class _BottomOperationPanelState extends State<BottomOperationPanel> {
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)),
|
||||
),
|
||||
child: const Text('设置'),
|
||||
child: Text(AppLocalizations.of(context).translate('route_planning.settings')),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:fpdart/fpdart.dart' hide State;
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/domain/usecases/device_work_hostrirty_usecase.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/domain/entities/device_run_hostrity_entity.dart';
|
||||
@@ -66,9 +67,10 @@ class _WorkParamsCardState extends State<WorkParamsCard> {
|
||||
decoration: BoxDecoration(color: Colors.blueAccent, borderRadius: BorderRadius.circular(2)),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
'作业参数',
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.black),
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('home.work_params'),
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.black),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -82,7 +84,11 @@ class _WorkParamsCardState extends State<WorkParamsCard> {
|
||||
children: [
|
||||
Icon(Icons.info, size: 14, color: Colors.grey[400]),
|
||||
const SizedBox(width: 4),
|
||||
Text('查看详情', style: TextStyle(fontSize: 12, color: Colors.grey[400])),
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('home.view_details'),
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[400]),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -92,12 +98,12 @@ class _WorkParamsCardState extends State<WorkParamsCard> {
|
||||
IntrinsicHeight(
|
||||
child: Row(
|
||||
children: [
|
||||
_buildParamItem('作业面积', '${workArea?.toStringAsFixed(1) ?? '0'}', '㎡'),
|
||||
_buildParamItem(context, 'home.work_area', '${workArea?.toStringAsFixed(1) ?? '0'}', '㎡'),
|
||||
_buildDivider(),
|
||||
_buildParamItem('作业里程', '${distance?.toStringAsFixed(1) ?? '0'}', 'm'),
|
||||
_buildParamItem(context, 'home.work_distance', '${distance?.toStringAsFixed(1) ?? '0'}', 'm'),
|
||||
_buildDivider(),
|
||||
// 显示实时计算的作业时长
|
||||
_buildParamItem('作业时长', '${_totalWorkMinutes}', 'min'),
|
||||
_buildParamItem(context, 'home.work_duration', '${_totalWorkMinutes}', 'min'),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -198,9 +204,10 @@ class _WorkParamsCardState extends State<WorkParamsCard> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Center(child: Container(width: 40, height: 4)),
|
||||
const Text(
|
||||
'历史记录详情',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black87),
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('home.history_details'),
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black87),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
@@ -213,13 +220,13 @@ class _WorkParamsCardState extends State<WorkParamsCard> {
|
||||
const SizedBox(height: 10),
|
||||
Expanded(
|
||||
child: data.isEmpty
|
||||
? const Center(
|
||||
? Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.description_outlined, size: 60, color: Colors.grey),
|
||||
SizedBox(height: 16),
|
||||
Text('暂无历史记录', style: TextStyle(fontSize: 16, color: Colors.grey)),
|
||||
const Icon(Icons.description_outlined, size: 60, color: Colors.grey),
|
||||
const SizedBox(height: 16),
|
||||
Text(AppLocalizations.of(context).translate('home.no_history'), style: const TextStyle(fontSize: 16, color: Colors.grey)),
|
||||
],
|
||||
),
|
||||
)
|
||||
@@ -237,12 +244,12 @@ class _WorkParamsCardState extends State<WorkParamsCard> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildDetailRow(Icons.calendar_today, '开始时间', item.startTime),
|
||||
_buildDetailRow(Icons.calendar_today_outlined, '结束时间', item.endTime),
|
||||
_buildDetailRow(Icons.square_foot, '工作面积', '${item.workArea} ㎡'),
|
||||
_buildDetailRow(context, Icons.calendar_today, 'home.start_time', item.startTime),
|
||||
_buildDetailRow(context, Icons.calendar_today_outlined, 'home.end_time', item.endTime),
|
||||
_buildDetailRow(context, Icons.square_foot, 'home.working_area', '${item.workArea} ㎡'),
|
||||
if (item.distance != null && item.distance! > 0)
|
||||
_buildDetailRow(Icons.directions_car, '工作距离', '${item.distance!.toStringAsFixed(2)} m'),
|
||||
_buildDetailRow(Icons.timer, '花费时间', '${item.time} min'),
|
||||
_buildDetailRow(context, Icons.directions_car, 'home.working_distance', '${item.distance!.toStringAsFixed(2)} m'),
|
||||
_buildDetailRow(context, Icons.timer, 'home.time_spent', '${item.time} min'),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -257,7 +264,7 @@ class _WorkParamsCardState extends State<WorkParamsCard> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDetailRow(IconData icon, String label, String value) {
|
||||
Widget _buildDetailRow(BuildContext context, IconData icon, String labelKey, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Row(
|
||||
@@ -265,7 +272,7 @@ class _WorkParamsCardState extends State<WorkParamsCard> {
|
||||
Icon(icon, size: 16, color: Colors.blue),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'$label: ',
|
||||
AppLocalizations.of(context).translate(labelKey) + ': ',
|
||||
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Colors.black87),
|
||||
),
|
||||
Expanded(
|
||||
@@ -276,7 +283,7 @@ class _WorkParamsCardState extends State<WorkParamsCard> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildParamItem(String label, String value, String unit) {
|
||||
Widget _buildParamItem(BuildContext context, String labelKey, String value, String unit) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -284,16 +291,16 @@ class _WorkParamsCardState extends State<WorkParamsCard> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
label == '作业面积'
|
||||
labelKey == 'home.work_area'
|
||||
? Icons.aspect_ratio
|
||||
: label == '作业里程'
|
||||
: labelKey == 'home.work_distance'
|
||||
? Icons.local_shipping_outlined
|
||||
: Icons.access_time,
|
||||
size: 14,
|
||||
color: Colors.black38,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(label, style: const TextStyle(fontSize: 12, color: Colors.black38)),
|
||||
Text(AppLocalizations.of(context).translate(labelKey), style: const TextStyle(fontSize: 12, color: Colors.black38)),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
Reference in New Issue
Block a user