import 'package:flutter/material.dart'; export 'road_alert_diagnostics.dart'; enum RoadAlertCategory { police, speedCamera, accident, hazard, pothole, debris, disabledVehicle, roadClosure, construction, traffic, weatherHazard, 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.pothole: return 'Pothole'; case RoadAlertCategory.debris: return 'Road Debris'; case RoadAlertCategory.disabledVehicle: return 'Disabled Vehicle'; case RoadAlertCategory.roadClosure: return 'Road Closure'; case RoadAlertCategory.construction: return 'Construction'; case RoadAlertCategory.traffic: return 'Heavy Traffic'; case RoadAlertCategory.weatherHazard: return 'Weather Hazard'; 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.pothole: return Icons.radio_button_checked; case RoadAlertCategory.debris: return Icons.scatter_plot; case RoadAlertCategory.disabledVehicle: return Icons.car_repair; case RoadAlertCategory.roadClosure: return Icons.do_not_disturb_on; case RoadAlertCategory.construction: return Icons.engineering; case RoadAlertCategory.traffic: return Icons.traffic; case RoadAlertCategory.weatherHazard: return Icons.thunderstorm; 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.pothole: return const Color(0xFFFFB300); // Amber 700 case RoadAlertCategory.debris: return const Color(0xFFFF7043); // Deep Orange 400 case RoadAlertCategory.disabledVehicle: return const Color(0xFFFF5252); // Red accent 200 case RoadAlertCategory.roadClosure: return Colors.deepOrange; case RoadAlertCategory.construction: return Colors.amber; case RoadAlertCategory.traffic: return Colors.yellowAccent; case RoadAlertCategory.weatherHazard: return const Color(0xFF4FC3F7); // Light Blue 300 case RoadAlertCategory.other: return Colors.cyanAccent; } } } enum RoadAlertSeverity { low, medium, high, critical } enum RoadAlertSourceType { providerReported, userReported } enum RoadAlertStatus { active, confirmed, cleared, expired } enum RoadAlertProviderStatus { notConfigured, configured, connected, rateLimited, authError, networkError, } class RoadAlert { final String id; final String providerId; final RoadAlertCategory category; final String? subtype; 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; final RoadAlertStatus status; final int confirmations; final int dismissals; final String? reporterUid; const RoadAlert({ required this.id, required this.providerId, required this.category, this.subtype, 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, this.status = RoadAlertStatus.active, this.confirmations = 1, this.dismissals = 0, this.reporterUid, }); bool get isCommunityConfirmed => confirmations >= 2; RoadAlert copyWith({ String? id, String? providerId, RoadAlertCategory? category, String? subtype, 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, RoadAlertStatus? status, int? confirmations, int? dismissals, String? reporterUid, }) { return RoadAlert( id: id ?? this.id, providerId: providerId ?? this.providerId, category: category ?? this.category, subtype: subtype ?? this.subtype, 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, status: status ?? this.status, confirmations: confirmations ?? this.confirmations, dismissals: dismissals ?? this.dismissals, reporterUid: reporterUid ?? this.reporterUid, ); } }