import 'package:flutter/material.dart'; enum RoadAlertCategory { police, speedCamera, accident, hazard, roadClosure, construction, traffic, other, } extension RoadAlertCategoryExtension on RoadAlertCategory { String get displayName { switch (this) { case RoadAlertCategory.police: return 'Police'; case RoadAlertCategory.speedCamera: return 'Speed Camera'; case RoadAlertCategory.accident: return 'Accident'; case RoadAlertCategory.hazard: return 'Hazard'; case RoadAlertCategory.roadClosure: return 'Road Closure'; case RoadAlertCategory.construction: return 'Construction'; case RoadAlertCategory.traffic: return 'Traffic Delay'; case RoadAlertCategory.other: return 'Other'; } } IconData get icon { switch (this) { case RoadAlertCategory.police: return Icons.local_police; case RoadAlertCategory.speedCamera: return Icons.camera_alt; case RoadAlertCategory.accident: return Icons.car_crash; case RoadAlertCategory.hazard: return Icons.warning_amber; case RoadAlertCategory.roadClosure: return Icons.do_not_disturb_on; case RoadAlertCategory.construction: return Icons.engineering; case RoadAlertCategory.traffic: return Icons.traffic; case RoadAlertCategory.other: return Icons.report_problem; } } Color get color { switch (this) { case RoadAlertCategory.police: return Colors.blueAccent; case RoadAlertCategory.speedCamera: return Colors.purpleAccent; case RoadAlertCategory.accident: return Colors.redAccent; case RoadAlertCategory.hazard: return Colors.orangeAccent; case RoadAlertCategory.roadClosure: return Colors.deepOrange; case RoadAlertCategory.construction: return Colors.amber; case RoadAlertCategory.traffic: return Colors.yellowAccent; case RoadAlertCategory.other: return Colors.cyanAccent; } } } enum RoadAlertSeverity { low, medium, high, critical } enum RoadAlertSourceType { providerReported, userReported } enum RoadAlertProviderStatus { notConfigured, configured, connected, rateLimited, authError, networkError, } class RoadAlert { final String id; final String providerId; final RoadAlertCategory category; final double latitude; final double longitude; final double? heading; final String? roadName; final String description; final DateTime reportedAt; final DateTime? expiresAt; final DateTime lastUpdated; final double? confidence; // 0.0 to 1.0 final RoadAlertSeverity severity; final String source; final String? sourceUrl; final double? distanceFromUser; // meters final RoadAlertSourceType sourceType; const RoadAlert({ required this.id, required this.providerId, required this.category, required this.latitude, required this.longitude, this.heading, this.roadName, required this.description, required this.reportedAt, this.expiresAt, required this.lastUpdated, this.confidence, this.severity = RoadAlertSeverity.medium, required this.source, this.sourceUrl, this.distanceFromUser, this.sourceType = RoadAlertSourceType.providerReported, }); RoadAlert copyWith({ String? id, String? providerId, RoadAlertCategory? category, double? latitude, double? longitude, double? heading, String? roadName, String? description, DateTime? reportedAt, DateTime? expiresAt, DateTime? lastUpdated, double? confidence, RoadAlertSeverity? severity, String? source, String? sourceUrl, double? distanceFromUser, RoadAlertSourceType? sourceType, }) { return RoadAlert( id: id ?? this.id, providerId: providerId ?? this.providerId, category: category ?? this.category, latitude: latitude ?? this.latitude, longitude: longitude ?? this.longitude, heading: heading ?? this.heading, roadName: roadName ?? this.roadName, description: description ?? this.description, reportedAt: reportedAt ?? this.reportedAt, expiresAt: expiresAt ?? this.expiresAt, lastUpdated: lastUpdated ?? this.lastUpdated, confidence: confidence ?? this.confidence, severity: severity ?? this.severity, source: source ?? this.source, sourceUrl: sourceUrl ?? this.sourceUrl, distanceFromUser: distanceFromUser ?? this.distanceFromUser, sourceType: sourceType ?? this.sourceType, ); } }