11/20/1
This commit is contained in:
@@ -12,13 +12,15 @@ class TokenController extends GetxController {
|
||||
bool isloading = false;
|
||||
|
||||
Future addToken() async {
|
||||
String? basicAuthCredentials =
|
||||
await storage.read(key: BoxName.basicAuthCredentials);
|
||||
isloading = true;
|
||||
update();
|
||||
var res = await http.post(
|
||||
Uri.parse(AppLink.addTokens),
|
||||
headers: {
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
|
||||
'Basic ${base64Encode(utf8.encode(basicAuthCredentials.toString()))}',
|
||||
},
|
||||
body: {
|
||||
'token': box.read(BoxName.tokenFCM.toString()),
|
||||
|
||||
@@ -64,11 +64,13 @@ class FirebaseMessagesController extends GetxController {
|
||||
}
|
||||
|
||||
Future getTokens() async {
|
||||
String? basicAuthCredentials =
|
||||
await storage.read(key: BoxName.basicAuthCredentials);
|
||||
var res = await http.post(
|
||||
Uri.parse(AppLink.getTokens),
|
||||
headers: {
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
|
||||
'Basic ${base64Encode(utf8.encode(basicAuthCredentials.toString()))}',
|
||||
},
|
||||
body: {},
|
||||
);
|
||||
@@ -94,7 +96,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
} else {
|
||||
box.write(BoxName.tokenFCM, token);
|
||||
}
|
||||
print(token);
|
||||
// print(token);
|
||||
});
|
||||
|
||||
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
|
||||
@@ -120,7 +122,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
driverID = myList[2].toString();
|
||||
|
||||
Get.snackbar(
|
||||
'Captin Applied the Ride for You'.tr,
|
||||
'Captain Applied the Ride for You'.tr,
|
||||
'message',
|
||||
colorText: AppColor.greenColor,
|
||||
duration: const Duration(seconds: 11),
|
||||
@@ -131,7 +133,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
style: const TextStyle(color: AppColor.redColor),
|
||||
),
|
||||
messageText: Text(
|
||||
'Captin Applied the Ride for You'.tr,
|
||||
'Captain Applied the Ride for You'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
icon: const Icon(Icons.approval),
|
||||
@@ -221,17 +223,17 @@ class FirebaseMessagesController extends GetxController {
|
||||
onPressed: () {
|
||||
String mapUrl =
|
||||
'https://www.google.com/maps/dir/${myList[0]}/${myList[1]}/';
|
||||
print(mapUrl);
|
||||
// print(mapUrl);
|
||||
launchUrl1(mapUrl);
|
||||
},
|
||||
icon: const Icon(Icons.map),
|
||||
label: Text('Rouats of Trip'.tr)),
|
||||
label: Text('Routs of Trip'.tr)),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
'Tatal From Passenger is '.tr +
|
||||
'Total From Passenger is '.tr +
|
||||
double.parse(myList[2]).toStringAsFixed(2),
|
||||
style: AppStyle.title,
|
||||
),
|
||||
@@ -239,7 +241,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
'Tatal For You is '.tr +
|
||||
'Total For You is '.tr +
|
||||
double.parse(myList[3]).toStringAsFixed(2),
|
||||
style: AppStyle.title,
|
||||
),
|
||||
@@ -315,7 +317,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
var myList = jsonDecode(passengerList) as List<dynamic>;
|
||||
driverID = myList[2].toString();
|
||||
Get.snackbar(
|
||||
'Captin Applied the Ride for You'.tr,
|
||||
'Captain Applied the Ride for You'.tr,
|
||||
'message',
|
||||
colorText: AppColor.greenColor,
|
||||
duration: const Duration(seconds: 11),
|
||||
@@ -326,7 +328,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
style: const TextStyle(color: AppColor.redColor),
|
||||
),
|
||||
messageText: Text(
|
||||
'Captin Applied the Ride for You'.tr,
|
||||
'Captain Applied the Ride for You'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
icon: const Icon(Icons.approval),
|
||||
@@ -404,7 +406,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
.post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'key=${AppCredintials.serverAPI}'
|
||||
'Authorization': 'key=${storage.read(key: BoxName.serverAPI)}'
|
||||
},
|
||||
body: jsonEncode({
|
||||
'notification': <String, dynamic>{
|
||||
@@ -432,7 +434,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
// .post(Uri.parse('https://fcm.googleapis.com/fcm/send'),
|
||||
// headers: <String, String>{
|
||||
// 'Content-Type': 'application/json',
|
||||
// 'Authorization': 'key=${AppCredintials.serverAPI}'
|
||||
// 'Authorization': 'key=${storage.read(key: BoxName.serverAPI}'
|
||||
// },
|
||||
// body: jsonEncode({
|
||||
// 'notification': <String, dynamic>{
|
||||
@@ -462,7 +464,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
Uri.parse('https://fcm.googleapis.com/fcm/send'),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'key=${AppCredintials.serverAPI}'
|
||||
'Authorization': 'key=${storage.read(key: BoxName.serverAPI)}'
|
||||
},
|
||||
body: jsonEncode({
|
||||
'notification': <String, dynamic>{
|
||||
@@ -499,7 +501,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
Uri.parse('https://fcm.googleapis.com/fcm/send'),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'key=${AppCredintials.serverAPI}'
|
||||
'Authorization': 'key=${storage.read(key: BoxName.serverAPI)}'
|
||||
},
|
||||
body: jsonEncode({
|
||||
'notification': <String, dynamic>{
|
||||
@@ -538,7 +540,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
Uri.parse('https://fcm.googleapis.com/fcm/send'),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'key=${AppCredintials.serverAPI}'
|
||||
'Authorization': 'key=${storage.read(key: BoxName.serverAPI)}'
|
||||
},
|
||||
body: jsonEncode({
|
||||
'notification': <String, dynamic>{
|
||||
|
||||
@@ -99,6 +99,8 @@ class CameraClassController extends GetxController {
|
||||
}
|
||||
|
||||
Future<String> uploadImage(File imageFile) async {
|
||||
String? basicAuthCredentials =
|
||||
await storage.read(key: BoxName.basicAuthCredentials);
|
||||
var request = http.MultipartRequest(
|
||||
'POST',
|
||||
Uri.parse(AppLink.uploadImage),
|
||||
@@ -111,7 +113,7 @@ class CameraClassController extends GetxController {
|
||||
request.headers.addAll({
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
|
||||
'Basic ${base64Encode(utf8.encode(basicAuthCredentials.toString()))}',
|
||||
});
|
||||
|
||||
// Add the driverID to the request
|
||||
|
||||
@@ -2,13 +2,17 @@ import 'dart:convert';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/credential.dart';
|
||||
import '../../main.dart';
|
||||
|
||||
class CRUD {
|
||||
Future<dynamic> get({
|
||||
required String link,
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
String? basicAuthCredentials =
|
||||
await storage.read(key: BoxName.basicAuthCredentials);
|
||||
var url = Uri.parse(
|
||||
link,
|
||||
);
|
||||
@@ -18,7 +22,7 @@ class CRUD {
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
|
||||
'Basic ${base64Encode(utf8.encode(basicAuthCredentials.toString()))}',
|
||||
},
|
||||
);
|
||||
print("--------------" + response.request.toString());
|
||||
@@ -26,7 +30,7 @@ class CRUD {
|
||||
if (response.statusCode == 200) {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (jsonData['status'] == 'success') {
|
||||
print(jsonData);
|
||||
// print(jsonData);
|
||||
|
||||
return response.body;
|
||||
}
|
||||
@@ -39,6 +43,7 @@ class CRUD {
|
||||
required String link,
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
String? secretKey = await storage.read(key: BoxName.secretKey);
|
||||
var url = Uri.parse(
|
||||
link,
|
||||
);
|
||||
@@ -47,7 +52,7 @@ class CRUD {
|
||||
body: payload,
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization': 'Bearer ${StripeKey.secretKey}',
|
||||
'Authorization': 'Bearer ${secretKey.toString()}',
|
||||
},
|
||||
);
|
||||
|
||||
@@ -58,6 +63,8 @@ class CRUD {
|
||||
required String link,
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
String? basicAuthCredentials =
|
||||
await storage.read(key: BoxName.basicAuthCredentials);
|
||||
var url = Uri.parse(
|
||||
link,
|
||||
);
|
||||
@@ -67,7 +74,7 @@ class CRUD {
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
|
||||
'Basic ${base64Encode(utf8.encode(basicAuthCredentials.toString()))}',
|
||||
},
|
||||
);
|
||||
print(response.request);
|
||||
@@ -91,6 +98,8 @@ class CRUD {
|
||||
required String link,
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
String? basicAuthCredentials =
|
||||
await storage.read(key: BoxName.basicAuthCredentials);
|
||||
var url = Uri.parse(
|
||||
link,
|
||||
);
|
||||
@@ -100,7 +109,7 @@ class CRUD {
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
|
||||
'Basic ${base64Encode(utf8.encode(basicAuthCredentials.toString()))}',
|
||||
},
|
||||
);
|
||||
print(response.request);
|
||||
@@ -149,13 +158,15 @@ class CRUD {
|
||||
required Map<String, dynamic> data,
|
||||
required String id,
|
||||
}) async {
|
||||
String? basicAuthCredentials =
|
||||
await storage.read(key: BoxName.basicAuthCredentials);
|
||||
var url = Uri.parse('$endpoint/$id');
|
||||
var response = await http.put(
|
||||
url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
|
||||
'Basic ${base64Encode(utf8.encode(basicAuthCredentials.toString()))}',
|
||||
},
|
||||
);
|
||||
return json.decode(response.body);
|
||||
@@ -165,12 +176,14 @@ class CRUD {
|
||||
required String endpoint,
|
||||
required String id,
|
||||
}) async {
|
||||
String? basicAuthCredentials =
|
||||
await storage.read(key: BoxName.basicAuthCredentials);
|
||||
var url = Uri.parse('$endpoint/$id');
|
||||
var response = await http.delete(
|
||||
url,
|
||||
headers: {
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
|
||||
'Basic ${base64Encode(utf8.encode(basicAuthCredentials.toString()))}',
|
||||
},
|
||||
);
|
||||
return json.decode(response.body);
|
||||
|
||||
@@ -284,6 +284,7 @@ class ScanDocumentsByApi extends GetxController {
|
||||
///
|
||||
|
||||
Future<void> scanDocumentsByApi() async {
|
||||
String? visionApi = await storage.read(key: BoxName.visionApi);
|
||||
// Pick an image from the camera or gallery
|
||||
image = await imagePicker.pickImage(source: ImageSource.camera);
|
||||
|
||||
@@ -294,7 +295,7 @@ class ScanDocumentsByApi extends GetxController {
|
||||
|
||||
isLoading = true;
|
||||
update();
|
||||
var headers = {'X-BLOBR-KEY': AppCredintials.visionApi};
|
||||
var headers = {'X-BLOBR-KEY': visionApi.toString()};
|
||||
var request = http.MultipartRequest('POST',
|
||||
Uri.parse('https://api.faceonlive.com/j2y3q25y1b6maif1/api/iddoc'));
|
||||
request.files.add(await http.MultipartFile.fromPath('image', image!.path));
|
||||
@@ -398,6 +399,7 @@ class ScanDocumentsByApi extends GetxController {
|
||||
|
||||
Map res = {};
|
||||
Future matchFaceApi() async {
|
||||
String? visionApi = await storage.read(key: BoxName.visionApi);
|
||||
imageFace = await imagePicker.pickImage(
|
||||
source: ImageSource.camera,
|
||||
preferredCameraDevice: CameraDevice.front,
|
||||
@@ -409,7 +411,7 @@ class ScanDocumentsByApi extends GetxController {
|
||||
}
|
||||
final imageFile = File(imageFace!.path);
|
||||
// Uint8List imageBytes = await imageFile.readAsBytes();
|
||||
var headers = {'X-BLOBR-KEY': AppCredintials.visionApi};
|
||||
var headers = {'X-BLOBR-KEY': visionApi.toString()};
|
||||
var request = http.MultipartRequest(
|
||||
'POST',
|
||||
Uri.parse(
|
||||
@@ -484,6 +486,8 @@ class ScanDocumentsByApi extends GetxController {
|
||||
// Todo upload images and fields
|
||||
|
||||
Future<String> uploadImage(File imageFile) async {
|
||||
String? basicAuthCredentials =
|
||||
await storage.read(key: BoxName.basicAuthCredentials);
|
||||
var request = http.MultipartRequest(
|
||||
'POST',
|
||||
Uri.parse(AppLink.uploadImage),
|
||||
@@ -496,7 +500,7 @@ class ScanDocumentsByApi extends GetxController {
|
||||
request.headers.addAll({
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}',
|
||||
'Basic ${base64Encode(utf8.encode(basicAuthCredentials.toString()))}',
|
||||
});
|
||||
|
||||
// Add the driverID to the request
|
||||
|
||||
@@ -59,6 +59,7 @@ class MapDriverController extends GetxController {
|
||||
String stringRemainingTimeRideBegin = '';
|
||||
double progressTimerRideBegin = 0;
|
||||
late Timer timer;
|
||||
String? mapAPIKEY;
|
||||
|
||||
void onMapCreated(GoogleMapController controller) {
|
||||
LocationController locationController = Get.find<LocationController>();
|
||||
@@ -315,7 +316,7 @@ class MapDriverController extends GetxController {
|
||||
update();
|
||||
|
||||
var url =
|
||||
('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AppCredintials.mapAPIKEY}');
|
||||
('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${mapAPIKEY}');
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
data = response['routes'][0]['legs'];
|
||||
@@ -359,7 +360,8 @@ class MapDriverController extends GetxController {
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
void onInit() async {
|
||||
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
|
||||
// Get the passenger location from the arguments.
|
||||
passengerLocation = Get.arguments['passengerLocation'];
|
||||
duration = Get.arguments['Duration'];
|
||||
|
||||
@@ -89,6 +89,7 @@ class MapPassengerController extends GetxController {
|
||||
bool isPassengerChosen = false;
|
||||
late String driverToken;
|
||||
int carsOrder = 0;
|
||||
String? mapAPIKEY;
|
||||
|
||||
void onChangedPassengerCount(int newValue) {
|
||||
selectedPassengerCount = newValue;
|
||||
@@ -596,8 +597,8 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
Future getPlaces() async {
|
||||
var url =
|
||||
// '${AppLink.googleMapsLink}place/nearbysearch/json?location=${mylocation.longitude}&radius=25000&language=ar&keyword=&key=${placeController.text}${AppCredintials.mapAPIKEY}';
|
||||
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeController.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=ar&key=${AppCredintials.mapAPIKEY}';
|
||||
// '${AppLink.googleMapsLink}place/nearbysearch/json?location=${mylocation.longitude}&radius=25000&language=ar&keyword=&key=${placeController.text}${mapAPIKEY}';
|
||||
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeController.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=ar&key=${mapAPIKEY.toString()}';
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
|
||||
@@ -811,7 +812,7 @@ class MapPassengerController extends GetxController {
|
||||
update();
|
||||
// Make API request to get exact distance and duration
|
||||
String apiUrl =
|
||||
'${AppLink.googleMapsLink}distancematrix/json?destinations=${carLocation['latitude']},${carLocation['longitude']}&origins=${myLocation.latitude},${myLocation.longitude}&units=metric&key=${AppCredintials.mapAPIKEY}';
|
||||
'${AppLink.googleMapsLink}distancematrix/json?destinations=${carLocation['latitude']},${carLocation['longitude']}&origins=${myLocation.latitude},${myLocation.longitude}&units=metric&key=${mapAPIKEY}';
|
||||
var response = await CRUD().getGoogleApi(link: apiUrl, payload: {});
|
||||
if (response['status'] == "OK") {
|
||||
var data = response;
|
||||
@@ -872,7 +873,7 @@ class MapPassengerController extends GetxController {
|
||||
// print(carsLocationByPassenger);
|
||||
|
||||
var url =
|
||||
('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AppCredintials.mapAPIKEY}');
|
||||
('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${mapAPIKEY}');
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
data = response['routes'][0]['legs'];
|
||||
@@ -1157,6 +1158,7 @@ class MapPassengerController extends GetxController {
|
||||
String? cardNumber;
|
||||
@override
|
||||
void onInit() async {
|
||||
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
|
||||
await getLocation();
|
||||
await getCarsLocationByPassenger();
|
||||
getNearestDriverByPassengerLocation();
|
||||
|
||||
Reference in New Issue
Block a user