first commit

This commit is contained in:
Hamza-Ayed
2025-07-30 10:22:20 +03:00
parent b92fc5bc1a
commit 66ae6c0ddb
231 changed files with 46683 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
import 'dart:convert';
import 'package:get/get.dart';
import '../../constant/colors.dart';
import '../../constant/links.dart';
import '../print.dart';
import 'functions/crud.dart';
class Driverthebest extends GetxController {
bool isLoading = false;
List driver = [];
getBestDriver() async {
var res = await CRUD().get(link: AppLink.getBestDriver, payload: {});
if (res != 'failure') {
driver = jsonDecode(res)['message'];
// Log.print('driver: ${driver}');
update();
} else {
Get.snackbar('error', '', backgroundColor: AppColor.redColor);
}
}
@override
void onInit() {
getBestDriver();
super.onInit();
}
}
class DriverTheBestGizaController extends GetxController {
bool isLoading = false;
List driver = [];
getBestDriver() async {
var res = await CRUD().get(link: AppLink.getBestDriverGiza, payload: {});
if (res != 'failure') {
driver = jsonDecode(res)['message'];
update();
} else {
Get.snackbar('error', '', backgroundColor: AppColor.redColor);
}
}
@override
void onInit() {
getBestDriver();
super.onInit();
}
}
class DriverTheBestAlexandriaController extends GetxController {
bool isLoading = false;
List driver = [];
getBestDriver() async {
var res =
await CRUD().get(link: AppLink.getBestDriverAlexandria, payload: {});
if (res != 'failure') {
driver = jsonDecode(res)['message'];
update();
} else {
Get.snackbar('error', '', backgroundColor: AppColor.redColor);
}
}
@override
void onInit() {
getBestDriver();
super.onInit();
}
}

View File

@@ -0,0 +1,117 @@
import 'dart:convert';
import 'dart:io';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:http/http.dart' as http;
import '../../constant/api_key.dart';
import '../../constant/box_name.dart';
import '../../constant/colors.dart';
import '../../constant/links.dart';
import '../../constant/style.dart';
import '../../main.dart';
class FirebaseMessagesController extends GetxController {
final fcmToken = FirebaseMessaging.instance;
List<String> tokens = [];
List dataTokens = [];
late String driverID;
late String driverToken;
NotificationSettings? notificationSettings;
Future<void> getNotificationSettings() async {
// Get the current notification settings
NotificationSettings? notificationSettings =
await FirebaseMessaging.instance.getNotificationSettings();
'Notification authorization status: ${notificationSettings.authorizationStatus}';
// Call the update function if needed
update();
}
Future<void> requestFirebaseMessagingPermission() async {
FirebaseMessaging messaging = FirebaseMessaging.instance;
// Check if the platform is Android
if (Platform.isAndroid) {
// Request permission for Android
await messaging.requestPermission();
} else if (Platform.isIOS) {
// Request permission for iOS
NotificationSettings settings = await messaging.requestPermission(
alert: true,
announcement: true,
badge: true,
carPlay: true,
criticalAlert: true,
provisional: false,
sound: true,
);
messaging.setForegroundNotificationPresentationOptions(
alert: true, badge: true, sound: true);
}
}
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(AK.basicAuthCredentials))}',
},
body: {},
);
var jsonResponse = jsonDecode(res.body);
if (jsonResponse['status'] == 'success') {
dataTokens = jsonResponse['data'];
for (var i = 0; i < dataTokens.length; i++) {
tokens.add(jsonResponse['data'][i]['token']);
}
box.write(BoxName.tokens, tokens);
} else {
Get.defaultDialog(title: "Warning", middleText: "Server Error");
}
}
Future getToken() async {
fcmToken.getToken().then((token) {
box.write(BoxName.tokenFCM, token);
});
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
// If the app is in the background or terminated, show a system tray message
RemoteNotification? notification = message.notification;
AndroidNotification? android = notification?.android;
// if (notification != null && android != null) {
if (message.data.isNotEmpty && message.notification != null) {
fireBaseTitles(message);
}
});
FirebaseMessaging.onBackgroundMessage((RemoteMessage message) async {
// Handle background message
if (message.data.isNotEmpty && message.notification != null) {
fireBaseTitles(message);
}
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
if (message.data.isNotEmpty && message.notification != null) {
fireBaseTitles(message);
}
});
}
void fireBaseTitles(RemoteMessage message) {
if (message.notification!.title! == 'Order'.tr) {
} else if (message.notification!.title! == 'Apply Ride'.tr) {
var passengerList = message.data['passengerList'];
var myList = jsonDecode(passengerList) as List<dynamic>;
driverID = myList[0].toString();
}
}
}

View File

@@ -0,0 +1,266 @@
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:jwt_decoder/jwt_decoder.dart';
import 'package:secure_string_operations/secure_string_operations.dart';
import 'package:service/constant/char_map.dart';
import '../../constant/api_key.dart';
import '../../constant/box_name.dart';
import '../../constant/info.dart';
import '../../constant/links.dart';
import '../../main.dart';
import '../../print.dart';
import 'encrypt_decrypt.dart';
import 'initilize.dart';
class CRUD {
var dev;
getJWT() async {
var dev = Platform.isAndroid ? 'android' : 'ios';
var payload = {
'password': AK.passnpassenger,
// 'email': box.read(BoxName.email),
'aud': '${AK.allowed}$dev',
};
// if (box.read(BoxName.firstTimeLoadKey).toString() != 'false') {
var response0 = await http.post(
Uri.parse(AppLink.jwtService),
body: payload,
);
print(response0.body);
print(response0.request);
if (response0.statusCode == 200) {
final decodedResponse1 = jsonDecode(response0.body);
final jwt = decodedResponse1['jwt'];
box.write(BoxName.jwt, X.c(X.c(X.c(jwt, cn), cC), cs));
// await AppInitializer().getAIKey(Service.keyOfApp);
// await AppInitializer().getAIKey(Service.initializationVector);
// await Future.delayed(Duration.zero);
await EncryptionHelper.initialize();
// await AppInitializer().getAIKey(Service.FCM_PRIVATE_KEY);
box.write(BoxName.firstTimeLoadKey, 'false');
// await AppInitializer().getKey();
} else {}
}
Future<dynamic> get({
required String link,
Map<String, dynamic>? payload,
}) async {
var url = Uri.parse(
link,
);
bool isTokenExpired = JwtDecoder.isExpired(X
.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs)
.toString()
.split(AppInformation.addd)[0]);
if (isTokenExpired) {
await getJWT();
}
var response = await http.post(
url,
body: payload,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
'Authorization':
'Bearer ${X.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs).toString().split(AppInformation.addd)[0]}'
},
);
print(response.request);
Log.print('response.body: ${response.body}');
print(payload); // if (response.statusCode == 200) {
var jsonData = jsonDecode(response.body);
if (jsonData['status'] == 'success') {
return response.body;
}
return jsonData['status'];
}
// }
Future<dynamic> arabicTextExtractByVisionAndAI({
required String imagePath,
required String driverID,
}) async {
var headers = {
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': AK.ocpApimSubscriptionKey
};
String imagePathFull =
'${AppLink.server}/card_image/$imagePath-$driverID.jpg';
var request = http.Request(
'POST',
Uri.parse(
'https://eastus.api.cognitive.microsoft.com/computervision/imageanalysis:analyze?features=caption,read&model-version=latest&language=en&api-version=2024-02-01'));
request.body = json.encode({"url": imagePathFull});
request.headers.addAll(headers);
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
return await response.stream.bytesToString();
} else {}
}
Future<dynamic> getAgoraToken({
required String channelName,
required String uid,
}) async {
var uid = box.read(BoxName.phone) ?? box.read(BoxName.phoneDriver);
var res = await http.get(Uri.parse(
// 'https://repulsive-pig-rugby-shirt.cyclic.app/token?channelName=$channelName'),
'https://orca-app-b2i85.ondigitalocean.app/token?channelName=$channelName'),
// headers: {'Authorization': 'Bearer ${AK.agoraAppCertificate}'});
headers: {'Authorization': 'Bearer '});
if (res.statusCode == 200) {
var response = jsonDecode(res.body);
return response['token'];
} else {}
}
Future<dynamic> getLlama({
required String link,
required String payload,
required String prompt,
}) async {
var url = Uri.parse(
link,
);
var headers = {
'Content-Type': 'application/json',
'Authorization':
'Bearer LL-X5lJ0Px9CzKK0HTuVZ3u2u4v3tGWkImLTG7okGRk4t25zrsLqJ0qNoUzZ2x4ciPy'
// 'Authorization': 'Bearer ${Env.llamaKey}'
};
var data = json.encode({
"model": "Llama-3-70b-Inst-FW",
// "model": "llama-13b-chat",
"messages": [
{
"role": "user",
"content":
"Extract the desired information from the following passage as json decoded like $prompt just in this:\n\n$payload"
}
],
"temperature": 0.9
});
var response = await http.post(
url,
body: data,
headers: headers,
);
if (response.statusCode == 200) {
return response.body;
}
return response.statusCode;
}
Future<dynamic> post({
required String link,
Map<String, dynamic>? payload,
}) async {
// String? basicAuthCredentials =
// await storage.read(key: BoxName.basicAuthCredentials);
var url = Uri.parse(
link,
);
bool isTokenExpired = JwtDecoder.isExpired(X
.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs)
.toString()
.split(AppInformation.addd)[0]);
if (isTokenExpired) {
await getJWT();
}
var response = await http.post(
url,
body: payload,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
'Authorization':
'Bearer ${X.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs).toString().split(AppInformation.addd)[0]}'
},
);
print(response.request);
Log.print('response.body: ${response.body}');
print(payload);
var jsonData = jsonDecode(response.body);
if (response.statusCode == 200) {
if (jsonData['status'] == 'success') {
return response.body;
} else {
String errorMessage = jsonData['message'];
// Get.snackbar('Error'.tr, errorMessage.tr,
// backgroundColor: AppColor.redColor);
return (jsonData['status']);
}
} else {
return response.statusCode;
}
}
sendEmail(
String link,
Map<String, String>? payload,
) async {
var headers = {
"Content-Type": "application/x-www-form-urlencoded",
'Authorization':
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
};
var request = http.Request('POST', Uri.parse(link));
request.bodyFields = payload!;
request.headers.addAll(headers);
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
} else {}
}
Future<dynamic> update({
required String endpoint,
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(AK.basicAuthCredentials))}',
},
);
return json.decode(response.body);
}
Future<dynamic> delete({
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(AK.basicAuthCredentials))}',
},
);
return json.decode(response.body);
}
extractTextFromLines(json) {}
}

View File

@@ -0,0 +1,68 @@
import 'package:encrypt/encrypt.dart' as encrypt;
import 'package:flutter/foundation.dart';
import 'package:service/env/env.dart';
import '../../constant/box_name.dart';
import '../../main.dart';
class EncryptionHelper {
static EncryptionHelper? _instance;
late final encrypt.Key key;
late final encrypt.IV iv;
EncryptionHelper._(this.key, this.iv);
static EncryptionHelper get instance {
if (_instance == null) {
throw Exception(
"EncryptionHelper is not initialized. Call `await EncryptionHelper.initialize()` in main.");
}
return _instance!;
}
/// Initializes and stores the instance globally
static Future<void> initialize() async {
if (_instance != null) {
debugPrint("EncryptionHelper is already initialized.");
return; // Prevent re-initialization
}
debugPrint("Initializing EncryptionHelper...");
// Read stored keys
String? keyOfApp = Env.keyOfApp;
// Log.print('keyOfApp: ${keyOfApp}');
String? initializationVector = Env.initializationVector;
// Log.print('initializationVector: ${initializationVector}');
// Set the global instance
_instance = EncryptionHelper._(
encrypt.Key.fromUtf8(keyOfApp!),
encrypt.IV.fromUtf8(initializationVector!),
);
debugPrint("EncryptionHelper initialized successfully.");
}
/// Encrypts a string
String encryptData(String plainText) {
try {
final encrypter =
encrypt.Encrypter(encrypt.AES(key, mode: encrypt.AESMode.cbc));
final encrypted = encrypter.encrypt(plainText, iv: iv);
return encrypted.base64;
} catch (e) {
debugPrint('Encryption Error: $e');
return '';
}
}
/// Decrypts a string
String decryptData(String encryptedText) {
try {
final encrypter =
encrypt.Encrypter(encrypt.AES(key, mode: encrypt.AESMode.cbc));
final encrypted = encrypt.Encrypted.fromBase64(encryptedText);
return encrypter.decrypt(encrypted, iv: iv);
} catch (e) {
debugPrint('Decryption Error: $e');
return '';
}
}
}

View File

@@ -0,0 +1,335 @@
import 'dart:convert';
import 'dart:io';
import 'package:get/get.dart';
import 'package:http/http.dart' as http;
import 'package:image_cropper/image_cropper.dart';
import 'package:image_picker/image_picker.dart';
import 'package:path/path.dart';
import 'package:image/image.dart' as img;
import 'package:flutter_image_compress/flutter_image_compress.dart';
import 'package:path_provider/path_provider.dart' as path_provider;
import '../../constant/api_key.dart';
import '../../constant/box_name.dart';
import '../../constant/colors.dart';
import '../../main.dart';
class ImageController extends GetxController {
File? myImage;
bool isloading = false;
CroppedFile? croppedFile;
final picker = ImagePicker();
var image;
Future<img.Image> detectAndCropDocument(File imageFile) async {
img.Image? image = img.decodeImage(await imageFile.readAsBytes());
if (image == null) throw Exception('Unable to decode image');
int left = image.width, top = image.height, right = 0, bottom = 0;
// Threshold for considering a pixel as part of the document (adjust as needed)
const int threshold = 240;
for (int y = 0; y < image.height; y++) {
for (int x = 0; x < image.width; x++) {
final pixel = image.getPixel(x, y);
final luminance = img.getLuminance(pixel);
if (luminance < threshold) {
left = x < left ? x : left;
top = y < top ? y : top;
right = x > right ? x : right;
bottom = y > bottom ? y : bottom;
}
}
}
// Add a small padding
left = (left - 5).clamp(0, image.width);
top = (top - 5).clamp(0, image.height);
right = (right + 5).clamp(0, image.width);
bottom = (bottom + 5).clamp(0, image.height);
return img.copyCrop(image,
x: left, y: top, width: right - left, height: bottom - top);
}
Future<File> rotateImageIfNeeded(File imageFile) async {
img.Image croppedDoc = await detectAndCropDocument(imageFile);
// Check if the document is in portrait orientation
bool isPortrait = croppedDoc.height > croppedDoc.width;
img.Image processedImage;
if (isPortrait) {
// Rotate the image by 90 degrees clockwise
processedImage = img.copyRotate(croppedDoc, angle: 90);
} else {
processedImage = croppedDoc;
}
// Get temporary directory
final tempDir = await path_provider.getTemporaryDirectory();
final tempPath = tempDir.path;
// Create the processed image file
File processedFile = File('$tempPath/processed_image.jpg');
await processedFile.writeAsBytes(img.encodeJpg(processedImage));
return processedFile;
}
Future<File> rotateImage(File imageFile) async {
// Read the image file
img.Image? image = img.decodeImage(await imageFile.readAsBytes());
if (image == null) return imageFile;
// Rotate the image by 90 degrees clockwise
img.Image rotatedImage = img.copyRotate(image, angle: 90);
// Get temporary directory
final tempDir = await path_provider.getTemporaryDirectory();
final tempPath = tempDir.path;
// Create the rotated image file
File rotatedFile = File('$tempPath/rotated_image.jpg');
await rotatedFile.writeAsBytes(img.encodeJpg(rotatedImage));
return rotatedFile;
}
choosImage(String link, String driverId, String imageType) async {
final pickedImage = await picker.pickImage(
source: ImageSource.gallery,
);
if (pickedImage == null) return;
image = File(pickedImage.path);
croppedFile = await ImageCropper().cropImage(
sourcePath: image!.path,
uiSettings: [
AndroidUiSettings(
toolbarTitle: 'Cropper'.tr,
toolbarColor: AppColor.blueColor,
toolbarWidgetColor: AppColor.yellowColor,
initAspectRatio: CropAspectRatioPreset.original,
lockAspectRatio: false),
IOSUiSettings(
title: 'Cropper'.tr,
),
],
);
if (croppedFile == null) return;
myImage = File(croppedFile!.path);
isloading = true;
update();
// Rotate the compressed image
// File rotatedImage = await rotateImage(compressedImage);
File processedImage = await rotateImageIfNeeded(File(croppedFile!.path));
File compressedImage = await compressImage(processedImage);
print('link =$link');
try {
await uploadImage(
compressedImage,
{'driverID': driverId, 'imageType': imageType},
link,
);
} catch (e) {
Get.snackbar('Image Upload Failed'.tr, e.toString(),
backgroundColor: AppColor.redColor);
} finally {
isloading = false;
update();
}
}
choosFace(String link, String imageType) async {
final pickedImage = await picker.pickImage(
source: ImageSource.camera,
preferredCameraDevice: CameraDevice.front,
);
if (pickedImage != null) {
image = File(pickedImage.path);
isloading = true;
update();
// Compress the image
File compressedImage = await compressImage(File(pickedImage.path));
// Save the picked image directly
// File savedImage = File(pickedImage.path);
print('link =$link');
try {
await uploadImage(
compressedImage,
{
'driverID':
box.read(BoxName.driverID) ?? box.read(BoxName.passengerID),
'imageType': imageType
},
link,
);
} catch (e) {
Get.snackbar('Image Upload Failed'.tr, e.toString(),
backgroundColor: AppColor.redColor);
} finally {
isloading = false;
update();
}
}
}
uploadImage(File file, Map data, String link) async {
var request = http.MultipartRequest(
'POST',
Uri.parse(link), //'https://ride.mobile-app.store/uploadImage1.php'
);
var length = await file.length();
var stream = http.ByteStream(file.openRead());
var multipartFile = http.MultipartFile(
'image',
stream,
length,
filename: basename(file.path),
);
request.headers.addAll({
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0',
'Authorization':
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials.toString()))}',
});
// Set the file name to the driverID
request.files.add(
http.MultipartFile(
'image',
stream,
length,
filename: '${box.read(BoxName.driverID)}.jpg',
),
);
data.forEach((key, value) {
request.fields[key] = value;
});
var myrequest = await request.send();
var res = await http.Response.fromStream(myrequest);
if (res.statusCode == 200) {
return jsonDecode(res.body);
} else {
throw Exception(
'Failed to upload image: ${res.statusCode} - ${res.body}');
}
}
choosImagePicture(String link, String imageType) async {
final pickedImage = await picker.pickImage(
source: ImageSource.gallery,
// preferredCameraDevice: CameraDevice.rear,
// maxHeight: Get.height * .3,
// maxWidth: Get.width * .9,
// imageQuality: 100,
);
image = File(pickedImage!.path);
croppedFile = await ImageCropper().cropImage(
sourcePath: image!.path,
uiSettings: [
AndroidUiSettings(
toolbarTitle: 'Cropper'.tr,
toolbarColor: AppColor.blueColor,
toolbarWidgetColor: AppColor.yellowColor,
initAspectRatio: CropAspectRatioPreset.original,
lockAspectRatio: false),
IOSUiSettings(
title: 'Cropper'.tr,
),
],
);
myImage = File(pickedImage.path);
isloading = true;
update();
// Save the cropped image
// File savedCroppedImage = File(croppedFile!.path);
File compressedImage = await compressImage(File(croppedFile!.path));
print('link =$link');
try {
await uploadImage(
compressedImage,
{
'driverID':
box.read(BoxName.driverID) ?? box.read(BoxName.passengerID),
'imageType': imageType
},
link,
);
} catch (e) {
Get.snackbar('Image Upload Failed'.tr, e.toString(),
backgroundColor: AppColor.redColor);
} finally {
isloading = false;
update();
}
}
uploadImagePicture(File file, Map data, String link) async {
var request = http.MultipartRequest(
'POST',
Uri.parse(link), //'https://ride.mobile-app.store/uploadImage1.php'
);
var length = await file.length();
var stream = http.ByteStream(file.openRead());
var multipartFile = http.MultipartFile(
'image',
stream,
length,
filename: basename(file.path),
);
request.headers.addAll({
'Authorization':
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials.toString()))}',
});
// Set the file name to the driverID
request.files.add(
http.MultipartFile(
'image',
stream,
length,
filename: '${box.read(BoxName.driverID)}.jpg',
),
);
data.forEach((key, value) {
request.fields[key] = value;
});
var myrequest = await request.send();
var res = await http.Response.fromStream(myrequest);
if (res.statusCode == 200) {
return jsonDecode(res.body);
} else {
throw Exception(
'Failed to upload image: ${res.statusCode} - ${res.body}');
}
}
}
Future<File> compressImage(File file) async {
final dir = await path_provider.getTemporaryDirectory();
final targetPath = "${dir.absolute.path}/temp.jpg";
var result = await FlutterImageCompress.compressAndGetFile(
file.absolute.path,
targetPath,
quality: 70,
minWidth: 1024,
minHeight: 1024,
);
return File(result!.path);
}

View File

@@ -0,0 +1,44 @@
import 'dart:convert';
import 'package:jwt_decoder/jwt_decoder.dart';
import 'package:secure_string_operations/secure_string_operations.dart';
import 'package:service/controller/functions/crud.dart';
import '../../constant/box_name.dart';
import '../../constant/char_map.dart';
import '../../constant/info.dart';
import '../../constant/links.dart';
import '../../env/env.dart';
import '../../main.dart';
import '../../print.dart';
class AppInitializer {
List<Map<String, dynamic>> links = [];
Future<void> initializeApp() async {
if (box.read(BoxName.jwt) == null) {
await CRUD().getJWT();
} else {
bool isTokenExpired = JwtDecoder.isExpired(X
.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs)
.toString()
.split(AppInformation.addd)[0]);
if (isTokenExpired) {
await CRUD().getJWT();
}
}
}
getAIKey(String key1) async {
if (box.read(BoxName.firstTimeLoadKey) == null) {
var res =
await CRUD().get(link: Env.getapiKey, payload: {"keyName": key1});
if (res != 'failure') {
var d = jsonDecode(res)['message'];
Log.print('d: ${d}');
await storage.write(key: key1, value: d[key1].toString());
await Future.delayed(Duration.zero);
} else {}
}
}
}

View File

@@ -0,0 +1,76 @@
import 'package:url_launcher/url_launcher.dart';
import 'dart:io';
void showInBrowser(String url) async {
if (await canLaunchUrl(Uri.parse(url))) {
launchUrl(Uri.parse(url));
} else {}
}
Future<void> makePhoneCall(String phoneNumber) async {
final Uri launchUri = Uri(
scheme: 'tel',
path: phoneNumber,
);
await launchUrl(launchUri);
}
void launchCommunication(
String method, String contactInfo, String message) async {
String url;
if (Platform.isIOS) {
switch (method) {
case 'phone':
url = 'tel:$contactInfo';
break;
case 'sms':
url = 'sms:$contactInfo?body=${Uri.encodeComponent(message)}';
break;
case 'whatsapp':
url =
'https://api.whatsapp.com/send?phone=$contactInfo&text=${Uri.encodeComponent(message)}';
break;
case 'email':
url =
'mailto:$contactInfo?subject=Subject&body=${Uri.encodeComponent(message)}';
break;
default:
return;
}
} else if (Platform.isAndroid) {
switch (method) {
case 'phone':
url = 'tel:$contactInfo';
break;
case 'sms':
url = 'sms:$contactInfo?body=${Uri.encodeComponent(message)}';
break;
case 'whatsapp':
// Check if WhatsApp is installed
final bool whatsappInstalled =
await canLaunchUrl(Uri.parse('whatsapp://'));
if (whatsappInstalled) {
url =
'whatsapp://send?phone=$contactInfo&text=${Uri.encodeComponent(message)}';
} else {
// Provide an alternative action, such as opening the WhatsApp Web API
url =
'https://api.whatsapp.com/send?phone=$contactInfo&text=${Uri.encodeComponent(message)}';
}
break;
case 'email':
url =
'mailto:$contactInfo?subject=Subject&body=${Uri.encodeComponent(message)}';
break;
default:
return;
}
} else {
return;
}
if (await canLaunchUrl(Uri.parse(url))) {
await launchUrl(Uri.parse(url));
} else {}
}

View File

@@ -0,0 +1,102 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../constant/box_name.dart';
import '../../main.dart';
import '../themes/themes.dart';
class LocaleController extends GetxController {
Locale? language;
String countryCode = '';
ThemeData appTheme = lightThemeEnglish;
void changeLang(String langcode) {
Locale locale;
switch (langcode) {
case "ar":
locale = const Locale("ar");
appTheme = lightThemeArabic;
box.write(BoxName.lang, 'ar');
break;
case "en":
locale = const Locale("en");
appTheme = lightThemeEnglish;
box.write(BoxName.lang, 'en');
break;
case "tr":
locale = const Locale("tr");
appTheme = lightThemeEnglish;
box.write(BoxName.lang, 'tr');
break;
case "fr":
locale = const Locale("fr");
appTheme = lightThemeEnglish;
box.write(BoxName.lang, 'fr');
break;
case "it":
locale = const Locale("it");
appTheme = lightThemeEnglish;
box.write(BoxName.lang, 'it');
break;
case "de":
locale = const Locale("de");
appTheme = lightThemeEnglish;
box.write(BoxName.lang, 'de');
break;
case "el":
locale = const Locale("el");
appTheme = lightThemeEnglish;
box.write(BoxName.lang, 'el');
break;
case "es":
locale = const Locale("es");
appTheme = lightThemeEnglish;
box.write(BoxName.lang, 'es');
break;
case "fa":
locale = const Locale("fa");
appTheme = lightThemeEnglish;
box.write(BoxName.lang, 'fa');
break;
case "zh":
locale = const Locale("zh");
appTheme = lightThemeEnglish;
box.write(BoxName.lang, 'zh');
break;
case "ru":
locale = const Locale("ru");
appTheme = lightThemeEnglish;
box.write(BoxName.lang, 'ru');
break;
case "hi":
locale = const Locale("hi");
appTheme = lightThemeEnglish;
box.write(BoxName.lang, 'hi');
break;
default:
locale = Locale(Get.deviceLocale!.languageCode);
box.write(BoxName.lang, Get.deviceLocale!.languageCode);
appTheme = lightThemeEnglish;
break;
}
box.write(BoxName.lang, langcode);
Get.changeTheme(appTheme);
Get.updateLocale(locale);
update();
}
@override
void onInit() {
String? storedLang = box.read(BoxName.lang);
if (storedLang == null) {
// Use device language if no language is stored
storedLang = Get.deviceLocale!.languageCode;
box.write(BoxName.lang, storedLang);
}
changeLang(storedLang);
super.onInit();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,48 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:service/constant/links.dart';
import 'package:service/controller/functions/crud.dart';
import '../views/home/main.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
class LoginController extends GetxController {
var email = TextEditingController();
var password = TextEditingController();
final formKey = GlobalKey<FormState>();
// Use FlutterSecureStorage instead of GetStorage
final FlutterSecureStorage storage = const FlutterSecureStorage();
void login() async {
String? storedEmail = await storage.read(key: 'email');
String? storedPassword = await storage.read(key: 'password');
if (storedEmail != null) {
Get.off(() => Main());
} else {
if (formKey.currentState!.validate()) {
var res = await CRUD().get(link: AppLink.login, payload: {
"email": storedEmail ?? email.text,
"password": storedPassword ?? password.text,
});
if (res != 'failure') {
var d = jsonDecode(res);
if (d['message'] == "Login successful") {
// Save data securely in FlutterSecureStorage
await storage.write(key: 'email', value: d['data']['email']);
await storage.write(key: 'name', value: d['data']['first_name']);
await storage.write(key: 'driverID', value: d['data']['id']);
await storage.write(key: 'password', value: password.text);
Get.off(() => Main());
}
}
}
}
}
}

View File

@@ -0,0 +1,417 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:service/constant/box_name.dart';
import 'package:service/constant/colors.dart';
import 'package:service/constant/links.dart';
import 'package:service/controller/functions/crud.dart';
import 'package:service/controller/mainController/pages/driver_page.dart';
import 'package:service/main.dart';
import 'package:service/views/widgets/my_dialog.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../print.dart';
import 'pages/passengers_page.dart';
class MainController extends GetxController {
final formKey = GlobalKey<FormState>();
bool isLoading = false;
final passengerPhoneController = TextEditingController();
final driverPhoneController = TextEditingController();
final notesController = TextEditingController();
final carplateController = TextEditingController();
TextEditingController colorController = TextEditingController();
TextEditingController makeController = TextEditingController();
TextEditingController modelController = TextEditingController();
TextEditingController expirationDateController = TextEditingController();
TextEditingController yearController = TextEditingController();
TextEditingController ownerController = TextEditingController();
TextEditingController carOwnerWorkController = TextEditingController();
TextEditingController driverNameController = TextEditingController();
TextEditingController nationalIdController = TextEditingController();
TextEditingController birthDateController = TextEditingController();
TextEditingController licenseTypeController = TextEditingController();
TextEditingController phoneController = TextEditingController();
TextEditingController phoneCarController = TextEditingController();
TextEditingController carNumberController = TextEditingController();
TextEditingController manufactureYearController = TextEditingController();
TextEditingController carModelController = TextEditingController();
TextEditingController carTypeController = TextEditingController();
TextEditingController siteCarController = TextEditingController();
TextEditingController siteDriverController = TextEditingController();
TextEditingController registrationDateController = TextEditingController();
Map passengerData = {};
Map driverData = {};
List filteredDrivers = [];
var color = ''.obs;
var colorHex = ''.obs;
searchPassengerByPhone() async {
if (formKey.currentState!.validate()) {
await getPassengersByPhone();
Get.back();
Get.to(() => PassengersPage());
}
}
void searchDrivers(String query) {
if (query.isEmpty) {
filteredDrivers = driverNotCompleteRegistration;
update();
} else {
filteredDrivers = driverNotCompleteRegistration
.where((driver) => driver['phone_number']
.toString()
.toLowerCase()
.contains(query.toLowerCase()))
.toList();
update();
}
}
Future<void> makePhoneCall(String phoneNumber) async {
final Uri launchUri = Uri(
scheme: 'tel',
path: phoneNumber,
);
await launchUrl(launchUri);
}
void launchCommunication(
String method, String contactInfo, String message) async {
String url;
if (Platform.isIOS) {
switch (method) {
case 'phone':
url = 'tel:$contactInfo';
break;
case 'sms':
url = 'sms:$contactInfo?body=${Uri.encodeComponent(message)}';
break;
case 'whatsapp':
url =
'https://api.whatsapp.com/send?phone=$contactInfo&text=${Uri.encodeComponent(message)}';
break;
case 'email':
url =
'mailto:$contactInfo?subject=Subject&body=${Uri.encodeComponent(message)}';
break;
default:
return;
}
} else if (Platform.isAndroid) {
switch (method) {
case 'phone':
url = 'tel:$contactInfo';
break;
case 'sms':
url = 'sms:$contactInfo?body=${Uri.encodeComponent(message)}';
break;
case 'whatsapp':
// Check if WhatsApp is installed
final bool whatsappInstalled =
await canLaunchUrl(Uri.parse('whatsapp://'));
if (whatsappInstalled) {
url =
'whatsapp://send?phone=$contactInfo&text=${Uri.encodeComponent(message)}';
} else {
// Provide an alternative action, such as opening the WhatsApp Web API
url =
'https://api.whatsapp.com/send?phone=$contactInfo&text=${Uri.encodeComponent(message)}';
}
break;
case 'email':
url =
'mailto:$contactInfo?subject=Subject&body=${Uri.encodeComponent(message)}';
break;
default:
return;
}
} else {
return;
}
if (await canLaunchUrl(Uri.parse(url))) {
await launchUrl(Uri.parse(url));
} else {}
}
List driverNotCompleteRegistration = [];
getDriverNotCompleteRegistration() async {
var res = await CRUD()
.get(link: AppLink.getDriverNotCompleteRegistration, payload: {});
if (res != 'failure') {
var d = jsonDecode(res)['message'];
driverNotCompleteRegistration = d;
filteredDrivers = driverNotCompleteRegistration;
update();
} else {
Get.snackbar(res, '');
}
}
List newDriverRegister = [];
getNewDriverRegister() async {
var res = await CRUD().get(link: AppLink.getNewDriverRegister, payload: {});
if (res != 'failure') {
var d = jsonDecode(res)['message'];
newDriverRegister = d;
update();
} else {
Get.snackbar(res, '');
}
}
addWelcomeCall(String driveId) async {
var res = await CRUD().post(link: AppLink.addWelcomeDriverNote, payload: {
"driverId": driveId,
"notes": notesController.text,
});
if (res != 'failue') {
Get.snackbar('Success'.tr, '', backgroundColor: AppColor.greenColor);
}
}
String selectedStatus = "I'm not ready yet".tr;
List passengerNotCompleteRegistration = [];
getPassengerNotCompleteRegistration() async {
var res = await CRUD()
.get(link: AppLink.getPassengersNotCompleteRegistration, payload: {});
if (res != 'failure') {
var d = jsonDecode(res)['message'];
passengerNotCompleteRegistration = d;
update();
} else {
Get.snackbar(res, '');
}
}
void setSelectedStatus(String status) {
selectedStatus = status;
update();
}
final List<String> statusOptions = [
"I'm not ready yet".tr,
"I don't have a suitable vehicle".tr,
"I'll register when the app is fully launched".tr,
"I need more help understanding the app".tr,
"My documents have expired".tr,
];
List carPlateNotEdit = [];
getCarPlateNotEdit() async {
var res = await CRUD().get(link: AppLink.getCarPlateNotEdit, payload: {});
if (res != 'failure') {
var d = jsonDecode(res)['message'];
carPlateNotEdit = d;
update();
} else {
MyDialog().getDialog('No Car found yet'.tr, 'thanks'.tr, const SizedBox(),
() {
Get.back();
});
}
}
List driverWithoutCar = [];
getdriverWithoutCar() async {
var res = await CRUD().get(link: AppLink.getdriverWithoutCar, payload: {});
if (res != 'failure') {
var d = jsonDecode(res)['message'];
driverWithoutCar = d;
update();
} else {
MyDialog().getDialog('No Car found yet'.tr, 'thanks'.tr, const SizedBox(),
() {
Get.back();
});
}
}
Future<void> addRegistrationCarEgyptHandling({
required String driverId,
required String carPlate,
required String color,
required String colorHex,
required String year,
required String make,
required String model,
required String expirationDate,
required String owner,
}) async {
try {
isLoading = true;
update();
var payload = {
'driverID': driverId,
'vin': 'vin',
'car_plate': carPlate,
'make': make,
'model': model,
'year': year,
'expiration_date': expirationDate,
'color': color,
'owner': owner,
'color_hex': colorHex,
'address': 'addressCar',
'displacement': 'displacement',
'fuel': 'fuel',
'registration_date': '2024-09-06',
};
Log.print('Payload: $payload');
var res =
await CRUD().post(link: AppLink.addCartoDriver, payload: payload);
isLoading = false;
update();
var status = jsonDecode(res);
Log.print('res: $res');
Log.print('status: $status');
if (status['status'] == 'success') {
await Future.wait([
CRUD().post(
link:
'${AppLink.seferAlexandriaServer}/ride/RegisrationCar/add.php',
payload: payload),
CRUD().post(
link: '${AppLink.seferGizaServer}/ride/RegisrationCar/add.php',
payload: payload),
]);
Get.snackbar('Success', 'Registration successful',
backgroundColor: AppColor.greenColor);
Get.back();
} else {
Log.print('Error: Unexpected status: ${status['status']}');
Get.snackbar('Error', 'Registration failed',
backgroundColor: Colors.red);
}
} catch (e) {
Log.print('Error: $e');
Get.snackbar('Error', 'An error occurred during registration',
backgroundColor: Colors.red);
}
}
editCarPlateNotEdit(
String driverId,
String carPlate,
String color,
String colorHex,
String year,
String make,
String model,
String expirationDate,
String owner,
) async {
var res = await CRUD().post(link: AppLink.editCarPlate, payload: {
"driverId": driverId,
"carPlate": carPlate,
"color": color,
"color_hex": colorHex,
"make": make,
"year": year,
"model": model,
"expiration_date": expirationDate.toString(),
"owner": owner,
"employee": storage.read(key: 'name').toString(),
});
Log.print('res: ${res}');
if (res != 'failure') {
// Get.snackbar(res, '', backgroundColor: AppColor.greenColor);
Get.back();
carplateController.clear();
yearController.clear();
makeController.clear();
modelController.clear();
ownerController.clear();
await getCarPlateNotEdit();
update();
} else {
Get.snackbar(res, '', backgroundColor: AppColor.redColor);
}
}
// editCarPlateNotEdit(String driverId, carPlate) async {
// var res = await CRUD().post(link: AppLink.editCarPlate, payload: {
// "driverId": driverId,
// "carPlate": carPlate,
// });
// if (res != 'failure') {
// Get.snackbar(res, '', backgroundColor: AppColor.greenColor);
// carplateController.clear();
// await getCarPlateNotEdit();
// update();
// } else {
// Get.snackbar(res, '', backgroundColor: AppColor.redColor);
// }
// }
saveNoteForDriverNotCompleteRegistration(String phone, editor, note) async {
var res = await CRUD().post(
link: AppLink.addNotesDriver,
payload: {"phone": phone, "editor": editor, "note": note});
if (res != 'failure') {
Get.snackbar(res, '', backgroundColor: AppColor.greenColor);
notesController.clear();
} else {
Get.snackbar(res, '', backgroundColor: AppColor.redColor);
}
}
saveNoteForPassengerNotCompleteRegistration(
String phone, editor, note) async {
var res = await CRUD().post(
link: AppLink.addNotesPassenger,
payload: {"phone": phone, "editor": editor, "note": note});
if (res != 'failure') {
Get.snackbar(res, '', backgroundColor: AppColor.greenColor);
notesController.clear();
} else {
Get.snackbar(res, '', backgroundColor: AppColor.redColor);
}
}
searchDriverByPhone() async {
if (formKey.currentState!.validate()) {
await getDriverByPhone();
Get.back();
Get.to(() => DriverPage());
}
}
getPassengersByPhone() async {
var res = await CRUD().get(
link: AppLink.getPassengersByPhone,
payload: {"phone": '+2${passengerPhoneController.text}'});
if (res != 'failure') {
var d = jsonDecode(res);
passengerData = d;
update();
}
}
getDriverByPhone() async {
var res = await CRUD().get(
link: AppLink.getDriverByPhone,
payload: {"phone": '+2${driverPhoneController.text}'});
if (res != 'failure') {
var d = jsonDecode(res);
driverData = d;
update();
}
}
}

View File

@@ -0,0 +1,378 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:service/constant/style.dart';
import 'package:service/controller/functions/launch.dart';
import 'package:service/views/widgets/my_scafold.dart';
import '../../../constant/colors.dart';
import '../../../constant/links.dart';
import '../../../views/widgets/my_textField.dart';
import '../../functions/encrypt_decrypt.dart';
import '../../functions/image.dart';
import '../main_controller.dart';
class AddCar extends StatelessWidget {
const AddCar({super.key});
@override
Widget build(BuildContext context) {
Get.put(MainController());
return GetBuilder<MainController>(builder: (mainController) {
return MyScaffold(
title: 'Edit car details'.tr,
isleading: true,
body: [
Expanded(
child: ListView.builder(
padding: const EdgeInsets.all(16.0),
itemCount: mainController
.driverWithoutCar.length, // 10 fields + 1 save button
itemBuilder: (context, index) {
var carData = mainController.driverWithoutCar[index];
return Padding(
padding: const EdgeInsets.all(8.0),
child: InkWell(
onTap: () {
Get.to(AddCarForm(carData: carData));
},
child: Container(
decoration: AppStyle.boxDecoration1,
child: Text((carData['name_arabic']))),
),
);
}),
),
],
);
});
}
}
class AddCarForm extends StatelessWidget {
final Map carData;
const AddCarForm({super.key, required this.carData});
@override
Widget build(BuildContext context) {
Get.put(MainController());
return GetBuilder<MainController>(builder: (mainController) {
return MyScaffold(
title: 'Add Car',
action: Row(
children: [
IconButton(
onPressed: () {
makePhoneCall(carData['phone']);
},
icon: const Icon(Icons.phone),
),
IconButton(
onPressed: () {
launchCommunication('whatsapp', carData['phone'], '');
},
icon: const Icon(
Icons.message,
color: AppColor.greenColor,
),
),
],
),
isleading: true,
body: [
ListView(
children: [
Column(
children: [
GestureDetector(
onLongPress: () async {
await ImageController().choosImage(
AppLink.uploadEgypt, carData['id'], 'car_front');
},
child: Image.network(
'https://sefer.click/sefer/card_image/car_front-${carData['id']}.jpg',
height: 200,
width: double.maxFinite,
fit: BoxFit.fill,
errorBuilder: (BuildContext context, Object exception,
StackTrace? stackTrace) {
// If the image fails to load, use the _copy version
return Image.network(
'https://sefer.click/sefer/card_image/car_front-${carData['id']}_copy.jpg',
height: 200,
width: double.maxFinite,
fit: BoxFit.fill,
);
},
),
),
GestureDetector(
onLongPress: () async {
await ImageController().choosImage(
AppLink.uploadEgypt, carData['id'], 'car_back');
},
child: Image.network(
'https://sefer.click/sefer/card_image/car_back-${carData['id']}.jpg',
height: 200,
width: double.maxFinite,
fit: BoxFit.fill,
errorBuilder: (BuildContext context, Object exception,
StackTrace? stackTrace) {
// If the image fails to load, use the _copy version
return Image.network(
'https://sefer.click/sefer/card_image/car_back-${carData['id']}_copy.jpg',
height: 200,
width: double.maxFinite,
fit: BoxFit.fill,
);
},
),
),
],
),
const SizedBox(height: 9),
Form(
key: mainController.formKey,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SizedBox(
width: Get.width * .6,
child: MyTextForm(
controller: mainController.carplateController,
label: 'car plate'.tr,
hint: 'car plate'.tr,
type: TextInputType.name,
),
),
IconButton(
onPressed: () async {
if (mainController.formKey.currentState!
.validate()) {
await mainController
.addRegistrationCarEgyptHandling(
driverId: carData['id'].toString(),
carPlate:
mainController.carplateController.text,
color: mainController.colorController.text,
colorHex:
mainController.colorHex.value.toString(),
year: mainController.yearController.text,
make: mainController.makeController.text,
model: mainController.modelController.text,
expirationDate: mainController
.expirationDateController.text,
owner: mainController.ownerController.text,
);
}
},
icon: const Icon(
Icons.upload_outlined,
color: AppColor.blueColor,
),
),
],
),
// Other fields
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: Get.width * .4,
child: MyTextForm(
controller: mainController.yearController,
label: 'Year'.tr,
hint: 'Year'.tr,
type: TextInputType.number,
),
),
SizedBox(
width: Get.width * .4,
child: DropdownButtonFormField<String>(
decoration: InputDecoration(
labelText: 'Color'.tr, // Localized label
),
value: mainController.colorHex.value.isEmpty
? null
: mainController.colorHex
.value, // Use the hex value as the current value
items: [
{'red'.tr: '#FF0000'},
{'green'.tr: '#008000'},
{'blue'.tr: '#0000FF'},
{'black'.tr: '#000000'},
{'white'.tr: '#FFFFFF'},
{'yellow'.tr: '#FFFF00'},
{'purple'.tr: '#800080'},
{'orange'.tr: '#FFA500'},
{'pink'.tr: '#FFC0CB'},
{'brown'.tr: '#A52A2A'},
{'gray'.tr: '#808080'},
{'cyan'.tr: '#00FFFF'},
{'magenta'.tr: '#FF00FF'},
{'lime'.tr: '#00FF00'},
{'indigo'.tr: '#4B0082'},
{'violet'.tr: '#EE82EE'},
{'gold'.tr: '#FFD700'},
{'silver'.tr: '#C0C0C0'},
{'teal'.tr: '#008080'},
{'navy'.tr: '#000080'},
].map((colorMap) {
String colorName = colorMap.keys.first;
String colorValue = colorMap.values.first;
return DropdownMenuItem<String>(
value: colorValue,
child: Text(colorName),
);
}).toList(),
onChanged: (value) {
if (value != null) {
// Find the selected color name based on the hex value
String selectedColorName = '';
for (var colorMap in [
{'red'.tr: '#FF0000'},
{'green'.tr: '#008000'},
{'blue'.tr: '#0000FF'},
{'black'.tr: '#000000'},
{'white'.tr: '#FFFFFF'},
{'yellow'.tr: '#FFFF00'},
{'purple'.tr: '#800080'},
{'orange'.tr: '#FFA500'},
{'pink'.tr: '#FFC0CB'},
{'brown'.tr: '#A52A2A'},
{'gray'.tr: '#808080'},
{'cyan'.tr: '#00FFFF'},
{'magenta'.tr: '#FF00FF'},
{'lime'.tr: '#00FF00'},
{'indigo'.tr: '#4B0082'},
{'violet'.tr: '#EE82EE'},
{'gold'.tr: '#FFD700'},
{'silver'.tr: '#C0C0C0'},
{'teal'.tr: '#008080'},
{'navy'.tr: '#000080'},
]) {
if (colorMap.values.first == value) {
selectedColorName = colorMap.keys.first;
break;
}
}
mainController.colorController.text =
selectedColorName;
mainController.colorHex.value = value;
}
},
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: Get.width * .4,
child: MyTextForm(
controller: mainController.makeController,
label: 'Make'.tr,
hint: 'Make'.tr,
type: TextInputType.name,
),
),
SizedBox(
width: Get.width * .4,
child: MyTextForm(
controller: mainController.modelController,
label: 'Model'.tr,
hint: 'Model'.tr,
type: TextInputType.name,
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: Get.width * .4,
child: TextField(
controller:
mainController.expirationDateController,
decoration: InputDecoration(
labelText: 'Expiration Date'.tr,
hintText: 'Expiration Date'.tr,
),
readOnly:
true, // Make the field read-only to prevent manual input
onTap: () async {
DateTime pickedDate =
DateTime.now(); // Declare the variable here
await showCupertinoModalPopup<void>(
context: context,
builder: (context) => Container(
height: 250,
color: Colors.white,
child: Column(
children: [
SizedBox(
height: 150,
child: CupertinoDatePicker(
initialDateTime: pickedDate,
minimumDate: DateTime(
1955), // Set the starting date
maximumDate: DateTime(
2034), // Set the ending date
mode: CupertinoDatePickerMode.date,
onDateTimeChanged:
(DateTime dateTime) {
pickedDate = dateTime;
},
),
),
CupertinoButton(
child: Text('Done'.tr),
onPressed: () {
String formattedDate =
DateFormat('yyyy-MM-dd')
.format(pickedDate);
mainController
.expirationDateController
.text =
formattedDate.toString();
Navigator.of(context).pop();
},
),
],
),
),
);
},
),
),
SizedBox(
width: Get.width * .4,
child: MyTextForm(
controller: mainController.ownerController,
label: 'Owner'.tr,
hint: 'Owner'.tr,
type: TextInputType.name,
),
),
],
),
],
),
)
],
)
]);
});
}
}

View File

@@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:service/views/widgets/my_scafold.dart';
import '../../best_driver_controllers.dart';
import '../../functions/encrypt_decrypt.dart';
class DriverTheBestAlexandria extends StatelessWidget {
const DriverTheBestAlexandria({super.key});
@override
Widget build(BuildContext context) {
Get.put(DriverTheBestAlexandriaController(), permanent: true);
return MyScaffold(
title: 'Alexandria'.tr,
body: [
GetBuilder<DriverTheBestAlexandriaController>(builder: (driverthebest) {
return driverthebest.driver.isNotEmpty
? ListView.builder(
itemCount: driverthebest.driver.length,
itemBuilder: (context, index) {
final driver = driverthebest.driver[index];
return ListTile(
leading: CircleAvatar(
child: Text(
(int.parse(driver['driver_count'] * 5) / 3600)
.toStringAsFixed(0),
),
),
title: Text((driver['name_arabic']) ??
'Unknown Name'),
subtitle: Text(
'Phone: ${(driver['phone']) ?? 'N/A'}'),
trailing: IconButton(
onPressed: () async {
Get.defaultDialog(
title:
'are you sure to pay to this driver gift'.tr,
middleText: '',
onConfirm: () async {},
onCancel: () => Get.back());
},
icon: const Icon(Icons.wallet_giftcard_rounded),
),
);
},
)
: const Center(
child: Text('No drivers available.'),
);
})
],
isleading: true,
);
}
}

View File

@@ -0,0 +1,111 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:service/controller/functions/encrypt_decrypt.dart';
import 'package:service/views/widgets/my_scafold.dart';
import '../../../constant/colors.dart';
import '../../../constant/links.dart';
import '../../../views/widgets/elevated_btn.dart';
import '../../functions/crud.dart';
import 'alexandria_besr_driver.dart';
import 'giza_best_driver.dart';
class DriverTheBest extends StatelessWidget {
const DriverTheBest({super.key});
@override
Widget build(BuildContext context) {
Get.put(Driverthebest());
return MyScaffold(
title: 'Best Drivers'.tr,
body: [
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
MyElevatedButton(
title: 'Giza',
onPressed: () {
Get.to(() => DriverTheBestGiza());
}),
MyElevatedButton(
title: 'Alexandria',
onPressed: () {
Get.to(() => DriverTheBestAlexandria());
}),
],
),
GetBuilder<Driverthebest>(builder: (driverthebest) {
return driverthebest.driver.isNotEmpty
? SizedBox(
height: Get.height * .7,
child: ListView.builder(
itemCount: driverthebest.driver.length,
itemBuilder: (context, index) {
final driver = driverthebest.driver[index];
return ListTile(
leading: CircleAvatar(
child: Text(
((int.parse(driver['driver_count']) * 5) / 3600)
.toStringAsFixed(0),
),
),
title: Text((driver['name_arabic']) ??
'Unknown Name'),
subtitle: Text(
'Phone: ${(driver['phone']) ?? 'N/A'}'),
trailing: IconButton(
onPressed: () async {
// Get.defaultDialog(
// title:
// 'are you sure to pay to this driver gift'.tr,
// middleText: '',
// onConfirm: () async {
// // final wallet = Get.put(WalletController());
// // await wallet.addPaymentToDriver('100',
// // driver['id'].toString(), driver['token']);
// // await wallet.addSeferWallet(
// // '100', driver['id'].toString());
// },
// onCancel: () => Get.back());
},
icon: const Icon(Icons.wallet_giftcard_rounded),
),
);
},
),
)
: const Center(
child: Text('No drivers available.'),
);
}),
],
)
],
isleading: true,
);
}
}
class Driverthebest extends GetxController {
bool isLoading = false;
List driver = [];
getBestDriver() async {
var res = await CRUD().get(link: AppLink.getBestDriver, payload: {});
if (res != 'failure') {
driver = jsonDecode(res)['message'];
update();
} else {
Get.snackbar('error', '', backgroundColor: AppColor.redColor);
}
}
@override
void onInit() {
getBestDriver();
super.onInit();
}
}

View File

@@ -0,0 +1,12 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:service/views/widgets/my_scafold.dart';
class Complaint extends StatelessWidget {
const Complaint({super.key});
@override
Widget build(BuildContext context) {
return MyScaffold(title: "View complaint".tr, isleading: true, body: []);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,128 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:service/views/widgets/my_scafold.dart';
import '../main_controller.dart';
class DriverPage extends StatelessWidget {
DriverPage({super.key});
MainController mainController = MainController();
@override
Widget build(BuildContext context) {
return Scaffold(
body: GetBuilder<MainController>(builder: (mainController) {
Map data = mainController.driverData['message'][0];
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text('${data['first_name']} ${data['last_name']}'),
),
child: SafeArea(
child: CupertinoScrollbar(
child: ListView(
children: [
_buildDriverInfoSection(
mainController.driverData['message'][0]),
_buildStatisticsSection(
mainController.driverData['message'][0]),
_buildCarInfoSection(mainController.driverData['message'][0]),
_buildLicenseInfoSection(
mainController.driverData['message'][0]),
_buildBankInfoSection(
mainController.driverData['message'][0]),
// buildCarInfo(mainController.driverData['message'][0]),
],
),
),
),
);
}),
);
}
Widget _buildDriverInfoSection(Map<String, dynamic> data) {
return CupertinoListSection.insetGrouped(
header: Text('Driver Information'.tr),
children: [
_buildInfoRow('Name'.tr, data['name_arabic'].toString()),
_buildInfoRow('Name (English)'.tr, data['name_english'].toString()),
_buildInfoRow('Phone'.tr, data['phone'].toString()),
_buildInfoRow('Email'.tr, data['email'].toString()),
_buildInfoRow('Gender'.tr, data['gender'].toString()),
_buildInfoRow('Birthdate'.tr, data['birthdate'].toString()),
_buildInfoRow('National Number'.tr, data['national_number'].toString()),
_buildInfoRow('Religion'.tr, data['religion'].toString()),
_buildInfoRow('Occupation'.tr, data['occupation'].toString()),
_buildInfoRow('Education'.tr, data['education'].toString()),
],
);
}
Widget _buildStatisticsSection(Map<String, dynamic> data) {
return CupertinoListSection.insetGrouped(
header: Text('Driver Statistics'.tr),
children: [
_buildInfoRow('Total Rides'.tr, data['countRide'].toString()),
_buildInfoRow('Average Rating'.tr, data['rating'].toString()),
_buildInfoRow('Total Payments'.tr, '\$${data['totalPayment']}'),
_buildInfoRow('Wallet Balance'.tr, '\$${data['totalDriverWallet']}'),
_buildInfoRow('Complaints'.tr, data['countComplaint'].toString()),
_buildInfoRow('Scam Reports'.tr, data['countScam'].toString()),
_buildInfoRow(
'Passengers Rated'.tr, data['DRatingPassengersCount'].toString()),
_buildInfoRow(
'Avg Passenger Rating'.tr, data['avgDRatingPassenger'].toString()),
],
);
}
Widget _buildCarInfoSection(Map<String, dynamic> data) {
return CupertinoListSection.insetGrouped(
header: Text('Vehicle Information'.tr),
children: [
_buildInfoRow('VIN'.tr, data['vin'].toString()),
_buildInfoRow('Plate Number'.tr, data['car_plate'].toString()),
_buildInfoRow('Make'.tr, data['make'].toString()),
_buildInfoRow('Model'.tr, data['model'].toString()),
_buildInfoRow('Year'.tr, data['year'].toString()),
_buildInfoRow('Color'.tr, data['color'].toString()),
_buildInfoRow('Fuel Type'.tr, data['fuel'].toString()),
_buildInfoRow('Displacement'.tr, data['displacement'].toString()),
_buildInfoRow(
'Registration Date'.tr, data['registration_date'].toString()),
_buildInfoRow('Expiration Date'.tr, data['expiration_date'].toString()),
],
);
}
Widget _buildLicenseInfoSection(Map<String, dynamic> data) {
return CupertinoListSection.insetGrouped(
header: Text('License Information'.tr),
children: [
_buildInfoRow('License Type'.tr, data['license_type'].toString()),
_buildInfoRow('Card ID'.tr, data['card_id'].toString()),
_buildInfoRow('Issue Date'.tr, data['issue_date'].toString()),
_buildInfoRow('Expiry Date'.tr, data['expiry_date'].toString()),
_buildInfoRow('Categories'.tr, data['license_categories'].toString()),
],
);
}
Widget _buildBankInfoSection(Map<String, dynamic> data) {
return CupertinoListSection.insetGrouped(
header: Text('Bank Information'.tr),
children: [
_buildInfoRow('Account Number'.tr, data['accountBank'].toString()),
_buildInfoRow('Bank Code'.tr, data['bankCode'].toString()),
],
);
}
Widget _buildInfoRow(String label, String value) {
return CupertinoListTile(
title: Text(label),
trailing: Text(value,
style: const TextStyle(color: CupertinoColors.systemGrey)),
);
}
}

View File

@@ -0,0 +1,219 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:service/constant/colors.dart';
import 'package:service/controller/functions/encrypt_decrypt.dart';
import 'package:service/controller/mainController/main_controller.dart';
import 'package:service/views/widgets/my_scafold.dart';
import 'registration_captain_page.dart';
class DriversCantRegister extends StatelessWidget {
DriversCantRegister({super.key});
@override
Widget build(BuildContext context) {
Get.put(MainController());
return MyScaffold(
title: 'Drivers Cant Register'.tr,
isleading: true,
body: [
GetBuilder<MainController>(builder: (mainController) {
return Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: CupertinoSearchTextField(
keyboardType: TextInputType.phone,
onChanged: (value) => mainController.searchDrivers(value),
placeholder: 'Search by phone number'.tr,
),
),
Expanded(
child: ListView.builder(
itemCount: mainController.filteredDrivers.length,
itemBuilder: (context, index) {
final driver = mainController.filteredDrivers[index];
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
color: driver['note'] == null
? AppColor.greenColor
: AppColor.greyColor,
child: CupertinoFormSection(
header: Text(
'Driver ID: ${driver['driverId']}',
),
children: [
InkWell(
onTap: () => mainController
.makePhoneCall(driver['phone_number']),
child: Container(
height: 40,
color: driver['note'] != null
? AppColor.greenColor
: AppColor.greyColor,
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Text((driver['phone_number'])),
IconButton(
onPressed: () {
String message = "مرحباً،\n\n"
"نلاحظ أنك لم تكمل عملية التسجيل في خدمة Tripz درايفر. نود تذكيرك بأن إكمال التسجيل يتيح لك فرصة الانضمام إلى فريق Tripz والاستفادة من خدماتنا المتنوعة.\n\n"
"إذا كنت بحاجة إلى أي مساعدة أو لديك أي استفسارات، لا تتردد في الاتصال بنا. نحن هنا لمساعدتك.\n\n"
"للاتصال بنا، يرجى الاتصال على الرقم التالي: +20 101 880 5430\n\n"
"مع تحيات فريق Tripz.";
mainController.launchCommunication(
'whatsapp',
'${driver['phone_number']}',
message);
},
icon: const Icon(
Icons.send_time_extension_sharp,
color: AppColor.secondaryColor,
),
),
IconButton(
onPressed: () {
Get.to(() => RegisterCaptain(),
arguments: {
"phone_number":
driver['phone_number']
.toString(),
'driverId': driver['driverId']
.toString(),
'email':
driver['email'].toString(),
});
},
icon: const Icon(
Icons.save,
color: AppColor.gold,
),
),
],
)
// CupertinoFormRow(
// prefix: Text('Phone Number'.tr),
// child: CupertinoTextFormFieldRow(
// initialValue: driver['phone_number'],
// readOnly: true,
// placeholder: 'Phone Number'.tr,
// ),
// ),
),
),
CupertinoFormRow(
prefix: Text('Created At'.tr),
child: CupertinoTextFormFieldRow(
initialValue: driver['created_at'],
readOnly: true,
placeholder: 'Created At',
),
),
CupertinoFormRow(
prefix: Text('Status'.tr),
child: GestureDetector(
onTap: () {
showCupertinoModalPopup<void>(
context: Get.context!,
builder: (BuildContext context) =>
Container(
height: 216,
padding: const EdgeInsets.only(top: 6.0),
margin: EdgeInsets.only(
bottom: MediaQuery.of(context)
.viewInsets
.bottom,
),
color: CupertinoColors.systemBackground
.resolveFrom(context),
child: SafeArea(
top: false,
child: CupertinoPicker(
magnification: 1.22,
squeeze: 1.2,
useMagnifier: true,
itemExtent: 32.0,
scrollController:
FixedExtentScrollController(
initialItem: mainController
.selectedStatus
.indexOf(mainController
.selectedStatus),
),
onSelectedItemChanged:
(int selectedItem) {
mainController.setSelectedStatus(
mainController
.statusOptions[selectedItem]
.tr);
},
children: List<Widget>.generate(
mainController.statusOptions
.length, (int index) {
return Center(
child: Text(mainController
.statusOptions[index].tr),
);
}),
),
),
),
);
},
child: CupertinoFormRow(
child: Text(
mainController.selectedStatus.tr,
style: TextStyle(
color: CupertinoColors.label
.resolveFrom(Get.context!)),
),
),
),
),
CupertinoFormRow(
prefix: Text('Notes'.tr),
child: CupertinoTextFormFieldRow(
cursorColor: AppColor.blueColor,
controller: mainController.notesController,
placeholder:
driver['note'] ?? "Additional comments".tr,
),
),
CupertinoButton(
child: Text('Save Notes'.tr),
onPressed: () {
// Save the notes for the driver
String notes =
mainController.notesController.text == ''
? mainController.selectedStatus
.toString()
: mainController.notesController.text;
mainController
.saveNoteForDriverNotCompleteRegistration(
driver['phone_number'],
'girls name',
notes);
print(
'Notes for driver ${driver['id']}: $notes');
},
),
],
),
),
);
},
),
),
],
);
}),
],
);
}
}

View File

@@ -0,0 +1,334 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:service/controller/mainController/main_controller.dart';
import 'package:service/views/widgets/my_scafold.dart';
import '../../../constant/colors.dart';
import '../../../constant/links.dart';
import '../../../views/widgets/my_textField.dart';
import '../../functions/image.dart';
import '../../functions/launch.dart';
class EditCar extends StatelessWidget {
final Map carData;
const EditCar({super.key, required this.carData});
@override
Widget build(BuildContext context) {
Get.put(MainController());
return GetBuilder<MainController>(builder: (mainController) {
return MyScaffold(
title: 'Edit',
isleading: true,
action: Row(
children: [
IconButton(
onPressed: () {
makePhoneCall(carData['phone']);
},
icon: const Icon(Icons.phone),
),
IconButton(
onPressed: () {
launchCommunication('whatsapp', carData['phone'], '');
},
icon: const Icon(
Icons.message,
color: AppColor.greenColor,
),
),
],
),
body: [
ListView(
children: [
Column(
children: [
GestureDetector(
onLongPress: () async {
await ImageController().choosImage(AppLink.uploadEgypt,
carData['driverID'], 'car_front');
},
child: Image.network(
'https://sefer.click/sefer/card_image/car_front-${carData['driverID']}.jpg',
height: 200,
width: double.maxFinite,
fit: BoxFit.fill,
errorBuilder: (BuildContext context, Object exception,
StackTrace? stackTrace) {
// If the image fails to load, use the _copy version
return Image.network(
'https://sefer.click/sefer/card_image/car_front-${carData['driverID']}_copy.jpg',
height: 200,
width: double.maxFinite,
fit: BoxFit.fill,
);
},
),
),
GestureDetector(
onLongPress: () async {
await ImageController().choosImage(
AppLink.uploadEgypt, carData['id'], 'car_back');
},
child: Image.network(
'https://sefer.click/sefer/card_image/car_back-${carData['driverID']}.jpg',
height: 200,
width: double.maxFinite,
fit: BoxFit.fill,
errorBuilder: (BuildContext context, Object exception,
StackTrace? stackTrace) {
// If the image fails to load, use the _copy version
return Image.network(
'https://sefer.click/sefer/card_image/car_back-${carData['driverID']}_copy.jpg',
height: 200,
width: double.maxFinite,
fit: BoxFit.fill,
);
},
),
),
],
),
const SizedBox(height: 9),
Form(
key: mainController.formKey,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SizedBox(
width: Get.width * .6,
child: MyTextForm(
controller: mainController.carplateController,
label: 'car plate'.tr,
hint: 'car plate'.tr,
type: TextInputType.name,
),
),
IconButton(
onPressed: () async {
if (mainController.formKey.currentState!
.validate()) {
await mainController.editCarPlateNotEdit(
carData['driverID'].toString(),
mainController.carplateController.text,
mainController.colorController.text,
mainController.colorHex.value.toString(),
mainController.yearController.text,
mainController.makeController.text,
mainController.modelController.text,
mainController.expirationDateController.text,
mainController.ownerController.text,
);
}
},
icon: const Icon(
Icons.upload_outlined,
color: AppColor.blueColor,
),
),
],
),
// Other fields
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: Get.width * .4,
child: MyTextForm(
controller: mainController.yearController,
label: 'Year'.tr,
hint: 'Year'.tr,
type: TextInputType.number,
),
),
SizedBox(
width: Get.width * .4,
child: DropdownButtonFormField<String>(
decoration: InputDecoration(
labelText: 'Color'.tr, // Localized label
),
value: mainController.colorHex.value.isEmpty
? null
: mainController.colorHex
.value, // Use the hex value as the current value
items: [
{'red'.tr: '#FF0000'},
{'green'.tr: '#008000'},
{'blue'.tr: '#0000FF'},
{'black'.tr: '#000000'},
{'white'.tr: '#FFFFFF'},
{'yellow'.tr: '#FFFF00'},
{'purple'.tr: '#800080'},
{'orange'.tr: '#FFA500'},
{'pink'.tr: '#FFC0CB'},
{'brown'.tr: '#A52A2A'},
{'gray'.tr: '#808080'},
{'cyan'.tr: '#00FFFF'},
{'magenta'.tr: '#FF00FF'},
{'lime'.tr: '#00FF00'},
{'indigo'.tr: '#4B0082'},
{'violet'.tr: '#EE82EE'},
{'gold'.tr: '#FFD700'},
{'silver'.tr: '#C0C0C0'},
{'teal'.tr: '#008080'},
{'navy'.tr: '#000080'},
].map((colorMap) {
String colorName = colorMap.keys.first;
String colorValue = colorMap.values.first;
return DropdownMenuItem<String>(
value: colorValue,
child: Text(colorName),
);
}).toList(),
onChanged: (value) {
if (value != null) {
// Find the selected color name based on the hex value
String selectedColorName = '';
for (var colorMap in [
{'red'.tr: '#FF0000'},
{'green'.tr: '#008000'},
{'blue'.tr: '#0000FF'},
{'black'.tr: '#000000'},
{'white'.tr: '#FFFFFF'},
{'yellow'.tr: '#FFFF00'},
{'purple'.tr: '#800080'},
{'orange'.tr: '#FFA500'},
{'pink'.tr: '#FFC0CB'},
{'brown'.tr: '#A52A2A'},
{'gray'.tr: '#808080'},
{'cyan'.tr: '#00FFFF'},
{'magenta'.tr: '#FF00FF'},
{'lime'.tr: '#00FF00'},
{'indigo'.tr: '#4B0082'},
{'violet'.tr: '#EE82EE'},
{'gold'.tr: '#FFD700'},
{'silver'.tr: '#C0C0C0'},
{'teal'.tr: '#008080'},
{'navy'.tr: '#000080'},
]) {
if (colorMap.values.first == value) {
selectedColorName = colorMap.keys.first;
break;
}
}
mainController.colorController.text =
selectedColorName;
mainController.colorHex.value = value;
}
},
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: Get.width * .4,
child: MyTextForm(
controller: mainController.makeController,
label: 'Make'.tr,
hint: 'Make'.tr,
type: TextInputType.name,
),
),
SizedBox(
width: Get.width * .4,
child: MyTextForm(
controller: mainController.modelController,
label: 'Model'.tr,
hint: 'Model'.tr,
type: TextInputType.name,
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: Get.width * .4,
child: TextField(
controller:
mainController.expirationDateController,
decoration: InputDecoration(
labelText: 'Expiration Date'.tr,
hintText: 'Expiration Date'.tr,
),
readOnly:
true, // Make the field read-only to prevent manual input
onTap: () async {
DateTime pickedDate =
DateTime.now(); // Declare the variable here
await showCupertinoModalPopup<void>(
context: context,
builder: (context) => Container(
height: 250,
color: Colors.white,
child: Column(
children: [
SizedBox(
height: 150,
child: CupertinoDatePicker(
initialDateTime: pickedDate,
minimumDate: DateTime(
1955), // Set the starting date
maximumDate: DateTime(
2034), // Set the ending date
mode: CupertinoDatePickerMode.date,
onDateTimeChanged:
(DateTime dateTime) {
pickedDate = dateTime;
},
),
),
CupertinoButton(
child: Text('Done'.tr),
onPressed: () {
String formattedDate =
DateFormat('yyyy-MM-dd')
.format(pickedDate);
mainController
.expirationDateController
.text =
formattedDate.toString();
Navigator.of(context).pop();
},
),
],
),
),
);
},
),
),
SizedBox(
width: Get.width * .4,
child: MyTextForm(
controller: mainController.ownerController,
label: 'Owner'.tr,
hint: 'Owner'.tr,
type: TextInputType.name,
),
),
],
),
],
),
)
],
)
]);
});
}
}

View File

@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:service/constant/style.dart';
import 'package:service/controller/mainController/pages/edit_car.dart';
import 'package:service/views/widgets/my_scafold.dart';
import '../../functions/encrypt_decrypt.dart';
import '../main_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class EditCarPlate extends StatelessWidget {
const EditCarPlate({super.key});
@override
Widget build(BuildContext context) {
Get.put(MainController());
return GetBuilder<MainController>(builder: (mainController) {
return MyScaffold(
title: 'Edit car details'.tr,
isleading: true,
body: [
Expanded(
child: ListView.builder(
padding: const EdgeInsets.all(16.0),
itemCount: mainController
.carPlateNotEdit.length, // 10 fields + 1 save button
itemBuilder: (context, index) {
var carData = mainController.carPlateNotEdit[index];
return Padding(
padding: const EdgeInsets.all(8.0),
child: InkWell(
onTap: () {
Get.to(EditCar(carData: carData));
},
child: Container(
decoration: AppStyle.boxDecoration1,
child: Text((carData['owner']))),
),
);
}),
),
],
);
});
}
}

View File

@@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:service/views/widgets/my_scafold.dart';
import '../../best_driver_controllers.dart';
import '../../functions/encrypt_decrypt.dart';
class DriverTheBestGiza extends StatelessWidget {
const DriverTheBestGiza({super.key});
@override
Widget build(BuildContext context) {
Get.put(DriverTheBestGizaController(), permanent: true);
return MyScaffold(
title: 'Giza'.tr,
body: [
GetBuilder<DriverTheBestGizaController>(builder: (driverthebest) {
return driverthebest.driver.isNotEmpty
? ListView.builder(
itemCount: driverthebest.driver.length,
itemBuilder: (context, index) {
final driver = driverthebest.driver[index];
return ListTile(
leading: CircleAvatar(
child: Text(
(int.parse(driver['driver_count'] * 5) / 3600)
.toStringAsFixed(0),
),
),
title: Text((driver['name_arabic']) ??
'Unknown Name'),
subtitle: Text(
'Phone: ${(driver['phone']) ?? 'N/A'}'),
trailing: IconButton(
onPressed: () async {
Get.defaultDialog(
title:
'are you sure to pay to this driver gift'.tr,
middleText: '',
onConfirm: () async {},
onCancel: () => Get.back());
},
icon: const Icon(Icons.wallet_giftcard_rounded),
),
);
},
)
: const Center(
child: Text('No drivers available.'),
);
})
],
isleading: true,
);
}
}

View File

@@ -0,0 +1,79 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:service/controller/mainController/main_controller.dart';
import 'package:service/views/widgets/my_scafold.dart';
import '../../functions/encrypt_decrypt.dart';
class PassengersCantRegister extends StatelessWidget {
PassengersCantRegister({super.key});
@override
Widget build(BuildContext context) {
Get.put(MainController());
return MyScaffold(
title: 'Passengers Cant Register'.tr,
isleading: true,
body: [
GetBuilder<MainController>(builder: (mainController) {
return ListView.builder(
itemCount: mainController.passengerNotCompleteRegistration.length,
itemBuilder: (context, index) {
final passenger =
mainController.passengerNotCompleteRegistration[index];
return Padding(
padding: const EdgeInsets.all(8.0),
child: CupertinoFormSection(
header: Text('Passenger ID: ${passenger['id']}'),
children: [
InkWell(
onTap: () => mainController
.makePhoneCall(passenger['phone_number']),
child: CupertinoFormRow(
prefix: Text('Phone Number'.tr),
child: CupertinoTextFormFieldRow(
initialValue: ((passenger['phone_number'])),
readOnly: true,
placeholder: 'Phone Number'.tr,
),
),
),
CupertinoFormRow(
prefix: Text('Created At'.tr),
child: CupertinoTextFormFieldRow(
initialValue: passenger['created_at'],
readOnly: true,
placeholder: 'Created At',
),
),
CupertinoFormRow(
prefix: Text('Notes'.tr),
child: CupertinoTextFormFieldRow(
controller: mainController.notesController,
placeholder:
passenger['note'] ?? 'Enter notes after call'.tr,
),
),
CupertinoButton(
child: Text('Save Notes'.tr),
onPressed: () {
// Save the notes for the Passenger
String notes = mainController.notesController.text;
mainController
.saveNoteForPassengerNotCompleteRegistration(
passenger['phone_number'], 'girls name', notes);
print('Notes for Passenger ${passenger['id']}: $notes');
},
),
],
),
);
},
);
}),
],
);
}
}

View File

@@ -0,0 +1,133 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:service/controller/mainController/main_controller.dart';
import 'package:service/views/widgets/my_scafold.dart';
class PassengersPage extends StatelessWidget {
PassengersPage({super.key});
final MainController mainController = MainController();
@override
Widget build(BuildContext context) {
return GetBuilder<MainController>(builder: (mainController) {
Map data = mainController.passengerData['message'][0];
return MyScaffold(
title: (data['first_name']?.toString() ?? '') +
' ' +
(data['last_name']?.toString() ?? ''),
isleading: true,
body: [
ListView(
children: [
_buildPersonalInfoCard(data),
_buildLatestRideCard(data),
_buildWalletInfoCard(data),
],
),
],
);
});
}
Widget _buildPersonalInfoCard(Map data) {
return Card(
margin: const EdgeInsets.all(16),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Personal Information'.tr,
style:
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 16),
_buildInfoRow('Phone'.tr, data['phone']?.toString() ?? 'N/A'),
_buildInfoRow('Email'.tr, data['email']?.toString() ?? 'N/A'),
_buildInfoRow('Gender'.tr, data['gender']?.toString() ?? 'N/A'),
_buildInfoRow(
'Birthdate'.tr, data['birthdate']?.toString() ?? 'N/A'),
_buildInfoRow(
'Education'.tr, data['education']?.toString() ?? 'N/A'),
_buildInfoRow(
'Employment'.tr, data['employmentType']?.toString() ?? 'N/A'),
_buildInfoRow('Marital Status'.tr,
data['maritalStatus']?.toString() ?? 'N/A'),
],
),
),
);
}
Widget _buildLatestRideCard(Map data) {
return Card(
margin: const EdgeInsets.all(16),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Latest Ride'.tr,
style:
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 16),
_buildInfoRow('Ride ID'.tr, data['ride_id']?.toString() ?? 'N/A'),
_buildInfoRow('Date'.tr, data['ride_date']?.toString() ?? 'N/A'),
_buildInfoRow(
'Start Time'.tr, data['ride_time']?.toString() ?? 'N/A'),
_buildInfoRow(
'End Time'.tr, data['ride_endtime']?.toString() ?? 'N/A'),
_buildInfoRow(
'Price'.tr, '\$${data['price']?.toString() ?? 'N/A'}'),
_buildInfoRow(
'Status'.tr, data['ride_status']?.toString() ?? 'N/A'),
_buildInfoRow('Payment Method'.tr,
data['ride_payment_method']?.toString() ?? 'N/A'),
_buildInfoRow('Car Type'.tr, data['car_type']?.toString() ?? 'N/A'),
_buildInfoRow(
'Distance'.tr,
data['distance'] != null
? '${data['distance'].toStringAsFixed(2)} km'
: 'N/A'),
],
),
),
);
}
Widget _buildWalletInfoCard(Map data) {
return Card(
margin: const EdgeInsets.all(16),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Wallet Information'.tr,
style:
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 16),
_buildInfoRow('Wallet Balance'.tr,
'\$${data['passenger_wallet_balance']?.toString() ?? 'N/A'}'),
_buildInfoRow('Last Payment Amount'.tr,
'\$${data['passenger_payment_amount']?.toString() ?? 'N/A'}'),
_buildInfoRow('Last Payment Method'.tr,
data['passenger_payment_method']?.toString() ?? 'N/A'),
],
),
),
);
}
Widget _buildInfoRow(String label, String value) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(label, style: const TextStyle(fontWeight: FontWeight.bold)),
Text(value),
],
),
);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,165 @@
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:service/constant/colors.dart';
import 'package:service/constant/style.dart';
import 'package:service/views/widgets/elevated_btn.dart';
import 'package:service/views/widgets/my_scafold.dart';
import '../main_controller.dart';
class WelcomeCall extends StatelessWidget {
const WelcomeCall({super.key});
@override
Widget build(BuildContext context) {
Get.put(MainController());
return MyScaffold(
title: 'Welcome Drivers'.tr,
isleading: true,
body: [
GetBuilder<MainController>(builder: (mainController) {
return Expanded(
child: CupertinoScrollbar(
child: ListView.builder(
itemCount: mainController.newDriverRegister.length,
itemBuilder: (context, index) {
final driver = mainController.newDriverRegister[index];
return DriverCard(driver: driver);
},
),
),
);
}),
],
);
}
}
class DriverCard extends StatelessWidget {
final Map<String, dynamic> driver;
const DriverCard({super.key, required this.driver});
@override
Widget build(BuildContext context) {
return CupertinoCard(
margin: const EdgeInsets.all(16.0),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
decoration: AppStyle.boxDecoration1.copyWith(
color: driver['isCall'].toString() == '1'
? AppColor.greenColor
: AppColor.accentColor),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 10, vertical: 2),
child: Text(
'Driver Information'.tr,
style: CupertinoTheme.of(context).textTheme.navTitleTextStyle,
),
),
),
const SizedBox(height: 16),
InfoText('Name'.tr, driver['name_arabic'].toString()),
InfoText('Phone'.tr, driver['phone'].toString()),
InfoText('Email'.tr, driver['email'].toString()),
InfoText('License Type'.tr, driver['license_type'].toString()),
InfoText(
'License Categories'.tr, driver['license_categories'] ?? ''),
InfoText(
'National Number'.tr, driver['national_number'].toString()),
InfoText('Occupation'.tr, driver['occupation'].toString()),
const SizedBox(height: 16),
Text(
'Notes:'.tr,
style: CupertinoTheme.of(context).textTheme.navTitleTextStyle,
),
const SizedBox(height: 8),
CupertinoTextField(
controller: Get.find<MainController>().notesController,
placeholder: driver['notes'] ?? 'Enter notes here...'.tr,
maxLines: 3,
padding: const EdgeInsets.all(12.0),
decoration: BoxDecoration(
border: Border.all(color: CupertinoColors.systemGrey),
borderRadius: BorderRadius.circular(8.0),
),
),
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: Get.width * .4,
child: MyElevatedButton(
title: 'Call Driver'.tr,
onPressed: () {
Get.find<MainController>()
.makePhoneCall(driver['phone'].toString());
})),
CupertinoButton(
onPressed: () async {
await Get.find<MainController>().addWelcomeCall(
driver['id'].toString(),
);
},
child: Text('Save Changes'.tr),
),
],
),
],
),
),
);
}
}
class InfoText extends StatelessWidget {
final String label;
final String value;
const InfoText(this.label, this.value, {super.key});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
'$label: $value',
style: CupertinoTheme.of(context).textTheme.textStyle,
),
);
}
}
class CupertinoCard extends StatelessWidget {
final Widget child;
final EdgeInsetsGeometry margin;
const CupertinoCard(
{super.key, required this.child, this.margin = EdgeInsets.zero});
@override
Widget build(BuildContext context) {
return Container(
margin: margin,
decoration: BoxDecoration(
color: CupertinoColors.systemBackground,
borderRadius: BorderRadius.circular(12.0),
boxShadow: [
BoxShadow(
color: CupertinoColors.systemGrey.withOpacity(0.2),
spreadRadius: 1,
blurRadius: 5,
offset: const Offset(0, 3),
),
],
),
child: child,
);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,147 @@
import 'package:flutter/material.dart';
import '../../constant/colors.dart';
import '../../constant/style.dart';
ThemeData lightThemeEnglish = ThemeData(
brightness: Brightness.light,
fontFamily: "SFPro",
textTheme: TextTheme(
displaySmall: AppStyle.title,
displayLarge: AppStyle.headTitle,
displayMedium: AppStyle.headTitle2,
bodyLarge: AppStyle.title,
bodyMedium: AppStyle.subtitle,
),
primarySwatch: Colors.blue,
dialogTheme: DialogThemeData(
backgroundColor: AppColor.secondaryColor,
contentTextStyle: AppStyle.title,
titleTextStyle: AppStyle.headTitle2,
),
appBarTheme: AppBarTheme(
elevation: 0,
color: AppColor.secondaryColor,
centerTitle: true,
iconTheme: const IconThemeData(
color: AppColor.primaryColor,
),
toolbarTextStyle: TextTheme(
titleSmall: AppStyle.subtitle,
headlineSmall: AppStyle.title,
titleLarge: AppStyle.headTitle2,
).bodyMedium,
titleTextStyle: TextTheme(
titleSmall: AppStyle.subtitle,
headlineSmall: AppStyle.title,
titleLarge: AppStyle.headTitle2,
).titleLarge,
),
);
ThemeData darkThemeEnglish = ThemeData(
brightness: Brightness.dark,
fontFamily: "SFPro",
textTheme: TextTheme(
displaySmall: AppStyle.title,
displayLarge: AppStyle.headTitle,
displayMedium: AppStyle.headTitle2,
bodyLarge: AppStyle.title,
bodyMedium: AppStyle.subtitle,
),
primarySwatch: Colors.blue,
dialogTheme: DialogThemeData(
backgroundColor: AppColor.secondaryColor,
contentTextStyle: AppStyle.title,
titleTextStyle: AppStyle.headTitle2,
),
appBarTheme: AppBarTheme(
elevation: 0,
color: AppColor.secondaryColor,
centerTitle: true,
iconTheme: const IconThemeData(
color: AppColor.primaryColor,
),
toolbarTextStyle: TextTheme(
titleSmall: AppStyle.subtitle,
headlineSmall: AppStyle.title,
titleLarge: AppStyle.headTitle2,
).bodyMedium,
titleTextStyle: TextTheme(
titleSmall: AppStyle.subtitle,
headlineSmall: AppStyle.title,
titleLarge: AppStyle.headTitle2,
).titleLarge,
),
);
ThemeData lightThemeArabic = ThemeData(
brightness: Brightness.light,
fontFamily: 'SFArabic',
textTheme: TextTheme(
displaySmall: AppStyle.title,
displayLarge: AppStyle.headTitle,
displayMedium: AppStyle.headTitle2,
bodyLarge: AppStyle.title,
bodyMedium: AppStyle.subtitle,
),
primarySwatch: Colors.blue,
dialogTheme: DialogThemeData(
backgroundColor: AppColor.secondaryColor,
contentTextStyle: AppStyle.title,
titleTextStyle: AppStyle.headTitle2,
),
appBarTheme: AppBarTheme(
elevation: 0,
color: AppColor.secondaryColor,
centerTitle: true,
iconTheme: const IconThemeData(
color: AppColor.primaryColor,
),
toolbarTextStyle: TextTheme(
titleSmall: AppStyle.subtitle,
headlineSmall: AppStyle.title,
titleLarge: AppStyle.headTitle2,
).bodyMedium,
titleTextStyle: TextTheme(
titleSmall: AppStyle.subtitle,
headlineSmall: AppStyle.title,
titleLarge: AppStyle.headTitle2,
).titleLarge,
),
);
ThemeData darkThemeArabic = ThemeData(
brightness: Brightness.dark,
fontFamily: 'SFArabic',
textTheme: TextTheme(
displaySmall: AppStyle.title,
displayLarge: AppStyle.headTitle,
displayMedium: AppStyle.headTitle2,
bodyLarge: AppStyle.title,
bodyMedium: AppStyle.subtitle,
),
primarySwatch: Colors.blue,
dialogTheme: DialogThemeData(
backgroundColor: AppColor.secondaryColor,
contentTextStyle: AppStyle.title,
titleTextStyle: AppStyle.headTitle2,
),
appBarTheme: AppBarTheme(
elevation: 0,
color: AppColor.secondaryColor,
centerTitle: true,
iconTheme: const IconThemeData(
color: AppColor.primaryColor,
),
toolbarTextStyle: TextTheme(
titleSmall: AppStyle.subtitle,
headlineSmall: AppStyle.title,
titleLarge: AppStyle.headTitle2,
).bodyMedium,
titleTextStyle: TextTheme(
titleSmall: AppStyle.subtitle,
headlineSmall: AppStyle.title,
titleLarge: AppStyle.headTitle2,
).titleLarge,
),
);