Add Docker build workflow and mobile application
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
/// Navigation route point
|
||||
class NavigationPoint {
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
final String? name;
|
||||
|
||||
NavigationPoint({
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
this.name,
|
||||
});
|
||||
|
||||
LatLng toLatLng() => LatLng(latitude, longitude);
|
||||
|
||||
factory NavigationPoint.fromLatLng(LatLng latlng, {String? name}) {
|
||||
return NavigationPoint(
|
||||
latitude: latlng.latitude,
|
||||
longitude: latlng.longitude,
|
||||
name: name,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
|
||||
factory NavigationPoint.fromJson(Map<String, dynamic> json) {
|
||||
return NavigationPoint(
|
||||
latitude: json['latitude'] as double,
|
||||
longitude: json['longitude'] as double,
|
||||
name: json['name'] as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Route leg with distance and duration
|
||||
class RouteLeg {
|
||||
final List<NavigationPoint> points;
|
||||
final double distance; // in meters
|
||||
final int duration; // in seconds
|
||||
final String summary;
|
||||
|
||||
RouteLeg({
|
||||
required this.points,
|
||||
required this.distance,
|
||||
required this.duration,
|
||||
required this.summary,
|
||||
});
|
||||
|
||||
String getDistanceKm() => (distance / 1000).toStringAsFixed(1);
|
||||
String getDurationMinutes() => (duration ~/ 60).toString();
|
||||
|
||||
factory RouteLeg.fromJson(Map<String, dynamic> json) {
|
||||
final coords = json['geometry']['coordinates'] as List;
|
||||
return RouteLeg(
|
||||
points: coords
|
||||
.map((coord) => NavigationPoint(
|
||||
latitude: coord[1] as double,
|
||||
longitude: coord[0] as double,
|
||||
))
|
||||
.toList(),
|
||||
distance: (json['distance'] as num).toDouble(),
|
||||
duration: (json['duration'] as num).toInt(),
|
||||
summary: json['summary'] as String? ?? 'Route',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Complete navigation route from start to end
|
||||
class NavigationRoute {
|
||||
final NavigationPoint start;
|
||||
final NavigationPoint end;
|
||||
final List<RouteLeg> legs;
|
||||
final double totalDistance; // in meters
|
||||
final int totalDuration; // in seconds
|
||||
|
||||
NavigationRoute({
|
||||
required this.start,
|
||||
required this.end,
|
||||
required this.legs,
|
||||
required this.totalDistance,
|
||||
required this.totalDuration,
|
||||
});
|
||||
|
||||
String getTotalDistanceKm() => (totalDistance / 1000).toStringAsFixed(1);
|
||||
String getTotalDurationMinutes() => (totalDuration ~/ 60).toString();
|
||||
String getTotalDurationHM() {
|
||||
final hours = totalDuration ~/ 3600;
|
||||
final minutes = (totalDuration % 3600) ~/ 60;
|
||||
if (hours > 0) {
|
||||
return '${hours}h ${minutes}m';
|
||||
}
|
||||
return '${minutes}m';
|
||||
}
|
||||
|
||||
List<NavigationPoint> getAllPoints() {
|
||||
final allPoints = <NavigationPoint>[];
|
||||
for (final leg in legs) {
|
||||
allPoints.addAll(leg.points);
|
||||
}
|
||||
return allPoints;
|
||||
}
|
||||
|
||||
factory NavigationRoute.fromJson(Map<String, dynamic> json) {
|
||||
final routes = json['routes'] as List;
|
||||
if (routes.isEmpty) {
|
||||
throw Exception('No route found');
|
||||
}
|
||||
|
||||
final routeData = routes[0] as Map<String, dynamic>;
|
||||
final legs = (routeData['legs'] as List)
|
||||
.map((leg) => RouteLeg.fromJson(leg as Map<String, dynamic>))
|
||||
.toList();
|
||||
|
||||
return NavigationRoute(
|
||||
start: NavigationPoint(latitude: 0, longitude: 0), // TODO: Set from request
|
||||
end: NavigationPoint(latitude: 0, longitude: 0), // TODO: Set from request
|
||||
legs: legs,
|
||||
totalDistance: (routeData['distance'] as num).toDouble(),
|
||||
totalDuration: (routeData['duration'] as num).toInt(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/// Bus Line model
|
||||
class BusLine {
|
||||
final int id;
|
||||
final int lineNumber;
|
||||
final String startStop;
|
||||
final String endStop;
|
||||
final int estimatedDuration; // in minutes
|
||||
final String? description;
|
||||
|
||||
BusLine({
|
||||
required this.id,
|
||||
required this.lineNumber,
|
||||
required this.startStop,
|
||||
required this.endStop,
|
||||
required this.estimatedDuration,
|
||||
this.description,
|
||||
});
|
||||
|
||||
factory BusLine.fromJson(Map<String, dynamic> json) {
|
||||
return BusLine(
|
||||
id: json['id'] as int,
|
||||
lineNumber: json['lineNumber'] as int,
|
||||
startStop: json['startStop'] as String,
|
||||
endStop: json['endStop'] as String,
|
||||
estimatedDuration: json['estimatedDuration'] as int,
|
||||
description: json['description'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'lineNumber': lineNumber,
|
||||
'startStop': startStop,
|
||||
'endStop': endStop,
|
||||
'estimatedDuration': estimatedDuration,
|
||||
'description': description,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Bus type model
|
||||
class BusType {
|
||||
final int id;
|
||||
final String name;
|
||||
final int seatCapacity;
|
||||
final String licensePlate;
|
||||
|
||||
BusType({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.seatCapacity,
|
||||
required this.licensePlate,
|
||||
});
|
||||
|
||||
factory BusType.fromJson(Map<String, dynamic> json) {
|
||||
return BusType(
|
||||
id: json['id'] as int,
|
||||
name: json['name'] as String,
|
||||
seatCapacity: json['seatCapacity'] as int,
|
||||
licensePlate: json['licensePlate'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'seatCapacity': seatCapacity,
|
||||
'licensePlate': licensePlate,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Route model for daily schedule
|
||||
class Route {
|
||||
final int id;
|
||||
final BusLine busLine;
|
||||
final BusType busType;
|
||||
final DateTime startTime;
|
||||
final DateTime? endTime;
|
||||
final String status; // scheduled, in_progress, completed, cancelled
|
||||
|
||||
Route({
|
||||
required this.id,
|
||||
required this.busLine,
|
||||
required this.busType,
|
||||
required this.startTime,
|
||||
this.endTime,
|
||||
required this.status,
|
||||
});
|
||||
|
||||
factory Route.fromJson(Map<String, dynamic> json) {
|
||||
return Route(
|
||||
id: json['id'] as int,
|
||||
busLine: BusLine.fromJson(json['busLine'] as Map<String, dynamic>),
|
||||
busType: BusType.fromJson(json['busType'] as Map<String, dynamic>),
|
||||
startTime: DateTime.parse(json['startTime'] as String),
|
||||
endTime:
|
||||
json['endTime'] != null ? DateTime.parse(json['endTime'] as String) : null,
|
||||
status: json['status'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'busLine': busLine.toJson(),
|
||||
'busType': busType.toJson(),
|
||||
'startTime': startTime.toIso8601String(),
|
||||
'endTime': endTime?.toIso8601String(),
|
||||
'status': status,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Daily schedule model
|
||||
class DailySchedule {
|
||||
final List<Route> routes;
|
||||
final DateTime date;
|
||||
|
||||
DailySchedule({
|
||||
required this.routes,
|
||||
required this.date,
|
||||
});
|
||||
|
||||
factory DailySchedule.fromJson(Map<String, dynamic> json) {
|
||||
return DailySchedule(
|
||||
routes: (json['routes'] as List)
|
||||
.map((r) => Route.fromJson(r as Map<String, dynamic>))
|
||||
.toList(),
|
||||
date: DateTime.parse(json['date'] as String),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'routes': routes.map((r) => r.toJson()).toList(),
|
||||
'date': date.toIso8601String(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/// User model
|
||||
class User {
|
||||
final int id;
|
||||
final String userCode;
|
||||
final String? job;
|
||||
|
||||
User({
|
||||
required this.id,
|
||||
required this.userCode,
|
||||
this.job,
|
||||
});
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) {
|
||||
return User(
|
||||
id: json['id'] as int,
|
||||
userCode: json['userCode'] as String,
|
||||
job: json['job'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'userCode': userCode,
|
||||
'job': job,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Login response model
|
||||
class AuthResponse {
|
||||
final String token;
|
||||
final User user;
|
||||
|
||||
AuthResponse({
|
||||
required this.token,
|
||||
required this.user,
|
||||
});
|
||||
|
||||
factory AuthResponse.fromJson(Map<String, dynamic> json) {
|
||||
return AuthResponse(
|
||||
token: json['token'] as String,
|
||||
user: User.fromJson(json['user'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user