feat(transport_helper): store vehicle lines in db upon parsing from json

This commit is contained in:
fbachus
2026-07-29 18:31:30 +02:00
parent 0069f370c2
commit 95e3edf699
+15 -11
View File
@@ -812,17 +812,21 @@ class Line {
VehicleType.regionalTrain, VehicleType.regionalTrain,
]; ];
factory Line.fromJson(Map<String, dynamic> json) => Line( factory Line.fromJson(Map<String, dynamic> json) {
lineId: json["lineId"] as String, Line line = Line(
name: json["name"] as String, lineId: json["lineId"] as String,
mode: _vehicleTypeAsCatCode[int.parse(json["catCode"] as String)], name: json["name"] as String,
fgColor: mode: _vehicleTypeAsCatCode[int.parse(json["catCode"] as String)],
Color.fromJson(json["icon"]["foregroundColor"]) as Color? ?? fgColor:
Color(r: 255, g: 255, b: 255), // fallback Color.fromJson(json["icon"]["foregroundColor"]) as Color? ??
bgColor: Color(r: 255, g: 255, b: 255), // fallback
Color.fromJson(json["icon"]["backgroundColor"]) as Color? ?? bgColor:
Color(r: 50, g: 50, b: 50), // fallback Color.fromJson(json["icon"]["backgroundColor"]) as Color? ??
); Color(r: 50, g: 50, b: 50), // fallback
);
line.dbInsert();
return line;
}
static void initLineTable() async { static void initLineTable() async {
Database database = DbHelper.db; Database database = DbHelper.db;
database.execute("""CREATE TABLE IF NOT EXISTS '$tableName'( database.execute("""CREATE TABLE IF NOT EXISTS '$tableName'(