This commit is contained in:
Hamza-Ayed
2024-07-05 23:46:05 +03:00
parent dc4677a6bf
commit 23ecaba97c
17 changed files with 310 additions and 225 deletions

View File

@@ -1,21 +1,19 @@
import 'package:encrypt/encrypt.dart' as encrypt;
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:encrypt/encrypt.dart' as encrypt;
//
import 'dart:convert';
import 'dart:math';
import 'package:encrypt/encrypt.dart' as encrypt;
import '../../constant/api_key.dart';
class KeyEncryption {
static final _key = encrypt.Key.fromUtf8('mehmetDEV@2101'); // ضع مفتاحك هنا
// استخدم مفتاح بطول 32 حرفًا
static final _key = encrypt.Key.fromUtf8(AK.keyOfApp);
static final _iv =
encrypt.IV.fromLength(16); // توليد تهيئة عشوائية بطول 16 بايت
static String encryptKey(String key) {
final iv = encrypt.IV.fromLength(16); // توليد تهيئة عشوائية
final encrypter =
encrypt.Encrypter(encrypt.AES(_key, mode: encrypt.AESMode.cbc));
final encrypted = encrypter.encrypt(key, iv: iv);
final result = iv.bytes + encrypted.bytes; // تضمين التهيئة مع النص المشفر
final encrypted = encrypter.encrypt(key, iv: _iv);
final result = _iv.bytes + encrypted.bytes; // تضمين التهيئة مع النص المشفر
return base64Encode(result);
}
@@ -29,55 +27,3 @@ class KeyEncryption {
return encrypter.decrypt(encrypted, iv: iv);
}
}
// class KeyEncryption {
// static final _key = encrypt.Key.fromUtf8('7'); // ضع مفتاحك هنا
//
// static String encryptKey(String key) {
// final iv = encrypt.IV.fromLength(16); // توليد تهيئة عشوائية
// final encrypter =
// encrypt.Encrypter(encrypt.AES(_key, mode: encrypt.AESMode.cbc));
// final encrypted = encrypter.encrypt(key, iv: iv);
// final result = iv.bytes + encrypted.bytes; // تضمين التهيئة مع النص المشفر
// return base64Encode(result);
// }
//
// static String decryptKey(String encryptedKey) {
// final decoded = base64Decode(encryptedKey);
// final iv = encrypt.IV(decoded.sublist(0, 16)); // استخراج التهيئة
// final encrypted =
// encrypt.Encrypted(decoded.sublist(16)); // استخراج النص المشفر
// final encrypter =
// encrypt.Encrypter(encrypt.AES(_key, mode: encrypt.AESMode.cbc));
// return encrypter.decrypt(encrypted, iv: iv);
// }
// }
// class KeyEncryption {
// static final _key =
// encrypt.Key.fromUtf8('32-character-key....'); // ضع مفتاحك هنا
//
// static String encryptKey(String key) {
// final iv = encrypt.IV.fromLength(16); // توليد تهيئة عشوائية
// final encrypter =
// encrypt.Encrypter(encrypt.AES(_key, mode: encrypt.AESMode.cbc));
// final encrypted = encrypter.encrypt(key, iv: iv);
// final result = iv.bytes + encrypted.bytes; // تضمين التهيئة مع النص المشفر
// return base64Encode(result);
// }
//
// static Future<void> storeApiKeys(List<String> apiKeys) async {
// final encryptedKeys = apiKeys.map((key) => encryptKey(key)).toList();
// final response = await http.post(
// Uri.parse('https://yourdomain.com/store_keys.php'),
// body: jsonEncode({'keys': encryptedKeys}),
// headers: {'Content-Type': 'application/json'},
// );
//
// if (response.statusCode == 200) {
// print('Keys stored successfully.');
// } else {
// print('Failed to store keys.');
// }
// }
// }

View File

@@ -0,0 +1,67 @@
import 'dart:convert';
import 'dart:io';
import 'package:SEFER/constant/links.dart';
import 'package:SEFER/controller/functions/crud.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../constant/info.dart';
Future<void> checkForUpdate(BuildContext context) async {
final packageInfo = await PackageInfo.fromPlatform();
final currentVersion = packageInfo.buildNumber;
print('currentVersion is : $currentVersion');
// Fetch the latest version from your server
String latestVersion = await getPackageInfo();
if (latestVersion.isNotEmpty && latestVersion != currentVersion) {
showUpdateDialog(context);
}
}
Future<String> getPackageInfo() async {
final response = await CRUD().get(link: AppLink.packageInfo, payload: {
"platform": Platform.isAndroid ? 'android' : 'ios',
"appName": AppInformation.appName,
});
if (response != 'failure') {
return jsonDecode(response)['message'][0]['version'];
}
return '';
}
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';
showCupertinoDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return CupertinoAlertDialog(
title: Text('Update Available'.tr),
content: Text(
'A new version of the app is available. Please update to the latest version.'
.tr,
),
actions: <Widget>[
CupertinoDialogAction(
child: Text('Update'.tr),
onPressed: () async {
if (await canLaunchUrl(Uri.parse(storeUrl))) {
await launchUrl(Uri.parse(storeUrl));
} else {
print('Could not launch $storeUrl');
}
Navigator.of(context).pop();
},
),
],
);
},
);
}

View File

@@ -4,6 +4,9 @@ class MyTranslation extends Translations {
@override
Map<String, Map<String, String>> get keys => {
"ar": {
"Update Available": "تحديث متوفر",
"A new version of the app is available. Please update to the latest version.":
"تتوفر نسخة جديدة من التطبيق. يرجى التحديث إلى أحدث إصدار.",
"We use location to get accurate and nearest passengers for you":
"نستخدم الموقع للحصول على أقرب الركاب وأكثرهم دقة لك",
"This ride is already applied by another driver.":

View File

@@ -56,43 +56,44 @@ class RateController extends GetxController {
if (value != 'failure') {
Get.snackbar('Wallet Added'.tr, '',
backgroundColor: AppColor.greenColor);
if (double.parse(
Get.find<CaptainWalletController>().totalAmountVisa) >
remainingFee) {
var paymentToken3 = await Get.find<MapDriverController>()
.generateTokenDriver((-1 * remainingFee).toString());
// if (double.parse(
// Get.find<CaptainWalletController>().totalAmountVisa) >
// remainingFee) {
var paymentToken3 = await Get.find<MapDriverController>()
.generateTokenDriver((-1 * remainingFee).toString());
await CRUD().post(link: AppLink.addDrivePayment, payload: {
'rideId': 'remain$rideId',
'amount': (-1 * remainingFee).toString(),
'payment_method': 'Remainder',
'passengerID': passengerId,
'token': paymentToken3,
'driverID': box.read(BoxName.driverID).toString(),
});
} else {
double pointsSubtraction = 0;
pointsSubtraction = remainingFee *
(-1) /
double.parse(
Get.find<MapDriverController>().kazan); // for egypt /100
var paymentToken4 = await Get.find<MapDriverController>()
.generateTokenDriver((pointsSubtraction).toStringAsFixed(0));
var res = await CRUD()
.post(link: AppLink.addDriversWalletPoints, payload: {
'paymentID': 'rideId$rideId',
'amount': (pointsSubtraction).toStringAsFixed(0),
'paymentMethod': 'Remainder',
'token': paymentToken4,
'driverID': box.read(BoxName.driverID).toString(),
});
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'Wallet Added'.tr,
'Wallet Added${(remainingFee).toStringAsFixed(0)}'.tr,
Get.find<MapDriverController>().tokenPassenger,
'tone2.wav');
walletChecked = 'true';
}
await CRUD().post(link: AppLink.addDrivePayment, payload: {
'rideId': 'remain$rideId',
'amount': (-1 * remainingFee).toString(),
'payment_method': 'Remainder',
'passengerID': passengerId,
'token': paymentToken3,
'driverID': box.read(BoxName.driverID).toString(),
});
// }
// else {
// double pointsSubtraction = 0;
// pointsSubtraction = remainingFee *
// (-1) /
// double.parse(
// Get.find<MapDriverController>().kazan); // for egypt /100
// var paymentToken4 = await Get.find<MapDriverController>()
// .generateTokenDriver((pointsSubtraction).toStringAsFixed(0));
// var res = await CRUD()
// .post(link: AppLink.addDriversWalletPoints, payload: {
// 'paymentID': 'rideId$rideId',
// 'amount': (pointsSubtraction).toStringAsFixed(0),
// 'paymentMethod': 'Remainder',
// 'token': paymentToken4,
// 'driverID': box.read(BoxName.driverID).toString(),
// });
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'Wallet Added'.tr,
'Wallet Added${(remainingFee).toStringAsFixed(0)}'.tr,
Get.find<MapDriverController>().tokenPassenger,
'tone2.wav');
walletChecked = 'true';
// }
update();
}