This commit is contained in:
Hamza-Ayed
2024-08-06 16:56:36 +03:00
parent 3caa1ef1f0
commit 46f11d5991
9 changed files with 368 additions and 191 deletions

View File

@@ -55,8 +55,8 @@ android {
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 34 targetSdkVersion 34
versionCode 53 versionCode 54
versionName '1.5.53' versionName '1.5.54'
// manifestPlaceholders = [mapsApiKey: 'android/app/src/main/AndroidManifest.xml'] // manifestPlaceholders = [mapsApiKey: 'android/app/src/main/AndroidManifest.xml']
} }

View File

@@ -171,6 +171,7 @@ class AppLink {
//==================certifcate========== //==================certifcate==========
static String location = '$server/ride/location'; static String location = '$server/ride/location';
static String getCarsLocationByPassenger = "$location/get.php"; static String getCarsLocationByPassenger = "$location/get.php";
static String addpassengerLocation = "$location/addpassengerLocation.php";
static String getCarsLocationByPassengerSpeed = "$location/getSpeed.php"; static String getCarsLocationByPassengerSpeed = "$location/getSpeed.php";
static String getCarsLocationByPassengerComfort = "$location/getComfort.php"; static String getCarsLocationByPassengerComfort = "$location/getComfort.php";
static String getCarsLocationByPassengerDelivery = static String getCarsLocationByPassengerDelivery =

View File

@@ -194,9 +194,12 @@ class FirebaseMessagesController extends GetxController {
title: 'Ok'.tr, title: 'Ok'.tr,
onPressed: () async { onPressed: () async {
Get.back(); Get.back();
await Get.find<MapPassengerController>()
.getCarsLocationByPassengerAndReloadMarker(
box.read(BoxName.carType), 7000);
Get.find<MapPassengerController>() Get.find<MapPassengerController>()
.delayAndFetchRideStatusForAllDriverAvailable( .confirmRideForAllDriverAvailable();
Get.find<MapPassengerController>().rideId);
}, },
), ),
cancel: MyElevatedButton( cancel: MyElevatedButton(

View File

@@ -1,7 +1,8 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:math' show cos, pow, sqrt; import 'dart:math' show Random, cos, pi, pow, sin, sqrt;
import 'dart:math' as math; import 'dart:math' as math;
import 'package:vector_math/vector_math.dart' show radians, degrees;
import 'package:SEFER/controller/functions/tts.dart'; import 'package:SEFER/controller/functions/tts.dart';
import 'package:SEFER/views/home/map_page_passenger.dart'; import 'package:SEFER/views/home/map_page_passenger.dart';
@@ -354,10 +355,15 @@ class MapPassengerController extends GetxController {
if (rideId != 'yet') { if (rideId != 'yet') {
await CRUD().post(link: AppLink.updateDriverOrder, payload: { await CRUD().post(link: AppLink.updateDriverOrder, payload: {
"order_id": rideId.toString(), // Convert to String "order_id": rideId.toString(), // Convert to String
"status": 'Cancel' "status": 'waiting'
}); });
await CRUD().post(link: AppLink.updateRides, payload: {
"id": rideId.toString(), // Convert to String
"status": 'waiting'
});
tick = 0;
} }
confirmRideForFirstDriver(); confirmRideForAllDriverAvailable();
} }
} }
} }
@@ -538,23 +544,33 @@ class MapPassengerController extends GetxController {
} }
bool isTimerFromDriverToPassengerAfterAppliedRunning = true; bool isTimerFromDriverToPassengerAfterAppliedRunning = true;
int beginRideInterval = 4; // Interval in seconds for getBeginRideFromDriver
void startTimerFromDriverToPassengerAfterApplied() async { void startTimerFromDriverToPassengerAfterApplied() async {
for (int i = 0; int secondsElapsed = 0;
i <= timeToPassengerFromDriverAfterApplied &&
isTimerFromDriverToPassengerAfterAppliedRunning; while (secondsElapsed <= timeToPassengerFromDriverAfterApplied &&
i++) { isTimerFromDriverToPassengerAfterAppliedRunning) {
await Future.delayed(const Duration(seconds: 1)); await Future.delayed(const Duration(seconds: 1));
secondsElapsed++;
progressTimerToPassengerFromDriverAfterApplied = progressTimerToPassengerFromDriverAfterApplied =
i / timeToPassengerFromDriverAfterApplied; secondsElapsed / timeToPassengerFromDriverAfterApplied;
remainingTimeToPassengerFromDriverAfterApplied = remainingTimeToPassengerFromDriverAfterApplied =
timeToPassengerFromDriverAfterApplied - i; timeToPassengerFromDriverAfterApplied - secondsElapsed;
if (remainingTimeToPassengerFromDriverAfterApplied < 69) { if (remainingTimeToPassengerFromDriverAfterApplied < 69) {
if (rideTimerBegin == false) { if (rideTimerBegin == false) {
getBeginRideFromDriver(); rideTimerBegin = true;
} }
} }
// Call getBeginRideFromDriver every 4 seconds
if (secondsElapsed % beginRideInterval == 0) {
getBeginRideFromDriver();
uploadPassengerLocation();
}
int minutes = int minutes =
(remainingTimeToPassengerFromDriverAfterApplied / 60).floor(); (remainingTimeToPassengerFromDriverAfterApplied / 60).floor();
int seconds = remainingTimeToPassengerFromDriverAfterApplied % 60; int seconds = remainingTimeToPassengerFromDriverAfterApplied % 60;
@@ -565,6 +581,8 @@ class MapPassengerController extends GetxController {
} }
} }
// Remove the getBeginRideFromDriverForDuration function as it's no longer needed
// Function to stop the timer // Function to stop the timer
void stopTimerFromDriverToPassengerAfterApplied() { void stopTimerFromDriverToPassengerAfterApplied() {
isTimerFromDriverToPassengerAfterAppliedRunning = false; isTimerFromDriverToPassengerAfterAppliedRunning = false;
@@ -712,22 +730,23 @@ class MapPassengerController extends GetxController {
try { try {
var res = await CRUD() var res = await CRUD()
.get(link: AppLink.getRideStatusBegin, payload: {'ride_id': rideId}); .get(link: AppLink.getRideStatusBegin, payload: {'ride_id': rideId});
if (res == 'failure') {} if (res != 'failure') {
var decode = jsonDecode(res); var decode = jsonDecode(res);
if (decode['data']['status'] == 'Begin') { if (decode['data']['status'] == 'Begin') {
timeToPassengerFromDriverAfterApplied = 0; timeToPassengerFromDriverAfterApplied = 0;
remainingTime = 0; remainingTime = 0;
remainingTimeToPassengerFromDriverAfterApplied = 0; remainingTimeToPassengerFromDriverAfterApplied = 0;
remainingTimeDriverWaitPassenger5Minute = 0; remainingTimeDriverWaitPassenger5Minute = 0;
rideTimerBegin = true; rideTimerBegin = true;
statusRide = 'Begin'; statusRide = 'Begin';
isDriverInPassengerWay = false; isDriverInPassengerWay = false;
isDriverArrivePassenger = false; isDriverArrivePassenger = false;
update(); update();
// isCancelRidePageShown = true; // isCancelRidePageShown = true;
rideIsBeginPassengerTimer(); rideIsBeginPassengerTimer();
runWhenRideIsBegin(); runWhenRideIsBegin();
}
} }
} catch (e) { } catch (e) {
// Handle the error or perform any necessary actions // Handle the error or perform any necessary actions
@@ -1138,6 +1157,7 @@ class MapPassengerController extends GetxController {
bool isDriversTokensSend = false; bool isDriversTokensSend = false;
confirmRideForAllDriverAvailable() async { confirmRideForAllDriverAvailable() async {
// isDriversTokensSend = true; // isDriversTokensSend = true;
driversToken.remove(driverToken); driversToken.remove(driverToken);
PaymentController paymentController = Get.find<PaymentController>(); PaymentController paymentController = Get.find<PaymentController>();
rideConfirm = true; rideConfirm = true;
@@ -1195,7 +1215,7 @@ class MapPassengerController extends GetxController {
polylineCoordinates.toString()); polylineCoordinates.toString());
} }
delayAndFetchRideStatusForAllDriverAvailable(rideId); (rideId);
update(); update();
} }
@@ -1210,9 +1230,10 @@ class MapPassengerController extends GetxController {
Log.print('tick: $tick'); Log.print('tick: $tick');
if (res.toString() == 'waiting' && tick == 15) { if (res.toString() == 'waiting' && tick >= 15) {
timer.cancel(); // Stop the current timer timer.cancel(); // Stop the current timer
delayAndFetchRideStatusForAllDriverAvailable(rideId); showAndResearchForCaptain();
// delayAndFetchRideStatusForAllDriverAvailable(rideId);
} else if (res.toString() == 'Apply') { } else if (res.toString() == 'Apply') {
timer.cancel(); // Stop the current timer timer.cancel(); // Stop the current timer
shouldFetch = false; // Stop further fetches shouldFetch = false; // Stop further fetches
@@ -1227,10 +1248,11 @@ class MapPassengerController extends GetxController {
confirmRideForAllDriverAvailable(); confirmRideForAllDriverAvailable();
isDriversTokensSend = true; isDriversTokensSend = true;
} // Start 15-second timer } // Start 15-second timer
} else if (isDriversTokensSend == false) {
// No need to recall delayAndFetchRideStatus as Timer.periodic is already running
update();
} }
//else if (isDriversTokensSend == false) {
// No need to recall delayAndFetchRideStatus as Timer.periodic is already running
update();
// }
tick++; tick++;
} else { } else {
timer timer
@@ -1242,13 +1264,26 @@ class MapPassengerController extends GetxController {
}); });
} }
void delayAndFetchRideStatusForAllDriverAvailable(String rideId) { showAndResearchForCaptain() {
Get.snackbar(
"No Captain Accepted Your Order".tr,
"We are looking for a captain but the price may increase to let a captain accept"
.tr,
backgroundColor: AppColor.bronze,
);
}
void delayAndFetchRideStatusForAllDriverAvailable(String rideId) async {
startCarLocationSearch(box.read(BoxName.carType));
int attemptCounter = 0; int attemptCounter = 0;
const int maxAttempts = 15; const int maxAttempts = 15;
tick = 0;
Log.print('tick delayAndFetchRideStatusForAllDriverAvailable: ${tick}');
void fetchRideStatus() async { void fetchRideStatus() async {
if (shouldFetch && attemptCounter < maxAttempts) { if (shouldFetch && attemptCounter < maxAttempts) {
attemptCounter++; attemptCounter++;
tick++;
var res = await getRideStatus(rideId); var res = await getRideStatus(rideId);
if (res.toString() == 'Apply') { if (res.toString() == 'Apply') {
@@ -1270,6 +1305,79 @@ class MapPassengerController extends GetxController {
MyDialog().getDialog('upgrade price'.tr, MyDialog().getDialog('upgrade price'.tr,
'You can upgrade price to may driver accept your order'.tr, () { 'You can upgrade price to may driver accept your order'.tr, () {
Get.back(); Get.back();
Get.defaultDialog(
barrierDismissible: false,
title: "Increase Your Trip Fee (Optional)".tr,
titleStyle: AppStyle.title,
content: Column(
children: [
Text(
"We haven't found any drivers yet. Consider increasing your trip fee to make your offer more attractive to drivers."
.tr,
style: AppStyle.title,
textAlign: TextAlign.center,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
onPressed: () {
increasFeeFromPassenger.text =
(totalPassenger + 6).toStringAsFixed(1);
// mapPassengerController.increasFeeFromPassenger.text =
// mapPassengerController.totalPassenger
// .toStringAsFixed(1);
update();
},
icon: Column(
children: [
Text(
'6',
style: AppStyle.number,
),
Container(
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: AppColor.greenColor),
child: const Icon(
Icons.arrow_circle_up,
size: 30,
color: AppColor.secondaryColor,
),
),
],
),
),
SizedBox(
width: 100,
child: Form(
key: increaseFeeFormKey,
child: MyTextForm(
controller: increasFeeFromPassenger,
label: totalPassenger.toStringAsFixed(2),
hint: totalPassenger.toStringAsFixed(2),
type: TextInputType.number),
),
),
],
)
],
),
actions: [
MyElevatedButton(
title: "No, thanks",
onPressed: () {
Get.back();
cancelRide();
}),
MyElevatedButton(
title: "Increase Fee".tr,
kolor: AppColor.greenColor,
onPressed: () {
increaseFeeByPassengerAndReOrder();
})
],
);
}); });
update(); update();
print('Stopped fetching ride status after 30 seconds.'); print('Stopped fetching ride status after 30 seconds.');
@@ -1470,27 +1578,48 @@ class MapPassengerController extends GetxController {
void startCarLocationSearch(String carType) { void startCarLocationSearch(String carType) {
int searchInterval = 5; // Interval in seconds int searchInterval = 5; // Interval in seconds
int boundIncreaseStep = 4500; // Initial bounds in meters Log.print('searchInterval: ${searchInterval}');
int maxAttempts = 3; // Maximum attempts to increase bounds int boundIncreaseStep = 2500; // Initial bounds in meters
Log.print('boundIncreaseStep: ${boundIncreaseStep}');
int maxAttempts = 6; // Maximum attempts to increase bounds
int maxBoundIncreaseStep = 6000; // Maximum bounds increase step
int attempt = 0; // Current attempt int attempt = 0; // Current attempt
Log.print('initial attempt: ${attempt}');
Timer.periodic(Duration(seconds: searchInterval), (Timer timer) async { Timer.periodic(Duration(seconds: searchInterval), (Timer timer) async {
Log.print('Current attempt: ${attempt}'); // Log current attempt
bool foundCars = false;
if (attempt >= maxAttempts) { if (attempt >= maxAttempts) {
timer.cancel(); timer.cancel();
noCarString = true; if (foundCars == false) {
dataCarsLocationByPassenger = 'failure'; noCarString = true;
update(); dataCarsLocationByPassenger = 'failure';
update();
}
return; return;
}
bool foundCars = await getCarsLocationByPassengerAndReloadMarker(
carType, boundIncreaseStep);
if (foundCars) {
timer.cancel();
} else { } else {
attempt++; foundCars = await getCarsLocationByPassengerAndReloadMarker(
boundIncreaseStep = boundIncreaseStep + 1500; // Increase bounds carType, boundIncreaseStep);
Log.print('foundCars: ${foundCars}');
if (foundCars) {
timer.cancel();
} else {
attempt++;
Log.print(
'Incrementing attempt to: ${attempt}'); // Log incremented attempt
if (boundIncreaseStep < maxBoundIncreaseStep) {
boundIncreaseStep += 1500; // Increase bounds
if (boundIncreaseStep > maxBoundIncreaseStep) {
boundIncreaseStep =
maxBoundIncreaseStep; // Ensure it does not exceed the maximum
}
Log.print(
'New boundIncreaseStep: ${boundIncreaseStep}'); // Log new bounds
}
}
} }
}); });
} }
@@ -1551,9 +1680,6 @@ class MapPassengerController extends GetxController {
} }
if (res == 'failure') { if (res == 'failure') {
// noCarString = true;
// dataCarsLocationByPassenger = res;
// update();
return false; return false;
} else { } else {
noCarString = false; noCarString = false;
@@ -1580,6 +1706,10 @@ class MapPassengerController extends GetxController {
driversToken.add(json['token']); driversToken.add(json['token']);
} }
// Add fake car markers
_addFakeCarMarkers(passengerLocation, 2);
update(); update();
return true; return true;
} }
@@ -1587,6 +1717,49 @@ class MapPassengerController extends GetxController {
return false; return false;
} }
final List<Map<String, dynamic>> fakeCarData = [];
void _addFakeCarMarkers(LatLng center, int count) {
if (fakeCarData.isEmpty) {
Random random = Random();
double radiusInKm = 1.5; // 3 km diameter, so 1.5 km radius
for (int i = 0; i < count; i++) {
// Generate a random angle and distance within the circle
double angle = random.nextDouble() * 2 * pi;
double distance = sqrt(random.nextDouble()) * radiusInKm;
// Convert distance to latitude and longitude offsets
double latOffset = (distance / 111.32); // 1 degree lat ≈ 111.32 km
double lonOffset =
(distance / (111.32 * cos(radians(center.latitude))));
// Calculate new position
double lat = center.latitude + (latOffset * cos(angle));
double lon = center.longitude + (lonOffset * sin(angle));
double heading = random.nextDouble() * 360;
fakeCarData.add({
'id': 'fake_$i',
'latitude': lat,
'longitude': lon,
'heading': heading,
'gender': 'Male', // Randomize gender
});
}
}
for (var carData in fakeCarData) {
_updateOrCreateMarker(
MarkerId(carData['id']).toString(),
LatLng(carData['latitude'], carData['longitude']),
carData['heading'],
_getIconForCar(carData),
);
}
}
BitmapDescriptor _getIconForCar(Map<String, dynamic> carData) { BitmapDescriptor _getIconForCar(Map<String, dynamic> carData) {
if (carData['model'].toString().contains('دراجة')) { if (carData['model'].toString().contains('دراجة')) {
return motoIcon; return motoIcon;
@@ -1976,26 +2149,7 @@ class MapPassengerController extends GetxController {
'cancel.wav', 'cancel.wav',
); );
} }
// rideConfirm = false;
// shouldFetch = false;
// isCashConfirmPageShown = false;
// isSearchingWindow = false;
// statusRide = 'Cancel';
// isPassengerChosen = false;
// isCashSelectedBeforeConfirmRide = false;
// isPickerShown = false;
// isMarkersShown = false;
// haveSteps = false;
// isMarkersShown = false;
// driverToken = '';
// driverId = '';
// driverPhone = '';
// driverName = '';
// // totalStepDurations = 0;
// timeToPassengerFromDriverAfterApplied = 0;
// remainingTime = 0;
// isWayPointStopsSheetUtilGetMap = false;
// update();
Get.offAll(const MapPagePassenger()); Get.offAll(const MapPagePassenger());
} else { } else {
clearPlacesDestination(); clearPlacesDestination();
@@ -2005,28 +2159,11 @@ class MapPassengerController extends GetxController {
"order_id": rideId.toString(), // Convert to String "order_id": rideId.toString(), // Convert to String
"status": 'Cancel' "status": 'Cancel'
}); });
await CRUD().post(link: AppLink.updateRides, payload: {
"id": rideId.toString(), // Convert to String
"status": 'Cancel'
});
Get.offAll(const MapPagePassenger()); Get.offAll(const MapPagePassenger());
// isPickerShown = false;
// isWayPointStopsSheetUtilGetMap = false;
// rideConfirm = false;
// shouldFetch = false;
// driverToken = '';
// driverId = '';
// driverPhone = '';
// driverName = '';
// isCashConfirmPageShown = false;
// isSearchingWindow = false;
// isPassengerChosen = false;
// isCashSelectedBeforeConfirmRide = false;
// statusRide = 'Cancel';
// haveSteps = false;
// isMarkersShown = false;
// timeToPassengerFromDriverAfterApplied = 0;
// changeCancelRidePageShow();
// clearPolyline();
// remainingTime = 0;
// durationTimer = 0;
// update();
} }
} }
@@ -2430,31 +2567,28 @@ class MapPassengerController extends GetxController {
startMarkerReloading() async { startMarkerReloading() async {
int reloadCount = 0; int reloadCount = 0;
Timer.periodic(const Duration(seconds: 5), (timer) { Timer.periodic(const Duration(seconds: 5), (timer) async {
reloadCount++; reloadCount++;
Log.print('reloadCount: ${reloadCount}');
if (!rideConfirm) { if (!rideConfirm) {
reloadMarkers(); clearMarkersExceptStartEnd();
// _smoothlyUpdateMarker();
// startCarLocationSearch(box.read(BoxName.carType));
await getCarsLocationByPassengerAndReloadMarker(
box.read(BoxName.carType), 6000);
await getNearestDriverByPassengerLocation();
Log.print('reloadMarkers: from startMarkerReloadin');
} else { } else {
// runWhenRideIsBegin(); // runWhenRideIsBegin();
} }
if (reloadCount >= 35) { if (reloadCount >= 10) {
timer.cancel(); // Stop the timer after 5 reloads timer.cancel(); // Stop the timer after 5 reloads
} }
}); });
} }
reloadMarkers() async {
// if (statusRide == 'wait') {
clearMarkersExceptStartEnd();
// _smoothlyUpdateMarker();
startCarLocationSearch(box.read(BoxName.carType));
// await getCarsLocationByPassengerAndReloadMarker();
await getNearestDriverByPassengerLocation();
// }
}
String durationByPassenger = ''; String durationByPassenger = '';
late DateTime newTime1 = DateTime.now(); late DateTime newTime1 = DateTime.now();
late DateTime timeFromDriverToPassenger = DateTime.now(); late DateTime timeFromDriverToPassenger = DateTime.now();
@@ -3349,6 +3483,15 @@ class MapPassengerController extends GetxController {
super.onInit(); super.onInit();
} }
uploadPassengerLocation() async {
await CRUD().post(link: AppLink.addpassengerLocation, payload: {
"passengerId": box.read(BoxName.passengerID),
"lat": passengerLocation.latitude,
"lng": passengerLocation.longitude,
"rideId": rideId
});
}
} }
class CarLocation { class CarLocation {

View File

@@ -49,9 +49,15 @@ class MyTranslation extends Translations {
"We will look for a new driver.\nPlease wait.": "We will look for a new driver.\nPlease wait.":
"سنبحث عن سائق جديد.\nمن فضلك انتظر.", "سنبحث عن سائق جديد.\nمن فضلك انتظر.",
"upgrade price": "رفع السعر", "upgrade price": "رفع السعر",
'airport': 'مطار',
"Best choice for a comfortable car with a flexible route and stop points. This airport offers visa entry at this price.":
"أفضل اختيار لسيارة مريحة مع طريق ونقاط توقف مرنة. يقدم هذا المطار تأشيرة دخول بهذا السعر.",
"You can upgrade price to may driver accept your order": "You can upgrade price to may driver accept your order":
"يمكنك رفع السعر حتى يقبل السائق طلبك", "يمكنك رفع السعر حتى يقبل السائق طلبك",
"Change Route": "تغيير المسار",
"No Captain Accepted Your Order": "لا يوجد كابتن قبل الطلب الخاص بك",
"We are looking for a captain but the price may increase to let a captain accept":
"نحن نبحث عن كابتن ولكن قد يرتفع السعر للسماح لكابتن بقبول الطلب",
"No, I want to cancel this trip": "لا، أريد إلغاء هذه الرحلة", "No, I want to cancel this trip": "لا، أريد إلغاء هذه الرحلة",
'Trip Cancelled. The cost of the trip will be added to your wallet.': 'Trip Cancelled. The cost of the trip will be added to your wallet.':
"تم إلغاء الرحلة. سيتم إضافة تكلفة الرحلة إلى محفظتك.", "تم إلغاء الرحلة. سيتم إضافة تكلفة الرحلة إلى محفظتك.",
@@ -154,6 +160,8 @@ iOS [https://getapp.cc/app/6458734951]
'The driver waiting you in picked location .': 'The driver waiting you in picked location .':
"السائق ينتظرك في موقع الركوب.", "السائق ينتظرك في موقع الركوب.",
'About Us': "نبذة عنا", 'About Us': "نبذة عنا",
"You can change the vibration feedback for all buttons":
"يمكنك تغيير اهتزاز الرج لجميع الأزرار",
"Most Secure Methods": "أساليب الأمان الأكثر فاعلية", "Most Secure Methods": "أساليب الأمان الأكثر فاعلية",
"In-App VOIP Calls": "مكالمات VOIP داخل التطبيق", "In-App VOIP Calls": "مكالمات VOIP داخل التطبيق",
"Recorded Trips for Safety": "تسجيل الرحلات من أجل السلامة", "Recorded Trips for Safety": "تسجيل الرحلات من أجل السلامة",

View File

@@ -90,7 +90,7 @@ class HomePage extends StatelessWidget {
); );
}), }),
subtitle: Text( subtitle: Text(
'You can change the Vibration for all butttons'.tr, "You can change the vibration feedback for all buttons".tr,
style: AppStyle.title, style: AppStyle.title,
), ),
onTap: () => Get.to(() => const FrequentlyQuestionsPage()), onTap: () => Get.to(() => const FrequentlyQuestionsPage()),

View File

@@ -11,6 +11,7 @@ import 'package:get/get.dart';
import '../../../constant/info.dart'; import '../../../constant/info.dart';
import '../../../controller/functions/tts.dart'; import '../../../controller/functions/tts.dart';
import '../../../controller/home/map_passenger_controller.dart'; import '../../../controller/home/map_passenger_controller.dart';
import '../../../print.dart';
class CarType { class CarType {
final String carType; final String carType;
@@ -295,6 +296,8 @@ class CarDetailsTypeToChoose extends StatelessWidget {
mapPassengerController.totalPassenger = mapPassengerController.totalPassenger =
mapPassengerController mapPassengerController
.totalPassengerComfort; .totalPassengerComfort;
Log.print(
'mapPassengerController.endNameAddress: ${mapPassengerController.endNameAddress}');
Get.defaultDialog( Get.defaultDialog(
title: 'Comfort'.tr, title: 'Comfort'.tr,
titleStyle: AppStyle.title, titleStyle: AppStyle.title,
@@ -302,8 +305,13 @@ class CarDetailsTypeToChoose extends StatelessWidget {
textToSpeechController: textToSpeechController:
textToSpeechController, textToSpeechController,
image: 'assets/images/blob.png', image: 'assets/images/blob.png',
text: text: mapPassengerController
'Best choice for comfort car and flexible route and stops point' .endNameAddress
.toLowerCase()
.contains("airport".tr)
? "Best choice for a comfortable car with a flexible route and stop points. This airport offers visa entry at this price."
.tr
: 'Best choice for comfort car and flexible route and stops point'
.tr), .tr),
confirm: MyElevatedButton( confirm: MyElevatedButton(
kolor: AppColor.greenColor, kolor: AppColor.greenColor,
@@ -602,7 +610,7 @@ class HeaderDestination extends StatelessWidget {
// mapPassengerController.cancelRide(); // mapPassengerController.cancelRide();
// }); // });
MyDialog().getDialog( MyDialog().getDialog(
'Change Ride'.tr, "Change Route".tr,
'You can change the destination by long-pressing any point on the map' 'You can change the destination by long-pressing any point on the map'
.tr, () { .tr, () {
Get.back(); Get.back();

View File

@@ -1,15 +1,9 @@
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/views/auth/sms_verfy_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
import '../../../constant/char_map.dart';
import '../../../constant/colors.dart'; import '../../../constant/colors.dart';
import '../../../constant/credential.dart';
import '../../../controller/firebase/firbase_messge.dart';
import '../../../controller/functions/tts.dart'; import '../../../controller/functions/tts.dart';
import '../../../controller/home/map_passenger_controller.dart'; import '../../../controller/home/map_passenger_controller.dart';
import '../../../main.dart';
GetBuilder<MapPassengerController> leftMainMenuIcons() { GetBuilder<MapPassengerController> leftMainMenuIcons() {
final textToSpeechController = Get.put(TextToSpeechController()); final textToSpeechController = Get.put(TextToSpeechController());
@@ -104,32 +98,32 @@ GetBuilder<MapPassengerController> leftMainMenuIcons() {
// ), // ),
// ), // ),
// ), // ),
AnimatedContainer( // AnimatedContainer(
duration: const Duration(microseconds: 200), // duration: const Duration(microseconds: 200),
width: controller.widthMapTypeAndTraffic, // width: controller.widthMapTypeAndTraffic,
decoration: BoxDecoration( // decoration: BoxDecoration(
color: AppColor.secondaryColor, // color: AppColor.secondaryColor,
border: Border.all(), // border: Border.all(),
borderRadius: BorderRadius.circular(15)), // borderRadius: BorderRadius.circular(15)),
child: IconButton( // child: IconButton(
onPressed: () async { // onPressed: () async {
FirebaseMessagesController().sendNotificationToDriverMAP( // FirebaseMessagesController().sendNotificationToDriverMAP(
'', // '',
'from: ', // 'from: ',
// jsonDecode(value)['message'].toString(), // // jsonDecode(value)['message'].toString(),
'cXavJMQgRACEfYdOnSLDU4:APA91bE_7aB5kLUcCgolp6BTy3girf7NCxR49dRt9wMDCu3C3td9V-KwZqsbJvYyIqgkI9oxZCiqyVv9ZnVG7rN0LBf7Nxe9AEcatgHNo0fEomaMWB3ff_SagtNkUuYeHc-GaPETq6Oa', // 'cXavJMQgRACEfYdOnSLDU4:-KwZqsbJvYyIqgkI9oxZCiqyVv9ZnVG7rN0LBf7Nxe9AEcatgHNo0fEomaMWB3ff_SagtNkUuYeHc-GaPETq6Oa',
[], // [],
'order.wav' // 'order.wav'
// polylineCoordinates.toString() // // polylineCoordinates.toString()
); // );
}, // },
icon: const Icon( // icon: const Icon(
Icons.chat, // Icons.chat,
size: 29, // size: 29,
), // ),
), // ),
), // ),
// AnimatedContainer( // AnimatedContainer(
// duration: const Duration(microseconds: 200), // duration: const Duration(microseconds: 200),
// width: controller.widthMapTypeAndTraffic, // width: controller.widthMapTypeAndTraffic,

View File

@@ -1,20 +1,17 @@
import 'package:SEFER/constant/box_name.dart'; import 'package:flutter/cupertino.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/main.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart'; import 'package:get_storage/get_storage.dart';
import 'package:SEFER/constant/box_name.dart';
import '../../constant/colors.dart';
class MyTextForm extends StatelessWidget { class MyTextForm extends StatelessWidget {
const MyTextForm({ const MyTextForm({
super.key, Key? key,
required this.controller, required this.controller,
required this.label, required this.label,
required this.hint, required this.hint,
required this.type, required this.type,
}); }) : super(key: key);
final TextEditingController controller; final TextEditingController controller;
final String label, hint; final String label, hint;
final TextInputType type; final TextInputType type;
@@ -25,50 +22,73 @@ class MyTextForm extends StatelessWidget {
padding: const EdgeInsets.only(bottom: 10), padding: const EdgeInsets.only(bottom: 10),
child: SizedBox( child: SizedBox(
width: Get.width * .8, width: Get.width * .8,
child: TextFormField( child: Column(
keyboardType: type, crossAxisAlignment: CrossAxisAlignment.start,
cursorColor: AppColor.accentColor, children: [
controller: controller, Text(
decoration: InputDecoration( label.tr,
focusedBorder: OutlineInputBorder( style: TextStyle(
borderSide: const BorderSide( color: CupertinoColors.label,
color: AppColor.primaryColor, fontSize: 16,
width: 2.0, fontWeight: FontWeight.w600,
), ),
borderRadius: BorderRadius.circular(10),
), ),
focusColor: AppColor.accentColor, const SizedBox(height: 8),
fillColor: AppColor.accentColor, CupertinoTextField(
border: const OutlineInputBorder( controller: controller,
borderRadius: BorderRadius.all(Radius.circular(12))), keyboardType: type,
labelText: label.tr, placeholder: hint.tr,
hintText: hint.tr, padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
hintStyle: AppStyle.title, decoration: BoxDecoration(
labelStyle: AppStyle.title, color: CupertinoColors.systemBackground,
), border: Border.all(color: CupertinoColors.systemGrey4),
validator: (value) { borderRadius: BorderRadius.circular(8),
if (value!.isEmpty) { ),
return '${'Please enter'.tr} $label.'.tr; style: const TextStyle(color: CupertinoColors.label),
} placeholderStyle:
const TextStyle(color: CupertinoColors.placeholderText),
if (type == TextInputType.emailAddress) { ),
if (!value.contains('@')) { const SizedBox(height: 4),
return 'Please enter a valid email.'.tr; ValueListenableBuilder<TextEditingValue>(
} valueListenable: controller,
} else if (type == TextInputType.phone) { builder: (context, value, child) {
if (box.read(BoxName.countryCode) == 'Egypt') { String? errorText = _getErrorText(value.text);
if (value.length != 11) { return errorText != null
return 'Please enter a valid phone number.'.tr; ? Text(
} errorText,
} else if (value.length != 10) { style: const TextStyle(
return 'Please enter a valid phone number.'.tr; color: CupertinoColors.destructiveRed,
} fontSize: 12),
} )
: const SizedBox.shrink();
return null; },
}, ),
],
), ),
), ),
); );
} }
String? _getErrorText(String value) {
if (value.isEmpty) {
return '${'Please enter'.tr} $label'.tr;
}
if (type == TextInputType.emailAddress) {
if (!value.contains('@')) {
return 'Please enter a valid email.'.tr;
}
} else if (type == TextInputType.phone) {
final box = GetStorage();
if (box.read(BoxName.countryCode) == 'Egypt') {
if (value.length != 11) {
return 'Please enter a valid phone number.'.tr;
}
} else if (value.length != 10) {
return 'Please enter a valid phone number.'.tr;
}
}
return null;
}
} }