Update: 2026-06-12 20:40:40
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void signOut() async {
|
||||
await _auth.signOut();
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,6 @@ class LoginDriverController extends GetxController {
|
||||
bool isGoogleLogin = false;
|
||||
bool isloading = false;
|
||||
late int isTest = 1;
|
||||
final FlutterSecureStorage _storage = const FlutterSecureStorage();
|
||||
final location = Location();
|
||||
void changeAgreeTerm() {
|
||||
isAgreeTerms = !isAgreeTerms;
|
||||
@@ -154,8 +153,12 @@ class LoginDriverController extends GetxController {
|
||||
Log.print('response.request: ${response1.request}');
|
||||
Log.print('response.body: ${response1.body}');
|
||||
var decoded = jsonDecode(response1.body);
|
||||
var jwt = decoded['message'] is Map && decoded['message']['jwt'] != null ? decoded['message']['jwt'] : decoded['jwt'];
|
||||
var hmac = decoded['message'] is Map && decoded['message']['hmac'] != null ? decoded['message']['hmac'] : decoded['hmac'];
|
||||
var jwt = decoded['message'] is Map && decoded['message']['jwt'] != null
|
||||
? decoded['message']['jwt']
|
||||
: decoded['jwt'];
|
||||
var hmac = decoded['message'] is Map && decoded['message']['hmac'] != null
|
||||
? decoded['message']['hmac']
|
||||
: decoded['hmac'];
|
||||
Log.print('payment["jwt"]: $jwt');
|
||||
|
||||
await box.write(BoxName.hmac, hmac);
|
||||
@@ -188,14 +191,16 @@ class LoginDriverController extends GetxController {
|
||||
Log.print('decodedResponse1: ${decodedResponse1}');
|
||||
|
||||
String? jwt;
|
||||
if (decodedResponse1['message'] is Map && decodedResponse1['message']['jwt'] != null) {
|
||||
if (decodedResponse1['message'] is Map &&
|
||||
decodedResponse1['message']['jwt'] != null) {
|
||||
jwt = decodedResponse1['message']['jwt'];
|
||||
} else {
|
||||
jwt = decodedResponse1['jwt'];
|
||||
}
|
||||
|
||||
|
||||
if (jwt != null) {
|
||||
box.write(BoxName.jwt, c(jwt));
|
||||
await storage.write(key: BoxName.jwt, value: c(jwt));
|
||||
}
|
||||
|
||||
// ✅ بعد التأكد أن كل المفاتيح موجودة
|
||||
@@ -226,14 +231,16 @@ class LoginDriverController extends GetxController {
|
||||
// Log.print('decodedResponse1: ${decodedResponse1}');
|
||||
|
||||
String? jwt;
|
||||
if (decodedResponse1['message'] is Map && decodedResponse1['message']['jwt'] != null) {
|
||||
if (decodedResponse1['message'] is Map &&
|
||||
decodedResponse1['message']['jwt'] != null) {
|
||||
jwt = decodedResponse1['message']['jwt'];
|
||||
} else {
|
||||
jwt = decodedResponse1['jwt'];
|
||||
}
|
||||
|
||||
|
||||
if (jwt != null) {
|
||||
await box.write(BoxName.jwt, c(jwt));
|
||||
await storage.write(key: BoxName.jwt, value: c(jwt));
|
||||
}
|
||||
|
||||
// await AppInitializer().getKey();
|
||||
@@ -303,7 +310,8 @@ class LoginDriverController extends GetxController {
|
||||
body: 'for '.tr + box.read(BoxName.phoneDriver).toString(),
|
||||
isTopic: false,
|
||||
tone: 'tone2',
|
||||
driverList: [], category: 'You have received a gift token!',
|
||||
driverList: [],
|
||||
category: 'You have received a gift token!',
|
||||
);
|
||||
} catch (e) {
|
||||
Log.print('invite notification error: $e');
|
||||
|
||||
@@ -8,7 +8,6 @@ import '../../../constant/box_name.dart';
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../../views/widgets/error_snakbar.dart';
|
||||
import '../../firebase/firbase_messge.dart';
|
||||
import '../../firebase/notification_service.dart';
|
||||
import '../../functions/crud.dart';
|
||||
|
||||
@@ -54,10 +53,11 @@ class OtpVerificationController extends GetxController {
|
||||
isLoading.value = true;
|
||||
try {
|
||||
final response = await CRUD().post(
|
||||
link:
|
||||
'${AppLink.server}/auth/token_passenger/driver/send_otp_driver.php',
|
||||
link: '${AppLink.server}/auth/otp/request.php',
|
||||
payload: {
|
||||
'receiver': phone,
|
||||
'context': 'token_change',
|
||||
'user_type': 'driver',
|
||||
// 'device_token': deviceToken,
|
||||
},
|
||||
);
|
||||
@@ -79,11 +79,12 @@ class OtpVerificationController extends GetxController {
|
||||
var finger = box.read(BoxName.deviceFingerprint);
|
||||
try {
|
||||
final response = await CRUD().post(
|
||||
link:
|
||||
'${AppLink.server}/auth/token_passenger/driver/verify_otp_driver.php',
|
||||
link: '${AppLink.server}/auth/otp/verify.php',
|
||||
payload: {
|
||||
'phone_number': phone,
|
||||
'otp': otpCode.value,
|
||||
'token_code': otpCode.value,
|
||||
'context': 'token_change',
|
||||
'user_type': 'driver',
|
||||
'token': box.read(BoxName.tokenDriver).toString(),
|
||||
'fingerPrint': finger.toString(),
|
||||
},
|
||||
|
||||
@@ -15,10 +15,9 @@ import '../../../views/auth/syria/registration_view.dart';
|
||||
|
||||
class PhoneAuthHelper {
|
||||
// Define your server URLs
|
||||
static final String _baseUrl = '${AppLink.server}/auth/syria/driver/';
|
||||
static final String _sendOtpUrl = '${_baseUrl}sendWhatsAppDriver.php';
|
||||
static final String _verifyOtpUrl = '${_baseUrl}verifyOtp.php';
|
||||
static final String _registerUrl = '${_baseUrl}register_driver.php';
|
||||
static final String _sendOtpUrl = '${AppLink.server}/auth/otp/request.php';
|
||||
static final String _verifyOtpUrl = '${AppLink.server}/auth/otp/verify.php';
|
||||
static final String _registerUrl = '${AppLink.server}/auth/syria/driver/register_driver.php';
|
||||
// removed formatSyrianPhone
|
||||
|
||||
/// Sends an OTP to the provided phone number.
|
||||
@@ -29,7 +28,11 @@ class PhoneAuthHelper {
|
||||
|
||||
final response = await CRUD().post(
|
||||
link: _sendOtpUrl,
|
||||
payload: {'receiver': fixedPhone},
|
||||
payload: {
|
||||
'receiver': fixedPhone,
|
||||
'context': 'login',
|
||||
'user_type': 'driver'
|
||||
},
|
||||
);
|
||||
Log.print('fixedPhone: ${fixedPhone}');
|
||||
|
||||
@@ -62,7 +65,9 @@ class PhoneAuthHelper {
|
||||
link: _verifyOtpUrl,
|
||||
payload: {
|
||||
'phone_number': fixedPhone,
|
||||
'otp': otpCode,
|
||||
'token_code': otpCode,
|
||||
'context': 'login',
|
||||
'user_type': 'driver'
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ class RegisterCaptainController extends GetxController {
|
||||
// Send OTP and SMS
|
||||
_sendOtpAndSms(String phoneNumber) async {
|
||||
SmsEgyptController smsEgyptController = Get.put(SmsEgyptController());
|
||||
int randomNumber = Random().nextInt(100000) + 1;
|
||||
int randomNumber = Random().nextInt(900) + 100;
|
||||
|
||||
await CRUD().post(
|
||||
link: AppLink.sendVerifyOtpMessage,
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// import 'package:firebase_auth/firebase_auth.dart';
|
||||
// import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
|
||||
|
||||
// class FacebookSignIn {
|
||||
// Future<UserCredential?> signInWithFacebook() async {
|
||||
// final LoginResult result = await FacebookAuth.instance.login();
|
||||
// if (result.status == LoginStatus.success) {
|
||||
// // Create a credential from the access token
|
||||
// final OAuthCredential credential =
|
||||
// FacebookAuthProvider.credential(result.accessToken!.tokenString);
|
||||
// // Once signed in, return the UserCredential
|
||||
// return await FirebaseAuth.instance.signInWithCredential(credential);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// Future<void> signOut() async {
|
||||
// try {
|
||||
// await FacebookAuth.instance.logOut();
|
||||
// print('Facebook Sign Out Successful');
|
||||
// } catch (e) {
|
||||
// print('Error during Facebook Sign Out: $e');
|
||||
// }
|
||||
// }
|
||||
|
||||
// Future<bool> isSignedIn() async {
|
||||
// final accessToken = await FacebookAuth.instance.accessToken;
|
||||
// return accessToken != null;
|
||||
// }
|
||||
// }
|
||||
@@ -1,117 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:siro_driver/views/widgets/error_snakbar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:siro_driver/constant/box_name.dart';
|
||||
import 'package:siro_driver/constant/links.dart';
|
||||
import 'package:siro_driver/controller/functions/crud.dart';
|
||||
import 'package:siro_driver/controller/functions/secure_storage.dart';
|
||||
import 'package:siro_driver/main.dart';
|
||||
import 'package:siro_driver/views/auth/verify_email_page.dart';
|
||||
|
||||
import '../functions/encrypt_decrypt.dart';
|
||||
|
||||
class LoginController extends GetxController {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
final formKeyAdmin = GlobalKey<FormState>();
|
||||
TextEditingController emailController = TextEditingController();
|
||||
TextEditingController phoneController = TextEditingController();
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
TextEditingController adminPasswordController = TextEditingController();
|
||||
TextEditingController adminNameController = TextEditingController();
|
||||
bool isAgreeTerms = false;
|
||||
bool isloading = false;
|
||||
final FlutterSecureStorage _storage = const FlutterSecureStorage();
|
||||
|
||||
void changeAgreeTerm() {
|
||||
isAgreeTerms = !isAgreeTerms;
|
||||
update();
|
||||
}
|
||||
|
||||
void saveAgreementTerms() {
|
||||
box.write(BoxName.agreeTerms, 'agreed');
|
||||
update();
|
||||
}
|
||||
|
||||
void saveCountryCode(String countryCode) {
|
||||
box.write(BoxName.countryCode, countryCode);
|
||||
update();
|
||||
}
|
||||
|
||||
void login() async {
|
||||
isloading = true;
|
||||
update();
|
||||
var res = await CRUD().get(link: AppLink.login, payload: {
|
||||
'email': emailController.text,
|
||||
'phone': phoneController.text,
|
||||
'password': passwordController.text
|
||||
});
|
||||
isloading = false;
|
||||
update();
|
||||
if (res == 'failure') {
|
||||
//Failure
|
||||
mySnackeBarError('');
|
||||
} else {
|
||||
var jsonDecoeded = jsonDecode(res);
|
||||
if (jsonDecoeded.isNotEmpty) {
|
||||
if (jsonDecoeded['status'] == 'success') {
|
||||
if (jsonDecoeded['data'][0]['verified'] == 1) {
|
||||
box.write(BoxName.driverID, jsonDecoeded['data'][0]['id']);
|
||||
box.write(BoxName.emailDriver, (jsonDecoeded['data'][0]['email']));
|
||||
box.write(
|
||||
BoxName.nameDriver,
|
||||
jsonDecoeded['data'][0]['first_name'] +
|
||||
' ' +
|
||||
jsonDecoeded['data'][0]['last_name']);
|
||||
box.write(BoxName.phone, jsonDecoeded['data'][0]['phone']);
|
||||
SecureStorage().saveData(BoxName.password, passwordController.text);
|
||||
// Get.offAll(() => const MapPagePassenger());
|
||||
isloading = false;
|
||||
update();
|
||||
await CRUD().post(link: AppLink.addTokens, payload: {
|
||||
'token': box.read(BoxName.tokenFCM),
|
||||
'passengerID': box.read(BoxName.passengerID).toString()
|
||||
});
|
||||
} else {
|
||||
isloading = false;
|
||||
update();
|
||||
Get.defaultDialog(
|
||||
title: 'You must Verify email !.'.tr,
|
||||
middleText: '',
|
||||
backgroundColor: Colors.yellow[300],
|
||||
onConfirm: () async {
|
||||
int randomNumber = Random().nextInt(100000) + 1;
|
||||
await CRUD().post(link: AppLink.sendVerifyEmail, payload: {
|
||||
'email': emailController.text,
|
||||
'token': randomNumber.toString(),
|
||||
});
|
||||
Get.to(() => const VerifyEmailPage());
|
||||
},
|
||||
);
|
||||
}
|
||||
} else if (jsonDecoeded['status'] == 'Failure') {
|
||||
mySnackeBarError(jsonDecoeded['data']);
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
} else {
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
goToMapPage() {
|
||||
if (box.read(BoxName.email) != null) {
|
||||
// Get.offAll(() => const MapPagePassenger());
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:siro_driver/constant/links.dart';
|
||||
import 'package:siro_driver/constant/style.dart';
|
||||
import 'package:siro_driver/controller/functions/crud.dart';
|
||||
import 'package:siro_driver/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../views/auth/captin/login_captin.dart';
|
||||
import '../../views/auth/verify_email_page.dart';
|
||||
|
||||
class RegisterController extends GetxController {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
|
||||
TextEditingController firstNameController = TextEditingController();
|
||||
TextEditingController lastNameController = TextEditingController();
|
||||
TextEditingController emailController = TextEditingController();
|
||||
TextEditingController phoneController = TextEditingController();
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
TextEditingController siteController = TextEditingController();
|
||||
TextEditingController verfyCode = TextEditingController();
|
||||
|
||||
String birthDate = 'Birth Date'.tr;
|
||||
String gender = 'Male'.tr;
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
getBirthDate() {
|
||||
Get.defaultDialog(
|
||||
title: 'Select Date'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
content: SizedBox(
|
||||
width: 300,
|
||||
child: CalendarDatePicker(
|
||||
initialDate:
|
||||
DateTime.now().subtract(const Duration(days: 14 * 365)),
|
||||
firstDate: DateTime.parse('1940-06-01'),
|
||||
lastDate: DateTime.now().subtract(const Duration(days: 14 * 365)),
|
||||
onDateChanged: (date) {
|
||||
// Get the selected date and convert it to a DateTime object
|
||||
DateTime dateTime = date;
|
||||
// Call the getOrders() function from the controller
|
||||
birthDate = dateTime.toString().split(' ')[0];
|
||||
update();
|
||||
},
|
||||
|
||||
// onDateChanged: (DateTime value) {},
|
||||
),
|
||||
),
|
||||
confirm: MyElevatedButton(title: 'Ok'.tr, onPressed: () => Get.back()));
|
||||
}
|
||||
|
||||
void changeGender(String value) {
|
||||
gender = value;
|
||||
update();
|
||||
}
|
||||
|
||||
sendVerifications() async {
|
||||
var res = await CRUD().post(link: AppLink.verifyEmail, payload: {
|
||||
'email': emailController.text,
|
||||
'token': verfyCode.text,
|
||||
});
|
||||
var dec = jsonDecode(res);
|
||||
if (dec['status'] == 'success') {
|
||||
Get.offAll(() => LoginCaptin());
|
||||
}
|
||||
}
|
||||
|
||||
void register() async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
var res = await CRUD().post(link: AppLink.signUp, payload: {
|
||||
'first_name': firstNameController.text.toString(),
|
||||
'last_name': lastNameController.text.toString(),
|
||||
'email': emailController.text.toString(),
|
||||
'phone': phoneController.text.toString(),
|
||||
'password': passwordController.text.toString(),
|
||||
'gender': 'yet',
|
||||
'site': siteController.text,
|
||||
'birthdate': birthDate,
|
||||
});
|
||||
if (jsonDecode(res)['status'] == 'success') {
|
||||
int randomNumber = Random().nextInt(100000) + 1;
|
||||
await CRUD().post(link: AppLink.sendVerifyEmail, payload: {
|
||||
'email': emailController.text,
|
||||
'token': randomNumber.toString(),
|
||||
});
|
||||
Get.to(() => const VerifyEmailPage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:siro_driver/constant/links.dart';
|
||||
import 'package:siro_driver/controller/functions/crud.dart';
|
||||
|
||||
class VerifyEmailController extends GetxController {
|
||||
TextEditingController verfyCode = TextEditingController();
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
sendverfications() async {
|
||||
await CRUD().post(link: AppLink.sendVerifyEmail);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +1 @@
|
||||
import 'dart:convert';
|
||||
import 'package:googleapis_auth/auth_io.dart';
|
||||
|
||||
import '../../print.dart';
|
||||
|
||||
class AccessTokenManager {
|
||||
static final AccessTokenManager _instance = AccessTokenManager._internal();
|
||||
late final String serviceAccountJsonKey;
|
||||
AccessToken? _accessToken;
|
||||
DateTime? _expiryDate;
|
||||
|
||||
AccessTokenManager._internal();
|
||||
|
||||
factory AccessTokenManager(String jsonKey) {
|
||||
if (_instance._isServiceAccountKeyInitialized()) {
|
||||
// Prevent re-initialization
|
||||
return _instance;
|
||||
}
|
||||
_instance.serviceAccountJsonKey = jsonKey;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
bool _isServiceAccountKeyInitialized() {
|
||||
try {
|
||||
serviceAccountJsonKey; // Access to check if initialized
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getAccessToken() async {
|
||||
if (_accessToken != null && DateTime.now().isBefore(_expiryDate!)) {
|
||||
return _accessToken!.data;
|
||||
}
|
||||
try {
|
||||
final serviceAccountCredentials = ServiceAccountCredentials.fromJson(
|
||||
json.decode(serviceAccountJsonKey));
|
||||
final client = await clientViaServiceAccount(
|
||||
serviceAccountCredentials,
|
||||
['https://www.googleapis.com/auth/firebase.messaging'],
|
||||
);
|
||||
|
||||
_accessToken = client.credentials.accessToken;
|
||||
_expiryDate = client.credentials.accessToken.expiry;
|
||||
client.close();
|
||||
// Log.print('_accessToken!.data: ${_accessToken!.data}');
|
||||
return _accessToken!.data;
|
||||
} catch (e) {
|
||||
throw Exception('Failed to obtain access token');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import 'package:siro_driver/constant/info.dart';
|
||||
import 'package:siro_driver/constant/style.dart';
|
||||
import 'package:siro_driver/constant/table_names.dart';
|
||||
import 'package:siro_driver/main.dart';
|
||||
import 'package:siro_driver/print.dart';
|
||||
import 'package:siro_driver/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
@@ -487,8 +488,10 @@ class ScanDocumentsByApi extends GetxController {
|
||||
isLoading = true;
|
||||
update();
|
||||
|
||||
final String token = box.read(BoxName.jwt)?.toString().split(AppInformation.addd)[0] ?? '';
|
||||
final String fingerPrint = box.read(BoxName.deviceFingerprint)?.toString() ?? '';
|
||||
final String token =
|
||||
box.read(BoxName.jwt)?.toString().split(AppInformation.addd)[0] ?? '';
|
||||
final String fingerPrint =
|
||||
box.read(BoxName.deviceFingerprint)?.toString() ?? '';
|
||||
final String driverID = box.read(BoxName.driverID).toString();
|
||||
final String link = AppLink.uploadImagePortrate;
|
||||
|
||||
@@ -500,11 +503,13 @@ class ScanDocumentsByApi extends GetxController {
|
||||
attempt++;
|
||||
final client = http.Client();
|
||||
try {
|
||||
Log.print('[UPLOAD_LOGGER] 🚀 [uploadImagePortrate] Attempt $attempt/$maxRetries started. Link: $link, Image Size: ${imagePortrait.length} bytes');
|
||||
|
||||
Log.print(
|
||||
'[UPLOAD_LOGGER] 🚀 [uploadImagePortrate] Attempt $attempt/$maxRetries started. Link: $link, Image Size: ${imagePortrait.length} bytes');
|
||||
|
||||
var request = http.MultipartRequest('POST', Uri.parse(link));
|
||||
request.files.add(
|
||||
http.MultipartFile.fromBytes('image', imagePortrait, filename: '$driverID.jpg'),
|
||||
http.MultipartFile.fromBytes('image', imagePortrait,
|
||||
filename: '$driverID.jpg'),
|
||||
);
|
||||
|
||||
request.headers.addAll({
|
||||
@@ -514,28 +519,35 @@ class ScanDocumentsByApi extends GetxController {
|
||||
request.fields['driverID'] = driverID;
|
||||
|
||||
final startTime = DateTime.now();
|
||||
var streamedResponse = await client.send(request).timeout(const Duration(seconds: 120));
|
||||
var streamedResponse =
|
||||
await client.send(request).timeout(const Duration(seconds: 120));
|
||||
var res = await http.Response.fromStream(streamedResponse);
|
||||
final duration = DateTime.now().difference(startTime);
|
||||
|
||||
Log.print('[UPLOAD_LOGGER] 📥 [uploadImagePortrate] Attempt $attempt response received in ${duration.inSeconds}s. Status Code: ${res.statusCode}');
|
||||
Log.print('[UPLOAD_LOGGER] 📥 [uploadImagePortrate] Response Body: ${res.body}');
|
||||
Log.print(
|
||||
'[UPLOAD_LOGGER] 📥 [uploadImagePortrate] Attempt $attempt response received in ${duration.inSeconds}s. Status Code: ${res.statusCode}');
|
||||
Log.print(
|
||||
'[UPLOAD_LOGGER] 📥 [uploadImagePortrate] Response Body: ${res.body}');
|
||||
|
||||
if (res.statusCode == 200) {
|
||||
responseString = res.body;
|
||||
break; // Success
|
||||
} else {
|
||||
throw Exception('Failed to upload portrait: ${res.statusCode} - ${res.body}');
|
||||
throw Exception(
|
||||
'Failed to upload portrait: ${res.statusCode} - ${res.body}');
|
||||
}
|
||||
} catch (e, st) {
|
||||
Log.print('[UPLOAD_LOGGER] ⚠️ [uploadImagePortrate] Attempt $attempt failed. Error: $e', stackTrace: st);
|
||||
Log.print(
|
||||
'[UPLOAD_LOGGER] ⚠️ [uploadImagePortrate] Attempt $attempt failed. Error: $e',
|
||||
stackTrace: st);
|
||||
if (attempt >= maxRetries) {
|
||||
isLoading = false;
|
||||
update();
|
||||
rethrow;
|
||||
}
|
||||
final waitSeconds = attempt * 2;
|
||||
Log.print('[UPLOAD_LOGGER] ⏳ Waiting $waitSeconds seconds before retrying...');
|
||||
Log.print(
|
||||
'[UPLOAD_LOGGER] ⏳ Waiting $waitSeconds seconds before retrying...');
|
||||
await Future.delayed(Duration(seconds: waitSeconds));
|
||||
} finally {
|
||||
client.close();
|
||||
|
||||
@@ -38,23 +38,36 @@ class AppInitializer {
|
||||
List<Map<String, dynamic>> links = [];
|
||||
|
||||
Future<void> initializeApp() async {
|
||||
if (box.read(BoxName.jwt) == null) {
|
||||
String? secureJwt = await storage.read(key: BoxName.jwt);
|
||||
if (secureJwt != null) {
|
||||
box.write(BoxName.jwt, secureJwt);
|
||||
}
|
||||
}
|
||||
|
||||
if (box.read(BoxName.jwt) == null) {
|
||||
await LoginDriverController().getJWT();
|
||||
} else {
|
||||
String token = r(box.read(BoxName.jwt)).toString().split(AppInformation.addd)[0];
|
||||
String token =
|
||||
r(box.read(BoxName.jwt)).toString().split(AppInformation.addd)[0];
|
||||
bool isTokenValid = false;
|
||||
try {
|
||||
final parts = token.split('.');
|
||||
if (parts.length == 3) {
|
||||
String payload = parts[1];
|
||||
switch (payload.length % 4) {
|
||||
case 2: payload += '=='; break;
|
||||
case 3: payload += '='; break;
|
||||
case 2:
|
||||
payload += '==';
|
||||
break;
|
||||
case 3:
|
||||
payload += '=';
|
||||
break;
|
||||
}
|
||||
final decoded = jsonDecode(utf8.decode(base64Url.decode(payload)));
|
||||
final exp = decoded['exp'];
|
||||
if (exp != null) {
|
||||
isTokenValid = DateTime.now().millisecondsSinceEpoch < (exp * 1000 - 30000);
|
||||
isTokenValid =
|
||||
DateTime.now().millisecondsSinceEpoch < (exp * 1000 - 30000);
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
@@ -66,6 +66,10 @@ class MyTranslation extends Translations {
|
||||
"4. Review Details & Response": "4. راجع التفاصيل والرد",
|
||||
"40 and get 8% discount": "40 واحصل على خصم 8%",
|
||||
"5 digit": "5 أرقام",
|
||||
"3 digit": "3 أرقام",
|
||||
"Enter the 3-digit code": "أدخل الكود المكون من ٣ أرقام",
|
||||
"Already have an account? Login": "هل لديك حساب بالفعل؟ تسجيل الدخول",
|
||||
"Don't have an account? Register": "ليس لديك حساب؟ تسجيل",
|
||||
"<< BACK": "<< رجوع",
|
||||
"A new version of the app is available. Please update to the latest version.":
|
||||
"في نسخة جديدة من التطبيق. تفضل حدّث لآخر إصدار.",
|
||||
@@ -702,7 +706,7 @@ class MyTranslation extends Translations {
|
||||
"For Siro and Delivery trips, the price is calculated dynamically. For Comfort trips, the price is based on time and distance":
|
||||
"لرحلات سيرو والتوصيل، السعر بيحسب ديناميكياً. لرحلات الكومفورت، السعر بيعتمد على الوقت والمسافة.",
|
||||
"For Siro and scooter trips, the price is calculated dynamically. For Comfort trips, the price is based on time and distance":
|
||||
"لرحلات انطلاق والسكوتر، السعر بيحسب ديناميكياً. لرحلات الكومفورت، السعر بيعتمد على الوقت والمسافة.",
|
||||
"لرحلات سيرو والسكوتر، السعر بيحسب ديناميكياً. لرحلات الكومفورت، السعر بيعتمد على الوقت والمسافة.",
|
||||
"Free Call": "مكالمة مجانية",
|
||||
"Frequently Asked Questions": "الأسئلة الشائعة",
|
||||
"Frequently Questions": "أسئلة متكررة",
|
||||
@@ -1793,7 +1797,7 @@ class MyTranslation extends Translations {
|
||||
"Type your Email": "اكتب بريدك الإلكتروني",
|
||||
"Type your message": "اكتب رسالتك",
|
||||
"Type your message...": "اكتب رسالتك...",
|
||||
"Types of Trips in Siro:": "أنواع الرحلات بانطلاق:",
|
||||
"Types of Trips in Siro:": "أنواع الرحلات بسيرو:",
|
||||
"USA": "أمريكا",
|
||||
"Uncompromising Security": "أمان لا يتنازل عنه",
|
||||
"Unknown": "غير معروف",
|
||||
@@ -1925,7 +1929,7 @@ class MyTranslation extends Translations {
|
||||
"إيش تفاصيل الطلب اللي بنقدملك؟",
|
||||
"What are the requirements to become a driver?":
|
||||
"إيش المتطلبات عشان تصير سائق؟",
|
||||
"What is Types of Trips in Siro?": "إيش أنواع الرحلات بانطلاق؟",
|
||||
"What is Types of Trips in Siro?": "إيش أنواع الرحلات بسيرو؟",
|
||||
"What is the feature of our wallet?": "إيش مميزات محفظتنا؟",
|
||||
"What safety measures does Siro offer?":
|
||||
"إيش إجراءات السلامة اللي بيقدمها سيرو؟",
|
||||
@@ -1971,7 +1975,7 @@ class MyTranslation extends Translations {
|
||||
"Yes": "إي",
|
||||
"Yes, Pay": "إي، ادفع",
|
||||
"Yes, you can cancel your ride under certain conditions (e.g., before driver is assigned). See the Siro cancellation policy for details.":
|
||||
"إي، تقدر تلغي رحلتك بشروط معينة (مثلاً قبل ما يتحدد سائق). شوف سياسة الإلغاء بانطلاق للتفاصيل.",
|
||||
"إي، تقدر تلغي رحلتك بشروط معينة (مثلاً قبل ما يتحدد سائق). شوف سياسة الإلغاء بسيرو للتفاصيل.",
|
||||
"Yes, you can cancel your ride, but please note that cancellation fees may apply depending on how far in advance you cancel.":
|
||||
"إي، تقدر تلغي رحلتك، بس انتبه إن في رسوم إلغاء ممكن تتطبق حسب الوقت اللي بتلغي فيه.",
|
||||
"You Are Stopped For this Day !": "تم إيقافك لهاليوم!",
|
||||
@@ -2389,7 +2393,7 @@ class MyTranslation extends Translations {
|
||||
"s license does not match the one on your ID document. Please verify and provide the correct documents.":
|
||||
"رخصته ما بتتطابق مع الهوية. تفضل تحقق وقدّم الوثائق الصحيحة.",
|
||||
"s license, ID document, and car registration document. Our AI system will instantly review and verify their authenticity in just 2-3 minutes. If your documents are approved, you can start working as a driver on the Siro app. Please note, submitting fraudulent documents is a serious offense and may result in immediate termination and legal consequences.":
|
||||
"رخصته، الهوية، ورخصة السيارة. نظام الذكاء الاصطناعي رح يراجعها ويوثّقها بدقيقتين لـ 3. إذا انقبلت، تقبل تشتغل كسائق بانطلاق. انتبه، تزوير وثائق جريمة خطيرة وبتسبب فصل فوري وعواقب قانونية.",
|
||||
"رخصته، الهوية، ورخصة السيارة. نظام الذكاء الاصطناعي رح يراجعها ويوثّقها بدقيقتين لـ 3. إذا انقبلت، تقبل تشتغل كسائق بسيرو. انتبه، تزوير وثائق جريمة خطيرة وبتسبب فصل فوري وعواقب قانونية.",
|
||||
"s license. Please verify and provide the correct documents.":
|
||||
"رخصته. تفضل تحقق وقدّم الوثائق الصحيحة.",
|
||||
"s phone": "هاتف",
|
||||
@@ -2484,10 +2488,10 @@ class MyTranslation extends Translations {
|
||||
"wallet due to a previous trip.": "المحفظة بسبب رحلة سابقة.",
|
||||
"wallet_credited_message": "تم إضافة",
|
||||
"wallet_updated": "تم تحديث المحفظة",
|
||||
"welcome to siro": "أهلاً بانطلاق",
|
||||
"welcome to siro": "أهلاً بك في سيرو",
|
||||
"welcome user": "أهلاً بالمستخدم",
|
||||
"welcome_message": "رسالة الترحيب",
|
||||
"welcome_to_siro": "أهلاً بانطلاق",
|
||||
"welcome_to_siro": "أهلاً بك في سيرو",
|
||||
"with type": "بالنوع",
|
||||
"witout zero": "بدون صفر",
|
||||
"write Color for your car": "اكتب لون سيارتك",
|
||||
|
||||
Reference in New Issue
Block a user