基本完成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';
|
||||
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')),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user