This commit is contained in:
Hamza-Ayed
2024-01-25 02:10:41 +03:00
parent cbd6b45245
commit 9a58d59f4e
9 changed files with 153 additions and 47 deletions

View File

@@ -271,11 +271,7 @@ class FirebaseMessagesController extends GetxController {
'notification': <String, dynamic>{
'title': title,
'body': body,
<<<<<<< HEAD
'sound': 'tone2.wav'
=======
'sound': 'tone2.wav'
>>>>>>> 158d5dfb356420937651bcd4d22a779f03a12e07
},
'data': {
'passengerList': map,
@@ -312,11 +308,7 @@ class FirebaseMessagesController extends GetxController {
'notification': <String, dynamic>{
'title': title,
'body': body,
<<<<<<< HEAD
'sound': 'tone2.wav'
=======
'sound': 'tone2.wav'
>>>>>>> 158d5dfb356420937651bcd4d22a779f03a12e07
},
'data': <String, dynamic>{
'click_action': 'FLUTTER_NOTIFICATION_CLICK',

View File

@@ -1,6 +1,7 @@
import 'package:url_launcher/url_launcher.dart';
import 'dart:io';
void launchUrl1(String url) async {
void showInBrowser(String url) async {
if (await canLaunchUrl(Uri.parse(url))) {
launchUrl(Uri.parse(url));
} else {
@@ -12,22 +13,53 @@ void launchCommunication(
String method, String contactInfo, String message) async {
String url;
switch (method) {
case 'phone':
url = 'tel:$contactInfo';
break;
case 'sms':
url = 'sms:$contactInfo?body=$message';
break;
case 'whatsapp':
url = 'whatsapp://send?phone=$contactInfo&text=$message';
break;
case 'email':
url = 'mailto:$contactInfo?subject=Subject&body=$message';
break;
default:
print('Invalid communication method');
return;
if (Platform.isIOS) {
switch (method) {
case 'phone':
url = 'tel:$contactInfo';
break;
case 'sms':
url = 'sms:$contactInfo?body=$message';
break;
case 'whatsapp':
url = 'https://api.whatsapp.com/send?phone=$contactInfo&text=$message';
break;
case 'email':
url = 'mailto:$contactInfo?subject=Subject&body=$message';
break;
default:
print('Method not supported on iOS');
return;
}
} else if (Platform.isAndroid) {
switch (method) {
case 'phone':
url = 'tel:$contactInfo';
break;
case 'sms':
url = 'sms:$contactInfo?body=$message';
break;
case 'whatsapp':
url = 'whatsapp://send?phone=$contactInfo&text=$message';
break;
case 'email':
url = 'mailto:$contactInfo?subject=Subject&body=$message';
break;
default:
print('Method not supported on Android');
return;
}
} else {
print('Platform not supported');
return;
}
if (await canLaunchUrl(Uri.parse(url))) {

View File

@@ -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;

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:ride/constant/style.dart';
import '../../constant/colors.dart';
@@ -25,6 +26,29 @@ ThemeData themeEnglish = ThemeData(
bodyMedium:
TextStyle(height: 2, color: AppColor.accentColor, fontSize: 14)),
primarySwatch: Colors.blue,
dialogTheme: DialogTheme(
backgroundColor: AppColor.secondaryColor,
contentTextStyle: AppStyle.title,
titleTextStyle: AppStyle.title,
),
appBarTheme: AppBarTheme(
elevation: 0,
color: AppColor.secondaryColor,
centerTitle: true,
iconTheme: const IconThemeData(
color: AppColor.primaryColor,
),
toolbarTextStyle: TextTheme(
titleSmall: AppStyle.subtitle,
headlineSmall: AppStyle.title,
titleLarge: AppStyle.headTitle2)
.bodyMedium,
titleTextStyle: TextTheme(
titleSmall: AppStyle.subtitle,
headlineSmall: AppStyle.title,
titleLarge: AppStyle.headTitle2)
.titleLarge,
),
);
ThemeData themeArabic = ThemeData(