2-10/4/1
This commit is contained in:
@@ -1,19 +1,56 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/constant/style.dart';
|
||||
import 'package:SEFER/controller/functions/location_controller.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
|
||||
import '../../constant/links.dart';
|
||||
import '../../main.dart';
|
||||
import '../../views/widgets/mydialoug.dart';
|
||||
import '../functions/crud.dart';
|
||||
|
||||
class RideAvailableController extends GetxController {
|
||||
bool isLoading = false;
|
||||
Map rideAvailableMap = {};
|
||||
late LatLng southwest;
|
||||
late LatLng northeast;
|
||||
LatLngBounds calculateBounds(
|
||||
double centerLat, double centerLng, double radius) {
|
||||
// double radius = 4000; // 10 km in meters
|
||||
|
||||
southwest = LatLng(
|
||||
centerLat - (radius / 111000),
|
||||
centerLng - (radius / (111000 * cos(centerLat))),
|
||||
);
|
||||
|
||||
northeast = LatLng(
|
||||
centerLat + (radius / 111000),
|
||||
centerLng + (radius / (111000 * cos(centerLat))),
|
||||
);
|
||||
|
||||
return LatLngBounds(southwest: southwest, northeast: northeast);
|
||||
}
|
||||
|
||||
getRideAvailable() async {
|
||||
isLoading = true;
|
||||
var res = await CRUD().get(link: AppLink.getRideWaiting, payload: {});
|
||||
LatLngBounds bounds = calculateBounds(
|
||||
Get.find<LocationController>().myLocation.latitude,
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
4000);
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getRideWaiting,
|
||||
payload: {
|
||||
"carType": box.read(BoxName.carTypeOfDriver),
|
||||
'southwestLat': bounds.southwest.latitude.toString(),
|
||||
'southwestLon': bounds.southwest.longitude.toString(),
|
||||
'northeastLat': bounds.northeast.latitude.toString(),
|
||||
'northeastLon': bounds.northeast.longitude.toString(),
|
||||
},
|
||||
);
|
||||
if (res != 'failure') {
|
||||
rideAvailableMap = jsonDecode(res);
|
||||
isLoading = false;
|
||||
|
||||
Reference in New Issue
Block a user