Skip to content

Commit 3c58aba

Browse files
committed
chore: re-organize types
1 parent 5f09d0e commit 3c58aba

File tree

3 files changed

+164
-149
lines changed

3 files changed

+164
-149
lines changed

lib/src/types/navigation.dart

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
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+
}

lib/src/types/simulation.dart

Lines changed: 0 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -12,119 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import '../../google_navigation_flutter.dart';
16-
17-
/// Type for speed alert severity.
18-
/// {@category Navigation}
19-
enum SpeedAlertSeverity {
20-
/// Unknown severity.
21-
unknown,
22-
23-
/// Not speeding severity.
24-
notSpeeding,
25-
26-
/// Minor speeding severity.
27-
minor,
28-
29-
/// Major speeding severity.
30-
major,
31-
}
32-
33-
/// SpeedingUpdated event message.
34-
/// {@category Navigation}
35-
class SpeedingUpdatedEvent {
36-
/// Initialize speeding updated event message.
37-
SpeedingUpdatedEvent({
38-
required this.percentageAboveLimit,
39-
required this.severity,
40-
});
41-
42-
/// Percentage above speed limit.
43-
final double percentageAboveLimit;
44-
45-
/// Severity of the speeding.
46-
final SpeedAlertSeverity severity;
47-
48-
@override
49-
String toString() =>
50-
'SpeedingUpdatedEvent('
51-
'percentageAboveLimit: $percentageAboveLimit, '
52-
'severity: $severity'
53-
')';
54-
}
55-
56-
/// RoadSnappedLocationUpdated event message.
57-
/// {@category Navigation}
58-
class RoadSnappedLocationUpdatedEvent {
59-
/// Initialize road snapped location updated event message.
60-
RoadSnappedLocationUpdatedEvent({required this.location});
61-
62-
/// Coordinate of the updated location.
63-
final LatLng location;
64-
65-
@override
66-
String toString() => 'RoadSnappedLocationUpdatedEvent(location: $location)';
67-
}
68-
69-
/// RoadSnappedRawLocationUpdated event message (Android only).
70-
/// {@category Navigation}
71-
class RoadSnappedRawLocationUpdatedEvent {
72-
/// Initialize road snapped raw location updated event message.
73-
RoadSnappedRawLocationUpdatedEvent({required this.location});
74-
75-
/// Coordinate of the updated location.
76-
final LatLng location;
77-
78-
@override
79-
String toString() =>
80-
'RoadSnappedRawLocationUpdatedEvent(location: $location)';
81-
}
82-
83-
/// GpsAvailabilityUpdated event message (Android only).
84-
/// {@category Navigation}
85-
@Deprecated(
86-
'Use getNavigationOnGpsAvailabilityChangeEventStream and GpsAvailabilityChangeEvent instead',
87-
)
88-
class GpsAvailabilityUpdatedEvent {
89-
/// Initialize GPS availability updated event message.
90-
GpsAvailabilityUpdatedEvent({required this.available});
91-
92-
/// GPS availability.
93-
final bool available;
94-
95-
@override
96-
String toString() => 'GpsAvailabilityUpdatedEvent(available: $available)';
97-
}
98-
99-
/// GpsAvailabilityChange event message (Android only).
100-
/// {@category Navigation}
101-
class GpsAvailabilityChangeEvent {
102-
/// Initialize GPS availability change event message.
103-
GpsAvailabilityChangeEvent({
104-
required this.isGpsLost,
105-
required this.isGpsValidForNavigation,
106-
});
107-
108-
/// Indicates a GPS signal or other sensors good enough for a reasonably certain location have been lost.
109-
///
110-
/// This state is triggered after a short timeout (10 seconds) and serves as an early warning of potential signal issues.
111-
/// For example, the "Searching for GPS" UI message may be shown when this value is true.
112-
final bool isGpsLost;
113-
114-
/// Indicates a GPS signal or other sensors are in general good enough for use in navigation.
115-
///
116-
/// Note that this value takes into account the frequent failure of GPS at the start of nav,
117-
/// and doesn't become true until some time later.
118-
final bool isGpsValidForNavigation;
119-
120-
@override
121-
String toString() =>
122-
'GpsAvailabilityChangeEvent('
123-
'isGpsLost: $isGpsLost, '
124-
'isGpsValidForNavigation: $isGpsValidForNavigation'
125-
')';
126-
}
127-
12815
/// Navigation simulation options.
12916
/// {@category Navigation}
13017
class SimulationOptions {
@@ -137,39 +24,3 @@ class SimulationOptions {
13724
@override
13825
String toString() => 'SimulationOptions(speedMultiplier: $speedMultiplier)';
13926
}
140-
141-
/// Remaining time or distance change event message.
142-
/// {@category Navigation}
143-
class RemainingTimeOrDistanceChangedEvent {
144-
/// Initialize with remaining distance in meters and remaining time in seconds.
145-
RemainingTimeOrDistanceChangedEvent({
146-
required this.remainingDistance,
147-
required this.remainingTime,
148-
});
149-
150-
/// Remaining distance in meters.
151-
final double remainingDistance;
152-
153-
/// Remaining time in seconds.
154-
final double remainingTime;
155-
156-
@override
157-
String toString() =>
158-
'RemainingTimeOrDistanceChangedEvent('
159-
'remainingDistance: $remainingDistance, '
160-
'remainingTime: $remainingTime'
161-
')';
162-
}
163-
164-
/// On arrival event message
165-
/// {@category Navigation}
166-
class OnArrivalEvent {
167-
/// Initialize with arrival waypoint.
168-
OnArrivalEvent({required this.waypoint});
169-
170-
/// Arrival waypoint.
171-
final NavigationWaypoint waypoint;
172-
173-
@override
174-
String toString() => 'OnArrivalEvent(waypoint: $waypoint)';
175-
}

lib/src/types/types.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export 'images.dart';
1717
export 'lat_lng.dart';
1818
export 'lat_lng_bounds.dart';
1919
export 'markers.dart';
20+
export 'navigation.dart';
2021
export 'navigation_destinations.dart';
2122
export 'navigation_initialization_params.dart';
2223
export 'navigation_view_types.dart';

0 commit comments

Comments
 (0)