This commit is contained in:
Hamza-Ayed
2024-05-29 16:09:37 +03:00
parent 058fb67a41
commit 4af52f4392
44 changed files with 9509 additions and 2044 deletions

View File

@@ -0,0 +1,35 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:get/get.dart';
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
class AuthController extends GetxController {
final FirebaseAuth _auth = FirebaseAuth.instance;
Future<User?> signInWithApple() async {
try {
final appleCredential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
);
final oAuthProvider = OAuthProvider('apple.com');
final credential = oAuthProvider.credential(
idToken: appleCredential.identityToken,
accessToken: appleCredential.authorizationCode,
);
UserCredential userCredential =
await _auth.signInWithCredential(credential);
return userCredential.user;
} catch (error) {
print("Error during Apple sign-in: $error");
return null;
}
}
void signOut() async {
await _auth.signOut();
}
}

View File

@@ -16,6 +16,8 @@ import 'package:SEFER/views/auth/captin/verify_email_captain.dart';
import 'package:SEFER/views/home/Captin/home_captain/home_captin.dart';
import 'package:location/location.dart';
import '../../firebase/firbase_messge.dart';
class LoginCaptinController extends GetxController {
final formKey = GlobalKey<FormState>();
TextEditingController emailController = TextEditingController();
@@ -115,7 +117,7 @@ class LoginCaptinController extends GetxController {
}
}
void loginFromSignInGoogle(String driverID, email) async {
loginFromSignInGoogle(String driverID, email) async {
isloading = true;
update();
var res = await CRUD().get(link: AppLink.loginFromGoogleCaptin, payload: {
@@ -125,7 +127,7 @@ class LoginCaptinController extends GetxController {
print(res);
if (res == 'Failure') {
//Failure
Get.offAll(SmsSignupEgypt());
Get.offAll(() => SmsSignupEgypt());
isloading = false;
update();
// Get.snackbar('Failure', '', backgroundColor: Colors.red);
@@ -139,9 +141,36 @@ class LoginCaptinController extends GetxController {
box.write(BoxName.phoneVerified,
jsonDecoeded['data'][0]['is_verified'].toString());
box.write(BoxName.phoneDriver, jsonDecoeded['data'][0]['phone']);
Get.off(HomeCaptain());
box.write(
BoxName.nameDriver,
'${jsonDecoeded['data'][0]['first_name']}'
' ${jsonDecoeded['data'][0]['last_name']}');
print(box.read(BoxName.tokenDriver));
var token = await CRUD().get(
link: AppLink.getDriverToken,
payload: {'captain_id': box.read(BoxName.driverID).toString()});
print(token);
print(box.read(BoxName.tokenDriver));
if (token != 'failure') {
if (jsonDecode(token)['data'][0]['token'] !=
box.read(BoxName.tokenDriver)) {
Get.put(FirebaseMessagesController())
.sendNotificationToAnyWithoutData(
'token change',
'change device',
jsonDecode(token)['data'][0]['token'].toString(),
);
await CRUD().post(link: AppLink.addTokensDriver, payload: {
'token': box.read(BoxName.tokenDriver),
'captain_id': box.read(BoxName.driverID).toString()
}).then((value) => print('cccc'));
}
}
Get.off(() => HomeCaptain());
} else {
Get.offAll(SmsSignupEgypt());
Get.offAll(() => SmsSignupEgypt());
// Get.snackbar(jsonDecoeded['status'], jsonDecoeded['data'],
// backgroundColor: Colors.redAccent);
isloading = false;

View File

@@ -109,13 +109,14 @@ class RegisterCaptainController extends GetxController {
if (res != 'failure') {
// var dec = jsonDecode(res);
box.write(BoxName.phoneDriver, '+2${phoneController.text}');
box.write(BoxName.phoneVerified, '1');
// var res1 = await CRUD().post(
// link: AppLink.updateAccountBank,
// payload: {'phone': '+2${phoneController.text}'});
// if (jsonDecode(res1)['status'] == 'success') {
Get.to(EgyptCardAI());
// }
box.write(BoxName.phoneVerified, 1);
var res1 = await CRUD().post(
link: AppLink.updateAccountBank,
payload: {'phone': '+2${phoneController.text}'});
if (jsonDecode(res1)['status'] == 'success') {
Get.to(EgyptCardAI());
}
}
}
}

View File

@@ -16,6 +16,7 @@ import '../../main.dart';
import '../../views/home/Captin/home_captain/home_captin.dart';
import '../../views/home/Captin/orderCaptin/order_speed_request.dart';
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
import '../auth/google_sign.dart';
import 'local_notification.dart';
class FirebaseMessagesController extends GetxController {
@@ -64,11 +65,8 @@ class FirebaseMessagesController extends GetxController {
Future getToken() async {
fcmToken.getToken().then((token) {
if (box.read(BoxName.email) == null) {
box.write(BoxName.tokenDriver, token);
} else {
box.write(BoxName.tokenFCM, token);
}
box.write(BoxName.tokenDriver, token);
print(token);
});
@@ -122,6 +120,10 @@ class FirebaseMessagesController extends GetxController {
NotificationController().showNotification(
'Cancel Trip'.tr, 'Passenger Cancel Trip'.tr, 'cancel');
cancelTripDialog();
} else if (message.notification!.title! == 'token change') {
NotificationController()
.showNotification('token change', 'token change', 'cancel');
GoogleSignInHelper.signOut();
} else if (message.notification!.title! == 'message From passenger') {
NotificationController()
.showNotification('message From passenger'.tr, ''.tr, 'tone2');

View File

@@ -7,9 +7,7 @@ import 'package:http/http.dart' as http;
import 'package:SEFER/env/env.dart';
import '../../constant/api_key.dart';
import '../../constant/colors.dart';
import 'gemeni.dart';
import 'llama_ai.dart';
import 'upload_image.dart';
class CRUD {
@@ -36,7 +34,7 @@ class CRUD {
// print(response.body);
var jsonData = jsonDecode(response.body);
if (jsonData['status'] == 'success') {
// print(jsonData);
print(jsonData);
return response.body;
}
@@ -248,8 +246,8 @@ class CRUD {
return response.body;
} else {
String errorMessage = jsonData['message'];
Get.snackbar('Erroe'.tr, errorMessage.tr,
backgroundColor: AppColor.redColor);
// Get.snackbar('Error'.tr, errorMessage.tr,
// backgroundColor: AppColor.redColor);
print(errorMessage.tr);
return (jsonData['status']);
}

View File

@@ -195,11 +195,11 @@ class AI extends GetxController {
);
} else {
await addDriverEgypt();
// await addRegistrationCarEgypt();
await addRegistrationCarEgypt();
if (isCarSaved && isDriverSaved) {
DeviceController().getDeviceSerialNumber();
box.write(BoxName.phoneVerified, '1');
box.write(BoxName.phoneVerified, 1);
Get.offAll(() => HomeCaptain());
// Get.offAll(() => HomeCaptain());
}

View File

@@ -12,15 +12,42 @@ class DurationController extends GetxController {
final data = DurationData;
// late AnimationController animationController;
late List<MonthlyDataModel> rideData;
late List<MonthlyRideModel> rideCountData;
late List<MonthlyPriceDriverModel> ridePriceDriverData;
Map<String, dynamic> jsonData1 = {};
Map<String, dynamic> jsonData2 = {};
bool isLoading = false;
String totalDurationToday = '';
var chartData;
var chartRideCount;
var chartRidePriceDriver;
List monthlyList = [];
@override
void onInit() async {
super.onInit();
await fetchData();
await fetchRideDriver();
await getStaticDriver();
}
getStaticDriver() async {
isLoading = true;
update();
var res = await CRUD().get(
link: AppLink.driverStatistic,
payload: {'driverID': box.read(BoxName.driverID)});
if (res == 'failure') {
monthlyList = [];
print('monthlyList $monthlyList');
isLoading = false;
update();
} else {
monthlyList = jsonDecode(res)['message'];
print(monthlyList);
isLoading = false;
update();
}
}
Future<void> fetchData() async {
@@ -50,6 +77,44 @@ class DurationController extends GetxController {
update(); // Notify the observers about the data and loading state change
}
Future<void> fetchRideDriver() async {
isLoading = true;
update(); // Notify the observers about the loading state change
var res = await CRUD().get(
link: AppLink.getRidesDriverByDay,
payload: {'driver_id': box.read(BoxName.driverID)},
);
jsonData2 = jsonDecode(res);
var jsonResponse = jsonDecode(res) as Map<String, dynamic>;
isLoading = false;
// print(jsonResponse);
final List<dynamic> jsonData = jsonResponse['message'];
rideCountData = jsonData.map<MonthlyRideModel>((item) {
return MonthlyRideModel.fromJson(item);
}).toList();
ridePriceDriverData = jsonData.map<MonthlyPriceDriverModel>((item) {
return MonthlyPriceDriverModel.fromJson(item);
}).toList();
final List<FlSpot> spots = rideCountData
.map((data) => FlSpot(
data.day.toDouble(),
data.countRide.toDouble(),
))
.toList();
chartRideCount = spots;
final List<FlSpot> spotsDriverPrices = ridePriceDriverData
.map((data) => FlSpot(
data.day.toDouble(),
data.pricePerDay.toDouble(),
))
.toList();
chartRidePriceDriver = spotsDriverPrices;
update(); // Notify the observers about the data and loading state change
}
List<DurationData> parseData(List<dynamic> json) {
return json.map((entry) {
final Map<String, dynamic> entryMap = entry;

View File

@@ -445,11 +445,12 @@ class MapDriverController extends GetxController {
isRideFinished = true;
isRideStarted = false;
isPriceWindow = false;
totalCost = carType != 'Comfort' && carType != 'Mashwari'
? totalPassenger
: price < double.parse(totalPassenger)
totalCost =
carType != 'Comfort' && carType != 'Mashwari' && carType != 'Lady'
? totalPassenger
: price.toStringAsFixed(2);
: price < double.parse(totalPassenger)
? totalPassenger
: price.toStringAsFixed(2);
paymentAmount = totalCost;
box.write(BoxName.statusDriverLocation, 'off');
// changeRideToBeginToPassenger();
@@ -574,14 +575,18 @@ class MapDriverController extends GetxController {
? (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().speedPrice)
: carType == 'Mashwari'
: carType == 'Lady'
? (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().deliveryPrice)
: (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>()
.mashwariPrice); // $1 for each minute + $4 for each km
Get.find<HomeCaptainController>().comfortPrice)
: carType == 'Mashwari'
? (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>().deliveryPrice)
: (i ~/ 60) +
(recentDistanceToDash *
Get.find<HomeCaptainController>()
.mashwariPrice); // $1 for each minute + $4 for each km
price = (price * .10) + price; // Add 10% tax
speed = Get.find<LocationController>().speed * 3.6;
progressTimerRideBegin = i / durationOfRide;
@@ -827,6 +832,8 @@ class MapDriverController extends GetxController {
int minutes = 0;
late String carType;
late String kazan;
late String startNameLocation;
late String endNameLocation;
@override
void onInit() async {
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
@@ -860,6 +867,8 @@ class MapDriverController extends GetxController {
timeOfOrder = Get.arguments['timeOfOrder'];
carType = Get.arguments['carType'];
kazan = Get.arguments['kazan'];
startNameLocation = Get.arguments['startNameLocation'];
endNameLocation = Get.arguments['endNameLocation'];
var coords = passengerLocation.split(',');
var coordDestination = passengerDestination.split(',');

View File

@@ -42,18 +42,18 @@ class SplashScreenController extends GetxController
startTimer();
}
void startTimer() {
Timer(const Duration(seconds: 5), () {
void startTimer() async {
debugPrint('onBoarding: ${box.read(BoxName.onBoarding)}');
debugPrint('emailDriver: ${box.read(BoxName.emailDriver)}');
debugPrint('phoneDriver: ${box.read(BoxName.phoneDriver)}');
debugPrint('phoneVerified: ${box.read(BoxName.phoneVerified)}');
Timer(const Duration(seconds: 5), () async {
box.read(BoxName.onBoarding) == null
? Get.off(() => OnBoardingPage())
: box.read(BoxName.emailDriver) != null
// todo
&&
: box.read(BoxName.emailDriver) != null &&
box.read(BoxName.phoneDriver) != null &&
box.read(BoxName.phoneVerified) == '1'
// ? Get.off(() => SmsSignupEgypt())
// ? Get.off(() => HomeCaptain())
? Get.put(LoginCaptinController()).loginFromSignInGoogle(
? await Get.put(LoginCaptinController()).loginFromSignInGoogle(
box.read(BoxName.driverID).toString(),
box.read(BoxName.emailDriver))
: Get.off(() => LoginCaptin());

View File

@@ -32,15 +32,59 @@ class LocaleController extends GetxController {
appTheme = themeEnglish;
box.write(BoxName.lang, 'tr');
break;
case "fr":
locale = const Locale("fr");
appTheme = themeEnglish;
box.write(BoxName.lang, 'fr');
break;
case "it":
locale = const Locale("it");
appTheme = themeEnglish;
box.write(BoxName.lang, 'it');
break;
case "de":
locale = const Locale("de");
appTheme = themeEnglish;
box.write(BoxName.lang, 'de');
break;
case "el":
locale = const Locale("el");
appTheme = themeEnglish;
box.write(BoxName.lang, 'el');
break;
case "es":
locale = const Locale("es");
appTheme = themeEnglish;
box.write(BoxName.lang, 'es');
break;
case "fa":
locale = const Locale("fa");
appTheme = themeEnglish;
box.write(BoxName.lang, 'fa');
break;
case "zh":
locale = const Locale("zh");
appTheme = themeEnglish;
box.write(BoxName.lang, 'zh');
break;
case "ru":
locale = const Locale("ru");
appTheme = themeEnglish;
box.write(BoxName.lang, 'ru');
break;
case "hi":
locale = const Locale("hi");
appTheme = themeEnglish;
box.write(BoxName.lang, 'hi');
break;
default:
locale = Locale(Get.deviceLocale!.languageCode);
box.write(BoxName.lang, 'en');
box.write(BoxName.lang, Get.deviceLocale!.languageCode);
appTheme = themeEnglish;
break;
}
box.write(BoxName.lang, langcode);
// box.write(BoxName.lang, langcode);
Get.changeTheme(appTheme);
Get.updateLocale(locale);
restartApp();
@@ -63,6 +107,42 @@ class LocaleController extends GetxController {
language = const Locale("tr");
appTheme = themeEnglish;
break;
case "fr":
language = const Locale("fr");
appTheme = themeEnglish;
break;
case "it":
language = const Locale("it");
appTheme = themeEnglish;
break;
case "de":
language = const Locale("de");
appTheme = themeEnglish;
break;
case "el":
language = const Locale("el");
appTheme = themeEnglish;
break;
case "es":
language = const Locale("es");
appTheme = themeEnglish;
break;
case "fa":
language = const Locale("fa");
appTheme = themeArabic;
break;
case "zh":
language = const Locale("zh");
appTheme = themeEnglish;
break;
case "ru":
language = const Locale("ru");
appTheme = themeEnglish;
break;
case "hi":
language = const Locale("hi");
appTheme = themeEnglish;
break;
default:
language = Locale(Get.deviceLocale!.languageCode);
appTheme = themeEnglish;

File diff suppressed because it is too large Load Diff

View File

@@ -10,6 +10,7 @@ import 'package:SEFER/main.dart';
class DriverWalletHistoryController extends GetxController {
bool isLoading = false;
List archive = [];
List weeklyList = [];
getArchivePayment() async {
isLoading = true;
@@ -36,9 +37,35 @@ class DriverWalletHistoryController extends GetxController {
update();
}
getWeekllyArchivePayment() async {
isLoading = true;
update();
var res = await CRUD().get(
link: AppLink.getDriverWeekPaymentMove,
payload: {'driverID': box.read(BoxName.driverID)});
print(res);
if (res == 'failure') {
Get.defaultDialog(
barrierDismissible: false,
title: 'There is no data yet.'.tr,
middleText: '',
confirm: MyElevatedButton(
title: 'Back'.tr,
onPressed: () {
Get.back();
Get.back();
},
));
}
weeklyList = jsonDecode(res)['message'];
print(archive);
isLoading = false;
update();
}
@override
void onInit() {
getArchivePayment();
// getArchivePayment();
super.onInit();
}
}

View File

@@ -62,6 +62,8 @@ class CaptainProfileController extends GetxController {
Map captainProfileData = {};
Future getProfileData() async {
isLoading = true;
update();
var res = await CRUD().get(
link: AppLink.getCaptainProfile,
payload: {'id': box.read(BoxName.driverID)});
@@ -69,7 +71,7 @@ class CaptainProfileController extends GetxController {
var d = jsonDecode(res);
captainProfileData = d['message'];
update();
print(d['message']);
print(captainProfileData);
box.write(BoxName.sexDriver, d['message']['gender']);
box.write(BoxName.dobDriver, d['message']['birthdate']);
box.write(BoxName.vin, d['message']['vin']);
@@ -80,7 +82,7 @@ class CaptainProfileController extends GetxController {
box.write(BoxName.year, d['message']['year']);
box.write(BoxName.expirationDate, d['message']['expiration_date']);
// box.write(BoxName.acc, d['message']['accountBank']);
isLoading = false;
update();
}
}

View File

@@ -61,6 +61,10 @@ class RateController extends GetxController {
'duration': Get.find<MapDriverController>().duration.toString(),
'phone': Get.find<MapDriverController>().passengerPhone.toString(),
'email': Get.find<MapDriverController>().passengerEmail.toString(),
'startNameLocation':
Get.find<MapDriverController>().startNameLocation.toString(),
'endNameLocation':
Get.find<MapDriverController>().endNameLocation.toString(),
});
// homeCaptainController.isActive = true;
// update();

View File

@@ -38,7 +38,7 @@ ThemeData themeEnglish = ThemeData(
);
ThemeData themeArabic = ThemeData(
fontFamily: "Cairo",
fontFamily: 'mohanad',
textTheme: const TextTheme(
displayLarge: TextStyle(
fontWeight: FontWeight.bold,