mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-08-31 15:11:07 +02:00
UX actually close
This commit is contained in:
@@ -189,16 +189,22 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
|||||||
void _onNavigationButtonPressed() {
|
void _onNavigationButtonPressed() {
|
||||||
final appState = context.read<AppState>();
|
final appState = context.read<AppState>();
|
||||||
|
|
||||||
|
debugPrint('[HomeScreen] Navigation button pressed - hasActiveRoute: ${appState.hasActiveRoute}, navigationMode: ${appState.navigationMode}');
|
||||||
|
|
||||||
if (appState.hasActiveRoute) {
|
if (appState.hasActiveRoute) {
|
||||||
// Route button - view route overview
|
// Route button - view route overview
|
||||||
|
debugPrint('[HomeScreen] Viewing route overview');
|
||||||
appState.viewRouteOverview();
|
appState.viewRouteOverview();
|
||||||
} else {
|
} else {
|
||||||
// Search button - enter search mode
|
// Search button - enter search mode
|
||||||
|
debugPrint('[HomeScreen] Entering search mode');
|
||||||
try {
|
try {
|
||||||
final mapCenter = _mapController.mapController.camera.center;
|
final mapCenter = _mapController.mapController.camera.center;
|
||||||
|
debugPrint('[HomeScreen] Map center: $mapCenter');
|
||||||
appState.enterSearchMode(mapCenter);
|
appState.enterSearchMode(mapCenter);
|
||||||
} catch (_) {
|
} catch (e) {
|
||||||
// Controller not ready, use fallback location
|
// Controller not ready, use fallback location
|
||||||
|
debugPrint('[HomeScreen] Map controller not ready: $e, using fallback');
|
||||||
appState.enterSearchMode(LatLng(37.7749, -122.4194));
|
appState.enterSearchMode(LatLng(37.7749, -122.4194));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,12 @@ class NavigationState extends ChangeNotifier {
|
|||||||
|
|
||||||
/// Enter search mode with provisional pin at current map center
|
/// Enter search mode with provisional pin at current map center
|
||||||
void enterSearchMode(LatLng mapCenter) {
|
void enterSearchMode(LatLng mapCenter) {
|
||||||
if (_mode != AppNavigationMode.normal) return;
|
debugPrint('[NavigationState] enterSearchMode called - current mode: $_mode, mapCenter: $mapCenter');
|
||||||
|
|
||||||
|
if (_mode != AppNavigationMode.normal) {
|
||||||
|
debugPrint('[NavigationState] Cannot enter search mode - current mode is $_mode (not normal)');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_mode = AppNavigationMode.search;
|
_mode = AppNavigationMode.search;
|
||||||
_provisionalPinLocation = mapCenter;
|
_provisionalPinLocation = mapCenter;
|
||||||
@@ -103,6 +108,8 @@ class NavigationState extends ChangeNotifier {
|
|||||||
|
|
||||||
/// Cancel search mode and return to normal
|
/// Cancel search mode and return to normal
|
||||||
void cancelSearchMode() {
|
void cancelSearchMode() {
|
||||||
|
debugPrint('[NavigationState] cancelSearchMode called - mode: $_mode, isInSearch: $isInSearchMode, isInRoute: $isInRouteMode');
|
||||||
|
|
||||||
if (!isInSearchMode && _mode != AppNavigationMode.routeSetup) return;
|
if (!isInSearchMode && _mode != AppNavigationMode.routeSetup) return;
|
||||||
|
|
||||||
_mode = AppNavigationMode.normal;
|
_mode = AppNavigationMode.normal;
|
||||||
@@ -110,16 +117,16 @@ class NavigationState extends ChangeNotifier {
|
|||||||
_provisionalPinAddress = null;
|
_provisionalPinAddress = null;
|
||||||
_clearSearchResults();
|
_clearSearchResults();
|
||||||
|
|
||||||
// Also clear any partial route data
|
// Clear ALL route data when canceling
|
||||||
if (_routeStart != null && _routeEnd == null) {
|
_routeStart = null;
|
||||||
_routeStart = null;
|
_routeEnd = null;
|
||||||
_routeStartAddress = null;
|
_routeStartAddress = null;
|
||||||
} else if (_routeEnd != null && _routeStart == null) {
|
_routeEndAddress = null;
|
||||||
_routeEnd = null;
|
_routePath = null;
|
||||||
_routeEndAddress = null;
|
_routeDistance = null;
|
||||||
}
|
_settingRouteStart = true;
|
||||||
|
|
||||||
debugPrint('[NavigationState] Cancelled search mode - cleaned up provisional pin');
|
debugPrint('[NavigationState] Cancelled search mode - cleaned up all data');
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,17 +169,18 @@ class NavigationState extends ChangeNotifier {
|
|||||||
_routePath = null;
|
_routePath = null;
|
||||||
_routeDistance = null;
|
_routeDistance = null;
|
||||||
|
|
||||||
_settingRouteStart = settingStart;
|
|
||||||
if (settingStart) {
|
if (settingStart) {
|
||||||
// "Route From" - this location is the START, we need to pick END
|
// "Route From" - this location is the START, now we need to pick END
|
||||||
_routeStart = _provisionalPinLocation;
|
_routeStart = _provisionalPinLocation;
|
||||||
_routeStartAddress = _provisionalPinAddress;
|
_routeStartAddress = _provisionalPinAddress;
|
||||||
debugPrint('[NavigationState] Set route start: $_routeStart');
|
_settingRouteStart = false; // Next, we'll be setting the END
|
||||||
|
debugPrint('[NavigationState] Set route start: $_routeStart, next will set END');
|
||||||
} else {
|
} else {
|
||||||
// "Route To" - this location is the END, we need to pick START
|
// "Route To" - this location is the END, now we need to pick START
|
||||||
_routeEnd = _provisionalPinLocation;
|
_routeEnd = _provisionalPinLocation;
|
||||||
_routeEndAddress = _provisionalPinAddress;
|
_routeEndAddress = _provisionalPinAddress;
|
||||||
debugPrint('[NavigationState] Set route end: $_routeEnd');
|
_settingRouteStart = true; // Next, we'll be setting the START
|
||||||
|
debugPrint('[NavigationState] Set route end: $_routeEnd, next will set START');
|
||||||
}
|
}
|
||||||
|
|
||||||
_mode = AppNavigationMode.routeSetup;
|
_mode = AppNavigationMode.routeSetup;
|
||||||
|
|||||||
@@ -120,8 +120,8 @@ class MapOverlays extends StatelessWidget {
|
|||||||
builder: (context, appState, child) {
|
builder: (context, appState, child) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
// Search/Route button (top of controls)
|
// Search/Route button (top of controls) - hide when in search/route modes
|
||||||
if (onSearchPressed != null)
|
if (onSearchPressed != null && !appState.isInSearchMode && !appState.isInRouteMode)
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
mini: true,
|
mini: true,
|
||||||
heroTag: "search_nav",
|
heroTag: "search_nav",
|
||||||
@@ -129,7 +129,8 @@ class MapOverlays extends StatelessWidget {
|
|||||||
tooltip: appState.hasActiveRoute ? 'Route Overview' : 'Search Location',
|
tooltip: appState.hasActiveRoute ? 'Route Overview' : 'Search Location',
|
||||||
child: Icon(appState.hasActiveRoute ? Icons.route : Icons.search),
|
child: Icon(appState.hasActiveRoute ? Icons.route : Icons.search),
|
||||||
),
|
),
|
||||||
if (onSearchPressed != null) const SizedBox(height: 8),
|
if (onSearchPressed != null && !appState.isInSearchMode && !appState.isInRouteMode)
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
// Layer selector button
|
// Layer selector button
|
||||||
const LayerSelectorButton(),
|
const LayerSelectorButton(),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:latlong2/latlong.dart';
|
import 'package:latlong2/latlong.dart';
|
||||||
@@ -171,6 +172,7 @@ class NavigationSheet extends StatelessWidget {
|
|||||||
icon: const Icon(Icons.check),
|
icon: const Icon(Icons.check),
|
||||||
label: const Text('Select Location'),
|
label: const Text('Select Location'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
debugPrint('[NavigationSheet] Select Location button pressed');
|
||||||
appState.selectRouteLocation();
|
appState.selectRouteLocation();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user