Tracking funkció fejlesztése

This commit is contained in:
2026-06-11 01:20:55 +02:00
parent 2364b2311c
commit 01e6105240
18 changed files with 858 additions and 162 deletions
+12 -3
View File
@@ -58,6 +58,7 @@ enum TrackStatus { recording, paused, finished }
class Track {
final int? id;
final int? projectId;
final String name;
final DateTime startTime;
final DateTime? endTime;
@@ -70,6 +71,7 @@ class Track {
const Track({
this.id,
this.projectId,
required this.name,
required this.startTime,
this.endTime,
@@ -81,6 +83,7 @@ class Track {
Track copyWith({
int? id,
int? projectId,
String? name,
DateTime? startTime,
DateTime? endTime,
@@ -91,6 +94,7 @@ class Track {
}) =>
Track(
id: id ?? this.id,
projectId: projectId ?? this.projectId,
name: name ?? this.name,
startTime: startTime ?? this.startTime,
endTime: endTime ?? this.endTime,
@@ -120,25 +124,30 @@ class Track {
Map<String, dynamic> toMap() => {
if (id != null) 'id': id,
if (projectId != null) 'project_id': projectId,
'name': name,
'start_time': startTime.toIso8601String(),
'end_time': endTime?.toIso8601String(),
'status': status.name,
'source': source,
'distance_meters': distanceMeters,
'distance_m': distanceMeters,
'point_count': pointCount,
};
factory Track.fromMap(Map<String, dynamic> m) => Track(
id: m['id'] as int?,
projectId: m['project_id'] as int?,
name: m['name'] as String,
startTime: DateTime.parse(m['start_time'] as String),
endTime: m['end_time'] != null
? DateTime.parse(m['end_time'] as String)
: null,
status: TrackStatus.values.byName(m['status'] as String),
status: TrackStatus.values.firstWhere(
(s) => s.name == (m['status'] as String?),
orElse: () => TrackStatus.finished,
),
source: m['source'] as String? ?? 'Telefon GPS',
distanceMeters: (m['distance_meters'] as num?)?.toDouble() ?? 0,
distanceMeters: (m['distance_m'] as num?)?.toDouble() ?? 0,
pointCount: m['point_count'] as int? ?? 0,
);
}