25-8-6-1
This commit is contained in:
@@ -12,7 +12,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_contacts/contact.dart';
|
||||
import 'package:flutter_contacts/flutter_contacts.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:share/share.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../../../main.dart';
|
||||
import '../../../views/widgets/error_snakbar.dart';
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:crypto/crypto.dart';
|
||||
|
||||
import 'dart:math';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:secure_string_operations/secure_string_operations.dart';
|
||||
import 'package:sefer_driver/controller/functions/location_background_controller.dart';
|
||||
import 'package:sefer_driver/views/auth/captin/cards/sms_signup.dart';
|
||||
@@ -49,6 +50,42 @@ class LoginDriverController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
bool showManualForm = false;
|
||||
bool isRegisterMode = false; // false = Login, true = Register
|
||||
|
||||
/// تبديل عرض نموذج الدخول/التسجيل اليدوي
|
||||
void toggleManualFormView() {
|
||||
showManualForm = !showManualForm;
|
||||
// مسح الحقول عند إغلاق النموذج
|
||||
if (!showManualForm) {
|
||||
emailController.clear();
|
||||
passwordController.clear();
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
/// تبديل بين وضع تسجيل الدخول ووضع إنشاء حساب جديد
|
||||
void toggleRegisterMode() {
|
||||
isRegisterMode = !isRegisterMode;
|
||||
update();
|
||||
}
|
||||
|
||||
bool isRegistering = false;
|
||||
|
||||
void toggleRegistration() {
|
||||
isRegistering = !isRegistering;
|
||||
update();
|
||||
}
|
||||
|
||||
bool isPasswordHidden = true;
|
||||
|
||||
void togglePasswordVisibility() {
|
||||
isPasswordHidden = !isPasswordHidden;
|
||||
update([
|
||||
'passwordVisibility'
|
||||
]); // Use a unique ID to only update the password field
|
||||
}
|
||||
|
||||
void changeGoogleDashOpen() {
|
||||
isGoogleDashOpen = !isGoogleDashOpen;
|
||||
update();
|
||||
@@ -195,8 +232,10 @@ class LoginDriverController extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> getLocationPermission() async {
|
||||
Get.put(LocationBackgroundController()).requestLocationPermission();
|
||||
|
||||
var status = await Permission.locationAlways.status;
|
||||
if (!status.isGranted) {
|
||||
await Permission.locationAlways.request();
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -229,9 +268,10 @@ class LoginDriverController extends GetxController {
|
||||
loginWithGoogleCredential(String driverID, email) async {
|
||||
isloading = true;
|
||||
update();
|
||||
await SecurityHelper.performSecurityChecks();
|
||||
// await SecurityHelper.performSecurityChecks();
|
||||
Log.print('(BoxName.emailDriver): ${box.read(BoxName.emailDriver)}');
|
||||
|
||||
Log.print('email: ${email}');
|
||||
Log.print('driverID: ${driverID}');
|
||||
var res = await CRUD().get(link: AppLink.loginFromGoogleCaptin, payload: {
|
||||
'email': email,
|
||||
'id': driverID,
|
||||
@@ -312,10 +352,14 @@ class LoginDriverController extends GetxController {
|
||||
key: BoxName.fingerPrint, value: fingerPrint.toString());
|
||||
|
||||
if (token != 'failure') {
|
||||
Log.print(
|
||||
'box.read(BoxName.tokenDriver): ${box.read(BoxName.tokenDriver)}');
|
||||
Log.print(
|
||||
' (jsonDecode(token): ${(jsonDecode(token)['data'][0]['token']).toString()}');
|
||||
if ((jsonDecode(token)['data'][0]['token']) !=
|
||||
(box.read(BoxName.tokenDriver))) {
|
||||
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
|
||||
'token change'.tr,
|
||||
'token change',
|
||||
'change device'.tr,
|
||||
(jsonDecode(token)['data'][0]['token']).toString(),
|
||||
[],
|
||||
@@ -342,14 +386,7 @@ class LoginDriverController extends GetxController {
|
||||
(box.read(BoxName.driverID)).toString(),
|
||||
'fingerPrint': (fingerPrint).toString()
|
||||
});
|
||||
// await CRUD().post(
|
||||
// link:
|
||||
// "${AppLink.seferGizaServer}/ride/firebase/addDriver.php",
|
||||
// payload: {
|
||||
// 'token': box.read(BoxName.tokenDriver),
|
||||
// 'captain_id':
|
||||
// box.read(BoxName.driverID).toString()
|
||||
// });
|
||||
|
||||
Get.back();
|
||||
}));
|
||||
}
|
||||
@@ -374,7 +411,7 @@ class LoginDriverController extends GetxController {
|
||||
loginUsingCredentialsWithoutGoogle(String password, email) async {
|
||||
isloading = true;
|
||||
isGoogleLogin = true;
|
||||
update();
|
||||
// update();
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.loginUsingCredentialsWithoutGoogle, payload: {
|
||||
'email': (email),
|
||||
|
||||
@@ -71,7 +71,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
|
||||
Future getToken() async {
|
||||
fcmToken.getToken().then((token) {
|
||||
// Log.print('token: ${token}');
|
||||
Log.print('token: ${token}');
|
||||
box.write(BoxName.tokenDriver, (token!));
|
||||
});
|
||||
|
||||
@@ -98,7 +98,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> fireBaseTitles(RemoteMessage message) async {
|
||||
if (message.notification!.title! == 'Order'.tr) {
|
||||
if (message.notification!.title! == 'Order') {
|
||||
if (Platform.isAndroid) {
|
||||
notificationController.showNotification(
|
||||
message.notification!.title.toString(),
|
||||
|
||||
39
lib/controller/functions/battery_status.dart
Normal file
39
lib/controller/functions/battery_status.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:battery_plus/battery_plus.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class BatteryNotifier {
|
||||
static final Battery _battery = Battery();
|
||||
static int? _lastNotifiedLevel;
|
||||
|
||||
static Future<void> checkBatteryAndNotify() async {
|
||||
try {
|
||||
final int batteryLevel = await _battery.batteryLevel;
|
||||
|
||||
// ✅ لا تكرر الإشعار إذا الفرق قليل
|
||||
if (_lastNotifiedLevel != null &&
|
||||
(batteryLevel >= _lastNotifiedLevel! - 2)) return;
|
||||
|
||||
if (batteryLevel <= 30) {
|
||||
Color backgroundColor = Colors.yellow;
|
||||
if (batteryLevel <= 20) {
|
||||
backgroundColor = Colors.red;
|
||||
}
|
||||
|
||||
Get.snackbar(
|
||||
"⚠️ تنبيه البطارية", // العنوان
|
||||
"مستوى البطارية: $batteryLevel٪", // النص
|
||||
snackPosition: SnackPosition.TOP,
|
||||
backgroundColor: backgroundColor,
|
||||
colorText: Colors.white,
|
||||
duration: const Duration(seconds: 10), // مدة الظهور
|
||||
margin: const EdgeInsets.all(10),
|
||||
);
|
||||
|
||||
_lastNotifiedLevel = batteryLevel;
|
||||
}
|
||||
} catch (e) {
|
||||
print('Battery check error: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
206
lib/controller/functions/device_analyzer.dart
Normal file
206
lib/controller/functions/device_analyzer.dart
Normal file
@@ -0,0 +1,206 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
|
||||
import 'performance_test.dart';
|
||||
|
||||
/// Analyzes various device hardware and software aspects to generate a compatibility score.
|
||||
/// This class provides a standardized output for the UI to consume easily.
|
||||
class DeviceAnalyzer {
|
||||
final DeviceInfoPlugin _deviceInfo = DeviceInfoPlugin();
|
||||
|
||||
/// Reads the total RAM from the system's meminfo file.
|
||||
/// Returns the value in Megabytes (MB).
|
||||
Future<double> _readTotalRamMB() async {
|
||||
try {
|
||||
final file = File('/proc/meminfo');
|
||||
if (!await file.exists()) return 0.0;
|
||||
final lines = await file.readAsLines();
|
||||
for (var line in lines) {
|
||||
if (line.startsWith('MemTotal')) {
|
||||
// Extracts the numeric value from the line.
|
||||
final kb = int.tryParse(RegExp(r'\d+').stringMatch(line) ?? '0') ?? 0;
|
||||
return kb / 1024.0; // Convert from Kilobytes to Megabytes
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print('❌ Error reading total RAM: $e');
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/// Reads the current RAM usage percentage from the system's meminfo file.
|
||||
Future<double> _readUsedRamPercent() async {
|
||||
try {
|
||||
final file = File('/proc/meminfo');
|
||||
if (!await file.exists()) return 0.0;
|
||||
final lines = await file.readAsLines();
|
||||
int? total, available;
|
||||
for (var line in lines) {
|
||||
if (line.startsWith('MemTotal')) {
|
||||
total = int.tryParse(RegExp(r'\d+').stringMatch(line) ?? '');
|
||||
} else if (line.startsWith('MemAvailable')) {
|
||||
available = int.tryParse(RegExp(r'\d+').stringMatch(line) ?? '');
|
||||
}
|
||||
}
|
||||
if (total != null && available != null && total > 0) {
|
||||
final used = total - available;
|
||||
return (used / total) * 100.0;
|
||||
}
|
||||
} catch (e) {
|
||||
print('❌ Error reading used RAM: $e');
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/// The main analysis function that runs all checks.
|
||||
Future<Map<String, dynamic>> analyzeDevice() async {
|
||||
List<Map<String, dynamic>> details = [];
|
||||
|
||||
if (!Platform.isAndroid) {
|
||||
return {
|
||||
'score': 0,
|
||||
'details': [
|
||||
{
|
||||
'label': 'النظام غير مدعوم',
|
||||
'status': false,
|
||||
'achieved_score': 0,
|
||||
'max_score': 100
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
final info = await _deviceInfo.androidInfo;
|
||||
final data = info.data;
|
||||
final features = List<String>.from(data['systemFeatures'] ?? []);
|
||||
|
||||
// 1. Android Version (Max: 10 points)
|
||||
final version =
|
||||
int.tryParse(info.version.release?.split('.').first ?? '0') ?? 0;
|
||||
final int androidScore = version >= 9 ? 10 : 0;
|
||||
details.add({
|
||||
'label': 'إصدار أندرويد ${info.version.release}',
|
||||
'status': androidScore > 0,
|
||||
'achieved_score': androidScore,
|
||||
'max_score': 10,
|
||||
});
|
||||
|
||||
// 2. Total RAM (Max: 10 points)
|
||||
final totalRam = await _readTotalRamMB();
|
||||
int ramScore;
|
||||
if (totalRam >= 8000) {
|
||||
ramScore = 10;
|
||||
} else if (totalRam >= 4000) {
|
||||
ramScore = 5;
|
||||
} else if (totalRam >= 3000) {
|
||||
ramScore = 3;
|
||||
} else {
|
||||
ramScore = 0;
|
||||
}
|
||||
details.add({
|
||||
'label': 'إجمالي الرام ${totalRam.toStringAsFixed(0)} ميجابايت',
|
||||
'status': ramScore >= 5,
|
||||
'achieved_score': ramScore,
|
||||
'max_score': 10,
|
||||
});
|
||||
|
||||
// 3. CPU Cores (Max: 10 points)
|
||||
final cores = Platform.numberOfProcessors;
|
||||
int coreScore = cores >= 6 ? 10 : (cores >= 4 ? 5 : 0);
|
||||
details.add({
|
||||
'label': 'أنوية المعالج ($cores)',
|
||||
'status': coreScore >= 5,
|
||||
'achieved_score': coreScore,
|
||||
'max_score': 10,
|
||||
});
|
||||
|
||||
// 4. Free Storage (Max: 5 points)
|
||||
final freeBytes = data['freeDiskSize'] ?? 0;
|
||||
final freeGB = freeBytes / (1024 * 1024 * 1024);
|
||||
int storeScore = freeGB >= 5 ? 5 : (freeGB >= 2 ? 3 : 0);
|
||||
details.add({
|
||||
'label': 'المساحة الحرة ${freeGB.toStringAsFixed(1)} جيجابايت',
|
||||
'status': storeScore >= 3,
|
||||
'achieved_score': storeScore,
|
||||
'max_score': 5,
|
||||
});
|
||||
|
||||
// 5. GPS + Gyroscope Sensors (Max: 10 points)
|
||||
bool okSensors = features.contains('android.hardware.location.gps') &&
|
||||
features.contains('android.hardware.sensor.gyroscope');
|
||||
final int sensorScore = okSensors ? 10 : 0;
|
||||
details.add({
|
||||
'label': 'حساسات GPS و Gyroscope',
|
||||
'status': okSensors,
|
||||
'achieved_score': sensorScore,
|
||||
'max_score': 10,
|
||||
});
|
||||
|
||||
// 6. Storage Write Speed (Max: 20 points)
|
||||
final writeSpeed = await PerformanceTester.testStorageWriteSpeed();
|
||||
int writeScore;
|
||||
if (writeSpeed >= 30) {
|
||||
writeScore = 20;
|
||||
} else if (writeSpeed >= 15) {
|
||||
writeScore = 15;
|
||||
} else if (writeSpeed >= 5) {
|
||||
writeScore = 10;
|
||||
} else {
|
||||
writeScore = 5;
|
||||
}
|
||||
details.add({
|
||||
'label': 'سرعة الكتابة (${writeSpeed.toStringAsFixed(1)} MB/s)',
|
||||
'status': writeScore >= 10,
|
||||
'achieved_score': writeScore,
|
||||
'max_score': 20,
|
||||
});
|
||||
|
||||
// 7. CPU Compute Speed (Max: 20 points)
|
||||
final cpuTime = await PerformanceTester.testCPUSpeed();
|
||||
int cpuScore;
|
||||
if (cpuTime <= 1.0) {
|
||||
cpuScore = 20;
|
||||
} else if (cpuTime <= 2.5) {
|
||||
cpuScore = 15;
|
||||
} else if (cpuTime <= 4.0) {
|
||||
cpuScore = 10;
|
||||
} else {
|
||||
cpuScore = 5;
|
||||
}
|
||||
details.add({
|
||||
'label': 'سرعة المعالجة (${cpuTime.toStringAsFixed(2)} ثانية)',
|
||||
'status': cpuScore >= 10,
|
||||
'achieved_score': cpuScore,
|
||||
'max_score': 20,
|
||||
});
|
||||
|
||||
// 8. Memory Pressure (Max: 15 points)
|
||||
final usedPercent = await _readUsedRamPercent();
|
||||
int memScore;
|
||||
if (usedPercent <= 60) {
|
||||
memScore = 15;
|
||||
} else if (usedPercent <= 80) {
|
||||
memScore = 10;
|
||||
} else if (usedPercent <= 90) {
|
||||
memScore = 5;
|
||||
} else {
|
||||
memScore = 0;
|
||||
}
|
||||
details.add({
|
||||
'label': 'استخدام الرام الحالي (${usedPercent.toStringAsFixed(0)}%)',
|
||||
'status': memScore >= 10,
|
||||
'achieved_score': memScore,
|
||||
'max_score': 15,
|
||||
});
|
||||
|
||||
// Calculate the final total score by summing up the achieved scores.
|
||||
final totalScore = details.fold<int>(
|
||||
0, (sum, item) => sum + (item['achieved_score'] as int));
|
||||
|
||||
return {
|
||||
'score': totalScore.clamp(0, 100),
|
||||
'details': details,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,54 +1,54 @@
|
||||
import 'dart:async';
|
||||
import 'package:background_location/background_location.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
// import 'dart:async';
|
||||
// import 'package:background_location/background_location.dart';
|
||||
// import 'package:get/get.dart';
|
||||
// import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class LocationBackgroundController extends GetxController {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
requestLocationPermission();
|
||||
configureBackgroundLocation();
|
||||
}
|
||||
// class LocationBackgroundController extends GetxController {
|
||||
// @override
|
||||
// void onInit() {
|
||||
// super.onInit();
|
||||
// requestLocationPermission();
|
||||
// configureBackgroundLocation();
|
||||
// }
|
||||
|
||||
Future<void> requestLocationPermission() async {
|
||||
var status = await Permission.locationAlways.status;
|
||||
if (!status.isGranted) {
|
||||
await Permission.locationAlways.request();
|
||||
}
|
||||
}
|
||||
// Future<void> requestLocationPermission() async {
|
||||
// var status = await Permission.locationAlways.status;
|
||||
// if (!status.isGranted) {
|
||||
// await Permission.locationAlways.request();
|
||||
// }
|
||||
// }
|
||||
|
||||
Future<void> configureBackgroundLocation() async {
|
||||
await BackgroundLocation.setAndroidNotification(
|
||||
title: 'Location Tracking Active'.tr,
|
||||
message: 'Your location is being tracked in the background.'.tr,
|
||||
icon: '@mipmap/launcher_icon',
|
||||
);
|
||||
// Future<void> configureBackgroundLocation() async {
|
||||
// await BackgroundLocation.setAndroidNotification(
|
||||
// title: 'Location Tracking Active'.tr,
|
||||
// message: 'Your location is being tracked in the background.'.tr,
|
||||
// icon: '@mipmap/launcher_icon',
|
||||
// );
|
||||
|
||||
BackgroundLocation.setAndroidConfiguration(3000);
|
||||
BackgroundLocation.startLocationService();
|
||||
BackgroundLocation.getLocationUpdates((location) {
|
||||
// Handle location updates here
|
||||
});
|
||||
}
|
||||
// BackgroundLocation.setAndroidConfiguration(3000);
|
||||
// BackgroundLocation.startLocationService();
|
||||
// BackgroundLocation.getLocationUpdates((location) {
|
||||
// // Handle location updates here
|
||||
// });
|
||||
// }
|
||||
|
||||
startBackLocation() async {
|
||||
Timer.periodic(const Duration(seconds: 3), (timer) {
|
||||
getBackgroundLocation();
|
||||
});
|
||||
}
|
||||
// startBackLocation() async {
|
||||
// Timer.periodic(const Duration(seconds: 3), (timer) {
|
||||
// getBackgroundLocation();
|
||||
// });
|
||||
// }
|
||||
|
||||
getBackgroundLocation() async {
|
||||
var status = await Permission.locationAlways.status;
|
||||
if (status.isGranted) {
|
||||
await BackgroundLocation.startLocationService(
|
||||
distanceFilter: 20, forceAndroidLocationManager: true);
|
||||
BackgroundLocation.setAndroidConfiguration(
|
||||
Duration.microsecondsPerSecond); // Set interval to 5 seconds
|
||||
// getBackgroundLocation() async {
|
||||
// var status = await Permission.locationAlways.status;
|
||||
// if (status.isGranted) {
|
||||
// await BackgroundLocation.startLocationService(
|
||||
// distanceFilter: 20, forceAndroidLocationManager: true);
|
||||
// BackgroundLocation.setAndroidConfiguration(
|
||||
// Duration.microsecondsPerSecond); // Set interval to 5 seconds
|
||||
|
||||
BackgroundLocation.getLocationUpdates((location1) {});
|
||||
} else {
|
||||
await Permission.locationAlways.request();
|
||||
}
|
||||
}
|
||||
}
|
||||
// BackgroundLocation.getLocationUpdates((location1) {});
|
||||
// } else {
|
||||
// await Permission.locationAlways.request();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -12,6 +12,7 @@ import '../../main.dart';
|
||||
import '../../print.dart';
|
||||
import '../home/captin/home_captain_controller.dart';
|
||||
import '../home/payment/captain_wallet_controller.dart';
|
||||
import 'battery_status.dart';
|
||||
import 'crud.dart';
|
||||
import 'encrypt_decrypt.dart';
|
||||
|
||||
@@ -40,6 +41,7 @@ class LocationController extends GetxController {
|
||||
location = Location();
|
||||
await location.changeSettings(
|
||||
accuracy: LocationAccuracy.high, interval: 5000, distanceFilter: 0);
|
||||
await location.enableBackgroundMode(enable: true);
|
||||
await getLocation();
|
||||
await startLocationUpdates();
|
||||
|
||||
@@ -82,6 +84,7 @@ class LocationController extends GetxController {
|
||||
_locationTimer =
|
||||
Timer.periodic(const Duration(seconds: 5), (timer) async {
|
||||
try {
|
||||
await BatteryNotifier.checkBatteryAndNotify();
|
||||
totalPoints =
|
||||
Get.find<CaptainWalletController>().totalPoints.toString();
|
||||
isActive = Get.find<HomeCaptainController>().isActive;
|
||||
|
||||
43
lib/controller/functions/performance_test.dart
Normal file
43
lib/controller/functions/performance_test.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'dart:io';
|
||||
|
||||
class PerformanceTester {
|
||||
/// ✅ فحص سرعة الكتابة إلى التخزين (Storage Write Speed) بوحدة MB/s
|
||||
static Future<double> testStorageWriteSpeed() async {
|
||||
try {
|
||||
final tempDir = Directory.systemTemp;
|
||||
final testFile = File('${tempDir.path}/speed_test.txt');
|
||||
final data = List<int>.filled(1024 * 1024 * 5, 0); // 5MB
|
||||
|
||||
final stopwatch = Stopwatch()..start();
|
||||
await testFile.writeAsBytes(data, flush: true);
|
||||
stopwatch.stop();
|
||||
|
||||
await testFile.delete();
|
||||
|
||||
double seconds = stopwatch.elapsedMilliseconds / 1000;
|
||||
if (seconds == 0) seconds = 0.001;
|
||||
|
||||
final speed = 5 / seconds;
|
||||
return double.parse(speed.toStringAsFixed(2));
|
||||
} catch (e) {
|
||||
print("❌ Storage write error: $e");
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
/// ✅ فحص سرعة المعالج (CPU Compute Speed) بوحدة الثواني
|
||||
static Future<double> testCPUSpeed() async {
|
||||
try {
|
||||
final stopwatch = Stopwatch()..start();
|
||||
double x = 0;
|
||||
for (int i = 0; i < 100000000; i++) {
|
||||
x += i * 0.000001;
|
||||
}
|
||||
stopwatch.stop();
|
||||
return stopwatch.elapsedMilliseconds / 1000.0;
|
||||
} catch (e) {
|
||||
print("❌ CPU compute error: $e");
|
||||
return 999.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ class HomeCaptainController extends GetxController {
|
||||
double widthMapTypeAndTraffic = 50;
|
||||
// Inject the LocationController class
|
||||
final locationController = Get.put(LocationController());
|
||||
final locationBackController = Get.put(LocationBackgroundController());
|
||||
// final locationBackController = Get.put(LocationBackgroundController());
|
||||
String formatDuration(Duration duration) {
|
||||
String twoDigits(int n) => n.toString().padLeft(2, "0");
|
||||
String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60));
|
||||
|
||||
@@ -65,7 +65,44 @@ class MyTranslation extends Translations {
|
||||
"Order Applied": "تم تطبيق الطلب",
|
||||
|
||||
//firebase above
|
||||
|
||||
"Driver Portal": "بوابة السائق",
|
||||
"Sign in to start your journey": "سجّل الدخول لبدء رحلتك",
|
||||
"Sign in with a provider for easy access":
|
||||
"سجّل الدخول عبر أحد المزودين للوصول بسهولة",
|
||||
"Sign In with Google": "تسجيل الدخول باستخدام جوجل",
|
||||
"Sign in with Apple": "تسجيل الدخول باستخدام آبل",
|
||||
"Or": "أو",
|
||||
'Is device compatible': 'هل الجهاز متوافق',
|
||||
"Create Account with Email": "إنشاء حساب بالبريد الإلكتروني",
|
||||
"Need help? Contact Us": "هل تحتاج للمساعدة؟ تواصل معنا",
|
||||
"Create Driver Account": "إنشاء حساب سائق",
|
||||
"Driver Login": "تسجيل دخول السائق",
|
||||
"Email": "البريد الإلكتروني",
|
||||
"Enter your email": "أدخل بريدك الإلكتروني",
|
||||
"Please enter a valid email": "الرجاء إدخال بريد إلكتروني صالح",
|
||||
"Password": "كلمة المرور",
|
||||
"Enter your password": "أدخل كلمة المرور",
|
||||
"Password must be at least 6 characters":
|
||||
"يجب أن تتكون كلمة المرور من 6 أحرف على الأقل",
|
||||
"Create Account": "إنشاء حساب",
|
||||
"Login": "تسجيل الدخول",
|
||||
"Back to other sign-in options": "العودة إلى خيارات التسجيل الأخرى",
|
||||
"Driver Agreement": "اتفاقية السائق",
|
||||
"To become a driver, you must review and agree to the ":
|
||||
"لتصبح سائقًا، يجب عليك مراجعة والموافقة على ",
|
||||
"Terms of Use": "شروط الاستخدام",
|
||||
" and acknowledge our Privacy Policy.":
|
||||
" والإقرار بسياسة الخصوصية الخاصة بنا.",
|
||||
"I Agree": "أنا أوافق",
|
||||
"Continue": "متابعة",
|
||||
"Privacy Policy": "سياسة الخصوصية",
|
||||
"Location Access Required": "مطلوب الوصول إلى الموقع",
|
||||
"We need access to your location to match you with nearby passengers and provide accurate navigation.":
|
||||
"نحتاج للوصول إلى موقعك لمطابقتك مع الركاب القريبين وتوفير توجيه دقيق.",
|
||||
"Please allow location access \"all the time\" to receive ride requests even when the app is in the background.":
|
||||
"الرجاء السماح بالوصول إلى الموقع \"طوال الوقت\" لاستقبال طلبات الرحلات حتى عندما يكون التطبيق في الخلفية.",
|
||||
"Allow Location Access": "السماح بالوصول إلى الموقع",
|
||||
"Open Settings": "فتح الإعدادات",
|
||||
"payment_success": "تمت العملية بنجاح",
|
||||
"transaction_id": "رقم العملية",
|
||||
"amount_paid": "المبلغ المدفوع",
|
||||
|
||||
@@ -15,7 +15,7 @@ class DriverWalletHistoryController extends GetxController {
|
||||
getArchivePayment() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().get(
|
||||
var res = await CRUD().getWallet(
|
||||
link: AppLink.getWalletByDriver,
|
||||
payload: {'driverID': box.read(BoxName.driverID)});
|
||||
if (res == 'failure') {
|
||||
@@ -40,7 +40,7 @@ class DriverWalletHistoryController extends GetxController {
|
||||
getWeekllyArchivePayment() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().get(
|
||||
var res = await CRUD().getWallet(
|
||||
link: AppLink.getDriverWeekPaymentMove,
|
||||
payload: {'driverID': box.read(BoxName.driverID)});
|
||||
if (res == 'failure') {
|
||||
|
||||
@@ -13,7 +13,7 @@ ThemeData lightThemeEnglish = ThemeData(
|
||||
bodyMedium: AppStyle.subtitle,
|
||||
),
|
||||
primarySwatch: Colors.blue,
|
||||
dialogTheme: DialogTheme(
|
||||
dialogTheme: DialogThemeData(
|
||||
backgroundColor: AppColor.secondaryColor,
|
||||
contentTextStyle: AppStyle.title,
|
||||
titleTextStyle: AppStyle.headTitle2,
|
||||
@@ -49,7 +49,7 @@ ThemeData darkThemeEnglish = ThemeData(
|
||||
bodyMedium: AppStyle.subtitle,
|
||||
),
|
||||
primarySwatch: Colors.blue,
|
||||
dialogTheme: DialogTheme(
|
||||
dialogTheme: DialogThemeData(
|
||||
backgroundColor: AppColor.secondaryColor,
|
||||
contentTextStyle: AppStyle.title,
|
||||
titleTextStyle: AppStyle.headTitle2,
|
||||
@@ -85,7 +85,7 @@ ThemeData lightThemeArabic = ThemeData(
|
||||
bodyMedium: AppStyle.subtitle,
|
||||
),
|
||||
primarySwatch: Colors.blue,
|
||||
dialogTheme: DialogTheme(
|
||||
dialogTheme: DialogThemeData(
|
||||
backgroundColor: AppColor.secondaryColor,
|
||||
contentTextStyle: AppStyle.title,
|
||||
titleTextStyle: AppStyle.headTitle2,
|
||||
@@ -121,7 +121,7 @@ ThemeData darkThemeArabic = ThemeData(
|
||||
bodyMedium: AppStyle.subtitle,
|
||||
),
|
||||
primarySwatch: Colors.blue,
|
||||
dialogTheme: DialogTheme(
|
||||
dialogTheme: DialogThemeData(
|
||||
backgroundColor: AppColor.secondaryColor,
|
||||
contentTextStyle: AppStyle.title,
|
||||
titleTextStyle: AppStyle.headTitle2,
|
||||
|
||||
@@ -170,6 +170,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
||||
|
||||
await FirebaseMessaging.instance.requestPermission();
|
||||
FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler);
|
||||
await FirebaseMessagesController().getToken();
|
||||
await NotificationController().initNotifications();
|
||||
|
||||
// You can add your other initializations here
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,248 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import '../../../../controller/functions/device_analyzer.dart';
|
||||
|
||||
// --- CompatibilityDetailCard Widget (Updated to use 'max_score') ---
|
||||
class CompatibilityDetailCard extends StatelessWidget {
|
||||
final Map<String, dynamic> detail;
|
||||
const CompatibilityDetailCard({super.key, required this.detail});
|
||||
|
||||
Color _getStatusColor(bool status, int achieved, int max) {
|
||||
if (!status) return Colors.red.shade400;
|
||||
if (achieved < max) return Colors.orange.shade600;
|
||||
return Colors.teal;
|
||||
}
|
||||
|
||||
IconData _getIconForLabel(String label) {
|
||||
if (label.contains('رام')) return Icons.memory;
|
||||
if (label.contains('معالج') || label.contains('CPU')) {
|
||||
return Icons.developer_board;
|
||||
}
|
||||
if (label.contains('تخزين') || label.contains('كتابة')) {
|
||||
return Icons.sd_storage_outlined;
|
||||
}
|
||||
if (label.contains('أندرويد')) return Icons.android;
|
||||
if (label.contains('خدمات')) return Icons.g_mobiledata;
|
||||
if (label.contains('حساسات') || label.contains('Gyroscope')) {
|
||||
return Icons.sensors;
|
||||
}
|
||||
return Icons.smartphone;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bool status = detail['status'] ?? false;
|
||||
final String label = detail['label'] ?? "";
|
||||
final int achievedScore = detail['achieved_score'] ?? 0;
|
||||
// Corrected to use 'max_score' from the analyzer
|
||||
final int maxScore = detail['max_score'] ?? 1;
|
||||
final Color color = _getStatusColor(status, achievedScore, maxScore);
|
||||
final double progress =
|
||||
(maxScore > 0) ? (achievedScore / maxScore).clamp(0.0, 1.0) : 0.0;
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 7),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.08),
|
||||
blurRadius: 15,
|
||||
offset: const Offset(0, 5),
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(_getIconForLabel(label),
|
||||
color: Colors.grey.shade600, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.grey.shade800,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
// Corrected to display points out of max_score
|
||||
Text(
|
||||
"$achievedScore/$maxScore نقطة",
|
||||
style: TextStyle(
|
||||
color: color, fontWeight: FontWeight.bold, fontSize: 14),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
LinearProgressIndicator(
|
||||
value: progress,
|
||||
backgroundColor: Colors.grey.shade200,
|
||||
color: color,
|
||||
minHeight: 6,
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Main Page Widget ---
|
||||
class DeviceCompatibilityPage extends StatefulWidget {
|
||||
const DeviceCompatibilityPage({super.key});
|
||||
@override
|
||||
State<DeviceCompatibilityPage> createState() =>
|
||||
_DeviceCompatibilityPageState();
|
||||
}
|
||||
|
||||
class _DeviceCompatibilityPageState extends State<DeviceCompatibilityPage> {
|
||||
int score = 0;
|
||||
List<Map<String, dynamic>> details = [];
|
||||
bool isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initializePage();
|
||||
}
|
||||
|
||||
Future<void> _initializePage() async {
|
||||
// await BatteryNotifier.checkBatteryAndNotify();
|
||||
final result = await DeviceAnalyzer().analyzeDevice();
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
score = result['score'];
|
||||
details = List<Map<String, dynamic>>.from(result['details']);
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Color _getColorForScore(int value) {
|
||||
if (value >= 80) return Colors.teal;
|
||||
if (value >= 60) return Colors.orange.shade700;
|
||||
return Colors.red.shade600;
|
||||
}
|
||||
|
||||
String _getScoreMessage(int value) {
|
||||
if (value >= 80) return "جهازك يقدم أداءً ممتازاً";
|
||||
if (value >= 60) return "جهازك جيد ومناسب جداً";
|
||||
if (value >= 40) return "متوافق، قد تلاحظ بعض البطء";
|
||||
return "قد لا يعمل التطبيق بالشكل الأمثل";
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF7F8FC),
|
||||
appBar: AppBar(
|
||||
title: const Text("توافق الجهاز",
|
||||
style:
|
||||
TextStyle(color: Colors.black87, fontWeight: FontWeight.bold)),
|
||||
centerTitle: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
iconTheme: const IconThemeData(color: Colors.black87),
|
||||
),
|
||||
body: isLoading
|
||||
? const Center(child: CircularProgressIndicator(color: Colors.teal))
|
||||
: Column(
|
||||
children: [
|
||||
_buildScoreHeader(),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 10, bottom: 20),
|
||||
itemCount: details.length,
|
||||
itemBuilder: (context, i) =>
|
||||
CompatibilityDetailCard(detail: details[i]),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 24),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.teal,
|
||||
minimumSize: const Size(double.infinity, 50),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
elevation: 0,
|
||||
),
|
||||
onPressed: () => Get.back(),
|
||||
child: const Text("المتابعة إلى التطبيق",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// ## Corrected Score Header Widget
|
||||
/// This widget now uses a `Stack` to correctly place the text over the `PieChart`.
|
||||
Widget _buildScoreHeader() {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
height: 220, // Give the container a fixed height
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
// Layer 1: The Pie Chart
|
||||
PieChart(
|
||||
PieChartData(
|
||||
sectionsSpace: 4,
|
||||
// This creates the "hole" in the middle.
|
||||
centerSpaceRadius: 80,
|
||||
startDegreeOffset: -90,
|
||||
sections: [
|
||||
PieChartSectionData(
|
||||
color: _getColorForScore(score),
|
||||
value: score.toDouble(),
|
||||
title: '',
|
||||
radius: 25,
|
||||
),
|
||||
PieChartSectionData(
|
||||
color: Colors.grey.shade200,
|
||||
value: (100 - score).toDouble().clamp(0, 100),
|
||||
title: '',
|
||||
radius: 25,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Layer 2: The text and message, centered on top of the chart
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"$score%",
|
||||
style: TextStyle(
|
||||
fontSize: 52,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _getColorForScore(score)),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
_getScoreMessage(score),
|
||||
style: TextStyle(
|
||||
color: Colors.grey.shade700,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:sefer_driver/constant/links.dart';
|
||||
import 'package:sefer_driver/constant/style.dart';
|
||||
import 'package:sefer_driver/controller/home/captin/home_captain_controller.dart';
|
||||
@@ -25,6 +27,8 @@ import '../assurance_health_page.dart';
|
||||
import '../maintain_center_page.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
import 'device_compatibility_page.dart';
|
||||
|
||||
// class CupertinoDrawerCaptain extends StatelessWidget {
|
||||
// final ImageController imageController = Get.put(ImageController());
|
||||
|
||||
@@ -363,10 +367,17 @@ class CupertinoDrawerCaptain extends StatelessWidget {
|
||||
onTap: () => Get.to(() => RatingScreen()),
|
||||
),
|
||||
_buildDrawerItem(
|
||||
icon: CupertinoIcons.settings_solid,
|
||||
text: 'Settings'.tr,
|
||||
onTap: () => Get.to(() => const SettingsCaptain()),
|
||||
icon: Icons.memory,
|
||||
text: 'Is device compatible'.tr,
|
||||
onTap: () => Get.to(() => const DeviceCompatibilityPage()),
|
||||
),
|
||||
Platform.isAndroid
|
||||
? _buildDrawerItem(
|
||||
icon: CupertinoIcons.settings_solid,
|
||||
text: 'Settings'.tr,
|
||||
onTap: () => Get.to(() => const SettingsCaptain()),
|
||||
)
|
||||
: SizedBox(),
|
||||
_buildDrawerItem(
|
||||
icon: CupertinoIcons.square_arrow_right,
|
||||
text: 'Sign Out'.tr,
|
||||
|
||||
@@ -26,6 +26,86 @@ import 'widget/connect.dart';
|
||||
import 'widget/left_menu_map_captain.dart';
|
||||
import '../../../../main.dart';
|
||||
|
||||
// =================================================================
|
||||
// STEP 1: Modify your LocationController
|
||||
// =================================================================
|
||||
/*
|
||||
In your `location_controller.dart` file, change `myLocation` and `heading`
|
||||
to be observable by adding `.obs`. This will allow other parts of your app,
|
||||
like the map, to automatically react to changes.
|
||||
|
||||
// BEFORE:
|
||||
// LatLng myLocation = LatLng(....);
|
||||
// double heading = 0.0;
|
||||
|
||||
// AFTER:
|
||||
final myLocation = const LatLng(30.0444, 31.2357).obs; // Default to Cairo or a sensible default
|
||||
final heading = 0.0.obs;
|
||||
|
||||
// When you update these values elsewhere in your controller,
|
||||
// make sure to update their `.value` property.
|
||||
// e.g., myLocation.value = newLatLng;
|
||||
// e.g., heading.value = newHeading;
|
||||
*/
|
||||
|
||||
// =================================================================
|
||||
// STEP 2: Modify your HomeCaptainController
|
||||
// =================================================================
|
||||
/*
|
||||
In your `home_captain_controller.dart` file, you need to add logic to
|
||||
listen for changes from the LocationController and animate the camera.
|
||||
|
||||
class HomeCaptainController extends GetxController {
|
||||
// ... your existing variables (mapController, carIcon, etc.)
|
||||
|
||||
// Make sure you have a reference to the GoogleMapController
|
||||
GoogleMapController? mapHomeCaptainController;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
_setupLocationListener();
|
||||
}
|
||||
|
||||
void onMapCreated(GoogleMapController controller) {
|
||||
mapHomeCaptainController = controller;
|
||||
// Any other map setup logic
|
||||
}
|
||||
|
||||
// THIS IS THE NEW LOGIC TO ADD
|
||||
void _setupLocationListener() {
|
||||
final locationController = Get.find<LocationController>();
|
||||
|
||||
// The 'ever' worker from GetX listens for changes to an observable variable.
|
||||
// Whenever `heading` or `myLocation` changes, it will call our method.
|
||||
ever(locationController.heading, (_) => _updateCameraPosition());
|
||||
ever(locationController.myLocation, (_) => _updateCameraPosition());
|
||||
}
|
||||
|
||||
void _updateCameraPosition() {
|
||||
final locationController = Get.find<LocationController>();
|
||||
if (mapHomeCaptainController != null) {
|
||||
final newPosition = CameraPosition(
|
||||
target: locationController.myLocation.value,
|
||||
zoom: 17.5, // A bit closer for a navigation feel
|
||||
tilt: 50.0, // A nice 3D perspective
|
||||
bearing: locationController.heading.value, // This rotates the map
|
||||
);
|
||||
|
||||
// Animate the camera smoothly to the new position and rotation
|
||||
mapHomeCaptainController!.animateCamera(
|
||||
CameraUpdate.newCameraPosition(newPosition),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ... rest of your controller code
|
||||
}
|
||||
*/
|
||||
|
||||
// =================================================================
|
||||
// STEP 3: Update the HomeCaptain Widget
|
||||
// =================================================================
|
||||
class HomeCaptain extends StatelessWidget {
|
||||
HomeCaptain({super.key});
|
||||
final LocationController locationController = Get.put(LocationController());
|
||||
@@ -34,16 +114,12 @@ class HomeCaptain extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Get.put(OrderRequestController());
|
||||
Get.put(HomeCaptainController());
|
||||
// Get.put(CaptainWalletController());
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
closeOverlayIfFound();
|
||||
checkForUpdate(context);
|
||||
getPermissionOverlay();
|
||||
showDriverGiftClaim(context);
|
||||
// getPermissionLocation1();
|
||||
// await showFirstTimeOfferNotification(context);
|
||||
});
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
@@ -118,14 +194,18 @@ class HomeCaptain extends StatelessWidget {
|
||||
onPressed: homeCaptainController.changeMapTraffic,
|
||||
),
|
||||
_MapControlButton(
|
||||
icon: Icons.location_on,
|
||||
tooltip: 'My Location'.tr,
|
||||
icon: Icons.my_location, // Changed for clarity
|
||||
tooltip: 'Center on Me'.tr,
|
||||
onPressed: () {
|
||||
homeCaptainController.mapHomeCaptainController!
|
||||
.animateCamera(CameraUpdate.newLatLng(LatLng(
|
||||
Get.find<LocationController>().myLocation.latitude,
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
)));
|
||||
// This button now just re-centers without changing rotation
|
||||
if (homeCaptainController.mapHomeCaptainController !=
|
||||
null) {
|
||||
homeCaptainController.mapHomeCaptainController!
|
||||
.animateCamera(CameraUpdate.newLatLngZoom(
|
||||
Get.find<LocationController>().myLocation,
|
||||
17.5,
|
||||
));
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -134,47 +214,57 @@ class HomeCaptain extends StatelessWidget {
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
),
|
||||
|
||||
drawer:
|
||||
CupertinoDrawerCaptain(), // Add this widget at the bottom of the file
|
||||
drawer: CupertinoDrawerCaptain(),
|
||||
body: Stack(
|
||||
children: [
|
||||
GetBuilder<HomeCaptainController>(builder: (homeCaptainController) {
|
||||
return homeCaptainController.isLoading
|
||||
// FIX: Replaced nested GetBuilder/Obx with a single GetX widget.
|
||||
// GetX handles both observable (.obs) variables and standard controller updates.
|
||||
GetBuilder<HomeCaptainController>(builder: (controller) {
|
||||
return controller.isLoading
|
||||
? const MyCircularProgressIndicator()
|
||||
: GoogleMap(
|
||||
onMapCreated: homeCaptainController.onMapCreated,
|
||||
// cameraTargetBounds: CameraTargetBounds(controller.boundsdata),
|
||||
onMapCreated: controller.onMapCreated,
|
||||
minMaxZoomPreference: const MinMaxZoomPreference(6, 18),
|
||||
|
||||
initialCameraPosition: CameraPosition(
|
||||
// Use .value to get the latest location from the reactive variable
|
||||
target: locationController.myLocation,
|
||||
zoom: 15,
|
||||
),
|
||||
onCameraMove: (position) {
|
||||
CameraPosition(
|
||||
target: locationController.myLocation,
|
||||
zoom: 17.5, // A bit closer for a navigation feel
|
||||
tilt: 50.0, // A nice 3D perspective
|
||||
bearing:
|
||||
locationController.heading, // This rotates the map
|
||||
);
|
||||
},
|
||||
markers: {
|
||||
Marker(
|
||||
markerId: MarkerId('MyLocation'.tr),
|
||||
position: locationController.myLocation,
|
||||
draggable: false,
|
||||
icon: homeCaptainController.carIcon,
|
||||
rotation: locationController.heading)
|
||||
markerId: MarkerId('MyLocation'.tr),
|
||||
// Use .value for position and rotation from the reactive variable
|
||||
position: locationController.myLocation,
|
||||
rotation: locationController.heading,
|
||||
// IMPORTANT: These two properties make the marker look
|
||||
// correct when the map is tilted and rotating.
|
||||
flat: true,
|
||||
anchor: const Offset(0.5, 0.5),
|
||||
icon: controller.carIcon,
|
||||
)
|
||||
},
|
||||
mapType: homeCaptainController.mapType
|
||||
mapType: controller.mapType
|
||||
? MapType.satellite
|
||||
: MapType.terrain,
|
||||
myLocationButtonEnabled: true,
|
||||
// liteModeEnabled: true, tiltGesturesEnabled: false,
|
||||
|
||||
// indoorViewEnabled: true,
|
||||
trafficEnabled: homeCaptainController.mapTrafficON,
|
||||
myLocationButtonEnabled: false, // Disable default button
|
||||
myLocationEnabled: false, // We use our custom marker
|
||||
trafficEnabled: controller.mapTrafficON,
|
||||
buildingsEnabled: true,
|
||||
mapToolbarEnabled: true,
|
||||
|
||||
myLocationEnabled: false,
|
||||
// liteModeEnabled: true,
|
||||
zoomControlsEnabled: false, // Cleaner UI for navigation
|
||||
);
|
||||
}),
|
||||
|
||||
// The rest of your UI remains the same...
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
right: Get.width * .1,
|
||||
@@ -384,45 +474,7 @@ class HomeCaptain extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
), // Positioned(
|
||||
// bottom: Get.height * .17,
|
||||
// right: Get.width * .01,
|
||||
// child: AnimatedContainer(
|
||||
// duration: const Duration(microseconds: 200),
|
||||
// width: Get.width * .12,
|
||||
// decoration: BoxDecoration(
|
||||
// color: AppColor.secondaryColor,
|
||||
// border: Border.all(),
|
||||
// borderRadius: BorderRadius.circular(15)),
|
||||
// child: IconButton(
|
||||
// onPressed: () async {
|
||||
// CRUD().sendEmail(AppLink.sendEmailToPassengerForTripDetails, {
|
||||
// 'startLocation': Get.find<MapDriverController>()
|
||||
// .passengerLocation
|
||||
// .toString(),
|
||||
// 'endLocation': Get.find<MapDriverController>()
|
||||
// .passengerDestination
|
||||
// .toString(),
|
||||
// 'name': Get.find<MapDriverController>().name.toString(),
|
||||
// 'timeOfTrip':
|
||||
// Get.find<MapDriverController>().timeOfOrder.toString(),
|
||||
// 'fee': Get.find<MapDriverController>()
|
||||
// .totalPassenger
|
||||
// .toString(),
|
||||
// 'duration':
|
||||
// Get.find<MapDriverController>().duration.toString(),
|
||||
// 'phone': Get.find<MapDriverController>().phone.toString(),
|
||||
// 'email': Get.find<MapDriverController>().email.toString(),
|
||||
// });
|
||||
// },
|
||||
// icon: const Icon(
|
||||
// MaterialCommunityIcons.map_marker_radius,
|
||||
// size: 45,
|
||||
// color: AppColor.blueColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
),
|
||||
Positioned(
|
||||
bottom: Get.height * .2,
|
||||
right: 6,
|
||||
@@ -438,14 +490,6 @@ class HomeCaptain extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(15)),
|
||||
child: IconButton(
|
||||
onPressed: () async {
|
||||
// final Bubble _bubble = Bubble(showCloseButton: false);
|
||||
// try {
|
||||
// await _bubble.startBubbleHead(
|
||||
// sendAppToBackground: false);
|
||||
// } on PlatformException {
|
||||
// print('Failed to call startBubbleHead');
|
||||
// }
|
||||
|
||||
Bubble().startBubbleHead(sendAppToBackground: true);
|
||||
},
|
||||
icon: Image.asset(
|
||||
@@ -483,8 +527,6 @@ class HomeCaptain extends StatelessWidget {
|
||||
),
|
||||
GetBuilder<HomeCaptainController>(
|
||||
builder: (homeCaptainController) {
|
||||
Log.print(
|
||||
'rideStatus from home 486 : ${box.read(BoxName.rideStatus)}');
|
||||
return box.read(BoxName.rideStatus) == 'Applied' ||
|
||||
box.read(BoxName.rideStatus) == 'Begin'
|
||||
? Positioned(
|
||||
@@ -537,27 +579,13 @@ class HomeCaptain extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
leftMainMenuCaptainIcons(),
|
||||
|
||||
// callPage(),
|
||||
|
||||
// Positioned(
|
||||
// top: Get.height * .2,
|
||||
// // left: 20,
|
||||
// // right: 20,
|
||||
// bottom: Get.height * .4,
|
||||
// child: IconButton(
|
||||
// onPressed: () {
|
||||
// homeCaptainController.getCountRideToday();
|
||||
// },
|
||||
// icon: const Icon(Icons.call),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// These helper widgets and functions remain unchanged
|
||||
showFirstTimeOfferNotification(BuildContext context) async {
|
||||
bool isFirstTime = _checkIfFirstTime();
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:sefer_driver/constant/box_name.dart';
|
||||
import 'package:sefer_driver/controller/firebase/local_notification.dart';
|
||||
import 'package:sefer_driver/main.dart';
|
||||
import 'package:sefer_driver/views/auth/login_page.dart';
|
||||
import 'package:sefer_driver/views/home/Captin/driver_map_page.dart';
|
||||
import 'package:sefer_driver/views/home/Captin/orderCaptin/vip_order_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -148,6 +149,9 @@ GetBuilder<HomeCaptainController> leftMainMenuCaptainIcons() {
|
||||
// child: Builder(builder: (context) {
|
||||
// return IconButton(
|
||||
// onPressed: () async {
|
||||
// Get.to(
|
||||
// () => LoginPage(),
|
||||
// );
|
||||
// },
|
||||
// icon: const Icon(
|
||||
// FontAwesome5.grin_tears,
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
|
||||
import '../../../../constant/colors.dart';
|
||||
import '../../../../controller/functions/location_controller.dart';
|
||||
import '../../../../controller/home/captin/map_driver_controller.dart';
|
||||
|
||||
@@ -36,6 +35,12 @@ class GoogleDriverMap extends StatelessWidget {
|
||||
cameraTargetBounds:
|
||||
CameraTargetBounds.unbounded, // Allow unrestricted movement
|
||||
onCameraMove: (position) {
|
||||
CameraPosition(
|
||||
target: locationController.myLocation,
|
||||
zoom: 13,
|
||||
bearing: locationController.heading,
|
||||
tilt: 40,
|
||||
);
|
||||
//todo
|
||||
// locationController.myLocation = position.target;
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user