多语言切换+首次设置语言
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
|
||||
/// 底部操作按钮
|
||||
@@ -13,7 +14,7 @@ class RobotActionButtons extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
label: '开始',
|
||||
label: AppLocalizations.of(context).translate('device_list_v2.action_start'),
|
||||
color: context.appColors.primary,
|
||||
onTap: () {},
|
||||
),
|
||||
@@ -21,7 +22,7 @@ class RobotActionButtons extends StatelessWidget {
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
label: '暂停',
|
||||
label: AppLocalizations.of(context).translate('device_list_v2.action_pause'),
|
||||
color: context.appColors.warning,
|
||||
onTap: () {},
|
||||
),
|
||||
@@ -29,7 +30,7 @@ class RobotActionButtons extends StatelessWidget {
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildActionButton(
|
||||
label: '返航',
|
||||
label: AppLocalizations.of(context).translate('device_list_v2.action_return'),
|
||||
color: context.appColors.cardBackground,
|
||||
borderColor: context.appColors.textTertiary,
|
||||
textColor: context.appColors.textSecondary,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
|
||||
/// 检查清单
|
||||
@@ -26,7 +27,7 @@ class RobotChecklist extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'检查清单',
|
||||
AppLocalizations.of(context).translate('device_list_v2.checklist_title'),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
import '../../../../../../core/di/injection.dart';
|
||||
import '../../../../devices/presentation/bloc/devices_cubit.dart';
|
||||
@@ -76,7 +77,7 @@ class RobotControlPanel extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'控制面板',
|
||||
AppLocalizations.of(context).translate('device_list_v2.control_panel'),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -148,17 +149,17 @@ class RobotControlPanel extends StatelessWidget {
|
||||
const SizedBox(height: 12),
|
||||
// 速度档位
|
||||
Text(
|
||||
'速度档位',
|
||||
AppLocalizations.of(context).translate('device_list_v2.speed_gear'),
|
||||
style: TextStyle(fontSize: 13, color: context.appColors.textTertiary),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: _buildSpeedButton(context, '低速', false, () {})),
|
||||
Expanded(child: _buildSpeedButton(context, AppLocalizations.of(context).translate('device_list_v2.speed_low'), false, () {})),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: _buildSpeedButton(context, '中速', true, () {})),
|
||||
Expanded(child: _buildSpeedButton(context, AppLocalizations.of(context).translate('device_list_v2.speed_mid'), true, () {})),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: _buildSpeedButton(context, '高速', false, () {})),
|
||||
Expanded(child: _buildSpeedButton(context, AppLocalizations.of(context).translate('device_list_v2.speed_high'), false, () {})),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_state.dart'; // 🔥 导入 AppUserState
|
||||
import 'package:maibu_satabot_v2/core/consts/tcp_consts.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
import 'package:maibu_satabot_v2/features/remote_control/presentation/widgets/webrtc/webrtc_local_player.dart';
|
||||
import '../../../device_run_param/presentation/pages/robot_param_settings_page.dart';
|
||||
@@ -30,19 +31,19 @@ class _RobotHeaderCardState extends State<RobotHeaderCard> {
|
||||
|
||||
// 视角配置
|
||||
final List<Map<String, dynamic>> _viewConfigs = [
|
||||
{'name': '前视', 'alignment': Alignment.topLeft, 'icon': Icons.arrow_upward},
|
||||
{'name': 'view_front', 'alignment': Alignment.topLeft, 'icon': Icons.arrow_upward},
|
||||
{
|
||||
'name': '后视',
|
||||
'name': 'view_back',
|
||||
'alignment': Alignment.topRight,
|
||||
'icon': Icons.arrow_downward,
|
||||
},
|
||||
{'name': '左视', 'alignment': Alignment.bottomLeft, 'icon': Icons.arrow_back},
|
||||
{'name': 'view_left', 'alignment': Alignment.bottomLeft, 'icon': Icons.arrow_back},
|
||||
{
|
||||
'name': '右视',
|
||||
'name': 'view_right',
|
||||
'alignment': Alignment.bottomRight,
|
||||
'icon': Icons.arrow_forward,
|
||||
},
|
||||
{'name': '全景', 'alignment': Alignment.center, 'icon': Icons.view_agenda},
|
||||
{'name': 'view_panorama', 'alignment': Alignment.center, 'icon': Icons.view_agenda},
|
||||
];
|
||||
|
||||
@override
|
||||
@@ -114,7 +115,7 @@ class _RobotHeaderCardState extends State<RobotHeaderCard> {
|
||||
Text(
|
||||
(widget.robot['alias'] as String?)?.isNotEmpty == true
|
||||
? widget.robot['alias'] as String
|
||||
: '暂无别名',
|
||||
: AppLocalizations.of(context).translate('device_list_v2.no_alias'),
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -147,7 +148,7 @@ class _RobotHeaderCardState extends State<RobotHeaderCard> {
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'强',
|
||||
AppLocalizations.of(context).translate('device_list_v2.signal_strong'),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: context.appColors.success,
|
||||
@@ -165,7 +166,7 @@ class _RobotHeaderCardState extends State<RobotHeaderCard> {
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
'在线',
|
||||
AppLocalizations.of(context).translate('device_list_v2.online'),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: context.appColors.success,
|
||||
@@ -286,7 +287,7 @@ class _RobotHeaderCardState extends State<RobotHeaderCard> {
|
||||
Icon(config['icon'] as IconData, size: 16),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
config['name'] as String,
|
||||
AppLocalizations.of(context).translate('device_list_v2.${config['name']}'),
|
||||
style: const TextStyle(fontSize: 10),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -323,9 +324,9 @@ class _RobotHeaderCardState extends State<RobotHeaderCard> {
|
||||
if (showNoStreamHint) ...[
|
||||
const Icon(Icons.videocam_off, size: 36, color: Colors.white38),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'暂无视频',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('device_list_v2.no_video'),
|
||||
style: const TextStyle(
|
||||
color: Colors.white54,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -363,9 +364,9 @@ class _RobotHeaderCardState extends State<RobotHeaderCard> {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// “播放”文字
|
||||
const Text(
|
||||
'播放',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('device_list_v2.play'),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
|
||||
@@ -74,7 +74,7 @@ class RobotItemCard extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
alias != null && alias!.isNotEmpty ? alias! : '暂无别名',
|
||||
alias != null && alias!.isNotEmpty ? alias! : AppLocalizations.of(context).translate('device_list_v2.no_alias'),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -158,7 +158,7 @@ class RobotItemCard extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
task,
|
||||
_displayTask(context, task),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -212,6 +212,20 @@ class RobotItemCard extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// 🔥 仅做显示层映射:把内部语义状态值转成当前语言文案,未命中则原样显示
|
||||
/// 注意:model 默认值与列表过滤逻辑仍使用 '待机中'/'充电中',此处不改数据
|
||||
String _displayTask(BuildContext context, String task) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
switch (task) {
|
||||
case '待机中':
|
||||
return loc.translate('device_list_v2.task_standby');
|
||||
case '充电中':
|
||||
return loc.translate('device_list_v2.task_charging');
|
||||
default:
|
||||
return task;
|
||||
}
|
||||
}
|
||||
|
||||
String _getRobotImage() {
|
||||
switch (type) {
|
||||
case 'inspection':
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
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 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
import '../../../../../components/device_status_modal.dart';
|
||||
import '../../../../devices/presentation/bloc/device_status_bloc.dart';
|
||||
@@ -111,21 +112,21 @@ class RobotStatusBar extends StatelessWidget {
|
||||
children: [
|
||||
_buildStatusItem(
|
||||
context,
|
||||
label: '转速',
|
||||
label: AppLocalizations.of(context).translate('device_list_v2.status_speed'),
|
||||
value: speed,
|
||||
unit: 'rpm',
|
||||
),
|
||||
Container(width: 1, height: 40, color: context.appColors.divider),
|
||||
_buildStatusItem(
|
||||
context,
|
||||
label: '模式',
|
||||
label: AppLocalizations.of(context).translate('device_list_v2.status_mode'),
|
||||
value: mode,
|
||||
unit: '',
|
||||
),
|
||||
Container(width: 1, height: 40, color: context.appColors.divider),
|
||||
_buildStatusItem(
|
||||
context,
|
||||
label: '电量',
|
||||
label: AppLocalizations.of(context).translate('device_list_v2.battery_level'),
|
||||
value: battery,
|
||||
unit: '%',
|
||||
valueColor: batteryColor,
|
||||
@@ -133,7 +134,7 @@ class RobotStatusBar extends StatelessWidget {
|
||||
Container(width: 1, height: 40, color: context.appColors.divider),
|
||||
_buildStatusItem(
|
||||
context,
|
||||
label: '信号',
|
||||
label: AppLocalizations.of(context).translate('device_list_v2.status_signal'),
|
||||
value: signal,
|
||||
unit: '',
|
||||
valueColor: signalColor,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
|
||||
/// 当前任务信息
|
||||
@@ -26,7 +27,7 @@ class RobotTaskInfo extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'当前任务',
|
||||
AppLocalizations.of(context).translate('device_list_v2.current_task'),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -53,7 +54,7 @@ class RobotTaskInfo extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
'进行中',
|
||||
AppLocalizations.of(context).translate('device_list_v2.task_in_progress'),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: context.appColors.primary,
|
||||
|
||||
Reference in New Issue
Block a user