highlight selected node

This commit is contained in:
stopflock
2025-10-01 13:36:51 -05:00
parent 1aeae18ebc
commit 792f94065d
3 changed files with 34 additions and 11 deletions

View File

@@ -37,6 +37,9 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
// Flag to prevent map bounce when transitioning from tag sheet to edit sheet
bool _transitioningToEdit = false;
// Track selected node for highlighting
int? _selectedNodeId;
@override
void initState() {
@@ -139,6 +142,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
if (height > 0 && _transitioningToEdit) {
_transitioningToEdit = false;
_tagSheetHeight = 0.0; // Now safe to reset
_selectedNodeId = null; // Clear selection when moving to edit
}
});
},
@@ -157,6 +161,10 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
}
void openNodeTagSheet(OsmNode node) {
setState(() {
_selectedNodeId = node.id; // Track selected node for highlighting
});
final controller = _scaffoldKey.currentState!.showBottomSheet(
(ctx) => MeasuredSheet(
onHeightChanged: (height) {
@@ -175,11 +183,12 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
),
);
// Reset height when sheet is dismissed (unless transitioning to edit)
// Reset height and selection when sheet is dismissed (unless transitioning to edit)
controller.closed.then((_) {
if (!_transitioningToEdit) {
setState(() {
_tagSheetHeight = 0.0;
_selectedNodeId = null; // Clear selection
});
}
// If transitioning to edit, keep the height until edit sheet takes over
@@ -249,6 +258,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
controller: _mapController,
followMeMode: appState.followMeMode,
sheetHeight: activeSheetHeight,
selectedNodeId: _selectedNodeId,
onNodeTap: openNodeTagSheet,
onUserGesture: () {
if (appState.followMeMode != FollowMeMode.off) {

View File

@@ -95,22 +95,32 @@ class CameraMarkersBuilder {
required List<OsmNode> cameras,
required MapController mapController,
LatLng? userLocation,
int? selectedNodeId,
void Function(OsmNode)? onNodeTap,
}) {
final markers = <Marker>[
// Camera markers
...cameras
.where(_isValidCameraCoordinate)
.map((n) => Marker(
point: n.coord,
width: kCameraIconDiameter,
height: kCameraIconDiameter,
child: CameraMapMarker(
node: n,
mapController: mapController,
onNodeTap: onNodeTap,
),
)),
.map((n) {
// Check if this node should be highlighted (selected) or dimmed
final isSelected = selectedNodeId == n.id;
final shouldDim = selectedNodeId != null && !isSelected;
return Marker(
point: n.coord,
width: kCameraIconDiameter,
height: kCameraIconDiameter,
child: Opacity(
opacity: shouldDim ? 0.5 : 1.0,
child: CameraMapMarker(
node: n,
mapController: mapController,
onNodeTap: onNodeTap,
),
),
);
}),
// User location marker
if (userLocation != null)

View File

@@ -35,12 +35,14 @@ class MapView extends StatefulWidget {
required this.followMeMode,
required this.onUserGesture,
this.sheetHeight = 0.0,
this.selectedNodeId,
this.onNodeTap,
});
final FollowMeMode followMeMode;
final VoidCallback onUserGesture;
final double sheetHeight;
final int? selectedNodeId;
final void Function(OsmNode)? onNodeTap;
@override
@@ -330,6 +332,7 @@ class MapViewState extends State<MapView> {
cameras: cameras,
mapController: _controller.mapController,
userLocation: _gpsController.currentLocation,
selectedNodeId: widget.selectedNodeId,
onNodeTap: widget.onNodeTap,
);