|
| 1 | +// Copyright 2023 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +import 'lat_lng.dart'; |
| 16 | +import 'navigation_destinations.dart'; |
| 17 | + |
| 18 | +/// Type for speed alert severity. |
| 19 | +/// {@category Navigation} |
| 20 | +enum SpeedAlertSeverity { |
| 21 | + /// Unknown severity. |
| 22 | + unknown, |
| 23 | + |
| 24 | + /// Not speeding severity. |
| 25 | + notSpeeding, |
| 26 | + |
| 27 | + /// Minor speeding severity. |
| 28 | + minor, |
| 29 | + |
| 30 | + /// Major speeding severity. |
| 31 | + major, |
| 32 | +} |
| 33 | + |
| 34 | +/// SpeedingUpdated event message. |
| 35 | +/// {@category Navigation} |
| 36 | +class SpeedingUpdatedEvent { |
| 37 | + /// Initialize speeding updated event message. |
| 38 | + SpeedingUpdatedEvent({ |
| 39 | + required this.percentageAboveLimit, |
| 40 | + required this.severity, |
| 41 | + }); |
| 42 | + |
| 43 | + /// Percentage above speed limit. |
| 44 | + final double percentageAboveLimit; |
| 45 | + |
| 46 | + /// Severity of the speeding. |
| 47 | + final SpeedAlertSeverity severity; |
| 48 | + |
| 49 | + @override |
| 50 | + String toString() => |
| 51 | + 'SpeedingUpdatedEvent(' |
| 52 | + 'percentageAboveLimit: $percentageAboveLimit, ' |
| 53 | + 'severity: $severity' |
| 54 | + ')'; |
| 55 | +} |
| 56 | + |
| 57 | +/// RoadSnappedLocationUpdated event message. |
| 58 | +/// {@category Navigation} |
| 59 | +class RoadSnappedLocationUpdatedEvent { |
| 60 | + /// Initialize road snapped location updated event message. |
| 61 | + RoadSnappedLocationUpdatedEvent({required this.location}); |
| 62 | + |
| 63 | + /// Coordinate of the updated location. |
| 64 | + final LatLng location; |
| 65 | + |
| 66 | + @override |
| 67 | + String toString() => 'RoadSnappedLocationUpdatedEvent(location: $location)'; |
| 68 | +} |
| 69 | + |
| 70 | +/// RoadSnappedRawLocationUpdated event message (Android only). |
| 71 | +/// {@category Navigation} |
| 72 | +class RoadSnappedRawLocationUpdatedEvent { |
| 73 | + /// Initialize road snapped raw location updated event message. |
| 74 | + RoadSnappedRawLocationUpdatedEvent({required this.location}); |
| 75 | + |
| 76 | + /// Coordinate of the updated location. |
| 77 | + final LatLng location; |
| 78 | + |
| 79 | + @override |
| 80 | + String toString() => |
| 81 | + 'RoadSnappedRawLocationUpdatedEvent(location: $location)'; |
| 82 | +} |
| 83 | + |
| 84 | +/// GpsAvailabilityUpdated event message (Android only). |
| 85 | +/// {@category Navigation} |
| 86 | +@Deprecated( |
| 87 | + 'Use getNavigationOnGpsAvailabilityChangeEventStream and GpsAvailabilityChangeEvent instead', |
| 88 | +) |
| 89 | +class GpsAvailabilityUpdatedEvent { |
| 90 | + /// Initialize GPS availability updated event message. |
| 91 | + GpsAvailabilityUpdatedEvent({required this.available}); |
| 92 | + |
| 93 | + /// GPS availability. |
| 94 | + final bool available; |
| 95 | + |
| 96 | + @override |
| 97 | + String toString() => 'GpsAvailabilityUpdatedEvent(available: $available)'; |
| 98 | +} |
| 99 | + |
| 100 | +/// GpsAvailabilityChange event message (Android only). |
| 101 | +/// {@category Navigation} |
| 102 | +class GpsAvailabilityChangeEvent { |
| 103 | + /// Initialize GPS availability change event message. |
| 104 | + GpsAvailabilityChangeEvent({ |
| 105 | + required this.isGpsLost, |
| 106 | + required this.isGpsValidForNavigation, |
| 107 | + }); |
| 108 | + |
| 109 | + /// Indicates a GPS signal or other sensors good enough for a reasonably certain location have been lost. |
| 110 | + /// |
| 111 | + /// This state is triggered after a short timeout (10 seconds) and serves as an early warning of potential signal issues. |
| 112 | + /// For example, the "Searching for GPS" UI message may be shown when this value is true. |
| 113 | + final bool isGpsLost; |
| 114 | + |
| 115 | + /// Indicates a GPS signal or other sensors are in general good enough for use in navigation. |
| 116 | + /// |
| 117 | + /// Note that this value takes into account the frequent failure of GPS at the start of nav, |
| 118 | + /// and doesn't become true until some time later. |
| 119 | + final bool isGpsValidForNavigation; |
| 120 | + |
| 121 | + @override |
| 122 | + String toString() => |
| 123 | + 'GpsAvailabilityChangeEvent(' |
| 124 | + 'isGpsLost: $isGpsLost, ' |
| 125 | + 'isGpsValidForNavigation: $isGpsValidForNavigation' |
| 126 | + ')'; |
| 127 | +} |
| 128 | + |
| 129 | +/// Remaining time or distance change event message. |
| 130 | +/// {@category Navigation} |
| 131 | +class RemainingTimeOrDistanceChangedEvent { |
| 132 | + /// Initialize with remaining distance in meters and remaining time in seconds. |
| 133 | + RemainingTimeOrDistanceChangedEvent({ |
| 134 | + required this.remainingDistance, |
| 135 | + required this.remainingTime, |
| 136 | + }); |
| 137 | + |
| 138 | + /// Remaining distance in meters. |
| 139 | + final double remainingDistance; |
| 140 | + |
| 141 | + /// Remaining time in seconds. |
| 142 | + final double remainingTime; |
| 143 | + |
| 144 | + @override |
| 145 | + String toString() => |
| 146 | + 'RemainingTimeOrDistanceChangedEvent(' |
| 147 | + 'remainingDistance: $remainingDistance, ' |
| 148 | + 'remainingTime: $remainingTime' |
| 149 | + ')'; |
| 150 | +} |
| 151 | + |
| 152 | +/// On arrival event message |
| 153 | +/// {@category Navigation} |
| 154 | +class OnArrivalEvent { |
| 155 | + /// Initialize with arrival waypoint. |
| 156 | + OnArrivalEvent({required this.waypoint}); |
| 157 | + |
| 158 | + /// Arrival waypoint. |
| 159 | + final NavigationWaypoint waypoint; |
| 160 | + |
| 161 | + @override |
| 162 | + String toString() => 'OnArrivalEvent(waypoint: $waypoint)'; |
| 163 | +} |
0 commit comments