Files
maps-saas/packages/tactical_app/lib/models/navigation_state.dart
T

95 lines
2.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:intaleq_maps/intaleq_maps.dart';
enum ManeuverType {
straight,
slightRight,
right,
sharpRight,
slightLeft,
left,
sharpLeft,
keepRight,
keepLeft,
uTurn,
roundabout,
arrive,
unknown,
}
class NavigationStep {
final String instructionAr;
final String streetName;
final ManeuverType maneuver;
final double distanceMeters;
final LatLng location;
const NavigationStep({
required this.instructionAr,
required this.streetName,
required this.maneuver,
required this.distanceMeters,
required this.location,
});
IconData get icon {
switch (maneuver) {
case ManeuverType.arrive:
return Icons.flag_circle_rounded;
case ManeuverType.roundabout:
return Icons.roundabout_right_rounded;
case ManeuverType.right:
case ManeuverType.keepRight:
return Icons.turn_right_rounded;
case ManeuverType.slightRight:
return Icons.turn_slight_right_rounded;
case ManeuverType.left:
case ManeuverType.keepLeft:
return Icons.turn_left_rounded;
case ManeuverType.slightLeft:
return Icons.turn_slight_left_rounded;
case ManeuverType.sharpRight:
return Icons.turn_sharp_right_rounded;
case ManeuverType.sharpLeft:
return Icons.turn_sharp_left_rounded;
case ManeuverType.uTurn:
return Icons.u_turn_right_rounded;
case ManeuverType.straight:
default:
return Icons.straight_rounded;
}
}
}
class ActiveNavigationState {
final bool isNavigating;
final List<LatLng> routePoints;
final List<NavigationStep> steps;
final int currentStepIndex;
final double remainingDistanceKm;
final double remainingDurationMinutes;
final double currentSpeedKmH;
final double currentHeadingDeg;
final LatLng? currentPosition;
final bool isSimulating;
const ActiveNavigationState({
this.isNavigating = false,
this.routePoints = const [],
this.steps = const [],
this.currentStepIndex = 0,
this.remainingDistanceKm = 0.0,
this.remainingDurationMinutes = 0.0,
this.currentSpeedKmH = 0.0,
this.currentHeadingDeg = 0.0,
this.currentPosition,
this.isSimulating = false,
});
NavigationStep? get currentStep =>
(steps.isNotEmpty && currentStepIndex < steps.length) ? steps[currentStepIndex] : null;
NavigationStep? get nextStep =>
(steps.isNotEmpty && currentStepIndex + 1 < steps.length) ? steps[currentStepIndex + 1] : null;
}