diff --git a/Sources/dafl_project_flutter/lib/main.dart b/Sources/dafl_project_flutter/lib/main.dart index d73e7c5..3a08669 100644 --- a/Sources/dafl_project_flutter/lib/main.dart +++ b/Sources/dafl_project_flutter/lib/main.dart @@ -21,7 +21,7 @@ class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context){ - Location.getCurrentLocation(); + Location.sendCurrentLocation(); Location.getData(); SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky); return ChangeNotifierProvider( diff --git a/Sources/dafl_project_flutter/lib/position/location.dart b/Sources/dafl_project_flutter/lib/position/location.dart index 906f252..68016e5 100644 --- a/Sources/dafl_project_flutter/lib/position/location.dart +++ b/Sources/dafl_project_flutter/lib/position/location.dart @@ -1,10 +1,13 @@ import 'package:geolocator/geolocator.dart'; -import 'package:tuple/tuple.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; +import 'dart:developer'; class Location { - static Future> getCurrentLocation() async { + + + static Future sendCurrentLocation() async { + Uri uri = Uri.parse("http://82.216.56.128/phpmyadmin/dafldev/insert.php"); LocationPermission permission; permission = await Geolocator.checkPermission(); if (permission == LocationPermission.denied) { @@ -15,16 +18,18 @@ class Location { } } Position current = await Geolocator.getCurrentPosition(); - return Tuple2(current.longitude, current.latitude); + await http.post(uri, body: { + "id" : "5".toString(), + "latitude" : current.latitude.toString(), + "longitude" : current.longitude.toString(), + }); } static Future getData() async { - var url = 'http://localhost:63342/phpLocation/get.php'; - http.Response response = await http.get(Uri.parse(url)); + Uri uri = Uri.parse("http://82.216.56.128/phpmyadmin/dafldev/distance.php"); + http.Response response = await http.get(uri); var data = jsonDecode(response.body); - print(data.toString()); + log(data.toString()); + return data.toString(); } -} - - - +} \ No newline at end of file diff --git a/Sources/phpLocation/config.php b/Sources/phpLocation/config.php new file mode 100644 index 0000000..3c617a7 --- /dev/null +++ b/Sources/phpLocation/config.php @@ -0,0 +1,14 @@ +getMessage(); echo $error; diff --git a/Sources/phpLocation/distance.php b/Sources/phpLocation/distance.php index 977256f..548363f 100644 --- a/Sources/phpLocation/distance.php +++ b/Sources/phpLocation/distance.php @@ -56,13 +56,5 @@ class ListUser } } -/* -echo "Normalement pas beaucoup = "; -echo (new distance)->meters(45.762595,3.108837,45.762524,3.1088743); - -echo "Normalement pas beaucoup = "; -echo (new distance)->distentre2co(45.891773, 4.662613,45.777222,3.087025); -*/ -echo "\nListe User = "; echo implode(",",(new ListUser)->ListOfUser()); diff --git a/Sources/phpLocation/insert.php b/Sources/phpLocation/insert.php new file mode 100644 index 0000000..7626f69 --- /dev/null +++ b/Sources/phpLocation/insert.php @@ -0,0 +1,22 @@ +0) +{ + echo "user added successfully"; +}