This commit is contained in:
Hamza-Ayed
2024-05-02 12:07:38 +03:00
parent 8684223b6a
commit 9d3c522038
14 changed files with 601 additions and 460 deletions

View File

@@ -0,0 +1,49 @@
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/main.dart';
import 'package:get/get.dart';
import 'package:google_sign_in/google_sign_in.dart';
import '../../views/auth/captin/ai_page.dart';
class GoogleSignInHelper {
static final GoogleSignIn _googleSignIn = GoogleSignIn(
scopes: [
'email',
'profile',
],
);
static Future<GoogleSignInAccount?> signIn() async {
try {
final GoogleSignInAccount? googleUser = await _googleSignIn.signIn();
getDriverInfo();
Get.to(() => AiPage());
return googleUser;
} catch (error) {
print('Google Sign-In error: $error');
return null;
}
}
static Future<void> signOut() async {
try {
await _googleSignIn.signOut();
} catch (error) {
print('Google Sign-Out error: $error');
}
}
static GoogleSignInAccount? getCurrentUser() {
return _googleSignIn.currentUser;
}
static String? getDriverInfo() {
final GoogleSignInAccount? user = _googleSignIn.currentUser;
box.write(BoxName.driverID, user!.id);
box.write(BoxName.emailDriver, user.email);
box.write(BoxName.nameDriver, user.displayName);
box.write(BoxName.driverPhotoUrl, user.photoUrl);
print('emailDriver =${box.read(BoxName.emailDriver)}');
return user.displayName;
}
}

View File

@@ -1225,6 +1225,7 @@ class MapPassengerController extends GetxController {
dataCarsLocationByPassenger = res;
update();
} else {
// Get.snackbar('no car', 'message');
noCarString = false;
dataCarsLocationByPassenger = jsonDecode(res);
//print(dataCarsLocationByPassenger);
@@ -1234,22 +1235,38 @@ class MapPassengerController extends GetxController {
.toString();
gender = dataCarsLocationByPassenger['message'][carsOrder]['gender']
.toString();
}
// }
// //print('driverId==============$driverId');
// //print('driverId==============$driverId');
carsLocationByPassenger.clear(); // Clear existing markers
carsLocationByPassenger.clear(); // Clear existing markers
// late LatLng lastDriverLocation; // Initialize a variable for last location
// late LatLng lastDriverLocation; // Initialize a variable for last location
for (var i = 0; i < dataCarsLocationByPassenger['message'].length; i++) {
var json = dataCarsLocationByPassenger['message'][i];
print(json);
CarLocationModel model = CarLocationModel.fromJson(json);
if (carLocationsModels.length < i + 1) {
carLocationsModels.add(model);
markers.add(
Marker(
for (var i = 0;
i < dataCarsLocationByPassenger['message'].length;
i++) {
var json = dataCarsLocationByPassenger['message'][i];
print(json);
CarLocationModel model = CarLocationModel.fromJson(json);
if (carLocationsModels.length < i + 1) {
carLocationsModels.add(model);
markers.add(
Marker(
markerId: MarkerId(json['latitude']),
position: LatLng(
double.parse(json['latitude']),
double.parse(json['longitude']),
),
rotation: double.parse(json['heading']),
icon: carIcon,
),
);
driversToken.add(json['token']);
// driversToken = json['token'];
} else {
carLocationsModels[i] = model;
markers[i] = Marker(
markerId: MarkerId(json['latitude']),
position: LatLng(
double.parse(json['latitude']),
@@ -1257,23 +1274,10 @@ class MapPassengerController extends GetxController {
),
rotation: double.parse(json['heading']),
icon: carIcon,
),
);
driversToken.add(json['token']);
// driversToken = json['token'];
} else {
carLocationsModels[i] = model;
markers[i] = Marker(
markerId: MarkerId(json['latitude']),
position: LatLng(
double.parse(json['latitude']),
double.parse(json['longitude']),
),
rotation: double.parse(json['heading']),
icon: carIcon,
);
// driversToken = json['token'];
driversToken.add(json['token']);
);
// driversToken = json['token'];
driversToken.add(json['token']);
}
}
}

View File

@@ -570,14 +570,19 @@ class MyTranslation extends Translations {
'Pick your ride location on the map - Tap to confirm':
'حدد موقع ‏الالتقاء على الخريطة - اضغط للتأكيد',
"To Work": "إلى العمل",
'Are you want to go this site': '‏هل تريد الذهاب إلى هذا المكان',
'Closest & Cheapest': ' الأقرب ',
"Work Saved": "تم حفظ العمل",
'Sefer is the ride-hailing app that is safe, reliable, and accessible.':
'"سفر: تطبيق طلب السيارة الآمن والموثوق والمعتمد"',
'With Sefer, you can get a ride to your destination in minutes.':
'مع سفر، يمكنك الحصول على رحلة إلى وجهتك في دقائق.',
'Sefer is committed to safety, and all of our captains are carefully screened and background checked.':
'تلتزم سفر بالسلامة، ويتم فحص جميع سائقينا وفحص سجلاتهم الشخصية بعناية.',
"To Home": "إلى المنزل",
"Home Saved": "تم حفظ المنزل",
"Destination Selected":
"تم تحديد الوجهة:", // "Tam تحديد al-waṣʿah:", (literally "The destination has been determined:")
"Now select start pick":
"حدد موقع الانطلاق الآن:", // "Ḥaddid mowāqiʿ al-inṭilāq al-ʾān:", (literally "Specify the starting location now:")
"Destination selected": "تم تحديد الوجهة:",
"Now select start pick": "حدد موقع الانطلاق الآن:",
"Pick from map": "اختيار من الخريطة",
"Click here point": "حدد هذا المكان",
"No Car in your site. Sorry!": "لا توجد سيارة في موقعك. آسف!",

View File

@@ -92,7 +92,7 @@ class ProfileController extends GetxController {
});
if (res.toString() == 'failure') {
Get.snackbar('failure', 'message');
// Get.snackbar('failure', 'message');
isloading = false;
update();
} else {