This commit is contained in:
Hamza-Ayed
2024-07-06 19:24:10 +03:00
21 changed files with 262 additions and 275 deletions

View File

@@ -14,6 +14,7 @@ import 'package:SEFER/main.dart';
import 'package:SEFER/views/auth/captin/login_captin.dart';
import 'package:SEFER/views/auth/captin/verify_email_captain.dart';
import '../../../constant/colors.dart';
import '../../../views/auth/captin/ai_page.dart';
import '../../../views/auth/captin/car_license_page.dart';
import '../../../views/home/Captin/home_captain/home_captin.dart';
@@ -86,16 +87,33 @@ class RegisterCaptainController extends GetxController {
update();
if (formKey3.currentState!.validate()) {
if (box.read(BoxName.countryCode) == 'Egypt') {
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
var responseCheker = await CRUD()
.post(link: AppLink.checkPhoneNumberISVerfiedDriver, payload: {
'phone_number': '+2${phoneController.text}',
'token_code': randomNumber.toString(),
});
var d = jsonDecode(responseCheker);
if (d['message'][0]['is_verified'].toString() == '1') {
Get.snackbar('Phone number is verified before'.tr, '',
backgroundColor: AppColor.greenColor);
box.write(BoxName.isVerified, '1');
box.write(BoxName.phone, '+2${phoneController.text}');
await Get.put(LoginDriverController()).loginUsingCredentials(
box.read(BoxName.driverID).toString(),
box.read(BoxName.emailDriver).toString(),
);
} else {
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
'phone_number': '+2${phoneController.text}',
'token_code': randomNumber.toString(),
});
await smsEgyptController.sendSmsEgypt(
phoneController.text.toString(), randomNumber.toString());
isSent = true;
isLoading = false;
update();
await smsEgyptController.sendSmsEgypt(
phoneController.text.toString(), randomNumber.toString());
isSent = true;
isLoading = false;
update();
}
}
}
}

View File

@@ -243,6 +243,7 @@ class FirebaseMessagesController extends GetxController {
confirm: MyElevatedButton(
title: 'Ok'.tr,
onPressed: () {
box.write(BoxName.rideStatus, 'Cancel');
Get.offAll(HomeCaptain());
}));
}

View File

@@ -27,9 +27,6 @@ class CRUD {
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials.toString()))}',
},
);
print(response.request);
print(response.body);
print(response.statusCode);
// if (response.statusCode == 200) {
var jsonData = jsonDecode(response.body);
if (jsonData['status'] == 'success') {
@@ -101,7 +98,6 @@ class CRUD {
await arabicTextExtractByVisionAndAI(imagePath: imagePath);
var json = jsonDecode(extractedString);
var textValues = extractTextFromLines(json);
print(textValues);
// await Get.put(AI()).geminiAiExtraction(prompt, textValues);
await Get.put(AI()).anthropicAI(textValues, prompt, imagePath);
}
@@ -134,8 +130,6 @@ class CRUD {
String imagePathFull =
'${AppLink.server}/card_image/$imagePath-${box.read(BoxName.driverID)}.jpg';
// print(box.read(BoxName.driverID));
// print(imagePathFull);
var request = http.Request('POST', Uri.parse(
// 'https://ocrhamza.cognitiveservices.azure.com/vision/v2.1/ocr?language=ar'));
// 'https://eastus.api.cognitive.microsoft.com/vision/v3.2/ocr'
@@ -146,7 +140,6 @@ class CRUD {
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
// print(await response.stream.bytesToString());
return await response.stream.bytesToString();
} else {}
}
@@ -224,9 +217,6 @@ class CRUD {
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
},
);
print(response.request);
print(response.body);
// print(response.statusCode);
var jsonData = jsonDecode(response.body);
if (response.statusCode == 200) {
if (jsonData['status'] == 'success') {

View File

@@ -18,7 +18,10 @@ class KeyEncryption {
}
static String decryptKey(String encryptedKey) {
print('encryptedKey: ${AK.keyOfApp}');
final decoded = base64Decode(encryptedKey);
print('encryptedKey: $encryptedKey');
final iv = encrypt.IV(decoded.sublist(0, 16)); // استخراج التهيئة
final encrypted =
encrypt.Encrypted(decoded.sublist(16)); // استخراج النص المشفر

View File

@@ -12,6 +12,7 @@ import '../../constant/info.dart';
Future<void> checkForUpdate(BuildContext context) async {
final packageInfo = await PackageInfo.fromPlatform();
final currentVersion = packageInfo.buildNumber;
final version = packageInfo.version;
print('currentVersion is : $currentVersion');
// Fetch the latest version from your server
String latestVersion = await getPackageInfo();
@@ -24,7 +25,7 @@ Future<void> checkForUpdate(BuildContext context) async {
Future<String> getPackageInfo() async {
final response = await CRUD().get(link: AppLink.packageInfo, payload: {
"platform": Platform.isAndroid ? 'android' : 'ios',
"appName": AppInformation.appName,
"appName": AppInformation.appVersion,
});
if (response != 'failure') {
@@ -36,7 +37,7 @@ Future<String> getPackageInfo() async {
void showUpdateDialog(BuildContext context) {
final String storeUrl = Platform.isAndroid
? 'https://play.google.com/store/apps/details?id=com.sefer_driver'
: 'https://apps.apple.com/ae/app/sefer/id6458734951';
: 'https://apps.apple.com/ae/app/sefer-driver/id6502189302';
showCupertinoDialog(
context: context,
barrierDismissible: false,

View File

@@ -13,6 +13,7 @@ class SmsEgyptController extends GetxController {
var headers = {'Content-Type': 'application/json'};
Future<dynamic> sendSmsEgypt(String phone, otp) async {
print('password ==== ${AK.smsPasswordEgypt}');
var body = jsonEncode({
"username": AppInformation.appName,
"password": AK.smsPasswordEgypt, //'E)Pu=an/@Z',

View File

@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:convert';
import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
import 'package:SEFER/views/widgets/mydialoug.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart';
@@ -221,6 +222,7 @@ class MapDriverController extends GetxController {
'driverGoToPassengerTime': DateTime.now().toString(),
'status': 'Applied'
});
box.write(BoxName.rideStatus, 'Applied');
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'DriverIsGoingToPassenger',
box.read(BoxName.name).toString(),
@@ -282,6 +284,7 @@ class MapDriverController extends GetxController {
remainingTimeInPassengerLocatioWait = 0;
timeWaitingPassenger = 0;
box.write(BoxName.statusDriverLocation, 'on');
box.write(BoxName.rideStatus, 'Begin'); //todo ride details
update();
await CRUD().post(link: AppLink.updateRides, payload: {
@@ -426,6 +429,12 @@ class MapDriverController extends GetxController {
}
void finishRideFromDriver() {
double distanceToDestination = Geolocator.distanceBetween(
latLngPassengerLocation.latitude,
latLngPassengerLocation.longitude,
Get.find<LocationController>().myLocation.latitude,
Get.find<LocationController>().myLocation.longitude,
);
Get.defaultDialog(
title: 'Are you sure to exit ride ?'.tr,
titleStyle: AppStyle.title,
@@ -434,8 +443,16 @@ class MapDriverController extends GetxController {
title: 'Ok'.tr,
kolor: AppColor.greenColor,
onPressed: () {
Get.back();
finishRideFromDriver1();
if (distanceToDestination > 1000) {
Get.back();
finishRideFromDriver1();
} else {
Get.back();
if (distanceToDestination < 150) {
// todo add scam from start point and dont move
}
MyDialog().getDialog('you are not moved yet !'.tr, '', () {});
}
}),
cancel: MyElevatedButton(
title: 'Cancel'.tr,
@@ -467,17 +484,12 @@ class MapDriverController extends GetxController {
}
void finishRideFromDriver1() async {
double distanceToDestination = Geolocator.distanceBetween(
latLngPassengerDestination.latitude,
latLngPassengerDestination.longitude,
Get.find<LocationController>().myLocation.latitude,
Get.find<LocationController>().myLocation.longitude,
);
// if (carType != 'Comfort' || carType != 'Free Ride') {
// if (distanceToDestination < 50) {
isRideFinished = true;
isRideStarted = false;
isPriceWindow = false;
box.write(BoxName.rideStatus, 'Finished');
totalCost = price < 30
? carType != 'Comfort' && carType != 'Mashwari' && carType != 'Lady'
? '20'
@@ -559,7 +571,6 @@ class MapDriverController extends GetxController {
'walletChecked': walletChecked
});
// Get.back();
// }
}
void cancelCheckRideFromPassenger() async {
@@ -599,7 +610,9 @@ class MapDriverController extends GetxController {
int durationOfRide = int.parse(durationOfRideValue);
update();
int infinity = 40000;
if (carType == 'Comfort' || carType == 'Mashwari') {
if (carType == 'Comfort' ||
carType == 'Mashwari' ||
carType == 'Rayeh Gai') {
durationOfRide = infinity;
update();
}
@@ -637,7 +650,7 @@ class MapDriverController extends GetxController {
remainingTimeTimerRideBegin = durationOfRide - i;
remainingTimeTimerRideBegin < 60 ? driverEndPage = 160 : 100;
updateMarker();
if (remainingTimeTimerRideBegin < 120) {
if (remainingTimeTimerRideBegin < 60) {
// to make driver available on last 2 minute in his trip
box.write(BoxName.statusDriverLocation, 'off');
}

View File

@@ -4,6 +4,7 @@ import 'package:SEFER/controller/auth/captin/login_captin_controller.dart';
import 'package:SEFER/views/home/on_boarding_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';
import '../../constant/box_name.dart';
import '../../main.dart';
@@ -16,10 +17,23 @@ class SplashScreenController extends GetxController
late Animation<double> zoomInAnimation;
late Animation<double> zoomOutAnimation;
String packageInfo = '';
late String version = '1.5.48';
Future<void> checkForUpdate() async {
final packageInfo = await PackageInfo.fromPlatform();
final currentVersion = packageInfo.buildNumber;
final version1 = packageInfo.version;
print('currentVersion is : $currentVersion');
// Fetch the latest version from your server
version = version1.toString();
print('version: ${version}');
update();
}
@override
void onInit() {
super.onInit();
checkForUpdate();
animationController = AnimationController(
vsync: this,
duration: const Duration(seconds: 4),

View File

@@ -4,6 +4,8 @@ class MyTranslation extends Translations {
@override
Map<String, Map<String, String>> get keys => {
"ar": {
"don't start trip if not": "لا تبدأ الرحلة إذا لم",
"you are not moved yet !": "أنت لم تتحرك بعد!",
"Update Available": "تحديث متوفر",
"A new version of the app is available. Please update to the latest version.":
"تتوفر نسخة جديدة من التطبيق. يرجى التحديث إلى أحدث إصدار.",