Add display of legs and top traction, adjust colour based on device theme

This commit is contained in:
2025-07-25 02:03:10 +01:00
parent 652e83bf38
commit 985eddb35a
15 changed files with 316 additions and 64 deletions

View File

@@ -84,8 +84,9 @@ class YearlyMileage {
class LocoSummary {
final String locoType, locoClass, locoNumber, locoName, locoOperator;
final String? locoNotes, locoEvn;
final int locoId, locoJourneys;
final double locoMileage;
final int locoId;
final int? locoJourneys;
final double? locoMileage;
LocoSummary({
required this.locoType,
@@ -96,8 +97,8 @@ class LocoSummary {
this.locoNotes,
this.locoEvn,
required this.locoId,
required this.locoMileage,
required this.locoJourneys,
this.locoMileage,
this.locoJourneys,
});
factory LocoSummary.fromJson(Map<String, dynamic> json) => LocoSummary(
@@ -151,3 +152,76 @@ class TripSummary {
tripMileage: (json['trip_mileage'] as num).toDouble(),
);
}
class Loco {
final int id;
final String type, number, name, locoClass, operator;
final String? notes, evn;
Loco({
required this.id,
required this.type,
required this.number,
required this.name,
required this.locoClass,
required this.operator,
this.notes,
this.evn,
});
factory Loco.fromJson(Map<String, dynamic> json) => Loco(
id: json['loco_id'],
type: json['loco_type'],
number: json['loco_number'],
name: json['loco_name'] ?? "",
locoClass: json['loco_class'],
operator: json['loco_operator'],
notes: json['loco_notes'],
evn: json['loco_evn'],
);
}
class Leg {
final int id, tripId, timezone, driving;
final String start, end, route, network, notes, headcode, user;
final DateTime beginTime;
final double mileage;
final List<Loco> locos;
Leg({
required this.id,
required this.tripId,
required this.start,
required this.end,
required this.beginTime,
required this.timezone,
required this.network,
required this.route,
required this.mileage,
required this.notes,
required this.headcode,
required this.driving,
required this.user,
required this.locos,
});
factory Leg.fromJson(Map<String, dynamic> json) => Leg(
id: json['leg_id'],
tripId: json['leg_trip'] ?? 0,
start: json['leg_start'],
end: json['leg_end'],
beginTime: DateTime.parse(json['leg_begin_time']),
timezone: (json['leg_timezone'] as num).toInt(),
network: json['leg_network'] ?? "",
route: json['leg_route'],
mileage: (json['leg_mileage'] as num).toDouble(),
notes: json['leg_notes'] ?? "",
headcode: json['leg_headcode'] ?? "",
driving: json['leg_driving'],
user: json['leg_user'],
locos: (json['locos'] as List)
.map((e) => Loco.fromJson(e as Map<String, dynamic>))
.toList(),
);
}