优化
This commit is contained in:
@@ -77,8 +77,14 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
||||
|
||||
if (state is DeviceStatusUpdated) {
|
||||
headingStatus = state.status.headingStatus == 0 ? '未初始化' : '已初始化';
|
||||
qual = _parseLocationQuality(state.status.qual);
|
||||
//qual = int.parse(state.status.qual.toString());
|
||||
// 强制转换为整型并解析定位质量
|
||||
int qualValue = 0;
|
||||
try {
|
||||
qualValue = int.parse(state.status.qual.toString());
|
||||
} catch (e) {
|
||||
qualValue = 0;
|
||||
}
|
||||
qual = _parseLocationQuality(qualValue);
|
||||
satelliteCnt = state.status.satelliteCnt.toString();
|
||||
} else if (state is DeviceStatusError) {
|
||||
qual = '-';
|
||||
@@ -89,13 +95,37 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
||||
return SliverToBoxAdapter(
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), // 减小内边距
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("航向角状态:$headingStatus", style: const TextStyle(fontSize: 14)),
|
||||
Text("定位质量:$qual", style: const TextStyle(fontSize: 14)),
|
||||
Text("卫星数:$satelliteCnt", style: const TextStyle(fontSize: 14)),
|
||||
// 优化1:减小字体大小到12,设置最大宽度,防止溢出
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text("航向角状态:$headingStatus", style: const TextStyle(fontSize: 12), maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
// 优化2:定位质量列,减小字体,设置最大宽度
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Text(
|
||||
"定位质量:$qual",
|
||||
style: const TextStyle(fontSize: 12),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
// 优化3:卫星数列,减小字体,设置最大宽度
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
"卫星数:$satelliteCnt",
|
||||
style: const TextStyle(fontSize: 12),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -160,7 +190,7 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: isActive ? const Color(0xFF1677FF) : const Color(0xFF666666),
|
||||
fontSize: 18,
|
||||
fontSize: 16, // 选项卡字体从18减小到16
|
||||
fontWeight: isActive ? FontWeight.bold : FontWeight.normal,
|
||||
decoration: isActive ? TextDecoration.underline : null,
|
||||
decorationColor: const Color(0xFF1677FF),
|
||||
@@ -172,13 +202,14 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
||||
// 电机参数表格
|
||||
Widget _buildMotorTable(DeviceStatusUpdated state) {
|
||||
final status = state.status;
|
||||
print(state);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 12),
|
||||
child: Text("电机参数", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
child: Text("电机参数", style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)), // 从20减小到18
|
||||
),
|
||||
Table(
|
||||
border: TableBorder.all(color: const Color(0xFFE5E5E5)),
|
||||
@@ -200,8 +231,6 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
||||
_buildTableCell("测量速度\n(rpm)"),
|
||||
_buildTableCell(status.leftTargetSpeed.toStringAsFixed(2)),
|
||||
_buildTableCell(status.rightTargetSpeed.toStringAsFixed(2)),
|
||||
//_buildTableCell(status.leftMeasuredSpeed.toStringAsFixed(2)),
|
||||
//_buildTableCell(status.rightMeasuredSpeed.toStringAsFixed(2)),
|
||||
],
|
||||
),
|
||||
TableRow(
|
||||
@@ -233,7 +262,7 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 12),
|
||||
child: Text("其他参数", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
child: Text("其他参数", style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)), // 从20减小到18
|
||||
),
|
||||
Table(
|
||||
border: TableBorder.all(color: const Color(0xFFE5E5E5)),
|
||||
@@ -249,6 +278,7 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
||||
TableRow(children: [_buildTableCell("电量(%)"), _buildTableCell(status.battery)]),
|
||||
TableRow(children: [_buildTableCell("芯片温度(°C)"), _buildTableCell(status.chipTemp.toStringAsFixed(2))]),
|
||||
TableRow(children: [_buildTableCell("割刀速度(rpm)"), _buildTableCell(status.knifeCuttingSpeed)]),
|
||||
TableRow(children: [_buildTableCell("经度(°)"), _buildTableCell(status.longitude.toStringAsFixed(6))]),
|
||||
TableRow(children: [_buildTableCell("纬度(°)"), _buildTableCell(status.latitude.toStringAsFixed(6))]),
|
||||
],
|
||||
),
|
||||
@@ -259,12 +289,12 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
||||
Widget _buildTableCell(String text, {bool isHeader = false}) {
|
||||
return TableCell(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 6), // 减小表格内边距
|
||||
child: Text(
|
||||
text,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontSize: 14, // 表格字体从16减小到14
|
||||
color: isHeader ? const Color(0xFF333333) : const Color(0xFF666666),
|
||||
fontWeight: isHeader ? FontWeight.bold : FontWeight.normal,
|
||||
),
|
||||
@@ -295,7 +325,7 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
||||
children: [
|
||||
Text("图表视图", style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 16),
|
||||
Text("可接入 fl_chart / charts_flutter 实现折线图/柱状图", style: TextStyle(color: Color(0xFF999999))),
|
||||
Text("可接入 fl_chart / charts_flutter 实现折线图/柱状图", style: TextStyle(color: Color(0xFF999999), fontSize: 14)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user