Initial commit

This commit is contained in:
Hamza-Ayed
2024-10-12 19:19:26 +03:00
parent 2e3ce78fe8
commit aca697578d
41 changed files with 2976 additions and 1188 deletions

View File

@@ -1,10 +1,17 @@
import 'dart:io';
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/controller/auth/login_controller.dart';
import 'package:SEFER/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../constant/links.dart';
import '../../onbording_page.dart';
import '../functions/crud.dart';
class GoogleSignInHelper {
static final GoogleSignIn _googleSignIn = GoogleSignIn(
@@ -32,26 +39,114 @@ class GoogleSignInHelper {
}
}
static Future<GoogleSignInAccount?> signInFromLogin() async {
Future<GoogleSignInAccount?> signInFromLogin() async {
try {
final GoogleSignInAccount? googleUser = await _googleSignIn.signIn();
if (googleUser != null) {
await _handleSignUp(googleUser);
// if (box.read(BoxName.countryCode) == 'Egypt') {
await Get.put(LoginController()).loginUsingCredentials(
box.read(BoxName.passengerID).toString(),
box.read(BoxName.email).toString(),
);
// } else if (box.read(BoxName.countryCode) == 'Jordan') {
// // Get.to(() => AiPage());
// }
}
return googleUser;
} catch (error) {
// if (error is GoogleSignInAuthenticationException) {
// // Handle authentication errors from Google Sign-In
// addError("Google sign-in authentication error: ${error.message}",
// '<GoogleSignInAccount?> signInFromLogin()');
// } else if (error is GoogleSignInAccountNotFoundException) {
// // Handle the case where the user is not found (if applicable)
// addError("Google sign-in account not found error: ${error.message}",
// '<GoogleSignInAccount?> signInFromLogin()');
// }
// else
if (error is SocketException) {
// Handle network issues, like SSL certificate issues
addError("Network error (SSL certificate issue): ${error.message}",
'<GoogleSignInAccount?> signInFromLogin()');
} else if (error is PlatformException) {
// Handle platform-specific errors, like Google Play Services issues
if (error.code == 'sign_in_required') {
// Google Play Services are required but not installed or outdated
showGooglePlayServicesError();
} else {
addError("Platform error: ${error.message}",
'<GoogleSignInAccount?> signInFromLogin()');
}
} else {
// Catch all other unknown errors
addError("Unknown error: ${error.toString()}",
'<GoogleSignInAccount?> signInFromLogin()');
}
return null;
}
}
void showGooglePlayServicesError() async {
const playStoreUrl =
'https://play.google.com/store/apps/details?id=com.google.android.gms&hl=en_US';
if (await canLaunchUrl(Uri.parse(playStoreUrl))) {
await launchUrl(Uri.parse(playStoreUrl));
} else {
// Fallback if the URL can't be opened
showDialog(
context: Get.context!,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Error'.tr),
content: Text(
'Could not open the Google Play Store. Please update Google Play Services manually.'
.tr),
actions: <Widget>[
TextButton(
onPressed: () => Navigator.pop(context),
child: Text('Close'.tr),
),
],
);
},
);
}
}
// Future<GoogleSignInAccount?> signInFromLogin() async {
// try {
// final GoogleSignInAccount? googleUser = await _googleSignIn.signIn();
// if (googleUser != null) {
// await _handleSignUp(googleUser);
// // if (box.read(BoxName.countryCode) == 'Egypt') {
// await Get.put(LoginController()).loginUsingCredentials(
// box.read(BoxName.passengerID).toString(),
// box.read(BoxName.email).toString(),
// );
// // } else if (box.read(BoxName.countryCode) == 'Jordan') {
// // // Get.to(() => AiPage());
// // }
// }
// return googleUser;
// } catch (error) {
// addError(error.toString(), '<GoogleSignInAccount?> signInFromLogin()');
// return null;
// }
// }
addError(String error, where) async {
CRUD().post(link: AppLink.addError, payload: {
'error': error.toString(), // Example error description
'userId': box.read(BoxName.driverID) ??
box.read(BoxName.passengerID), // Example user ID
'userType': box.read(BoxName.driverID) != null
? 'Driver'
: 'passenger', // Example user type
'phone': box.read(BoxName.phone) ??
box.read(BoxName.phoneDriver), // Example phone number
'device': where
});
}
// Method to handle Google Sign-Out
static Future<void> signOut() async {
try {

View File

@@ -1,9 +1,11 @@
import 'dart:convert';
import 'dart:io';
import 'package:SEFER/constant/info.dart';
import 'package:SEFER/controller/firebase/firbase_messge.dart';
import 'package:SEFER/views/auth/login_page.dart';
import 'package:SEFER/views/auth/sms_verfy_page.dart';
import 'package:SEFER/views/widgets/my_dialog.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:SEFER/constant/box_name.dart';
@@ -13,6 +15,8 @@ import 'package:SEFER/main.dart';
import 'package:SEFER/views/home/map_page_passenger.dart';
import 'package:location/location.dart';
import '../functions/package_info.dart';
class LoginController extends GetxController {
final formKey = GlobalKey<FormState>();
final formKeyAdmin = GlobalKey<FormState>();
@@ -29,9 +33,20 @@ class LoginController extends GetxController {
update();
}
getAppTester(String appPlatform) async {
var res = await CRUD()
.get(link: AppLink.getTesterApp, payload: {'appPlatform': appPlatform});
@override
void onInit() async {
box.read(BoxName.isTest) == null ||
box.read(BoxName.isTest).toString() == '0'
? await getAppTester()
: null;
super.onInit();
}
getAppTester() async {
var res = await CRUD().get(
link: AppLink.getTesterApp,
payload: {'appPlatform': AppInformation.appName});
if (res != 'failure') {
var d = jsonDecode(res);
@@ -64,6 +79,8 @@ class LoginController extends GetxController {
await CRUD().get(link: AppLink.loginFromGooglePassenger, payload: {
'email': email,
'id': passengerID,
"platform": Platform.isAndroid ? 'android' : 'ios',
"appName": AppInformation.appName,
});
if (res == 'Failure') {
Get.offAll(SmsSignupEgypt());
@@ -79,6 +96,17 @@ class LoginController extends GetxController {
box.write(BoxName.isVerified, '1');
box.write(BoxName.email, jsonDecoeded['data'][0]['email']);
box.write(BoxName.phone, jsonDecoeded['data'][0]['phone']);
box.write(BoxName.isTest, '1');
box.write(BoxName.package, jsonDecoeded['data'][0]['package']);
box.write(BoxName.promo, jsonDecoeded['data'][0]['promo']);
box.write(BoxName.discount, jsonDecoeded['data'][0]['discount']);
box.write(BoxName.validity, jsonDecoeded['data'][0]['validity']);
box.write(BoxName.isInstall,
jsonDecoeded['data'][0]['isInstall'] ?? 'none');
box.write(BoxName.isGiftToken,
jsonDecoeded['data'][0]['isGiftToken'] ?? 'none');
box.write(BoxName.inviteCode,
jsonDecoeded['data'][0]['inviteCode'] ?? 'none');
var token = await CRUD().get(link: AppLink.getTokens, payload: {
'passengerID': box.read(BoxName.passengerID).toString()
@@ -94,10 +122,25 @@ class LoginController extends GetxController {
'cancel.wav',
);
Future.delayed(const Duration(seconds: 1));
await CRUD().post(link: AppLink.addTokens, payload: {
'token': box.read(BoxName.tokenFCM),
'passengerID': box.read(BoxName.passengerID).toString()
});
await CRUD().post(
link: "${AppLink.server}/ride/firebase/add.php",
payload: {
'token': box.read(BoxName.tokenFCM),
'passengerID': box.read(BoxName.passengerID).toString()
});
CRUD().post(
link:
"${AppLink.seferAlexandriaServer}/ride/firebase/add.php",
payload: {
'token': box.read(BoxName.tokenFCM),
'passengerID': box.read(BoxName.passengerID).toString()
});
CRUD().post(
link: "${AppLink.seferGizaServer}/ride/firebase/add.php",
payload: {
'token': box.read(BoxName.tokenFCM),
'passengerID': box.read(BoxName.passengerID).toString()
});
Get.defaultDialog(
title: 'Device Change Detected'.tr,
middleText:
@@ -111,8 +154,31 @@ class LoginController extends GetxController {
},
);
}
} // Logging to check if inviteCode is written correctly
print("Invite Code in Box: ${box.read(BoxName.inviteCode)}");
print("Is Install: ${box.read(BoxName.isInstall)}");
if (box.read(BoxName.inviteCode).toString() != 'none' &&
box.read(BoxName.isInstall).toString() != '1') {
await CRUD()
.post(link: AppLink.updatePassengersInvitation, payload: {
"inviteCode": box.read(BoxName.inviteCode).toString(),
"passengerID": box.read(BoxName.passengerID).toString(),
});
Get.defaultDialog(
title: 'Invitation Used'
.tr, // Automatically translates based on the current locale
middleText: "Your invite code was successfully applied!"
.tr, // Automatically translates based on the current locale
onConfirm: () {
Get.offAll(() =>
const MapPagePassenger()); // Navigate to MapPagePassenger after confirmation
},
textConfirm: "OK".tr, // Confirm button text
);
} else {
Get.offAll(() => const MapPagePassenger());
}
Get.offAll(() => const MapPagePassenger());
} else {
Get.offAll(() => SmsSignupEgypt());
// Get.snackbar(jsonDecoeded['status'], jsonDecoeded['data'],
@@ -241,15 +307,4 @@ class LoginController extends GetxController {
}
update();
}
@override
void onInit() async {
// permissionLocation = await Permission.locationWhenInUse.isGranted;
await getAppTester(AppInformation.appName);
// if (isTest == 0 && box.read(BoxName.passengerID) != null) {
// await loginUsingCredentials(
// box.read(BoxName.passengerID), box.read(BoxName.email));
// }
super.onInit();
}
}

View File

@@ -3,6 +3,7 @@ import 'dart:convert';
import 'dart:math';
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/controller/auth/login_controller.dart';
import 'package:SEFER/controller/local/phone_intel/phone_number.dart';
import 'package:SEFER/views/home/map_page_passenger.dart';
import 'package:SEFER/views/widgets/my_dialog.dart';
@@ -214,6 +215,8 @@ class RegisterController extends GetxController {
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
'phone_number': phoneNumber,
'token': otp.toString(),
// 'urlImage': box.read(BoxName.passengerPhotoUrl),
// 'name': box.read(BoxName.name),
});
await controller.sendSmsEgypt(phoneNumber, otp.toString());
@@ -257,7 +260,7 @@ class RegisterController extends GetxController {
'password': 'unknown',
'gender': 'unknown',
'birthdate': '2002-01-01',
'site': 'unknown',
'site': box.read(BoxName.passengerPhotoUrl) ?? 'unknown',
'first_name': box.read(BoxName.name).toString().split(' ')[0],
'last_name': box.read(BoxName.name).toString().split(' ')[1],
};
@@ -276,8 +279,13 @@ class RegisterController extends GetxController {
payload: payload,
);
box.write(BoxName.isVerified, '1');
box.write(BoxName.isFirstTime, '0');
box.write(BoxName.phone, phoneController.text);
Get.offAll(const MapPagePassenger());
// Get.offAll(const MapPagePassenger());
Get.put(LoginController()).loginUsingCredentials(
box.read(BoxName.passengerID).toString(),
box.read(BoxName.email).toString(),
);
}
} else {
Get.snackbar(

View File

@@ -1,12 +1,8 @@
import 'dart:convert';
import 'dart:io';
import 'package:SEFER/env/env.dart';
import 'package:SEFER/views/widgets/my_dialog.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:googleapis_auth/auth_io.dart';
import 'package:googleapis_auth/googleapis_auth.dart';
import 'package:http/http.dart' as http;
import 'package:SEFER/controller/functions/toast.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
@@ -131,16 +127,22 @@ class FirebaseMessagesController extends GetxController {
Get.find<MapPassengerController>().statusRide == 'Apply';
Get.find<MapPassengerController>().isSearchingWindow == false;
Get.find<MapPassengerController>().update();
NotificationController().showNotification(
'Apply Order'.tr, 'Driver Applied the Ride for You'.tr, 'order1');
if (Platform.isAndroid) {
NotificationController().showNotification(
'Apply Order'.tr, 'Driver Applied the Ride for You'.tr, 'order1');
}
// driverAppliedTripSnakBar();
} else if (message.notification!.title! == 'Promo'.tr) {
NotificationController()
.showNotification('Promo', 'Show latest promo'.tr, 'promo');
if (Platform.isAndroid) {
NotificationController()
.showNotification('Promo', 'Show latest promo'.tr, 'promo');
}
Get.to(const PromosPassengerPage());
} else if (message.notification!.title! == 'Trip Monitoring'.tr) {
NotificationController()
.showNotification('Trip Monitoring'.tr, '', 'iphone_ringtone');
if (Platform.isAndroid) {
NotificationController()
.showNotification('Trip Monitoring'.tr, '', 'iphone_ringtone');
}
var myListString = message.data['passengerList'];
var myList = jsonDecode(myListString) as List<dynamic>;
Get.toNamed('/tripmonitor', arguments: {
@@ -148,46 +150,59 @@ class FirebaseMessagesController extends GetxController {
'driverId': myList[1].toString(),
});
} else if (message.notification!.title! == 'token change'.tr) {
NotificationController()
.showNotification('token change'.tr, 'token change'.tr, 'cancel');
if (Platform.isAndroid) {
NotificationController()
.showNotification('token change'.tr, 'token change'.tr, 'cancel');
}
GoogleSignInHelper.signOut();
} else if (message.notification!.title! == 'DriverIsGoingToPassenger'.tr) {
Get.find<MapPassengerController>().isDriverInPassengerWay = true;
Get.find<MapPassengerController>().update();
NotificationController().showNotification('Driver is Going To You'.tr,
'Please stay on the picked point.'.tr, 'tone1');
if (Platform.isAndroid) {
NotificationController().showNotification('Driver is Going To You'.tr,
'Please stay on the picked point.'.tr, 'tone1');
}
// Get.snackbar('Driver is Going To Passenger', '',
// backgroundColor: AppColor.greenColor);
} else if (message.notification!.title! == 'message From passenger') {
NotificationController()
.showNotification('message From passenger'.tr, ''.tr, 'tone2');
if (Platform.isAndroid) {
NotificationController()
.showNotification('message From passenger'.tr, ''.tr, 'tone2');
}
passengerDialog(message.notification!.body!);
update();
} else if (message.notification!.title! == 'message From Driver') {
NotificationController()
.showNotification('message From passenger'.tr, ''.tr, 'tone2');
passengerDialog(message.notification!.body!);
if (Platform.isAndroid) {
NotificationController()
.showNotification('message From passenger'.tr, ''.tr, 'tone2');
}
update();
} else if (message.notification!.title! == 'RideIsBegin'.tr) {
Get.find<MapPassengerController>().getBeginRideFromDriver();
// Get.snackbar('RideIsBegin', '', backgroundColor: AppColor.greenColor);
box.write(BoxName.passengerWalletTotal, '0');
NotificationController()
.showNotification('Trip is Begin'.tr, ''.tr, 'start');
update();
if (Platform.isAndroid) {
NotificationController()
.showNotification('Trip is Begin'.tr, ''.tr, 'start');
}
} else if (message.notification!.title! == 'Hi ,I will go now'.tr) {
// Get.snackbar('Hi ,I will go now', '',
// backgroundColor: AppColor.greenColor);
NotificationController().showNotification(
'Passenger come to you'.tr, 'Hi ,I will go now'.tr, 'tone2');
if (Platform.isAndroid) {
NotificationController().showNotification(
'Passenger come to you'.tr, 'Hi ,I will go now'.tr, 'tone2');
}
update();
} else if (message.notification!.title! == 'Hi ,I Arrive your site'.tr) {
NotificationController()
.showNotification('Hi ,I Arrive your site'.tr, ''.tr, 'tone2');
driverArrivePassengerDialoge();
if (Platform.isAndroid) {
NotificationController()
.showNotification('Hi ,I Arrive your site'.tr, ''.tr, 'tone2');
}
update();
} else if (message.notification!.title! == "Cancel Trip from driver".tr) {
Get.back();
@@ -214,10 +229,12 @@ class FirebaseMessagesController extends GetxController {
} else if (message.notification!.title! == 'Driver Finish Trip'.tr) {
var myListString = message.data['passengerList'];
var driverList = jsonDecode(myListString) as List<dynamic>;
NotificationController().showNotification(
'Driver Finish Trip'.tr,
'you will pay to Driver'.tr + ' ${driverList[3].toString()} \$'.tr,
'tone1');
if (Platform.isAndroid) {
NotificationController().showNotification(
'Driver Finish Trip'.tr,
'you will pay to Driver'.tr + ' ${driverList[3].toString()} \$'.tr,
'tone1');
}
Get.find<AudioRecorderController>().stopRecording();
if (double.parse(box.read(BoxName.passengerWalletTotal)) < 0) {
box.write(BoxName.passengerWalletTotal, 0);
@@ -249,11 +266,13 @@ class FirebaseMessagesController extends GetxController {
var myListString = message.data['passengerList'];
var driverList = jsonDecode(myListString) as List<dynamic>;
// if (Platform.isAndroid) {
NotificationController().showNotification(
'Call Income'.tr,
message.notification!.body!,
'iphone_ringtone',
);
if (Platform.isAndroid) {
NotificationController().showNotification(
'Call Income'.tr,
message.notification!.body!,
'iphone_ringtone',
);
}
// }
// Assuming GetMaterialApp is initialized and context is valid for navigation
// Get.to(() => PassengerCallPage(
@@ -267,12 +286,13 @@ class FirebaseMessagesController extends GetxController {
var myListString = message.data['passengerList'];
var driverList = jsonDecode(myListString) as List<dynamic>;
// if (Platform.isAndroid) {
NotificationController().showNotification(
'Call Income'.tr,
message.notification!.body!,
'iphone_ringtone',
);
// }
if (Platform.isAndroid) {
NotificationController().showNotification(
'Call Income'.tr,
message.notification!.body!,
'iphone_ringtone',
);
}
// Assuming GetMaterialApp is initialized and context is valid for navigation
// Get.to(() => PassengerCallPage(
// channelName: driverList[1].toString(),
@@ -325,11 +345,13 @@ class FirebaseMessagesController extends GetxController {
// }
else if (message.notification!.title! == 'Order Applied'.tr) {
NotificationController().showNotification(
'The order Accepted by another Driver'.tr,
'We regret to inform you that another driver has accepted this order.'
.tr,
'order');
if (Platform.isAndroid) {
NotificationController().showNotification(
'The order Accepted by another Driver'.tr,
'We regret to inform you that another driver has accepted this order.'
.tr,
'order');
}
}
}
@@ -645,7 +667,7 @@ class FirebaseMessagesController extends GetxController {
if (response.statusCode == 200) {
print(
'Notification sent successfully. Status code: ${response.statusCode}');
print('Response body: ${response.body}');
print('Response token: ${token}');
} else {
print(
'Failed to send notification. Status code: ${response.statusCode}');
@@ -696,8 +718,9 @@ class FirebaseMessagesController extends GetxController {
// }
// }
Future<void> sendNotificationToDriverMAP(String title, String body,
String token, List<String> data, String tone) async {
Future<void> sendNotificationToDriverMAP(
String title, String body, String token, List<String> data, String tone,
{int retryCount = 2}) async {
try {
String serviceAccountKeyJson = '''{
"type": "service_account",
@@ -719,7 +742,7 @@ class FirebaseMessagesController extends GetxController {
// Obtain an OAuth 2.0 access token
final accessToken = await accessTokenManager.getAccessToken();
Log.print('accessToken: ${accessToken}');
// Log.print('accessToken: ${accessToken}');
// Send the notification
final response = await http.post(
@@ -762,14 +785,28 @@ class FirebaseMessagesController extends GetxController {
if (response.statusCode == 200) {
print(
'Notification sent successfully. Status code: ${response.statusCode}');
print('Response body: ${response.body}');
print('Response token: ${token}');
} else {
print(
'Failed to send notification. Status code: ${response.statusCode}');
print('Response body: ${response.body}');
if (retryCount > 0) {
print('Retrying... Attempts remaining: $retryCount');
await Future.delayed(
Duration(seconds: 2)); // Optional delay before retrying
return sendNotificationToDriverMAP(title, body, token, data, tone,
retryCount: retryCount - 1);
}
}
} catch (e) {
print('Error sending notification: $e');
if (retryCount > 0) {
print('Retrying... Attempts remaining: $retryCount');
await Future.delayed(
Duration(seconds: 2)); // Optional delay before retrying
return sendNotificationToDriverMAP(title, body, token, data, tone,
retryCount: retryCount - 1);
}
}
}

View File

@@ -17,7 +17,7 @@ class NotificationController extends GetxController {
// Displays a notification with the given title and message
void showNotification(String title, String message, String tone) async {
AndroidNotificationDetails android = AndroidNotificationDetails(
'your channel id', 'your channel name',
'high_importance_channel', 'High Importance Notifications',
importance: Importance.max,
priority: Priority.high,
showWhen: false,

View File

@@ -109,7 +109,7 @@ class CRUD {
print(await response.stream.bytesToString());
Get.defaultDialog(
title: 'You will receive a code in WhatsApp Messenger'.tr,
middleText: '',
middleText: 'wait 1 minute to recive message'.tr,
confirm: MyElevatedButton(
title: 'OK'.tr,
onPressed: () {

View File

@@ -3,7 +3,6 @@ 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';
@@ -17,7 +16,7 @@ Future<void> checkForUpdate(BuildContext context) async {
final version = packageInfo.version;
print('currentVersion is : $currentVersion');
// Fetch the latest version from your server
String latestVersion = await getPackageInfo();
String latestVersion = box.read(BoxName.package);
box.write(BoxName.packagInfo, version);
if (latestVersion.isNotEmpty && latestVersion != currentVersion) {
@@ -25,18 +24,22 @@ 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,
});
if (response != 'failure') {
return jsonDecode(response)['message'][0]['version'];
}
return '';
checkForBounusInvitation() {
if (box.read(BoxName.inviteCode) != null) {}
}
// 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.mobileapp.store.ride'

View File

@@ -0,0 +1,91 @@
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../constant/links.dart';
import '../../views/widgets/elevated_btn.dart';
import '../functions/crud.dart';
class BlinkingController extends GetxController {
final promoFormKey = GlobalKey<FormState>();
final promo = TextEditingController();
bool promoTaken = false;
void applyPromoCodeToPassenger() async {
//TAWJIHI
if (promoFormKey.currentState!.validate()) {
CRUD().get(link: AppLink.getPassengersPromo, payload: {
'promo_code': promo.text,
}).then((value) {
if (value == 'failure') {
Get.defaultDialog(
title: 'Promo End !'.tr,
confirm: MyElevatedButton(
title: 'Back',
onPressed: () {
Get.back();
Get.back();
},
));
}
var decode = jsonDecode(value);
// if (decode["status"] == "success") {
// var firstElement = decode["message"][0];
// if (double.parse(box.read(BoxName.passengerWalletTotal)) < 0) {
// totalPassenger = totalCostPassenger -
// (totalCostPassenger * int.parse(firstElement['amount']) / 100);
// update();
// } else {
// totalPassenger = totalCostPassenger -
// (totalCostPassenger * int.parse(firstElement['amount']) / 100);
// update();
// }
// totalDriver = totalDriver -
// (totalDriver * int.parse(firstElement['amount']) / 100);
// promoTaken = true;
// update();
// Get.back();
// }
});
}
}
// Reactive variable for blinking (on/off)
var isLightOn = false.obs;
// To animate the border color
var borderColor = Colors.black.obs;
Timer? _blinkingTimer;
// Method to start blinking for 5 seconds
void startBlinking() {
int count = 0;
_blinkingTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
// Toggle light on/off
isLightOn.value = !isLightOn.value;
borderColor.value = isLightOn.value
? Colors.yellow
: Colors.black; // Animate border color
count++;
// Stop blinking after 5 seconds
if (count >= 35) {
timer.cancel();
isLightOn.value = false; // Ensure light turns off
borderColor.value = Colors.black; // Reset the border color
}
});
}
@override
void onClose() {
_blinkingTimer?.cancel();
super.onClose();
}
}

View File

@@ -0,0 +1,78 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_font_icons/flutter_font_icons.dart';
import 'package:get/get.dart';
import '../../../constant/colors.dart';
import '../functions/launch.dart';
class ContactUsController extends GetxController {
final String phone1 = '+201018805430';
final String phone2 = '+201080182934';
final TimeOfDay workStartTime = const TimeOfDay(hour: 12, minute: 0);
final TimeOfDay workEndTime = const TimeOfDay(hour: 19, minute: 0);
bool _isWithinWorkTime(TimeOfDay now) {
return (now.hour > workStartTime.hour ||
(now.hour == workStartTime.hour &&
now.minute >= workStartTime.minute)) &&
(now.hour < workEndTime.hour ||
(now.hour == workEndTime.hour && now.minute <= workEndTime.minute));
}
void showContactDialog(BuildContext context) {
TimeOfDay now = TimeOfDay.now();
showCupertinoModalPopup(
context: context,
builder: (context) => CupertinoActionSheet(
title: Text('Contact Us'.tr),
message: Text('Choose a contact option'.tr),
actions: <Widget>[
if (_isWithinWorkTime(now))
CupertinoActionSheetAction(
child: Text(phone1),
onPressed: () => makePhoneCall(
phone1,
),
),
if (_isWithinWorkTime(now))
CupertinoActionSheetAction(
child: Text(phone2),
onPressed: () => makePhoneCall(phone2),
),
if (!_isWithinWorkTime(now))
CupertinoActionSheetAction(
child: Text(
'Work time is from 12:00 - 19:00.\nYou can send a WhatsApp message or email.'
.tr),
onPressed: () => Navigator.pop(context),
),
CupertinoActionSheetAction(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const Icon(
FontAwesome.whatsapp,
color: AppColor.greenColor,
),
Text('Send WhatsApp Message'.tr),
],
),
onPressed: () =>
launchCommunication('whatsapp', phone1, 'Hello'.tr),
),
CupertinoActionSheetAction(
child: Text('Send Email'.tr),
onPressed: () =>
launchCommunication('email', 'support@sefer.live', 'Hello'.tr),
),
],
cancelButton: CupertinoActionSheetAction(
child: Text('Cancel'.tr),
onPressed: () => Navigator.pop(context),
),
),
);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -606,6 +606,45 @@ iOS [https://getapp.cc/app/6458734951]
'الرَّجَاء التَّحَرُّك إِلَى السَّيَّارَة الآن',
'You will receive a code in WhatsApp Messenger':
"سوف تتلقى رمزًا في واتساب ماسنجر",
'If you need assistance, contact us':
"إذا كنت بحاجة إلى المساعدة، تواصل معنا",
"Promo Ended": "انتهى العرض",
'Enter the promo code and get': 'أدخل رمز الترويج واحصل على',
'DISCOUNT': 'خصم',
'No wallet record found': 'لم يتم العثور على سجل محفظة',
'for': 'لمدة',
"SEFER is the safest ride-sharing app that introduces many features for both captains and passengers. We offer the lowest commission rate of just 8%, ensuring you get the best value for your rides. Our app includes insurance for the best captains, regular maintenance of cars with top engineers, and on-road services to ensure a respectful and high-quality experience for all users.":
"سفر هو التطبيق الأكثر أمانًا لمشاركة الركوب الذي يقدم العديد من الميزات لكل من السائقين والركاب. نحن نقدم أقل عمولة بنسبة 8% فقط، مما يضمن حصولك على أفضل قيمة لرحلاتك. يتضمن تطبيقنا التأمين لأفضل السائقين، الصيانة المنتظمة للسيارات مع أفضل المهندسين، والخدمات على الطريق لضمان تجربة محترمة وعالية الجودة لجميع المستخدمين.",
"You can contact us during working hours from 12:00 - 19:00.":
"يمكنك الاتصال بنا خلال ساعات العمل من 12:00 - 7:00.",
"Contact Us": "اتصل بنا",
'Choose a contact option': 'اختر خيار الاتصال',
'Work time is from 12:00 - 19:00.\nYou can send a WhatsApp message or email.':
'ساعات العمل من 12:00 - 19:00.\nيمكنك إرسال رسالة عبر واتساب أو بريد إلكتروني.',
'Promo code copied to clipboard!': "'تم نسخ رمز العرض إلى الحافظة!'",
'Copy Code': 'نسخ الرمز',
"Your invite code was successfully applied!":
"تم تطبيق رمز الدعوة بنجاح!",
"Payment Options": " خيارات الدفع",
"wait 1 minute to receive message":
"انتظر دقيقة واحدة لاستلام الرسالة",
'Promo Copied!': 'تم نسخ العرض!',
'You have copied the promo code.': 'لقد قمت بنسخ رمز العرض.',
'Valid Until:': 'لمدة:',
"Select Payment Amount": " اختر مبلغ الدفع",
"The promotion period has ended.": "انتهت فترة العرض.",
"Promo Code Accepted": "تم قبول كود العرض",
'Tap on the promo code to copy it!': 'اضغط على رمز العرض لنسخه!',
"Lowest Price Achieved": "تم الوصول إلى أدنى سعر",
"Cannot apply further discounts.":
"لا يمكن تطبيق المزيد من الخصومات.",
"Promo Already Used": "تم استخدام كود العرض بالفعل",
'Invitation Used': "تم استخدام الدعوة",
"You have already used this promo code.":
"لقد استخدمت هذا الكود بالفعل.",
"Insert Your Promo Code": "أدخل كود العرض الخاص بك",
"Enter promo code here": "أدخل كود العرض هنا",
"Please enter a valid promo code": "يرجى إدخال كود عرض صالح",
'Awfar Car': 'أوفر كار',
"Old and affordable, perfect for budget rides.":
"سيارة ميسورة التكلفة، مثالية للرحلات الاقتصادية.",

View File

@@ -1,13 +1,12 @@
import 'dart:convert';
import 'package:SEFER/views/widgets/my_dialog.dart';
import 'package:get/get.dart';
import 'package:SEFER/controller/firebase/firbase_messge.dart';
import '../../constant/box_name.dart';
import '../../constant/links.dart';
import '../../constant/style.dart';
import '../../main.dart';
import '../../views/widgets/elevated_btn.dart';
import '../functions/crud.dart';
class PassengerNotificationController extends GetxController {
@@ -21,22 +20,17 @@ class PassengerNotificationController extends GetxController {
link: AppLink.getNotificationPassenger,
payload: {'passenger_id': box.read(BoxName.passengerID)});
if (res == "failure") {
Get.defaultDialog(
title: 'There is no notification yet'.tr,
titleStyle: AppStyle.title,
middleText: '',
confirm: MyElevatedButton(
title: 'Back',
onPressed: () {
Get.back();
Get.back();
}));
MyDialog().getDialog('There is no notification yet'.tr, '', () {
Get.back();
Get.back();
});
} else {
notificationData = jsonDecode(res);
isloading = false;
update();
}
notificationData = jsonDecode(res);
// sql.insertData(notificationData['message'], TableName.captainNotification);
isloading = false;
update();
// sql.insertData(notificationData['message'], TableName.captainNotification);
}
updateNotification(String id) async {

View File

@@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:SEFER/views/widgets/my_dialog.dart';
import 'package:get/get.dart';
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/constant/links.dart';
@@ -23,17 +24,10 @@ class PassengerWalletHistoryController extends GetxController {
isLoading = false;
update();
} else {
Get.defaultDialog(
barrierDismissible: false,
title: 'No wallet record found'.tr,
titleStyle: AppStyle.title,
middleText: '',
confirm: MyElevatedButton(
title: 'OK'.tr,
onPressed: () {
Get.back();
Get.back();
}));
MyDialog().getDialog('No wallet record found'.tr, '', () {
Get.back();
Get.back();
});
}
}

View File

@@ -167,7 +167,7 @@ class PaymentController extends GetxController {
? '1140'
: '0');
getPassengerWallet();
// getPassengerWallet();
isLoading = false;
update();
@@ -698,24 +698,28 @@ class PaymentController extends GetxController {
onPayment: (PaymobResponseWallet response) {},
);
if (response!.success == true && response.responseCode == '200') {
Get.defaultDialog(
barrierDismissible: false,
title: 'Payment Successful'.tr,
titleStyle: AppStyle.title,
content: Text(
'The payment was approved.'.tr,
style: AppStyle.title,
),
confirm: MyElevatedButton(
title: 'OK'.tr,
kolor: AppColor.greenColor,
onPressed: () async {
Get.back();
method();
},
),
);
// if (response!.success == true && response.responseCode == '200') {
if (response!.responseCode == '200' && response.success == true) {
// Log.print('transactionID wewer: ${response.transactionID}');
Toast.show(context, 'Payment Successful'.tr, AppColor.greenColor);
method();
// Get.defaultDialog(
// barrierDismissible: false,
// title: 'Payment Successful'.tr,
// titleStyle: AppStyle.title,
// content: Text(
// 'The payment was approved.'.tr,
// style: AppStyle.title,
// ),
// confirm: MyElevatedButton(
// title: 'OK'.tr,
// kolor: AppColor.greenColor,
// onPressed: () async {
// Get.back();
// method();
// },
// ),
// );
} else {
Get.defaultDialog(
barrierDismissible: false,
@@ -763,46 +767,49 @@ class PaymentController extends GetxController {
billingData: PaymobBillingData(),
onPayment: (PaymobResponse response) {},
);
if (response!.success == true && response.responseCode == '200') {
if (response!.responseCode == 'APPROVED') {
Get.defaultDialog(
barrierDismissible: false,
title: 'Payment Successful'.tr,
titleStyle: AppStyle.title,
// backgroundColor: AppColor.greenColor,
content: Text(
'The payment was approved.'.tr,
style: AppStyle.title,
),
confirm: MyElevatedButton(
kolor: AppColor.greenColor,
title: 'OK'.tr,
onPressed: () async {
Get.back();
method();
},
),
);
} else {
Get.defaultDialog(
barrierDismissible: false,
// backgroundColor: AppColor.redColor,
title: 'Payment Failed'.tr,
content: Text(
'The payment was not approved. Please try again.'.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
confirm: MyElevatedButton(
title: 'OK'.tr,
kolor: AppColor.redColor,
onPressed: () async {
Get.back();
},
),
);
}
if (response!.responseCode == '200' && response.success == true) {
// if (response!.success == true && response.responseCode == '200') {
// if (response!.responseCode == 'APPROVED') {
Toast.show(context, 'Payment Successful'.tr, AppColor.greenColor);
method();
// Get.defaultDialog(
// barrierDismissible: false,
// title: 'Payment Successful'.tr,
// titleStyle: AppStyle.title,
// // backgroundColor: AppColor.greenColor,
// content: Text(
// 'The payment was approved.'.tr,
// style: AppStyle.title,
// ),
// confirm: MyElevatedButton(
// kolor: AppColor.greenColor,
// title: 'OK'.tr,
// onPressed: () async {
// Get.back();
// method();
// },
// ),
// );
} else {
Get.defaultDialog(
barrierDismissible: false,
// backgroundColor: AppColor.redColor,
title: 'Payment Failed'.tr,
content: Text(
'The payment was not approved. Please try again.'.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
confirm: MyElevatedButton(
title: 'OK'.tr,
kolor: AppColor.redColor,
onPressed: () async {
Get.back();
},
),
);
}
// }
}
} catch (e) {
Get.defaultDialog(

View File

@@ -79,13 +79,33 @@ class RateController extends GetxController {
}
}
}
await CRUD().post(link: AppLink.addRateToDriver, payload: {
'passenger_id': box.read(BoxName.passengerID).toString(),
'driver_id': driverId,
'ride_id': rideId,
'rating': selectedRateItemId.toString(),
'comment': comment.text,
}).then((value) {
await CRUD().post(
link: "${AppLink.seferCairoServer}/rate/addRateToDriver.php",
payload: {
'passenger_id': box.read(BoxName.passengerID).toString(),
'driver_id': driverId,
'ride_id': rideId,
'rating': selectedRateItemId.toString(),
'comment': comment.text,
}).then((value) {
CRUD().post(
link: "${AppLink.seferAlexandriaServer}/rate/addRateToDriver.php",
payload: {
'passenger_id': box.read(BoxName.passengerID).toString(),
'driver_id': driverId,
'ride_id': rideId,
'rating': selectedRateItemId.toString(),
'comment': comment.text,
});
CRUD().post(
link: "${AppLink.seferGizaServer}/rate/addRateToDriver.php",
payload: {
'passenger_id': box.read(BoxName.passengerID).toString(),
'driver_id': driverId,
'ride_id': rideId,
'rating': selectedRateItemId.toString(),
'comment': comment.text,
});
Get.find<MapPassengerController>().restCounter();
Get.offAll(const MapPagePassenger());
});