import 'package:flutter/material.dart'; import 'package:flutter_osm_plugin/flutter_osm_plugin.dart'; class DeviceFlowMap extends StatefulWidget { const DeviceFlowMap( {super.key, required this.title, required this.deviceName, required this.deviceAddress}); final String title; final String deviceName; final String deviceAddress; @override State createState() => _DeviceFlowMapState(); } class _DeviceFlowMapState extends State { TextEditingController tecTakingPoint = TextEditingController(); MapController mapController = MapController( initPosition: GeoPoint(latitude: 47.4358055, longitude: 8.4737324), ); @override void initState() { tecTakingPoint.text = '5'; } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.deviceName, style: const TextStyle(color: Colors.white)), backgroundColor: Colors.blue, leading: IconButton( icon: const Icon(Icons.arrow_back, color: Colors.white), onPressed: () { mapController.dispose(); Navigator.pop(context); }, ), actions: [ IconButton( icon: Icon(Icons.settings, color: Colors.white), onPressed: () { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: const Text('Paramètres'), content: Column( children: [ const Text('Temps de prise de point (en secondes)'), TextField( controller: tecTakingPoint, keyboardType: TextInputType.number, ), ], ), actions: [ TextButton( onPressed: () { Navigator.of(context).pop(); }, child: const Text('Annuler'), ), TextButton( onPressed: () { Navigator.of(context).pop(); ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text('Paramètres enregistrés'), ), ); }, child: const Text('Enregistrer'), ), ], ); }, ); }) ], ), body: OSMFlutter( controller: mapController, osmOption: OSMOption( userTrackingOption: UserTrackingOption( enableTracking: true, unFollowUser: false, ), zoomOption: ZoomOption( initZoom: 14, minZoomLevel: 3, maxZoomLevel: 19, stepZoom: 1.0, ), userLocationMarker: UserLocationMaker( personMarker: MarkerIcon( icon: Icon( Icons.location_history_rounded, color: Colors.red, size: 48, ), ), directionArrowMarker: MarkerIcon( icon: Icon( Icons.double_arrow, size: 48, ), ), ), )), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButton: Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ FloatingActionButton( heroTag: 'mapFab', backgroundColor: Colors.blue, onPressed: () {}, child: Icon(Icons.map_outlined, color: Colors.white), ), FloatingActionButton( heroTag: 'mapFab2', backgroundColor: Colors.blue, onPressed: () { //Alert for ask to delete piont ?= showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: const Text('Réinitialiser les points'), content: const Text('Voulez-vous supprimer tous les points ?'), actions: [ TextButton( onPressed: () { Navigator.of(context).pop(); }, child: const Text('Annuler'), ), TextButton( onPressed: () { Navigator.of(context).pop(); ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text('Tous les points ont été supprimés'), ), ); }, child: const Text('Oui'), ), ], ); }, ); }, child: const Icon(Icons.delete_sharp, color: Colors.white), ) ]), ); } }