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