Set my location by long-pressing the path maps
Move the map's confirm-and-set-location flow into a shared helper and call it on long-press and right-click in the path trace and channel message path maps, so the self position can be set while viewing a path.
This commit is contained in:
1 parent
c296597a2d
commit
00756ef05e
4 files changed
+99
-67
No files matched your search
@@ -22,6 +22,7 @@ import 'package:meshcore_open/helpers/snack_bar_builder.dart';
|
||||
import 'package:meshcore_open/widgets/path_map_scaffold.dart';
|
||||
import 'package:meshcore_open/widgets/path_map_ui.dart';
|
||||
import 'package:meshcore_open/widgets/snr_indicator.dart';
|
||||
import 'package:meshcore_open/widgets/set_my_location_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
|
||||
@@ -239,6 +240,16 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _setMyLocation(LatLng point) async {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final ok = await confirmAndSetMyLocation(context, connector, point);
|
||||
if (!ok || !mounted || !_hasData) return;
|
||||
// Display paths start at the self position, so redraw them from it.
|
||||
setState(() {
|
||||
_rebuildDisplayPaths(connector);
|
||||
});
|
||||
}
|
||||
|
||||
/// Keeps the camera centered on the packet while the follow lock is on.
|
||||
void _followPacketCamera() {
|
||||
if (!mounted) return;
|
||||
@@ -1497,6 +1508,8 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
|
||||
initialCenter: _initialCenter!,
|
||||
initialZoom: _initialZoom,
|
||||
bounds: _bounds,
|
||||
onLongPress: (_, point) => _setMyLocation(point),
|
||||
onSecondaryTap: (_, point) => _setMyLocation(point),
|
||||
onPositionChanged: (camera, hasGesture) {
|
||||
if (!mounted) return;
|
||||
// A manual pan/zoom releases the follow lock.
|
||||
|
||||
Reference in new issue
Block a user