mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 08:20:36 +00:00
@@ -39,6 +39,7 @@ class MapProvider with ChangeNotifier {
|
|||||||
|
|
||||||
LocationTrail? _currentTrail;
|
LocationTrail? _currentTrail;
|
||||||
bool _isTrailVisible = true;
|
bool _isTrailVisible = true;
|
||||||
|
bool _isTrailRecordingEnabled = true;
|
||||||
final List<LocationTrail> _trailHistory = [];
|
final List<LocationTrail> _trailHistory = [];
|
||||||
|
|
||||||
bool _showCadastralOverlay = false;
|
bool _showCadastralOverlay = false;
|
||||||
@@ -71,6 +72,7 @@ class MapProvider with ChangeNotifier {
|
|||||||
String? get targetMapId => _targetMapId;
|
String? get targetMapId => _targetMapId;
|
||||||
LocationTrail? get currentTrail => _currentTrail;
|
LocationTrail? get currentTrail => _currentTrail;
|
||||||
bool get isTrailVisible => _isTrailVisible;
|
bool get isTrailVisible => _isTrailVisible;
|
||||||
|
bool get isTrailRecordingEnabled => _isTrailRecordingEnabled;
|
||||||
List<LocationTrail> get trailHistory => List.unmodifiable(_trailHistory);
|
List<LocationTrail> get trailHistory => List.unmodifiable(_trailHistory);
|
||||||
bool get isTrailActive => _currentTrail?.isActive ?? false;
|
bool get isTrailActive => _currentTrail?.isActive ?? false;
|
||||||
|
|
||||||
@@ -373,6 +375,10 @@ class MapProvider with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addTrailPoint(LatLng position, {double? accuracy, double? speed}) {
|
void addTrailPoint(LatLng position, {double? accuracy, double? speed}) {
|
||||||
|
if (!_isTrailRecordingEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_currentTrail == null || !_currentTrail!.isActive) {
|
if (_currentTrail == null || !_currentTrail!.isActive) {
|
||||||
startTrail();
|
startTrail();
|
||||||
}
|
}
|
||||||
@@ -405,6 +411,24 @@ class MapProvider with ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setTrailRecordingEnabled(bool enabled) {
|
||||||
|
if (_isTrailRecordingEnabled == enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_isTrailRecordingEnabled = enabled;
|
||||||
|
if (!enabled) {
|
||||||
|
if (_currentTrail != null) {
|
||||||
|
endTrail();
|
||||||
|
} else {
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
void clearCurrentTrail() {
|
void clearCurrentTrail() {
|
||||||
if (_currentTrail != null) {
|
if (_currentTrail != null) {
|
||||||
_currentTrail = null;
|
_currentTrail = null;
|
||||||
@@ -698,6 +722,7 @@ class MapProvider with ChangeNotifier {
|
|||||||
'trailHistory': _trailHistory.map((trail) => trail.toJson()).toList(),
|
'trailHistory': _trailHistory.map((trail) => trail.toJson()).toList(),
|
||||||
'importedTrail': _importedTrail?.toJson(),
|
'importedTrail': _importedTrail?.toJson(),
|
||||||
'isTrailVisible': _isTrailVisible,
|
'isTrailVisible': _isTrailVisible,
|
||||||
|
'isTrailRecordingEnabled': _isTrailRecordingEnabled,
|
||||||
'showCadastralOverlay': _showCadastralOverlay,
|
'showCadastralOverlay': _showCadastralOverlay,
|
||||||
'showForestRoadsOverlay': _showForestRoadsOverlay,
|
'showForestRoadsOverlay': _showForestRoadsOverlay,
|
||||||
'showHikingTrailsOverlay': _showHikingTrailsOverlay,
|
'showHikingTrailsOverlay': _showHikingTrailsOverlay,
|
||||||
@@ -728,6 +753,8 @@ class MapProvider with ChangeNotifier {
|
|||||||
? LocationTrail.fromJson(json['importedTrail'] as Map<String, dynamic>)
|
? LocationTrail.fromJson(json['importedTrail'] as Map<String, dynamic>)
|
||||||
: null;
|
: null;
|
||||||
_isTrailVisible = json['isTrailVisible'] as bool? ?? true;
|
_isTrailVisible = json['isTrailVisible'] as bool? ?? true;
|
||||||
|
_isTrailRecordingEnabled =
|
||||||
|
json['isTrailRecordingEnabled'] as bool? ?? true;
|
||||||
_showCadastralOverlay = json['showCadastralOverlay'] as bool? ?? false;
|
_showCadastralOverlay = json['showCadastralOverlay'] as bool? ?? false;
|
||||||
_showForestRoadsOverlay = json['showForestRoadsOverlay'] as bool? ?? false;
|
_showForestRoadsOverlay = json['showForestRoadsOverlay'] as bool? ?? false;
|
||||||
_showHikingTrailsOverlay =
|
_showHikingTrailsOverlay =
|
||||||
|
|||||||
@@ -39,14 +39,33 @@ class TrailControls extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
|
// Trail recording toggle
|
||||||
|
SwitchListTile(
|
||||||
|
secondary: Icon(Icons.fiber_manual_record),
|
||||||
|
title: Text('Record location trail'),
|
||||||
|
subtitle: Text(
|
||||||
|
mapProvider.isTrailRecordingEnabled
|
||||||
|
? 'Trail recording is on'
|
||||||
|
: 'Trail recording is stopped',
|
||||||
|
),
|
||||||
|
value: mapProvider.isTrailRecordingEnabled,
|
||||||
|
onChanged: (value) {
|
||||||
|
mapProvider.setTrailRecordingEnabled(value);
|
||||||
|
setModalState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Divider(),
|
||||||
|
|
||||||
// Trail visibility toggle
|
// Trail visibility toggle
|
||||||
SwitchListTile(
|
SwitchListTile(
|
||||||
secondary: Icon(Icons.visibility),
|
secondary: Icon(Icons.visibility),
|
||||||
title: Text(l10n.showTrailOnMap),
|
title: Text(l10n.showTrailOnMap),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
mapProvider.isTrailVisible
|
!mapProvider.isTrailRecordingEnabled
|
||||||
? l10n.trailVisible
|
? 'Trail recording is stopped'
|
||||||
: l10n.trailHiddenRecording,
|
: (mapProvider.isTrailVisible
|
||||||
|
? l10n.trailVisible
|
||||||
|
: l10n.trailHiddenRecording),
|
||||||
),
|
),
|
||||||
value: mapProvider.isTrailVisible,
|
value: mapProvider.isTrailVisible,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user