基本完成APP的所有页面中的语言切换支持的开发和设计
This commit is contained in:
@@ -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