nice
This commit is contained in:
@@ -8,25 +8,29 @@ import 'package:bus_infotainment/backend/modules/info_module.dart';
|
||||
import 'package:bus_infotainment/tfl_datasets.dart';
|
||||
import 'package:bus_infotainment/utils/OrdinanceSurveyUtils.dart';
|
||||
import 'package:bus_infotainment/utils/audio%20wrapper.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:vector_math/vector_math.dart';
|
||||
|
||||
class TrackerModule extends InfoModule {
|
||||
|
||||
|
||||
// Constructor
|
||||
TrackerModule() {
|
||||
locationStream();
|
||||
Geolocator.getLastKnownPosition().then((Position? position) {
|
||||
this._position = position;
|
||||
updateNearestStop();
|
||||
});
|
||||
if (!kIsWeb)
|
||||
{
|
||||
Geolocator.getLastKnownPosition().then((Position? position) {
|
||||
this._position = position;
|
||||
updateNearestStop();
|
||||
});
|
||||
}
|
||||
liveInformation.routeVariantDelegate.addListener((routeVariant) {
|
||||
print("Route variant changed");
|
||||
updateNearestStop();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Location Tracker - will update the recorded location when the user moves.
|
||||
Position? _position;
|
||||
Position? get position => _position;
|
||||
|
||||
@@ -45,6 +49,7 @@ class TrackerModule extends InfoModule {
|
||||
updateNearestStop();
|
||||
});
|
||||
|
||||
// Location Refresher - will update the recorded location periodically.
|
||||
Timer refreshTimer() => Timer.periodic(Duration(seconds: 1), (timer) async {
|
||||
_position = await Geolocator.getCurrentPosition();
|
||||
});
|
||||
@@ -52,6 +57,7 @@ class TrackerModule extends InfoModule {
|
||||
BusRouteStop? nearestStop;
|
||||
bool hasArrived = false;
|
||||
|
||||
|
||||
Future<void> updateNearestStop() async {
|
||||
if (liveInformation.getRouteVariant() == null) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user