优化
This commit is contained in:
@@ -77,8 +77,14 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
|||||||
|
|
||||||
if (state is DeviceStatusUpdated) {
|
if (state is DeviceStatusUpdated) {
|
||||||
headingStatus = state.status.headingStatus == 0 ? '未初始化' : '已初始化';
|
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();
|
satelliteCnt = state.status.satelliteCnt.toString();
|
||||||
} else if (state is DeviceStatusError) {
|
} else if (state is DeviceStatusError) {
|
||||||
qual = '-';
|
qual = '-';
|
||||||
@@ -89,13 +95,37 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
|||||||
return SliverToBoxAdapter(
|
return SliverToBoxAdapter(
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), // 减小内边距
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text("航向角状态:$headingStatus", style: const TextStyle(fontSize: 14)),
|
// 优化1:减小字体大小到12,设置最大宽度,防止溢出
|
||||||
Text("定位质量:$qual", style: const TextStyle(fontSize: 14)),
|
Expanded(
|
||||||
Text("卫星数:$satelliteCnt", style: const TextStyle(fontSize: 14)),
|
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,
|
title,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isActive ? const Color(0xFF1677FF) : const Color(0xFF666666),
|
color: isActive ? const Color(0xFF1677FF) : const Color(0xFF666666),
|
||||||
fontSize: 18,
|
fontSize: 16, // 选项卡字体从18减小到16
|
||||||
fontWeight: isActive ? FontWeight.bold : FontWeight.normal,
|
fontWeight: isActive ? FontWeight.bold : FontWeight.normal,
|
||||||
decoration: isActive ? TextDecoration.underline : null,
|
decoration: isActive ? TextDecoration.underline : null,
|
||||||
decorationColor: const Color(0xFF1677FF),
|
decorationColor: const Color(0xFF1677FF),
|
||||||
@@ -172,13 +202,14 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
|||||||
// 电机参数表格
|
// 电机参数表格
|
||||||
Widget _buildMotorTable(DeviceStatusUpdated state) {
|
Widget _buildMotorTable(DeviceStatusUpdated state) {
|
||||||
final status = state.status;
|
final status = state.status;
|
||||||
|
print(state);
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 12),
|
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(
|
Table(
|
||||||
border: TableBorder.all(color: const Color(0xFFE5E5E5)),
|
border: TableBorder.all(color: const Color(0xFFE5E5E5)),
|
||||||
@@ -200,8 +231,6 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
|||||||
_buildTableCell("测量速度\n(rpm)"),
|
_buildTableCell("测量速度\n(rpm)"),
|
||||||
_buildTableCell(status.leftTargetSpeed.toStringAsFixed(2)),
|
_buildTableCell(status.leftTargetSpeed.toStringAsFixed(2)),
|
||||||
_buildTableCell(status.rightTargetSpeed.toStringAsFixed(2)),
|
_buildTableCell(status.rightTargetSpeed.toStringAsFixed(2)),
|
||||||
//_buildTableCell(status.leftMeasuredSpeed.toStringAsFixed(2)),
|
|
||||||
//_buildTableCell(status.rightMeasuredSpeed.toStringAsFixed(2)),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
TableRow(
|
TableRow(
|
||||||
@@ -233,7 +262,7 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
|||||||
children: [
|
children: [
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 12),
|
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(
|
Table(
|
||||||
border: TableBorder.all(color: const Color(0xFFE5E5E5)),
|
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("电量(%)"), _buildTableCell(status.battery)]),
|
||||||
TableRow(children: [_buildTableCell("芯片温度(°C)"), _buildTableCell(status.chipTemp.toStringAsFixed(2))]),
|
TableRow(children: [_buildTableCell("芯片温度(°C)"), _buildTableCell(status.chipTemp.toStringAsFixed(2))]),
|
||||||
TableRow(children: [_buildTableCell("割刀速度(rpm)"), _buildTableCell(status.knifeCuttingSpeed)]),
|
TableRow(children: [_buildTableCell("割刀速度(rpm)"), _buildTableCell(status.knifeCuttingSpeed)]),
|
||||||
|
TableRow(children: [_buildTableCell("经度(°)"), _buildTableCell(status.longitude.toStringAsFixed(6))]),
|
||||||
TableRow(children: [_buildTableCell("纬度(°)"), _buildTableCell(status.latitude.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}) {
|
Widget _buildTableCell(String text, {bool isHeader = false}) {
|
||||||
return TableCell(
|
return TableCell(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8),
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 6), // 减小表格内边距
|
||||||
child: Text(
|
child: Text(
|
||||||
text,
|
text,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 14, // 表格字体从16减小到14
|
||||||
color: isHeader ? const Color(0xFF333333) : const Color(0xFF666666),
|
color: isHeader ? const Color(0xFF333333) : const Color(0xFF666666),
|
||||||
fontWeight: isHeader ? FontWeight.bold : FontWeight.normal,
|
fontWeight: isHeader ? FontWeight.bold : FontWeight.normal,
|
||||||
),
|
),
|
||||||
@@ -295,7 +325,7 @@ class _RunningStatusPageState extends State<RunningStatusPage> {
|
|||||||
children: [
|
children: [
|
||||||
Text("图表视图", style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
Text("图表视图", style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||||
SizedBox(height: 16),
|
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