25-10-2/1
This commit is contained in:
@@ -174,9 +174,9 @@ class MapPassengerController extends GetxController {
|
||||
bool rideConfirm = false;
|
||||
bool isMarkersShown = false;
|
||||
bool isMainBottomMenuMap = true;
|
||||
late Timer markerReloadingTimer2;
|
||||
late Timer markerReloadingTimer1;
|
||||
late int durationToPassenger = 0;
|
||||
Timer? markerReloadingTimer2 = Timer(Duration.zero, () {});
|
||||
Timer? markerReloadingTimer1 = Timer(Duration.zero, () {});
|
||||
int durationToPassenger = 0;
|
||||
bool isWayPointSheet = false;
|
||||
bool isWayPointStopsSheet = false;
|
||||
bool isWayPointStopsSheetUtilGetMap = false;
|
||||
@@ -192,7 +192,7 @@ class MapPassengerController extends GetxController {
|
||||
var dataCarsLocationByPassenger;
|
||||
var datadriverCarsLocationToPassengerAfterApplied;
|
||||
CarLocation? nearestCar;
|
||||
late Timer markerReloadingTimer;
|
||||
late Timer? markerReloadingTimer = Timer(Duration.zero, () {});
|
||||
bool shouldFetch = true; // Flag to determine if fetch should be executed
|
||||
int selectedPassengerCount = 1;
|
||||
double progress = 0;
|
||||
@@ -245,7 +245,7 @@ class MapPassengerController extends GetxController {
|
||||
late String driverToken = '';
|
||||
int carsOrder = 0;
|
||||
int wayPointIndex = 0;
|
||||
late double kazan;
|
||||
late double kazan = 8;
|
||||
String? mapAPIKEY;
|
||||
late double totalME = 0;
|
||||
late double tax = 0;
|
||||
@@ -273,7 +273,10 @@ class MapPassengerController extends GetxController {
|
||||
int minutes = 0;
|
||||
|
||||
// --- إضافة جديدة: للوصول إلى وحدة التحكم بالروابط ---
|
||||
final DeepLinkController _deepLinkController = Get.find();
|
||||
final DeepLinkController _deepLinkController =
|
||||
Get.isRegistered<DeepLinkController>()
|
||||
? Get.find<DeepLinkController>()
|
||||
: Get.put(DeepLinkController());
|
||||
// ------------------------------------------------
|
||||
|
||||
void onChangedPassengerCount(int newValue) {
|
||||
@@ -2640,6 +2643,15 @@ class MapPassengerController extends GetxController {
|
||||
'northeastLon': bounds.northeast.longitude.toString(),
|
||||
});
|
||||
break;
|
||||
case 'Electric':
|
||||
res = await CRUD()
|
||||
.get(link: AppLink.getCarsLocationByPassengerElectric, payload: {
|
||||
'southwestLat': bounds.southwest.latitude.toString(),
|
||||
'southwestLon': bounds.southwest.longitude.toString(),
|
||||
'northeastLat': bounds.northeast.latitude.toString(),
|
||||
'northeastLon': bounds.northeast.longitude.toString(),
|
||||
});
|
||||
break;
|
||||
case 'Pink Bike':
|
||||
res = await CRUD()
|
||||
.get(link: AppLink.getCarsLocationByPassengerPinkBike, payload: {
|
||||
@@ -3198,9 +3210,9 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
// 1. إلغاء المؤقتات الفردية
|
||||
// Using ?.cancel() is safe even if the timer is null
|
||||
markerReloadingTimer.cancel();
|
||||
markerReloadingTimer1.cancel();
|
||||
markerReloadingTimer2.cancel();
|
||||
markerReloadingTimer!.cancel();
|
||||
markerReloadingTimer1!.cancel();
|
||||
markerReloadingTimer2!.cancel();
|
||||
timerToPassengerFromDriverAfterApplied?.cancel();
|
||||
_timer?.cancel();
|
||||
|
||||
@@ -3302,11 +3314,6 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
|
||||
Future cancelRide() async {
|
||||
// if (rideConfirm == true ||
|
||||
// statusRide == 'Apply' ||
|
||||
// statusRide == 'Applied' ||
|
||||
// statusRide == 'wait' ||
|
||||
// statusRide == 'waiting') {
|
||||
clearPlacesDestination();
|
||||
clearPolyline();
|
||||
// clearPolylineAll();
|
||||
@@ -3315,7 +3322,7 @@ class MapPassengerController extends GetxController {
|
||||
if (rideId != 'yet') {
|
||||
Log.print('cancelRide: 1');
|
||||
await firebaseMessagesController.sendNotificationToDriverMAP(
|
||||
'Cancel Trip'.tr,
|
||||
'Cancel Trip',
|
||||
'Trip Cancelled'.tr,
|
||||
driverToken.toString(),
|
||||
[],
|
||||
@@ -3336,31 +3343,8 @@ class MapPassengerController extends GetxController {
|
||||
"status": 'Cancel'
|
||||
}),
|
||||
]);
|
||||
|
||||
if (AppLink.endPoint != AppLink.IntaleqCairoServer) {
|
||||
CRUD().post(
|
||||
link: "${AppLink.endPoint}/ride/driver_order/update.php",
|
||||
payload: {
|
||||
"order_id": rideId.toString(), // Convert to String
|
||||
"status": 'Cancel'
|
||||
});
|
||||
CRUD()
|
||||
.post(link: "${AppLink.endPoint}/ride/rides/update.php", payload: {
|
||||
"id": rideId.toString(), // Convert to String
|
||||
"status": 'Cancel'
|
||||
});
|
||||
CRUD().post(
|
||||
link:
|
||||
"${AppLink.endPoint}/ride/notificationCaptain/updateWaitingTrip.php",
|
||||
payload: {
|
||||
"id": rideId.toString(), // Convert to String
|
||||
"status": 'Cancel'
|
||||
});
|
||||
}
|
||||
print('Cancel');
|
||||
// }
|
||||
}
|
||||
Future.delayed(const Duration(seconds: 1));
|
||||
// Future.delayed(const Duration(seconds: 1));
|
||||
Get.offAll(() => const MapPagePassenger());
|
||||
}
|
||||
|
||||
@@ -4560,6 +4544,7 @@ class MapPassengerController extends GetxController {
|
||||
url += '&waypoints=$formattedWaypoints';
|
||||
}
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
|
||||
data = response['routes'][0]['legs'];
|
||||
box.remove(BoxName.tripData);
|
||||
box.write(BoxName.tripData, response);
|
||||
@@ -4642,10 +4627,17 @@ class MapPassengerController extends GetxController {
|
||||
if (polyLines.isNotEmpty) {
|
||||
clearPolyline();
|
||||
} else {
|
||||
// الآن بإمكانك قراءة القيمة من الـBox في أي مكان:
|
||||
bool lowEndMode = box.read(BoxName.lowEndMode) ?? true;
|
||||
// الآن نقرأ القيمة ونحدد عدد النقاط بناءً عليها
|
||||
bool lowEndMode = box.read(BoxName.lowEndMode) ??
|
||||
false; // الأفضل أن يكون الافتراضي هو الجودة العالية
|
||||
|
||||
// نمرر عدد النقاط المناسب هنا
|
||||
animatePolylineLayered(
|
||||
polylineCoordinates,
|
||||
maxPoints:
|
||||
lowEndMode ? 30 : 150, // 30 نقطة لوضع الأداء، 150 للوضع العادي
|
||||
);
|
||||
|
||||
animatePolylineLayered(polylineCoordinates);
|
||||
rideConfirm = false;
|
||||
isMarkersShown = true;
|
||||
|
||||
@@ -4680,12 +4672,13 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
// 2) رسم متدرّج بطبقات متراكبة (بدون حذف)، برونزي ↔ أخضر، مع zIndex وعرض مختلف
|
||||
Future<void> animatePolylineLayered(List<LatLng> coordinates,
|
||||
{int layersCount = 8, int stepDelayMs = 10}) async {
|
||||
{int layersCount = 1, int stepDelayMs = 10, int maxPoints = 150}) async {
|
||||
// امسح أي طبقات قديمة فقط الخاصة بالطريق
|
||||
polyLines.removeWhere((p) => p.polylineId.value.startsWith('route_layer_'));
|
||||
update();
|
||||
|
||||
final List<LatLng> coords = _downsampleEven(coordinates, maxPoints: 20);
|
||||
final List<LatLng> coords =
|
||||
_downsampleEven(coordinates, maxPoints: maxPoints);
|
||||
if (coords.length < 2) return;
|
||||
|
||||
// ألوان مع شفافية خفيفة للتمييز
|
||||
@@ -4816,6 +4809,7 @@ class MapPassengerController extends GetxController {
|
||||
var url =
|
||||
('${AppLink.googleMapsLink}directions/json?&language=${box.read(BoxName.lang)}&avoid=tolls|ferries&destination=$destinationSteps&origin=$originSteps&key=${AK.mapAPIKEY}');
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
|
||||
data = response['routes'][0]['legs'];
|
||||
// isLoading = false;
|
||||
|
||||
@@ -5300,30 +5294,23 @@ class MapPassengerController extends GetxController {
|
||||
changeBottomSheetShown();
|
||||
}
|
||||
|
||||
addToken() async {
|
||||
String fingerPrint = await DeviceHelper.getDeviceFingerprint();
|
||||
// addToken() async {
|
||||
// String fingerPrint = await DeviceHelper.getDeviceFingerprint();
|
||||
|
||||
await CRUD()
|
||||
.post(link: "${AppLink.server}/ride/firebase/add.php", payload: {
|
||||
'token': (box.read(BoxName.tokenFCM.toString())),
|
||||
'passengerID': box.read(BoxName.passengerID).toString(),
|
||||
"fingerPrint": fingerPrint
|
||||
});
|
||||
CRUD().postWallet(
|
||||
link: "${AppLink.seferPaymentServer}/ride/firebase/add.php",
|
||||
payload: {
|
||||
'token': (box.read(BoxName.tokenFCM.toString())),
|
||||
'passengerID': box.read(BoxName.passengerID).toString(),
|
||||
"fingerPrint": fingerPrint
|
||||
});
|
||||
// CRUD().post(
|
||||
// link: "${AppLink.IntaleqGizaServer}/ride/firebase/add.php",
|
||||
// payload: {
|
||||
// 'token': (box.read(BoxName.tokenFCM.toString())),
|
||||
// 'passengerID': box.read(BoxName.passengerID).toString(),
|
||||
// "fingerPrint": fingerPrint
|
||||
// });
|
||||
}
|
||||
// await CRUD()
|
||||
// .post(link: "${AppLink.server}/ride/firebase/add.php", payload: {
|
||||
// 'token': (box.read(BoxName.tokenFCM.toString())),
|
||||
// 'passengerID': box.read(BoxName.passengerID).toString(),
|
||||
// "fingerPrint": fingerPrint
|
||||
// });
|
||||
// CRUD().postWallet(
|
||||
// link: "${AppLink.seferPaymentServer}/ride/firebase/add.php",
|
||||
// payload: {
|
||||
// 'token': (box.read(BoxName.tokenFCM.toString())),
|
||||
// 'passengerID': box.read(BoxName.passengerID).toString(),
|
||||
// "fingerPrint": fingerPrint
|
||||
// });
|
||||
// }
|
||||
|
||||
List<LatLng> polylineCoordinate = [];
|
||||
String? cardNumber;
|
||||
@@ -5794,13 +5781,13 @@ class MapPassengerController extends GetxController {
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
// // --- إضافة جديدة: تهيئة وحدة التحكم في الروابط العميقة ---
|
||||
// Get.put(DeepLinkController(), permanent: true);
|
||||
Get.put(DeepLinkController(), permanent: true);
|
||||
// // ----------------------------------------------------
|
||||
// مرحلة 0: الضروري جداً لعرض الخريطة سريعاً
|
||||
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
|
||||
// mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
|
||||
await initilizeGetStorage(); // إعداد سريع
|
||||
await _initMinimalIcons(); // start/end فقط
|
||||
await addToken(); // لو لازم للمصادقة
|
||||
// await addToken(); // لو لازم للمصادقة
|
||||
_listenForDeepLink();
|
||||
await getLocation(); // لتحديد الكاميرا
|
||||
box.write(BoxName.carType, 'yet');
|
||||
|
||||
@@ -1,110 +1,140 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:Intaleq/constant/style.dart';
|
||||
import 'package:Intaleq/controller/functions/secure_storage.dart';
|
||||
import 'package:Intaleq/views/widgets/my_scafold.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:Intaleq/views/auth/login_page.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
// import 'package:uni_links/uni_links.dart';
|
||||
import 'package:Intaleq/constant/box_name.dart';
|
||||
import 'package:Intaleq/onbording_page.dart';
|
||||
import 'package:Intaleq/views/auth/login_page.dart';
|
||||
import 'package:Intaleq/controller/auth/login_controller.dart';
|
||||
import 'package:Intaleq/controller/functions/secure_storage.dart';
|
||||
import 'package:Intaleq/views/widgets/my_scafold.dart';
|
||||
import 'package:Intaleq/constant/style.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../main.dart';
|
||||
import '../../onbording_page.dart';
|
||||
import '../../views/auth/otp_page.dart';
|
||||
import '../auth/login_controller.dart';
|
||||
|
||||
// كنترولر مع منطق تحميل محسن ينتظر العمليات غير المتزامنة
|
||||
class SplashScreenController extends GetxController
|
||||
with GetTickerProviderStateMixin {
|
||||
late AnimationController _animationController;
|
||||
late Animation<double> animation;
|
||||
|
||||
// الحركات الخاصة بكل عنصر من عناصر الواجهة
|
||||
late Animation<double> titleFadeAnimation;
|
||||
late Animation<double> titleScaleAnimation;
|
||||
late Animation<double> taglineFadeAnimation;
|
||||
late Animation<Offset> taglineSlideAnimation;
|
||||
late Animation<double> footerFadeAnimation;
|
||||
|
||||
final progress = 0.0.obs;
|
||||
Timer? _progressTimer;
|
||||
|
||||
String packageInfo = '';
|
||||
|
||||
Future<void> _getPackageInfo() async {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
packageInfo = info.version;
|
||||
box.write(BoxName.packagInfo, packageInfo);
|
||||
update();
|
||||
}
|
||||
|
||||
String iss = '';
|
||||
@override
|
||||
Future<void> onInit() async {
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
// storage.read(key: 'iss').then((s) {
|
||||
// // print(s);
|
||||
// iss = s!;
|
||||
// });
|
||||
// if (iss == null) {
|
||||
SecureStorage().saveData('iss', 'mobile-app:');
|
||||
// }
|
||||
|
||||
_getPackageInfo();
|
||||
_animationController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 1500), // Reduced duration
|
||||
)..forward();
|
||||
duration: const Duration(milliseconds: 2000),
|
||||
);
|
||||
|
||||
animation =
|
||||
CurvedAnimation(parent: _animationController, curve: Curves.easeOut);
|
||||
// --- تعريف الحركات المتتالية ---
|
||||
titleFadeAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.0, 0.5, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
titleScaleAnimation = Tween<double>(begin: 0.8, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.0, 0.5, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
taglineFadeAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.3, 0.8, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
taglineSlideAnimation =
|
||||
Tween<Offset>(begin: const Offset(0, 0.5), end: Offset.zero).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.3, 0.8, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
footerFadeAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.5, 1.0, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
|
||||
startTimer();
|
||||
_startProgressTimer();
|
||||
_animationController.forward();
|
||||
|
||||
// بدء عملية التهيئة والتحميل
|
||||
_initializeApp();
|
||||
}
|
||||
|
||||
void _startProgressTimer() {
|
||||
const totalTime = 2000; // 5 seconds in milliseconds
|
||||
const interval = 50; // Update every 50ms
|
||||
/// تهيئة التطبيق وانتظار انتهاء التحميل قبل الانتقال
|
||||
Future<void> _initializeApp() async {
|
||||
// تشغيل مؤقت شريط التقدم ليعطي انطباعاً مرئياً فقط
|
||||
_startProgressAnimation();
|
||||
|
||||
// تعريف مهمتين: منطق التحميل، والحد الأدنى لوقت عرض الشاشة
|
||||
final logicFuture = _performNavigationLogic();
|
||||
final minTimeFuture = Future.delayed(const Duration(seconds: 3));
|
||||
|
||||
// الانتظار حتى انتهاء المهمتين معاً
|
||||
await Future.wait([logicFuture, minTimeFuture]);
|
||||
|
||||
// بعد انتهاء الانتظار، سيتم الانتقال تلقائياً من داخل a_performNavigationLogic
|
||||
}
|
||||
|
||||
/// تشغيل حركة شريط التقدم بشكل مرئي ومنفصل عن منطق التحميل
|
||||
void _startProgressAnimation() {
|
||||
const totalTime = 2800; // مدة ملء الشريط
|
||||
const interval = 50;
|
||||
int elapsed = 0;
|
||||
|
||||
_progressTimer =
|
||||
Timer.periodic(const Duration(milliseconds: interval), (timer) async {
|
||||
Timer.periodic(const Duration(milliseconds: interval), (timer) {
|
||||
elapsed += interval;
|
||||
progress.value = (elapsed / totalTime).clamp(0.0, 1.0);
|
||||
|
||||
if (elapsed >= totalTime) {
|
||||
timer.cancel();
|
||||
// await SecurityHelper.performSecurityChecks();
|
||||
// if (box.read('isNotTrust') ||
|
||||
// box.read('isJailBroken') ||
|
||||
// box.read('isTampered')) {
|
||||
// Get.to(() => SecurityPage());
|
||||
// } else {
|
||||
box.read(BoxName.onBoarding) == null
|
||||
? Get.off(() => OnBoardingPage())
|
||||
: box.read(BoxName.email) != null &&
|
||||
box.read(BoxName.phone) != null &&
|
||||
box.read(BoxName.isVerified) == '1'
|
||||
// ? Get.off(() => const MapPagePassenger())
|
||||
? await Get.put(LoginController()).loginUsingCredentials(
|
||||
box.read(BoxName.passengerID).toString(),
|
||||
box.read(BoxName.email).toString(),
|
||||
)
|
||||
: Get.off(() => LoginPage());
|
||||
}
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
void startTimer() async {
|
||||
Timer(const Duration(seconds: 5), () async {
|
||||
// box.read(BoxName.onBoarding) == null
|
||||
// ? Get.off(() => OnBoardingPage())
|
||||
// : box.read(BoxName.email) != null &&
|
||||
// box.read(BoxName.phone) != null &&
|
||||
// box.read(BoxName.isVerified) == '1'
|
||||
// // ? Get.off(() => const MapPagePassenger())
|
||||
// ? await Get.put(LoginController()).loginUsingCredentials(
|
||||
// box.read(BoxName.passengerID).toString(),
|
||||
// box.read(BoxName.email).toString(),
|
||||
// )
|
||||
// : Get.off(() => LoginPage());
|
||||
});
|
||||
/// تنفيذ منطق التحميل الفعلي وتسجيل الدخول وتحديد وجهة الانتقال
|
||||
Future<void> _performNavigationLogic() async {
|
||||
// تنفيذ المهام الأولية
|
||||
await _getPackageInfo();
|
||||
SecureStorage().saveData('iss', 'mobile-app:');
|
||||
|
||||
// تحديد الشاشة التالية
|
||||
if (box.read(BoxName.onBoarding) == null) {
|
||||
Get.off(() => OnBoardingPage());
|
||||
} else if (box.read(BoxName.email) != null &&
|
||||
box.read(BoxName.phone) != null &&
|
||||
box.read(BoxName.isVerified) == '1') {
|
||||
// -- النقطة الأهم --
|
||||
// هنا ننتظر انتهاء عملية تسجيل الدخول قبل الانتقال
|
||||
await Get.put(LoginController()).loginUsingCredentials(
|
||||
box.read(BoxName.passengerID).toString(),
|
||||
box.read(BoxName.email).toString(),
|
||||
);
|
||||
// بعد هذه العملية، سيتولى LoginController بنفسه الانتقال للصفحة الرئيسية أو صفحة الدخول
|
||||
} else {
|
||||
Get.off(() => LoginPage());
|
||||
}
|
||||
}
|
||||
|
||||
/// جلب معلومات الحزمة لعرض إصدار التطبيق
|
||||
Future<void> _getPackageInfo() async {
|
||||
final info = await PackageInfo.fromPlatform();
|
||||
box.write(BoxName.packagInfo, info.version);
|
||||
update();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -115,6 +145,7 @@ class SplashScreenController extends GetxController
|
||||
}
|
||||
}
|
||||
|
||||
// يمكن الإبقاء على هذه الفئة لواجهة المستخدم المتعلقة بالأمان كما في الملف الأصلي
|
||||
class SecurityPage extends StatelessWidget {
|
||||
const SecurityPage({
|
||||
super.key,
|
||||
|
||||
Reference in New Issue
Block a user