fix: repair record processing logic
This commit is contained in:
@@ -149,7 +149,7 @@ class TrainRecord {
|
|||||||
final lbjClassValue = lbjClass.trim();
|
final lbjClassValue = lbjClass.trim();
|
||||||
final trainValue = train.trim();
|
final trainValue = train.trim();
|
||||||
|
|
||||||
if (trainValue == "<NUL>") {
|
if (trainValue == "<NUL>" || trainValue.contains("-----")) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -580,17 +580,7 @@ class HistoryScreenState extends State<HistoryScreen> {
|
|||||||
_buildRecordHeader(record),
|
_buildRecordHeader(record),
|
||||||
_buildPositionAndSpeed(record),
|
_buildPositionAndSpeed(record),
|
||||||
_buildLocoInfo(record),
|
_buildLocoInfo(record),
|
||||||
AnimatedCrossFade(
|
if (isExpanded) _buildExpandedContent(record),
|
||||||
duration: const Duration(milliseconds: 300),
|
|
||||||
firstChild: const SizedBox.shrink(),
|
|
||||||
secondChild: _buildExpandedContent(record),
|
|
||||||
crossFadeState: isExpanded
|
|
||||||
? CrossFadeState.showSecond
|
|
||||||
: CrossFadeState.showFirst,
|
|
||||||
firstCurve: Curves.easeInOut,
|
|
||||||
secondCurve: Curves.easeInOut,
|
|
||||||
sizeCurve: Curves.easeInOut,
|
|
||||||
)
|
|
||||||
]))));
|
]))));
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
@@ -623,7 +613,7 @@ class HistoryScreenState extends State<HistoryScreen> {
|
|||||||
formattedLocoInfo = record.loco;
|
formattedLocoInfo = record.loco;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (record.fullTrainNumber.isEmpty) {
|
if (record.fullTrainNumber.isEmpty && formattedLocoInfo.isEmpty) {
|
||||||
return Text(
|
return Text(
|
||||||
(record.time == "<NUL>" || record.time.isEmpty)
|
(record.time == "<NUL>" || record.time.isEmpty)
|
||||||
? record.receivedTimestamp.toString().split(".")[0]
|
? record.receivedTimestamp.toString().split(".")[0]
|
||||||
@@ -632,6 +622,11 @@ class HistoryScreenState extends State<HistoryScreen> {
|
|||||||
overflow: TextOverflow.ellipsis);
|
overflow: TextOverflow.ellipsis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final hasTrainNumber = record.fullTrainNumber.isNotEmpty;
|
||||||
|
final hasDirection = record.direction == 1 || record.direction == 3;
|
||||||
|
final hasLocoInfo = formattedLocoInfo.isNotEmpty && formattedLocoInfo != "<NUL>";
|
||||||
|
final shouldShowTrainRow = hasTrainNumber || hasDirection || hasLocoInfo;
|
||||||
|
|
||||||
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
@@ -647,6 +642,7 @@ class HistoryScreenState extends State<HistoryScreen> {
|
|||||||
style: const TextStyle(fontSize: 11, color: Colors.grey),
|
style: const TextStyle(fontSize: 11, color: Colors.grey),
|
||||||
overflow: TextOverflow.ellipsis))
|
overflow: TextOverflow.ellipsis))
|
||||||
]),
|
]),
|
||||||
|
if (shouldShowTrainRow) ...[
|
||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
@@ -657,6 +653,7 @@ class HistoryScreenState extends State<HistoryScreen> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
if (hasTrainNumber)
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(record.fullTrainNumber,
|
child: Text(record.fullTrainNumber,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
@@ -664,8 +661,8 @@ class HistoryScreenState extends State<HistoryScreen> {
|
|||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.white),
|
color: Colors.white),
|
||||||
overflow: TextOverflow.ellipsis)),
|
overflow: TextOverflow.ellipsis)),
|
||||||
const SizedBox(width: 6),
|
if (hasTrainNumber && hasDirection) const SizedBox(width: 6),
|
||||||
if (record.direction == 1 || record.direction == 3)
|
if (hasDirection)
|
||||||
Container(
|
Container(
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 20,
|
height: 20,
|
||||||
@@ -679,11 +676,12 @@ class HistoryScreenState extends State<HistoryScreen> {
|
|||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.black))))
|
color: Colors.black))))
|
||||||
])),
|
])),
|
||||||
if (formattedLocoInfo.isNotEmpty && formattedLocoInfo != "<NUL>")
|
if (hasLocoInfo)
|
||||||
Text(formattedLocoInfo,
|
Text(formattedLocoInfo,
|
||||||
style: const TextStyle(fontSize: 14, color: Colors.white70))
|
style: const TextStyle(fontSize: 14, color: Colors.white70))
|
||||||
]),
|
]),
|
||||||
const SizedBox(height: 2)
|
const SizedBox(height: 2)
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class MergeService {
|
|||||||
static String? _generateGroupKey(TrainRecord record, GroupBy groupBy) {
|
static String? _generateGroupKey(TrainRecord record, GroupBy groupBy) {
|
||||||
final train = record.train.trim();
|
final train = record.train.trim();
|
||||||
final loco = record.loco.trim();
|
final loco = record.loco.trim();
|
||||||
final hasTrain = train.isNotEmpty && train != "<NUL>";
|
final hasTrain = train.isNotEmpty && train != "<NUL>" && !train.contains("-----");
|
||||||
final hasLoco = loco.isNotEmpty && loco != "<NUL>";
|
final hasLoco = loco.isNotEmpty && loco != "<NUL>";
|
||||||
|
|
||||||
switch (groupBy) {
|
switch (groupBy) {
|
||||||
|
|||||||
Reference in New Issue
Block a user