25-1/4/1
This commit is contained in:
@@ -166,7 +166,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
'token change'.tr, 'token change'.tr, 'cancel');
|
||||
}
|
||||
GoogleSignInHelper.signOut();
|
||||
} else if (message.notification!.title! == 'DriverIsGoingToPassenger'.tr) {
|
||||
} else if (message.notification!.title! == 'Driver Is Going To Passenger'.tr) {
|
||||
Get.find<MapPassengerController>().isDriverInPassengerWay = true;
|
||||
Get.find<MapPassengerController>().update();
|
||||
if (Platform.isAndroid) {
|
||||
|
||||
@@ -31,12 +31,6 @@ class CRUD {
|
||||
},
|
||||
);
|
||||
|
||||
Log.print('response.request: ${response.request}');
|
||||
Log.print('payload: ${payload}');
|
||||
// Log.print('response.reasonPhrase: ${response.reasonPhrase}');
|
||||
|
||||
Log.print('response.body: ${response.body}');
|
||||
// print(payload);
|
||||
// if (response.statusCode == 200) {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
if (jsonData['status'] == 'success') {
|
||||
@@ -110,15 +104,10 @@ class CRUD {
|
||||
request.headers.addAll(headers);
|
||||
|
||||
try {
|
||||
print('Sending request to $url');
|
||||
print('Request headers: $headers');
|
||||
print('Request body: $body');
|
||||
|
||||
http.StreamedResponse response = await request.send();
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
String responseBody = await response.stream.bytesToString();
|
||||
print('Response: $responseBody');
|
||||
|
||||
Get.defaultDialog(
|
||||
title: 'You will receive a code in WhatsApp Messenger'.tr,
|
||||
@@ -132,12 +121,8 @@ class CRUD {
|
||||
);
|
||||
} else {
|
||||
String errorBody = await response.stream.bytesToString();
|
||||
print('Error ${response.statusCode}: ${response.reasonPhrase}');
|
||||
print('Error body: $errorBody');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Exception occurred: $e');
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
Future<dynamic> getAgoraToken({
|
||||
@@ -302,9 +287,6 @@ class CRUD {
|
||||
// 'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
|
||||
// },
|
||||
// );
|
||||
// Log.print('payload: ${payload}');
|
||||
// Log.print('response.request: ${response.request}');
|
||||
// Log.print('response.body: ${response.body}');
|
||||
// var jsonData = jsonDecode(response.body);
|
||||
// if (response.statusCode == 200) {
|
||||
// if (jsonData['status'] == 'success') {
|
||||
@@ -332,11 +314,6 @@ class CRUD {
|
||||
},
|
||||
);
|
||||
|
||||
Log.print('Response.request: ${response.request}');
|
||||
Log.print('Payload: $payload');
|
||||
// Log.print('Response.statusCode: ${response.statusCode}');
|
||||
Log.print('Response.body: ${response.body}');
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
try {
|
||||
var jsonData = jsonDecode(response.body);
|
||||
@@ -347,18 +324,15 @@ class CRUD {
|
||||
return jsonData['status'];
|
||||
}
|
||||
} catch (e) {
|
||||
Log.print('JSON parsing error: $e');
|
||||
addError(e.toString(), 'crud().post');
|
||||
return 'failure'; // Return a recognizable failure string for JSON errors
|
||||
}
|
||||
} else {
|
||||
Log.print('Non-200 response code: ${response.statusCode}');
|
||||
addError(
|
||||
'Non-200 response code: ${response.statusCode}', 'crud().post');
|
||||
return 'failure'; // Handle unexpected status codes as failures
|
||||
}
|
||||
} catch (e) {
|
||||
Log.print('HTTP request error: $e');
|
||||
addError('HTTP request error: $e', 'crud().post');
|
||||
return 'failure'; // Handle HTTP request errors as failures
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
import '../../constant/links.dart';
|
||||
import '../../main.dart';
|
||||
import 'crud.dart';
|
||||
|
||||
class SecureStorage {
|
||||
final FlutterSecureStorage _storage = const FlutterSecureStorage();
|
||||
|
||||
@@ -12,3 +18,41 @@ class SecureStorage {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
const List<String> keysToFetch = [
|
||||
'serverPHP',
|
||||
'seferAlexandriaServer',
|
||||
'seferPaymentServer',
|
||||
'seferCairoServer',
|
||||
'seferGizaServer',
|
||||
];
|
||||
|
||||
class AppInitializer {
|
||||
// final FlutterSecureStorage _storage = const FlutterSecureStorage();
|
||||
|
||||
Future<void> initializeApp() async {
|
||||
// Check if app is running for the first time
|
||||
|
||||
// Loop through the keys and fetch their values
|
||||
for (String key in keysToFetch) {
|
||||
try {
|
||||
String? value = await getKey(key); // Fetch from server
|
||||
if (value != null) {
|
||||
await box.write(key, value); // Save securely
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
Future<String?> getKey(String key) async {
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.getapiKey, payload: {"keyName": key});
|
||||
if (res != 'failure') {
|
||||
try {
|
||||
var data = jsonDecode(res)['message'];
|
||||
return data[key]?.toString();
|
||||
} catch (e) {}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5222,13 +5222,24 @@ class MapPassengerController extends GetxController {
|
||||
link: AppLink.getPassengerRate,
|
||||
payload: {'passenger_id': box.read(BoxName.passengerID)});
|
||||
if (res != 'failure') {
|
||||
if (jsonDecode(res)['message']['rating'] == null) {
|
||||
passengerRate = 5;
|
||||
var message = jsonDecode(res)['message'];
|
||||
if (message['rating'] == null) {
|
||||
passengerRate = 5.0; // Default rating
|
||||
} else {
|
||||
passengerRate = jsonDecode(res)['message']['rating'].toDouble();
|
||||
// Safely parse the rating to double
|
||||
var rating = message['rating'];
|
||||
if (rating is String) {
|
||||
passengerRate =
|
||||
double.tryParse(rating) ?? 5.0; // Default if parsing fails
|
||||
} else if (rating is num) {
|
||||
passengerRate =
|
||||
rating.toDouble(); // Already a number, convert to double
|
||||
} else {
|
||||
passengerRate = 5.0; // Default for unexpected data types
|
||||
}
|
||||
}
|
||||
} else {
|
||||
passengerRate = 5;
|
||||
passengerRate = 5.0; // Default rating for failure
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user