Public Access
feat(transport_helper: add "ref" to Segments for journeyDetails later
This commit is contained in:
@@ -309,7 +309,9 @@ class Route {
|
||||
class Segment {
|
||||
static const String tableName = "segment";
|
||||
|
||||
// TODO: add attribute for departures on the way?
|
||||
int? id;
|
||||
String ref;
|
||||
Station startPoint;
|
||||
Station endPoint;
|
||||
DateTime startTime;
|
||||
@@ -318,6 +320,7 @@ class Segment {
|
||||
|
||||
Segment({
|
||||
this.id, // might throw errors - needs testing, I guess
|
||||
required this.ref,
|
||||
required this.startPoint,
|
||||
required this.endPoint,
|
||||
required this.startTime,
|
||||
@@ -327,6 +330,7 @@ class Segment {
|
||||
|
||||
Map<String, Object?> toMap() {
|
||||
return {
|
||||
"ref": ref,
|
||||
"startpoint": startPoint.id,
|
||||
"endpoint": endPoint.id,
|
||||
"starttime": startTime,
|
||||
@@ -338,6 +342,7 @@ class Segment {
|
||||
factory Segment.fromMap(Map<String, Object?> map) {
|
||||
return Segment(
|
||||
id: map["id"] as int,
|
||||
ref: map["ref"] as String,
|
||||
startPoint: map["startPoint"] as Station,
|
||||
endPoint: map["endPoint"] as Station,
|
||||
startTime: map["startTime"] as DateTime,
|
||||
@@ -348,6 +353,7 @@ class Segment {
|
||||
|
||||
factory Segment.fromJson(Map<String, dynamic> json) {
|
||||
Segment tmp = Segment(
|
||||
ref: json["JourneyDetail"]["ref"],
|
||||
startPoint: Station.fromJson(json["Origin"]),
|
||||
endPoint: Station.fromJson(json["Destination"]),
|
||||
startTime: json["Origin"]["rtTime"],
|
||||
@@ -372,6 +378,8 @@ class Segment {
|
||||
String vehicle = Vehicle.tableName;
|
||||
database.execute("""
|
||||
CREATE TABLE IF NOT EXISTS $tableName(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
ref TEXT,
|
||||
startpoint TEXT,
|
||||
endpoint TEXT,
|
||||
starttime TEXT,
|
||||
@@ -943,4 +951,4 @@ enum VehicleType {
|
||||
subway,
|
||||
regionalTrain,
|
||||
PLACEHOLDER,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user