mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-08-12 14:10:18 +02:00
Navigation settings
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:provider/provider.dart';
|
||||
|
||||
import '../../app_state.dart';
|
||||
import '../../dev_config.dart';
|
||||
import '../../services/localization_service.dart';
|
||||
import '../camera_icon.dart';
|
||||
import 'layer_selector_button.dart';
|
||||
|
||||
@@ -126,7 +127,9 @@ class MapOverlays extends StatelessWidget {
|
||||
mini: true,
|
||||
heroTag: "search_nav",
|
||||
onPressed: onSearchPressed,
|
||||
tooltip: appState.showRouteButton ? 'Route Overview' : 'Search Location',
|
||||
tooltip: appState.showRouteButton
|
||||
? LocalizationService.instance.t('navigation.routeOverview')
|
||||
: LocalizationService.instance.t('navigation.searchLocation'),
|
||||
child: Icon(appState.showRouteButton ? Icons.route : Icons.search),
|
||||
),
|
||||
if (onSearchPressed != null && (appState.showSearchButton || appState.showRouteButton))
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
import '../app_state.dart';
|
||||
import '../services/localization_service.dart';
|
||||
|
||||
class NavigationSheet extends StatelessWidget {
|
||||
final VoidCallback? onStartRoute;
|
||||
@@ -94,32 +95,32 @@ class NavigationSheet extends StatelessWidget {
|
||||
// SEARCH MODE: Initial location with route options
|
||||
if (navigationMode == AppNavigationMode.search && !appState.isSettingSecondPoint && !appState.isCalculating && !appState.showingOverview && provisionalLocation != null) ...[
|
||||
_buildLocationInfo(
|
||||
label: 'Location',
|
||||
label: LocalizationService.instance.t('navigation.location'),
|
||||
coordinates: provisionalLocation,
|
||||
address: provisionalAddress,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.directions),
|
||||
label: const Text('Route To'),
|
||||
onPressed: () {
|
||||
appState.startRoutePlanning(thisLocationIsStart: false);
|
||||
},
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.directions),
|
||||
label: Text(LocalizationService.instance.t('navigation.routeTo')),
|
||||
onPressed: () {
|
||||
appState.startRoutePlanning(thisLocationIsStart: false);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.my_location),
|
||||
label: const Text('Route From'),
|
||||
onPressed: () {
|
||||
appState.startRoutePlanning(thisLocationIsStart: true);
|
||||
},
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.my_location),
|
||||
label: Text(LocalizationService.instance.t('navigation.routeFrom')),
|
||||
onPressed: () {
|
||||
appState.startRoutePlanning(thisLocationIsStart: true);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -129,7 +130,7 @@ class NavigationSheet extends StatelessWidget {
|
||||
// Show existing route points
|
||||
if (appState.routeStart != null) ...[
|
||||
_buildLocationInfo(
|
||||
label: 'Start',
|
||||
label: LocalizationService.instance.t('navigation.startPoint'),
|
||||
coordinates: appState.routeStart!,
|
||||
address: appState.routeStartAddress,
|
||||
),
|
||||
@@ -137,7 +138,7 @@ class NavigationSheet extends StatelessWidget {
|
||||
],
|
||||
if (appState.routeEnd != null) ...[
|
||||
_buildLocationInfo(
|
||||
label: 'End',
|
||||
label: LocalizationService.instance.t('navigation.endPoint'),
|
||||
coordinates: appState.routeEnd!,
|
||||
address: appState.routeEndAddress,
|
||||
),
|
||||
@@ -146,7 +147,9 @@ class NavigationSheet extends StatelessWidget {
|
||||
|
||||
// Show the point we're selecting
|
||||
_buildLocationInfo(
|
||||
label: appState.settingRouteStart ? 'Start (select)' : 'End (select)',
|
||||
label: appState.settingRouteStart
|
||||
? LocalizationService.instance.t('navigation.startSelect')
|
||||
: LocalizationService.instance.t('navigation.endSelect'),
|
||||
coordinates: provisionalLocation,
|
||||
address: provisionalAddress,
|
||||
),
|
||||
@@ -154,7 +157,7 @@ class NavigationSheet extends StatelessWidget {
|
||||
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.check),
|
||||
label: const Text('Select Location'),
|
||||
label: Text(LocalizationService.instance.t('navigation.selectLocation')),
|
||||
onPressed: () {
|
||||
debugPrint('[NavigationSheet] Select Location button pressed');
|
||||
appState.selectSecondRoutePoint();
|
||||
@@ -172,11 +175,14 @@ class NavigationSheet extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text('Calculating route...', textAlign: TextAlign.center),
|
||||
Text(
|
||||
LocalizationService.instance.t('navigation.calculatingRoute'),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () => appState.cancelNavigation(),
|
||||
child: const Text('Cancel'),
|
||||
child: Text(LocalizationService.instance.t('actions.cancel')),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -189,7 +195,7 @@ class NavigationSheet extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Route calculation failed',
|
||||
LocalizationService.instance.t('navigation.routeCalculationFailed'),
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
@@ -205,7 +211,7 @@ class NavigationSheet extends StatelessWidget {
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: const Text('Retry'),
|
||||
label: Text(LocalizationService.instance.t('navigation.retry')),
|
||||
onPressed: () {
|
||||
// Retry route calculation
|
||||
appState.retryRouteCalculation();
|
||||
@@ -216,7 +222,7 @@ class NavigationSheet extends StatelessWidget {
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.close),
|
||||
label: const Text('Cancel'),
|
||||
label: Text(LocalizationService.instance.t('actions.cancel')),
|
||||
onPressed: () => appState.cancelNavigation(),
|
||||
),
|
||||
),
|
||||
@@ -228,7 +234,7 @@ class NavigationSheet extends StatelessWidget {
|
||||
if (appState.showingOverview) ...[
|
||||
if (appState.routeStart != null) ...[
|
||||
_buildLocationInfo(
|
||||
label: 'Start',
|
||||
label: LocalizationService.instance.t('navigation.startPoint'),
|
||||
coordinates: appState.routeStart!,
|
||||
address: appState.routeStartAddress,
|
||||
),
|
||||
@@ -236,7 +242,7 @@ class NavigationSheet extends StatelessWidget {
|
||||
],
|
||||
if (appState.routeEnd != null) ...[
|
||||
_buildLocationInfo(
|
||||
label: 'End',
|
||||
label: LocalizationService.instance.t('navigation.endPoint'),
|
||||
coordinates: appState.routeEnd!,
|
||||
address: appState.routeEndAddress,
|
||||
),
|
||||
@@ -244,7 +250,7 @@ class NavigationSheet extends StatelessWidget {
|
||||
],
|
||||
if (appState.routeDistance != null) ...[
|
||||
Text(
|
||||
'Distance: ${(appState.routeDistance! / 1000).toStringAsFixed(1)} km',
|
||||
LocalizationService.instance.t('navigation.distance', params: [(appState.routeDistance! / 1000).toStringAsFixed(1)]),
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
@@ -257,7 +263,7 @@ class NavigationSheet extends StatelessWidget {
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.play_arrow),
|
||||
label: const Text('Start'),
|
||||
label: Text(LocalizationService.instance.t('navigation.start')),
|
||||
onPressed: onStartRoute ?? () => appState.startRoute(),
|
||||
),
|
||||
),
|
||||
@@ -265,7 +271,7 @@ class NavigationSheet extends StatelessWidget {
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.close),
|
||||
label: const Text('Cancel'),
|
||||
label: Text(LocalizationService.instance.t('actions.cancel')),
|
||||
onPressed: () => appState.cancelNavigation(),
|
||||
),
|
||||
),
|
||||
@@ -274,7 +280,7 @@ class NavigationSheet extends StatelessWidget {
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.play_arrow),
|
||||
label: const Text('Resume'),
|
||||
label: Text(LocalizationService.instance.t('navigation.resume')),
|
||||
onPressed: onResumeRoute ?? () => appState.hideRouteOverview(),
|
||||
),
|
||||
),
|
||||
@@ -282,7 +288,7 @@ class NavigationSheet extends StatelessWidget {
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
icon: const Icon(Icons.close),
|
||||
label: const Text('End Route'),
|
||||
label: Text(LocalizationService.instance.t('navigation.endRoute')),
|
||||
onPressed: () => appState.cancelRoute(),
|
||||
),
|
||||
),
|
||||
|
||||
+12
-11
@@ -3,6 +3,7 @@ import 'package:provider/provider.dart';
|
||||
|
||||
import '../app_state.dart';
|
||||
import '../models/search_result.dart';
|
||||
import '../services/localization_service.dart';
|
||||
import '../widgets/debouncer.dart';
|
||||
|
||||
class LocationSearchBar extends StatefulWidget {
|
||||
@@ -115,24 +116,24 @@ class _LocationSearchBarState extends State<LocationSearchBar> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (isLoading)
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
Text('Searching...'),
|
||||
const SizedBox(width: 12),
|
||||
Text(LocalizationService.instance.t('navigation.searching')),
|
||||
],
|
||||
),
|
||||
)
|
||||
else if (results.isEmpty && _controller.text.isNotEmpty)
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Text('No results found'),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(LocalizationService.instance.t('navigation.noResultsFound')),
|
||||
)
|
||||
else
|
||||
...results.map((result) => ListTile(
|
||||
@@ -179,14 +180,14 @@ class _LocationSearchBarState extends State<LocationSearchBar> {
|
||||
controller: _controller,
|
||||
focusNode: _focusNode,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Search places or coordinates...',
|
||||
hintText: LocalizationService.instance.t('navigation.searchPlaceholder'),
|
||||
prefixIcon: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: _onCancel,
|
||||
tooltip: 'Cancel search',
|
||||
tooltip: LocalizationService.instance.t('navigation.cancelSearch'),
|
||||
),
|
||||
const Icon(Icons.search),
|
||||
],
|
||||
@@ -196,7 +197,7 @@ class _LocationSearchBarState extends State<LocationSearchBar> {
|
||||
? IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
onPressed: _onClear,
|
||||
tooltip: 'Clear text',
|
||||
tooltip: LocalizationService.instance.t('actions.clear'),
|
||||
)
|
||||
: null,
|
||||
border: OutlineInputBorder(
|
||||
|
||||
Reference in New Issue
Block a user