1/25/1
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math' show cos;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -12,6 +13,7 @@ import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/controller/home/points_for_rider_controller.dart';
|
||||
import 'package:ride/views/home/map_page_passenger.dart';
|
||||
import 'package:ride/views/home/map_widget.dart/form_serch_multiy_point.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../../constant/api_key.dart';
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/info.dart';
|
||||
@@ -436,6 +438,25 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
// Create a StreamController to manage the timer values
|
||||
final timerController = StreamController<int>();
|
||||
|
||||
// Start the timer when the ride begins
|
||||
void beginRideTimer() {
|
||||
// Set up the timer to run every second
|
||||
Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
// Update the timer value and notify listeners
|
||||
timerController.add(timer.tick);
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
// Stop the timer when the ride ends
|
||||
void stopRideTimer() {
|
||||
timerController.close();
|
||||
update();
|
||||
}
|
||||
|
||||
void rideIsBeginPassengerTimer() async {
|
||||
for (int i = 0; i <= durationToRide; i++) {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
@@ -962,12 +983,12 @@ class MapPassengerController extends GetxController {
|
||||
// int waypointsLength = Get.find<WayPointController>().wayPoints.length;
|
||||
|
||||
print('isWayPointStopsSheet $wayPointIndex');
|
||||
if (wayPointIndex > 1) {
|
||||
if (wayPointIndex > -1) {
|
||||
isWayPointStopsSheet = true;
|
||||
isWayPointStopsSheetUtilGetMap = true;
|
||||
}
|
||||
isWayPointStopsSheet = !isWayPointStopsSheet;
|
||||
wayPointSheetHeight = isWayPointStopsSheet == false ? 0 : Get.height * .45;
|
||||
wayPointSheetHeight = isWayPointStopsSheet ? Get.height * .45 : 0;
|
||||
// if (heightMenuBool == true) {
|
||||
// getDrawerMenu();
|
||||
// }
|
||||
@@ -1416,26 +1437,26 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
// Calculate the zoom level based on the distance and screen size
|
||||
|
||||
double distanceOfDestnation =
|
||||
getDistanceFromText(data[0]['distance']['text']);
|
||||
|
||||
// getDistanceFromText(data[0]['distance']['text']);
|
||||
double distanceOfTrip = (data[0]['distance']['value']) / 1000;
|
||||
print('distance is $distanceOfTrip');
|
||||
// Animate the camera to the adjusted bounds
|
||||
if (distanceOfDestnation <= 5) {
|
||||
if (distanceOfTrip <= 5) {
|
||||
mapController!
|
||||
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 14));
|
||||
} else if (distanceOfDestnation > 5 && distanceOfDestnation <= 8) {
|
||||
} else if (distanceOfTrip > 5 && distanceOfTrip <= 8) {
|
||||
mapController!
|
||||
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 13));
|
||||
} else if (distanceOfDestnation > 8 && distanceOfDestnation < 16) {
|
||||
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 16));
|
||||
} else if (distanceOfTrip > 8 && distanceOfTrip < 16) {
|
||||
mapController!
|
||||
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 12));
|
||||
} else if (distanceOfDestnation >= 16 && distanceOfDestnation < 30) {
|
||||
} else if (distanceOfTrip >= 16 && distanceOfTrip < 30) {
|
||||
mapController!
|
||||
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 11));
|
||||
} else if (distanceOfDestnation >= 30 && distanceOfDestnation < 100) {
|
||||
} else if (distanceOfTrip >= 30 && distanceOfTrip < 100) {
|
||||
mapController!
|
||||
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 10));
|
||||
} else if (distanceOfDestnation >= 100) {
|
||||
} else if (distanceOfTrip >= 100) {
|
||||
mapController!
|
||||
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 7));
|
||||
}
|
||||
@@ -1476,9 +1497,9 @@ class MapPassengerController extends GetxController {
|
||||
durationToRide = durationToRide + durationToRide0;
|
||||
print('durationToRide is ${data[0]['duration']['value']}');
|
||||
print('totalStepDurations is $durationToRide');
|
||||
double distanceToRide0 = (data[0]['distance']['value']) / 1000;
|
||||
distanceOfDestnation = distanceOfDestnation + distanceToRide0;
|
||||
print('distanceToRide is $distanceToRide0');
|
||||
print('distanceToRide is ${(data[0]['distance']['value']) / 1000}');
|
||||
distance = distanceOfDestnation + (data[0]['distance']['value']) / 1000;
|
||||
|
||||
print('totalStepdistance is $distanceOfDestnation');
|
||||
update();
|
||||
final points =
|
||||
@@ -1596,11 +1617,11 @@ class MapPassengerController extends GetxController {
|
||||
Future bottomSheet() async {
|
||||
if (data.isNotEmpty) {
|
||||
String distanceText = await data[0]['distance']['text'];
|
||||
String durationText = await data[0]['duration']['text'];
|
||||
// String durationText = await data[0]['duration']['text'];
|
||||
print(data[0]['duration']['text']);
|
||||
print('=================================');
|
||||
distance = getDistanceFromText(distanceText);
|
||||
duration = getDistanceFromText(durationText);
|
||||
// distance = getDistanceFromText(distanceText);
|
||||
// duration = getDistanceFromText(durationText);
|
||||
durationToAdd = Duration(seconds: durationToRide);
|
||||
print('durationToRide----- $durationToRide');
|
||||
hours = durationToAdd.inHours;
|
||||
|
||||
Reference in New Issue
Block a user