mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-09-30 13:09:35 +02:00
Enable avoidance distance settings
This commit is contained in:
1 parent
9782352909
commit
0ec53c3a11
5 files changed
+57
-46
No files matched your search
@@ -122,6 +122,7 @@ class AppState extends ChangeNotifier {
|
|||||||
// Navigation search state
|
// Navigation search state
|
||||||
bool get isNavigationSearchLoading => _navigationState.isSearchLoading;
|
bool get isNavigationSearchLoading => _navigationState.isSearchLoading;
|
||||||
List<SearchResult> get navigationSearchResults => _navigationState.searchResults;
|
List<SearchResult> get navigationSearchResults => _navigationState.searchResults;
|
||||||
|
int get navigationAvoidanceDistance => _settingsState.navigationAvoidanceDistance;
|
||||||
|
|
||||||
// Profile state
|
// Profile state
|
||||||
List<NodeProfile> get profiles => _profileState.profiles;
|
List<NodeProfile> get profiles => _profileState.profiles;
|
||||||
@@ -645,6 +646,11 @@ class AppState extends ChangeNotifier {
|
|||||||
await _settingsState.setSuspectedLocationMinDistance(distance);
|
await _settingsState.setSuspectedLocationMinDistance(distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set navigation avoidance distance
|
||||||
|
Future<void> setNavigationAvoidanceDistance(int distance) async {
|
||||||
|
await _settingsState.setNavigationAvoidanceDistance(distance);
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- Queue Methods ----------
|
// ---------- Queue Methods ----------
|
||||||
void clearQueue() {
|
void clearQueue() {
|
||||||
_uploadQueueState.clearQueue();
|
_uploadQueueState.clearQueue();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class NavigationSettingsScreen extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final appState = context.watch<AppState>();
|
||||||
final locService = LocalizationService.instance;
|
final locService = LocalizationService.instance;
|
||||||
|
|
||||||
return AnimatedBuilder(
|
return AnimatedBuilder(
|
||||||
@@ -26,48 +27,28 @@ class NavigationSettingsScreen extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// Coming soon message
|
ListTile(
|
||||||
Card(
|
leading: const Icon(Icons.social_distance),
|
||||||
child: Padding(
|
title: Text(locService.t('navigation.avoidanceDistance')),
|
||||||
padding: const EdgeInsets.all(16),
|
subtitle: Text(locService.t('navigation.avoidanceDistanceSubtitle')),
|
||||||
child: Column(
|
trailing: SizedBox(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
width: 80,
|
||||||
children: [
|
child: TextFormField(
|
||||||
Row(
|
initialValue: appState.navigationAvoidanceDistance.toString(),
|
||||||
children: [
|
keyboardType: const TextInputType.numberWithOptions(signed: false, decimal: false),
|
||||||
Icon(Icons.info_outline, color: Colors.blue),
|
textInputAction: TextInputAction.done,
|
||||||
const SizedBox(width: 8),
|
decoration: const InputDecoration(
|
||||||
Text(
|
isDense: true,
|
||||||
'Navigation Features',
|
contentPadding: EdgeInsets.symmetric(vertical: 6, horizontal: 8),
|
||||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
border: OutlineInputBorder(),
|
||||||
fontWeight: FontWeight.bold,
|
suffixText: 'm',
|
||||||
),
|
),
|
||||||
),
|
onFieldSubmitted: (value) {
|
||||||
],
|
final distance = int.tryParse(value) ?? 250;
|
||||||
),
|
appState.setNavigationAvoidanceDistance(distance.clamp(0, 2000));
|
||||||
const SizedBox(height: 8),
|
}
|
||||||
Text(
|
)
|
||||||
'Navigation and routing settings will be available here. Coming soon:\n\n'
|
)
|
||||||
'• Surveillance avoidance distance\n'
|
|
||||||
'• Route planning preferences\n'
|
|
||||||
'• Search history management\n'
|
|
||||||
'• Distance units (metric/imperial)',
|
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
|
|
||||||
// Placeholder settings (disabled for now)
|
|
||||||
_buildDisabledSetting(
|
|
||||||
context,
|
|
||||||
icon: Icons.warning_outlined,
|
|
||||||
title: locService.t('navigation.avoidanceDistance'),
|
|
||||||
subtitle: locService.t('navigation.avoidanceDistanceSubtitle'),
|
|
||||||
value: '100 ${locService.t('navigation.meters')}',
|
|
||||||
),
|
),
|
||||||
|
|
||||||
const Divider(),
|
const Divider(),
|
||||||
@@ -126,4 +107,4 @@ class NavigationSettingsScreen extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ import 'dart:convert';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:latlong2/latlong.dart';
|
import 'package:latlong2/latlong.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class RouteResult {
|
class RouteResult {
|
||||||
final List<LatLng> waypoints;
|
final List<LatLng> waypoints;
|
||||||
@@ -31,6 +32,9 @@ class RoutingService {
|
|||||||
required LatLng end,
|
required LatLng end,
|
||||||
}) async {
|
}) async {
|
||||||
debugPrint('[RoutingService] Calculating route from $start to $end');
|
debugPrint('[RoutingService] Calculating route from $start to $end');
|
||||||
|
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final avoidance_distance = await prefs.getInt('navigation_avoidance_distance');
|
||||||
|
|
||||||
final uri = Uri.parse('$_baseUrl');
|
final uri = Uri.parse('$_baseUrl');
|
||||||
final params = {
|
final params = {
|
||||||
@@ -42,6 +46,7 @@ class RoutingService {
|
|||||||
'longitude': end.longitude,
|
'longitude': end.longitude,
|
||||||
'latitude': end.latitude
|
'latitude': end.latitude
|
||||||
},
|
},
|
||||||
|
'avoidance_distance': avoidance_distance,
|
||||||
'enabled_profiles': [ // revise to be dynamic based on user input
|
'enabled_profiles': [ // revise to be dynamic based on user input
|
||||||
{
|
{
|
||||||
'id': 'generic-ALPR',
|
'id': 'generic-ALPR',
|
||||||
@@ -50,7 +55,8 @@ class RoutingService {
|
|||||||
'surveillance:type': 'ALPR'
|
'surveillance:type': 'ALPR'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
'show_exclusion_zone': false, // if true, returns a GeoJSON Feature MultiPolygon showing what areas are avoided in calculating the route
|
||||||
};
|
};
|
||||||
|
|
||||||
debugPrint('[RoutingService] alprwatch request: $uri $params');
|
debugPrint('[RoutingService] alprwatch request: $uri $params');
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ class NavigationState extends ChangeNotifier {
|
|||||||
/// Calculate route using alprwatch
|
/// Calculate route using alprwatch
|
||||||
void _calculateRoute() {
|
void _calculateRoute() {
|
||||||
if (_routeStart == null || _routeEnd == null) return;
|
if (_routeStart == null || _routeEnd == null) return;
|
||||||
|
|
||||||
debugPrint('[NavigationState] Calculating route with alprwatch...');
|
debugPrint('[NavigationState] Calculating route with alprwatch...');
|
||||||
_isCalculating = true;
|
_isCalculating = true;
|
||||||
_routingError = null;
|
_routingError = null;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class SettingsState extends ChangeNotifier {
|
|||||||
static const String _networkStatusIndicatorEnabledPrefsKey = 'network_status_indicator_enabled';
|
static const String _networkStatusIndicatorEnabledPrefsKey = 'network_status_indicator_enabled';
|
||||||
static const String _suspectedLocationMinDistancePrefsKey = 'suspected_location_min_distance';
|
static const String _suspectedLocationMinDistancePrefsKey = 'suspected_location_min_distance';
|
||||||
static const String _pauseQueueProcessingPrefsKey = 'pause_queue_processing';
|
static const String _pauseQueueProcessingPrefsKey = 'pause_queue_processing';
|
||||||
|
static const String _navigationAvoidanceDistancePrefsKey = 'navigation_avoidance_distance';
|
||||||
|
|
||||||
bool _offlineMode = false;
|
bool _offlineMode = false;
|
||||||
bool _pauseQueueProcessing = false;
|
bool _pauseQueueProcessing = false;
|
||||||
@@ -41,6 +42,7 @@ class SettingsState extends ChangeNotifier {
|
|||||||
int _suspectedLocationMinDistance = 100; // meters
|
int _suspectedLocationMinDistance = 100; // meters
|
||||||
List<TileProvider> _tileProviders = [];
|
List<TileProvider> _tileProviders = [];
|
||||||
String _selectedTileTypeId = '';
|
String _selectedTileTypeId = '';
|
||||||
|
int _navigationAvoidanceDistance = 250; // meters
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
bool get offlineMode => _offlineMode;
|
bool get offlineMode => _offlineMode;
|
||||||
@@ -54,6 +56,7 @@ class SettingsState extends ChangeNotifier {
|
|||||||
int get suspectedLocationMinDistance => _suspectedLocationMinDistance;
|
int get suspectedLocationMinDistance => _suspectedLocationMinDistance;
|
||||||
List<TileProvider> get tileProviders => List.unmodifiable(_tileProviders);
|
List<TileProvider> get tileProviders => List.unmodifiable(_tileProviders);
|
||||||
String get selectedTileTypeId => _selectedTileTypeId;
|
String get selectedTileTypeId => _selectedTileTypeId;
|
||||||
|
int get navigationAvoidanceDistance => _navigationAvoidanceDistance;
|
||||||
|
|
||||||
/// Get the currently selected tile type
|
/// Get the currently selected tile type
|
||||||
TileType? get selectedTileType {
|
TileType? get selectedTileType {
|
||||||
@@ -100,6 +103,11 @@ class SettingsState extends ChangeNotifier {
|
|||||||
|
|
||||||
// Load max nodes
|
// Load max nodes
|
||||||
_maxNodes = prefs.getInt(_maxNodesPrefsKey) ?? kDefaultMaxNodes;
|
_maxNodes = prefs.getInt(_maxNodesPrefsKey) ?? kDefaultMaxNodes;
|
||||||
|
|
||||||
|
// Load navigation avoidance distance
|
||||||
|
if (prefs.containsKey(_navigationAvoidanceDistancePrefsKey)) {
|
||||||
|
_navigationAvoidanceDistance = prefs.getInt(_navigationAvoidanceDistancePrefsKey) ?? 250;
|
||||||
|
}
|
||||||
|
|
||||||
// Load proximity alerts settings
|
// Load proximity alerts settings
|
||||||
_proximityAlertsEnabled = prefs.getBool(_proximityAlertsEnabledPrefsKey) ?? false;
|
_proximityAlertsEnabled = prefs.getBool(_proximityAlertsEnabledPrefsKey) ?? false;
|
||||||
@@ -351,4 +359,14 @@ class SettingsState extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
// Set distance for avoidance of nodes during navigation
|
||||||
|
Future<void> setNavigationAvoidanceDistance(int distance) async {
|
||||||
|
if (_navigationAvoidanceDistance != distance) {
|
||||||
|
_navigationAvoidanceDistance = distance;
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.setInt(_navigationAvoidanceDistancePrefsKey, distance);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in new issue
Block a user