diff --git a/.env b/.env index acbbfda..c9b3997 100644 --- a/.env +++ b/.env @@ -18,4 +18,5 @@ claudeAiAPI=sk-ant-api03-bHIbOKhHWIsTCNmODYGGucds_GPQplU-7_8SJER79K_ANU67ijWIZZi payPalClientId=AWj9MdPaA5Djpx8gOkvBn2qhP-3KvfB6W-l8USTsm19Xi2NhkNkE9QzosOvTPTsKjCMNffgpqStUA1-x payPalSecret=EKkasSl9O61lrfrbaJfXp1B-CIs2Rv71J0WPouxxugi38DsWaMhWpovJxN2ftYPQ0l6v9eoBvnyWkemp geminiApi=AIzaSyADz49pIaeO1grPEcpV8HNCJijzekd037o +geminiApiMasa=AIzaSyAOxZ8NLyGzqXEIV1xSv5-t7MHctu1VQrA diff --git a/android/app/build.gradle b/android/app/build.gradle index 33d7d50..b9214b5 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -9,17 +9,17 @@ if (localPropertiesFile.exists()) { def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { - throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { - flutterVersionCode = '11' + flutterVersionCode = '12' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { - flutterVersionName = '1.1.1' + flutterVersionName = '1.1.2' } apply plugin: 'com.android.application' @@ -55,8 +55,8 @@ android { // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdkVersion 26 targetSdkVersion flutter.targetSdkVersion - versionCode 18 - versionName '1.4.2' + versionCode 20 + versionName '1.4.4' // manifestPlaceholders = [mapsApiKey: 'android/app/src/main/AndroidManifest.xml'] } @@ -71,7 +71,6 @@ android { buildTypes { release { signingConfig signingConfigs.release - // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } diff --git a/lib/constant/box_name.dart b/lib/constant/box_name.dart index 202d0ea..d04d59d 100644 --- a/lib/constant/box_name.dart +++ b/lib/constant/box_name.dart @@ -1,6 +1,7 @@ class BoxName { static const String driverID = "driverID"; static const String countryCode = "countryCode"; + static const String googlaMapApp = "googlaMapApp"; static const String lang = "lang"; static const String statusDriverLocation = "statusDriverLocation"; diff --git a/lib/constant/links.dart b/lib/constant/links.dart index 93a996c..5d1a48c 100644 --- a/lib/constant/links.dart +++ b/lib/constant/links.dart @@ -135,6 +135,7 @@ class AppLink { // =========================================== static String pathImage = "$server/upload/types/"; static String uploadImage = "$server/uploadImage.php"; + static String uploadImage1 = "$server/uploadImage1.php"; static String uploadImagePortrate = "$server/uploadImagePortrate.php"; static String uploadImageType = "$server/uploadImageType.php"; diff --git a/lib/constant/style.dart b/lib/constant/style.dart index b37c5aa..fdbea1c 100644 --- a/lib/constant/style.dart +++ b/lib/constant/style.dart @@ -1,3 +1,5 @@ +import 'package:SEFER/constant/box_name.dart'; +import 'package:SEFER/main.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'colors.dart'; @@ -7,22 +9,38 @@ class AppStyle { fontWeight: FontWeight.bold, fontSize: 40, color: AppColor.accentColor, - fontFamily: GoogleFonts.josefinSans().fontFamily); + fontFamily: box.read(BoxName.lang) == 'en' + ? GoogleFonts.josefinSans().fontFamily + : box.read(BoxName.lang) == 'ar' + ? GoogleFonts.amiri().fontFamily + : GoogleFonts.josefinSans().fontFamily); static TextStyle headTitle2 = TextStyle( fontWeight: FontWeight.bold, fontSize: 26, color: AppColor.primaryColor, - fontFamily: GoogleFonts.josefinSans().fontFamily); + fontFamily: box.read(BoxName.lang) == 'en' + ? GoogleFonts.josefinSans().fontFamily + : box.read(BoxName.lang) == 'ar' + ? GoogleFonts.amiri().fontFamily + : GoogleFonts.josefinSans().fontFamily); static TextStyle title = TextStyle( fontWeight: FontWeight.bold, fontSize: 16, color: AppColor.primaryColor, - fontFamily: GoogleFonts.josefinSans().fontFamily); + fontFamily: box.read(BoxName.lang) == 'en' + ? GoogleFonts.josefinSans().fontFamily + : box.read(BoxName.lang) == 'ar' + ? GoogleFonts.amiri().fontFamily + : GoogleFonts.josefinSans().fontFamily); static TextStyle subtitle = TextStyle( fontWeight: FontWeight.bold, fontSize: 13, color: AppColor.primaryColor, - fontFamily: GoogleFonts.josefinSans().fontFamily); + fontFamily: box.read(BoxName.lang) == 'en' + ? GoogleFonts.josefinSans().fontFamily + : box.read(BoxName.lang) == 'ar' + ? GoogleFonts.amiri().fontFamily + : GoogleFonts.josefinSans().fontFamily); static TextStyle number = TextStyle( fontWeight: FontWeight.bold, fontSize: 20, diff --git a/lib/controller/auth/captin/register_captin_controller.dart b/lib/controller/auth/captin/register_captin_controller.dart index 84a9006..fd1a94c 100644 --- a/lib/controller/auth/captin/register_captin_controller.dart +++ b/lib/controller/auth/captin/register_captin_controller.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'dart:math'; +import 'package:SEFER/controller/auth/captin/login_captin_controller.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:SEFER/constant/box_name.dart'; @@ -13,6 +14,7 @@ import 'package:SEFER/views/auth/captin/verify_email_captain.dart'; import '../../../views/auth/captin/ai_page.dart'; import '../../../views/auth/captin/car_license_page.dart'; +import '../../../views/home/Captin/home_captain/home_captin.dart'; class RegisterCaptainController extends GetxController { final formKey = GlobalKey(); @@ -67,12 +69,19 @@ class RegisterCaptainController extends GetxController { sendVerifications() async { var res = await CRUD().post(link: AppLink.verifyEmail, payload: { - 'email': emailController.text, + 'email': emailController.text.isEmpty + ? Get.find().emailController.text.toString() + : emailController.text, 'token': verifyCode.text, }); if (res != 'failure') { - Get.to(() => CarLicensePage()); + if (Get.find().emailController.text.toString() != + '') { + Get.offAll(() => HomeCaptain()); + } else { + Get.to(() => CarLicensePage()); + } } } diff --git a/lib/controller/auth/login_controller.dart b/lib/controller/auth/login_controller.dart index aa3f963..2466390 100644 --- a/lib/controller/auth/login_controller.dart +++ b/lib/controller/auth/login_controller.dart @@ -39,6 +39,11 @@ class LoginController extends GetxController { update(); } + void saveCountryCode(String countryCode) { + box.write(BoxName.countryCode, countryCode); + update(); + } + void adminDashboardOpen() async { if (formKeyAdmin.currentState!.validate()) { await DeviceInfoPlus.getDeviceInfo(); diff --git a/lib/controller/functions/crud.dart b/lib/controller/functions/crud.dart index ca49d39..0dfd1a7 100644 --- a/lib/controller/functions/crud.dart +++ b/lib/controller/functions/crud.dart @@ -1,13 +1,11 @@ import 'dart:convert'; import 'package:SEFER/constant/box_name.dart'; -import 'package:SEFER/constant/links.dart'; import 'package:SEFER/main.dart'; import 'package:get/get.dart'; import 'package:http/http.dart' as http; import 'package:SEFER/env/env.dart'; import '../../constant/api_key.dart'; -import '../home/captin/map_driver_controller.dart'; class CRUD { Future get({ @@ -32,8 +30,9 @@ class CRUD { ); print("-----request----" + response.request.toString()); // print("-----headers-----" + response.headers.toString()); - // print("-----payload-----" + payload.toString()); + print("-----payload-----" + payload.toString()); if (response.statusCode == 200) { + // print(response.body); var jsonData = jsonDecode(response.body); if (jsonData['status'] == 'success') { // print(jsonData); @@ -178,6 +177,7 @@ class CRUD { print(payload); var jsonData = jsonDecode(response.body); + // print(jsonData); if (response.statusCode == 200) { if (jsonData['status'] == 'success') { // Get.snackbar( @@ -205,7 +205,8 @@ class CRUD { request.headers.addAll(headers); http.StreamedResponse response = await request.send(); - + // print(request.body); + // print(response); if (response.statusCode == 200) { print(await response.stream.bytesToString()); } else { diff --git a/lib/controller/functions/gemeni.dart b/lib/controller/functions/gemeni.dart index 0ececbd..7e35a8a 100644 --- a/lib/controller/functions/gemeni.dart +++ b/lib/controller/functions/gemeni.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:developer'; import 'dart:io'; import 'package:get/get.dart'; import 'package:image_cropper/image_cropper.dart'; @@ -10,7 +11,7 @@ import 'package:path_provider/path_provider.dart'; import '../../constant/api_key.dart'; import '../../constant/colors.dart'; -class ContentController extends GetxController { +class AI extends GetxController { final picker = ImagePicker(); Map responseMap = {}; Map responseCarLicenseMap = {}; @@ -157,7 +158,7 @@ class ContentController extends GetxController { } } - Future generateDriverLicenseJordanContent() async { + Future getDriverLicenseJordanContent() async { await pickImage(); isloading = true; update(); @@ -253,7 +254,7 @@ class ContentController extends GetxController { } } - Future generateCarLicenseJordanContent() async { + Future getCarLicenseJordanContent() async { await pickImage(); isloading = true; update(); @@ -273,7 +274,114 @@ class ContentController extends GetxController { }, { 'text': - 'write json output of this car license in jordan json contain name , address , car kind ,car color , car year , car plate ,registration adjective , using ,expire date of license and make date format like YYYY-MM-DD .dont add data else this image', + '''Extract the following information from the front face of the Jordanian ID card: +Name +National ID number +Gender +Date of birth +Output the extracted information in the following JSON format''', + }, + ], + }, + ], + 'generationConfig': { + 'temperature': 0.4, + 'topK': 32, + 'topP': 1, + 'maxOutputTokens': 4096, + 'stopSequences': [], + }, + 'safetySettings': [ + { + 'category': 'HARM_CATEGORY_HARASSMENT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_HATE_SPEECH', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_DANGEROUS_CONTENT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + ], + }); + print(requestBody); + + final response = await http.post( + Uri.parse( + // 'https://${API_ENDPOINT}/v1/projects/${PROJECT_ID}/locations/${LOCATION_ID}/publishers/google/models/${MODEL_ID}:streamGenerateContent'), + 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro-vision:generateContent?key=${AK.geminiApi}'), + headers: {'Content-Type': 'application/json'}, + body: requestBody, + ); + isloading = false; + update(); + if (response.statusCode == 200) { + var responseData = jsonDecode(response.body); + // Process the responseData as needed + // print(responseData); + + var result = + responseData['candidates'][0]['content']['parts'][0]['text']; + // print(jsonEncode(result)); + // print((result)); + // print(result['dob']); + RegExp regex = RegExp(r"```json([^`]*)```"); + String? jsonString = + regex.firstMatch(responseData.toString())?.group(1)?.trim(); + + if (jsonString != null) { + // Convert the JSON object to a String + jsonString = jsonEncode(json.decode(jsonString)); + responseCarLicenseMap = jsonDecode(jsonString); + print(jsonString); + print(responseCarLicenseMap); + print(responseCarLicenseMap['plate_number']); + } else { + print("JSON string not found"); + } + + // Rest of your code... + } else { + print('Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.body}'); + } + } else { + print('No image selected'); + } + } + + Future jordanID() async { + await pickImage(); + isloading = true; + update(); + if (image != null) { + final imageBytes = await image.readAsBytes(); + final imageData = base64Encode(imageBytes); + + var requestBody = jsonEncode({ + 'contents': [ + { + 'parts': [ + { + 'inlineData': { + 'mimeType': 'image/jpeg', + 'data': imageData, + }, + }, + { + 'text': + '''Extract the following information from the front face of the Jordanian ID card: +Name +National ID number +Gender +Date of birth +Output the extracted information in the following JSON format''', }, ], }, @@ -349,6 +457,211 @@ class ContentController extends GetxController { } } + Future carLicenseJordan() async { + await pickImage(); + isloading = true; + update(); + if (image != null) { + final imageBytes = await image.readAsBytes(); + final imageData = base64Encode(imageBytes); + + var requestBody = jsonEncode({ + 'contents': [ + { + 'parts': [ + { + 'inlineData': { + 'mimeType': 'image/jpeg', + 'data': imageData, + }, + }, + { + 'text': + '''Extract the following information from the front face of the car license card in Jordan: + +* name +* Address +* Vehicle type +* car_kind +* car_color +* Vehicle category +* car_year +* car_plate +* Registration type +* Usage type +* expire_date_of_license + +Output the extracted information in the following JSON formate and make date format like YYYY-MM-DD''', + }, + ], + }, + ], + 'generationConfig': { + 'temperature': 0.4, + 'topK': 32, + 'topP': 1, + 'maxOutputTokens': 4096, + 'stopSequences': [], + }, + 'safetySettings': [ + { + 'category': 'HARM_CATEGORY_HARASSMENT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_HATE_SPEECH', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_DANGEROUS_CONTENT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + ], + }); + print(requestBody); + + final response = await http.post( + Uri.parse( + 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.0-pro-vision-latest:generateContent?key=${AK.geminiApi}'), + headers: {'Content-Type': 'application/json'}, + body: requestBody, + ); + isloading = false; + update(); + if (response.statusCode == 200) { + var responseData = jsonDecode(response.body); + // Process the responseData as needed + // print(responseData); + + var result = + responseData['candidates'][0]['content']['parts'][0]['text']; + // print(jsonEncode(result)); + // print((result)); + // print(result['dob']); + RegExp regex = RegExp(r"```json([^`]*)```"); + String? jsonString = + regex.firstMatch(responseData.toString())?.group(1)?.trim(); + + if (jsonString != null) { + // Convert the JSON object to a String + jsonString = jsonEncode(json.decode(jsonString)); + responseCarLicenseMap = jsonDecode(jsonString); + print(jsonString); + print(responseCarLicenseMap); + print(responseCarLicenseMap['plate_number']); + } else { + print("JSON string not found"); + } + + // Rest of your code... + } else { + print('Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.body}'); + } + } else { + print('No image selected'); + } + } + + Future getTextFromCard(String prompt) async { + await pickImage(); + isloading = true; + update(); + if (image != null) { + final imageBytes = await image.readAsBytes(); + final imageData = base64Encode(imageBytes); + + var requestBody = jsonEncode({ + 'contents': [ + { + 'parts': [ + { + 'inlineData': { + 'mimeType': 'image/jpeg', + 'data': imageData, + }, + }, + { + 'text': prompt, + }, + ], + }, + ], + 'generationConfig': { + "temperature": 1, + "topK": 32, + "topP": 0.1, + "maxOutputTokens": 4096, + "stopSequences": [] + }, + 'safetySettings': [ + { + 'category': 'HARM_CATEGORY_HARASSMENT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_HATE_SPEECH', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_DANGEROUS_CONTENT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + ], + }); + print(requestBody); + + final response = await http.post( + Uri.parse( + 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.0-pro-vision-latest:generateContent?key=${AK.geminiApi}'), + headers: {'Content-Type': 'application/json'}, + body: requestBody, + ); + isloading = false; + update(); + if (response.statusCode == 200) { + var responseData = jsonDecode(response.body); + // Process the responseData as needed + // print(responseData); + + var result = + responseData['candidates'][0]['content']['parts'][0]['text']; + // print(jsonEncode(result)); + // print((result)); + // print(result['dob']); + RegExp regex = RegExp(r"```json([^`]*)```"); + String? jsonString = + regex.firstMatch(responseData.toString())?.group(1)?.trim(); + + if (jsonString != null) { + // Convert the JSON object to a String + jsonString = jsonEncode(json.decode(jsonString)); + responseBackCarLicenseMap = jsonDecode(jsonString); + // print(jsonString); + print(responseBackCarLicenseMap); + // print(responseCarLicenseMap['plate_number']); + } else { + print("JSON string not found"); + } + + // Rest of your code... + } else { + print('Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.body}'); + } + } else { + print('No image selected'); + } + } + Future generateBackCarLicenseJordanContent() async { await pickImage(); isloading = true; diff --git a/lib/controller/functions/location_controller.dart b/lib/controller/functions/location_controller.dart index 3b24b61..8ff374b 100644 --- a/lib/controller/functions/location_controller.dart +++ b/lib/controller/functions/location_controller.dart @@ -31,7 +31,7 @@ class LocationController extends GetxController { } void startLocationUpdates() async { - _locationTimer = Timer.periodic(const Duration(seconds: 10), (timer) async { + _locationTimer = Timer.periodic(const Duration(seconds: 5), (timer) async { try { totalPoints = Get.find().totalPoints; diff --git a/lib/controller/functions/upload_image.dart b/lib/controller/functions/upload_image.dart new file mode 100644 index 0000000..0d61ae1 --- /dev/null +++ b/lib/controller/functions/upload_image.dart @@ -0,0 +1,73 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:SEFER/constant/api_key.dart'; +import 'package:get/get.dart'; +import 'package:http/http.dart' as http; +import 'package:image_picker/image_picker.dart'; +import 'package:path/path.dart'; + +import '../../constant/box_name.dart'; +import '../../constant/colors.dart'; +import '../../main.dart'; + +class ImageController extends GetxController { + File? myImage; + bool isloading = false; + void choosImage(String link) async { + XFile? xFile = await ImagePicker().pickImage(source: ImageSource.gallery); + myImage = File(xFile!.path); + isloading = true; + update(); + var response = await uploadImage( + myImage!, + { + 'driverID': box.read(BoxName.driverID).toString(), + }, + link, + ); + isloading = false; + update(); + if (response['status'] == 'success') { + Get.snackbar('Image Uploaded'.tr, 'Sucsses', + backgroundColor: AppColor.greenColor); + } + } + + 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({ + '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); + } + } +} diff --git a/lib/controller/home/captin/home_captain_controller.dart b/lib/controller/home/captin/home_captain_controller.dart index e6e575f..17c787f 100644 --- a/lib/controller/home/captin/home_captain_controller.dart +++ b/lib/controller/home/captin/home_captain_controller.dart @@ -26,6 +26,7 @@ class HomeCaptainController extends GetxController { bool isLoading = true; bool isCallOn = false; String totalMoneyToday = '0'; + String rating = '0'; String countRideToday = '0'; String totalMoneyInSEFER = '0'; String totalDurationToday = '0'; @@ -104,7 +105,7 @@ class HomeCaptainController extends GetxController { await sql.getCustomQuery(customQuery); countRefuse = results[0]['count'].toString(); update(); - if (int.parse(countRefuse) > 3 || double.parse(totalPoints) < -100) { + if (int.parse(countRefuse) > 3 || double.parse(totalPoints) <= -500) { print('total point is $totalPoints'); locationController.stopLocationUpdates(); activeStartTime = null; @@ -196,11 +197,11 @@ class HomeCaptainController extends GetxController { await addToken(); await getlocation(); onButtonSelected(); - getPaymentToday(); + await getPaymentToday(); getCountRideToday(); getAllPayment(); startPeriodicExecution(); - onMapCreated(mapHomeCaptaiController!); + onMapCreated(mapHomeCaptaiController); getRefusedOrderByCaptain(); totalPoints = Get.find().totalPoints; // LocationController().getLocation(); @@ -222,7 +223,7 @@ class HomeCaptainController extends GetxController { payload: {'driverID': box.read(BoxName.driverID).toString()}); data = jsonDecode(res); totalMoneyToday = data['message'][0]['todayAmount']; - + rating = data['message'][0]['rating'].toString(); update(); } diff --git a/lib/controller/home/captin/map_driver_controller.dart b/lib/controller/home/captin/map_driver_controller.dart index fefe1cf..af7e42f 100644 --- a/lib/controller/home/captin/map_driver_controller.dart +++ b/lib/controller/home/captin/map_driver_controller.dart @@ -8,6 +8,7 @@ import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_polyline_algorithm/google_polyline_algorithm.dart'; import 'package:SEFER/constant/style.dart'; import 'package:SEFER/views/widgets/elevated_btn.dart'; +import 'package:url_launcher/url_launcher.dart'; import '../../../constant/api_key.dart'; import '../../../constant/box_name.dart'; @@ -130,6 +131,22 @@ class MapDriverController extends GetxController { super.dispose(); } + void openGoogleMapFromDriverToPassenger() async { + var endLat = latLngpassengerLocation.latitude; + var endLng = latLngpassengerLocation.longitude; + + var startLat = Get.find().myLocation.latitude; + var startLng = Get.find().myLocation.longitude; + + String url = + 'https://www.google.com/maps/dir/$startLat,$startLng/$endLat,$endLng/&directionsmode=driving'; + if (await canLaunchUrl(Uri.parse(url))) { + await launchUrl(Uri.parse(url)); + } else { + throw 'Could not launch google maps'; + } + } + void checkIsDriverNearPassenger() async { if (isDriverNearPassengerStart) { Timer.periodic(const Duration(seconds: 3), (timer) { @@ -248,6 +265,9 @@ class MapDriverController extends GetxController { 'DriverIsGoingToPassenger', box.read(BoxName.name).toString(), tokenPassenger); + if (box.read(BoxName.googlaMapApp) == true) { + openGoogleMapFromDriverToPassenger(); + } } bool isSocialPressed = false; @@ -291,76 +311,100 @@ class MapDriverController extends GetxController { } Position? currentPosition; + void startRideFromDriver() async { - changeRideToBeginToPassenger(); - isPassengerInfoWindow = false; - isRideStarted = true; - isRideFinished = false; - remainingTimeInPassengerLocatioWait = 0; - timeWaitingPassenger = 0; - box.write(BoxName.statusDriverLocation, 'on'); + double _distance = + await calculateDistanseBetweenDriverAndPassengerLocation(); - update(); - await CRUD().post(link: AppLink.addDriverpayment, payload: { - 'rideId': rideId, - 'amount': paymentAmount, - 'payment_method': paymentMethod, - 'passengerID': passengerId, - 'driverID': box.read(BoxName.driverID).toString(), - }); + if (_distance < 50) { + changeRideToBeginToPassenger(); + isPassengerInfoWindow = false; + isRideStarted = true; + isRideFinished = false; + remainingTimeInPassengerLocatioWait = 0; + timeWaitingPassenger = 0; + box.write(BoxName.statusDriverLocation, 'on'); - await CRUD().post(link: AppLink.updateRides, payload: { - 'id': rideId, - 'rideTimeStart': DateTime.now().toString(), - 'status': 'Begin' - }); - FirebaseMessagesController().sendNotificationToAnyWithoutData( - 'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger); - rideIsBeginPassengerTimer(); - double pointsSubstraction = 0; - pointsSubstraction = double.parse(paymentAmount) * -100; - var res = await CRUD().post(link: AppLink.addDriversWalletPoints, payload: { - 'paymentID': 'rideId$rideId', - 'amount': (pointsSubstraction).toString(), - 'paymentMethod': paymentMethod, - 'driverID': box.read(BoxName.driverID).toString(), - }); - var d = jsonDecode(res); - // mapController!.animateCamera( - // CameraUpdate.newLatLngZoom( - // myLocation, - // 12, - // ), - // ); + update(); + await CRUD().post(link: AppLink.addDriverpayment, payload: { + 'rideId': rideId, + 'amount': paymentAmount, + 'payment_method': paymentMethod, + 'passengerID': passengerId, + 'driverID': box.read(BoxName.driverID).toString(), + }); + await CRUD().post(link: AppLink.updateRides, payload: { + 'id': rideId, + 'rideTimeStart': DateTime.now().toString(), + 'status': 'Begin', + }); + FirebaseMessagesController().sendNotificationToAnyWithoutData( + 'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger); + rideIsBeginPassengerTimer(); + double pointsSubstraction = 0; + pointsSubstraction = double.parse(paymentAmount) * -17; + var res = + await CRUD().post(link: AppLink.addDriversWalletPoints, payload: { + 'paymentID': 'rideId$rideId', + 'amount': (pointsSubstraction).toString(), + 'paymentMethod': paymentMethod, + 'driverID': box.read(BoxName.driverID).toString(), + }); + var d = jsonDecode(res); + + update(); + // Start updating location and moving camera + // updateLocation(); + } else { + Get.defaultDialog( + barrierDismissible: false, + title: 'Your are far from passenger location'.tr, + middleText: + 'go to your passenger location before\nPassenger cancel trip'.tr, + confirm: MyElevatedButton( + title: 'Ok', + onPressed: () { + Get.back(); + }), + ); + } + } + + void updateLocation() async { StreamSubscription? locationSubscription; try { - locationSubscription = - Geolocator.getPositionStream().listen((Position position) { - currentPosition = position; - // Update camera position on the map - mapController!.animateCamera( - CameraUpdate.newCameraPosition( - CameraPosition( - target: LatLng(position.latitude, position.longitude), - zoom: 7, + for (var i = 0; i < remainingTimeTimerRideBegin; i++) { + await Future.delayed(const Duration(seconds: 2)); + locationSubscription = + Geolocator.getPositionStream().listen((Position position) { + currentPosition = position; + // Update camera position on the map + mapController!.animateCamera( + CameraUpdate.newCameraPosition( + CameraPosition( + target: myLocation, + zoom: 17, // Adjust zoom level as needed + ), ), - ), - ); - }); // Stop listening to GPS updates when the ride is finished + ); + }); + update(); + } + + // Stop listening after ride finishes if (!isRideBegin) { locationSubscription?.cancel(); } } catch (error) { debugPrint('Error listening to GPS: $error'); - // Handle GPS errors gracefully, e.g., show a user-friendly message + // Handle GPS errors gracefully } - update(); - print('...................'); - print(d); - print('...................'); + // Periodically call updateLocation again + await Future.delayed(const Duration(seconds: 2)); + updateLocation(); } calculateDistanseBetweenDriverAndPassengerLocation() { @@ -527,6 +571,7 @@ class MapDriverController extends GetxController { int seconds = remainingTimeTimerRideBegin % 60; stringRemainingTimeRideBegin = '$minutes:${seconds.toString().padLeft(2, '0')}'; + update(); } } diff --git a/lib/controller/home/map_passenger_controller.dart b/lib/controller/home/map_passenger_controller.dart index 3d176c4..59ce480 100644 --- a/lib/controller/home/map_passenger_controller.dart +++ b/lib/controller/home/map_passenger_controller.dart @@ -130,6 +130,7 @@ class MapPassengerController extends GetxController { double heightBottomSheetShown = 0; double cashConfirmPageShown = 250; late String driverId; + late String gender; double widthMapTypeAndTraffic = 50; double paymentPageShown = Get.height * .6; late LatLng southwest; @@ -910,6 +911,8 @@ class MapPassengerController extends GetxController { // if (dataCarsLocationByPassenger.length > carsOrder) { driverId = dataCarsLocationByPassenger['message'][carsOrder]['driver_id'] .toString(); + gender = dataCarsLocationByPassenger['message'][carsOrder]['gender'] + .toString(); // } // //print('driverId==============$driverId'); @@ -1368,7 +1371,7 @@ class MapPassengerController extends GetxController { (_locationData.latitude != null && _locationData.longitude != null ? LatLng(_locationData.latitude!, _locationData.longitude!) : null)!; - + newStartPointLocation = passengerLocation; // //print location details // //print('Accuracy: ${_locationData.accuracy}'); // //print('Latitude: ${_locationData.latitude}'); @@ -1576,7 +1579,9 @@ class MapPassengerController extends GetxController { double latPassengerDestination = double.parse(coordDestination[0]); double lngPassengerDestination = double.parse(coordDestination[1]); myDestination = LatLng(latPassengerDestination, lngPassengerDestination); - + // if (origin.isEmpty) { + // origin = passengerLocation.toString(); //todo + // } isLoading = false; update(); var url = @@ -1610,7 +1615,7 @@ class MapPassengerController extends GetxController { LatLngBounds(northeast: northeast, southwest: southwest); // Fit the camera to the bounds - var cameraUpdate = CameraUpdate.newLatLngBounds(boundsData, 130); + var cameraUpdate = CameraUpdate.newLatLngBounds(boundsData, 160); mapController!.animateCamera(cameraUpdate); // getDistanceFromText(data[0]['distance']['text']); diff --git a/lib/controller/local/local_controller.dart b/lib/controller/local/local_controller.dart index 6306355..66b3908 100644 --- a/lib/controller/local/local_controller.dart +++ b/lib/controller/local/local_controller.dart @@ -20,18 +20,21 @@ class LocaleController extends GetxController { case "ar": locale = const Locale("ar"); appTheme = themeArabic; + box.write(BoxName.lang, 'ar'); break; case "en": locale = const Locale("en"); appTheme = themeEnglish; + box.write(BoxName.lang, 'en'); break; case "tr": locale = const Locale("tr"); appTheme = themeEnglish; + box.write(BoxName.lang, 'tr'); break; default: locale = Locale(Get.deviceLocale!.languageCode); - + box.write(BoxName.lang, 'en'); appTheme = themeEnglish; break; } diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index 8e21a62..9a4187a 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -202,16 +202,16 @@ class MyTranslation extends Translations { "you will pay to Driver": "ستدفع للسائق", "Driver Cancel Your Trip": "السائق ألغى رحلتك", "you will pay to Driver you will be pay the cost of driver time look to your SEFER Wallet": - "ستدفع للسائق تكلفة وقته تفقد محفظتك في سيفر", + "ستدفع للسائق تكلفة وقته تفقد محفظتك في سفر", "I will go now": "سأذهب الآن", "You Have Tips": "لديك زيادة مال", " tips\nTotal is": "زيادة مال\nالمجموع هو", "No,I want": "لا، أريد", "Your fee is ": "أجرك هو", "Do you want to pay Tips for this Driver": - "هل تريد دفع زيادة مال لهذا السائق؟", - "Tip is ": "زيادة المال هي", - "Tip is": "زيادة المال هي", + "هل تريد دفع أكراميه لهذا السائق؟", + "Tip is ": " مبلغ الاكراميه هو", + "Tip is": " مبلغ الاكراميه هو", "Camera Access Denied.": "تم رفض الوصول إلى الكاميرا.", "Open Settings": "افتح الإعدادات", "GPS Required Allow !.": "تمكن الـ GPS مطلوب!", @@ -263,8 +263,8 @@ class MyTranslation extends Translations { "Feedback data saved successfully": "تم حفظ بيانات التعليقات بنجاح", "No Promo for today .": "لا يوجد عرض ترويجي اليوم.", "Select your destination": "اختر وجهتك", - "Search for your Start point": "بحث عن نقطة بدايتك", - "Search for waypoint": "بحث عن نقطة الوجهة", + "Search for your Start point": "بحث عن نقطة الانطلاق", + "Search for waypoint": "بحث عن النقطة الة", "Current Location": "الموقع الحالي", "Add Location 1": "إضافة الموقع 1", 'You must Verify email !.': "يجب التحقق من البريد الإلكتروني!", @@ -273,6 +273,9 @@ class MyTranslation extends Translations { 'Select Date': "اختر التاريخ", 'Birth Date': "تاريخ الميلاد", 'Ok': "موافق", + 'the 500 points equal 30 JOD': "النقاط الـ 500 تساوي 30 دينار أردني", + 'the 500 points equal 30 JOD for you \nSo go and gain your money': + "النقاط الـ 500 تساوي 30 دينار أردني\nفاستحق فلوسك واكسب النقاط", 'token updated': "تم تحديث الرمز", 'Add Location 2': "إضافة الموقع 2", 'Add Location 3': "إضافة الموقع 3", @@ -286,13 +289,14 @@ class MyTranslation extends Translations { 'is driving a ': "يقود", ' with license plate ': "بلوحة ترخيص", ' I am currently located at ': "أنا حاليا في", + 'Please go to Car now ': 'الرجاء التحرك الى السياره الان', ' If you need to reach me, please contact the driver directly at': "إذا كنت تحتاج إلى التواصل معي، يرجى التواصل مع السائق مباشرة على", 'No Car or Driver Found in your area.': "لم يتم العثور على سيارة أو سائق في منطقتك.", 'Please Try anther time ': "الرجاء إعادة المحاولة", 'There no Driver Aplly your order sorry for that ': - "لا يوجد سائق قدم طلبك، نعتذر عن ذلك", + "لا يوجد سائق قبل طلبك، نعتذر عن ذلك", 'Trip Cancelled': "تم إلغاء الرحلة", 'The Driver Will be in your location soon .': "سيكون السائق قريبا في موقعك.", @@ -336,7 +340,7 @@ class MyTranslation extends Translations { 'Date of Birth': "تاريخ الميلاد", 'Age': "العمر", 'Expiry Date': "تاريخ الإنتهاء", - 'Lets check Car license ': "دعونا نتحقق من رخصة السيارة ", + 'Lets check Car license ': "دعنا نتحقق من رخصة السيارة ", 'Color': "اللون", 'Car Kind': "نوع السيارة", 'Year': "السنة", @@ -345,9 +349,10 @@ class MyTranslation extends Translations { 'Car License Card': "بطاقة رخصة السيارة", 'No image selected yet': "لم يتم إختيار أي صورة بعد", 'Made :': "الصناعة:", - 'model :': "النموذج:", + 'model :': "النوع:", 'VIN :': "رقم الشاصي:", 'year :': "السنة:", + 'ُExpire Date': 'تاريخ الانتهاء', 'Login Driver': "تسجيل دخول السائق", 'Password must br at least 6 character.': "كلمة المرور يجب أن تكون على الأقل 6 أحرف.", @@ -366,13 +371,16 @@ class MyTranslation extends Translations { 'Your name': "إسمك", 'Your password': "كلمة المرور الخاصة بك", 'title': "العنوان", - 'If You Want be Driver Click Here.': - "إذا كنت تريد أن تكون سائقًا انقر هنا.", + "To ensure you receive the most accurate information for your location, please select your country below. This will help tailor the app experience and content to your country.": + "لكي يتم تقديم أفضل خدمة ومحتوى متخصص لك، نطلب منك تحديد بلدك حتى نتمكن من تخصيص التطبيق بناءًا على مكان سكنك. سوف تساعدنا هذه الخطوة في ضمان حصولك على أحدث المعلومات والتحديثات المتعلقة بدولتك.", + 'If You Want be Driver \nClick Here.': + "إذا كنت تريد أن تكون سائقًا \nانقر هنا.", 'Enter your City': "أدخل مدينتك", - 'History Page': "صفحة التاريخ", + "Select Your Country": "تحديد دولتك", + 'History Page': "ارشيف الرحلات", 'This Trip Cancelled': "تم إلغاء هذه الرحلة", 'Trip Detail': "تفاصيل الرحلة", - 'Trip on Map Click here': "ضغط هنا لعرض الرحلة على الخريطة", + 'Trip on Map Click here': "اضغط هنا لعرض الرحلة على الخريطة", 'Order ID': "رقم الطلب", 'Price is': "السعر هو", 'Distance is': "المسافة هي", @@ -430,7 +438,7 @@ class MyTranslation extends Translations { 'Distance from Passenger to destination is ': "المسافة من الراكب إلى الوجهة هي ", 'Cost Of Trip IS ': "تكلفة الرحلة هي ", - 'Accept Order': "قبول الطلب", + 'Accept Order': "تم قبول الطلب", 'rejct your order.': "رفض طلبك.", 'Bottom Bar Example': "مثال لشريط الأسفل", 'Statistics': "الإحصائيات", @@ -534,29 +542,28 @@ class MyTranslation extends Translations { 'Car Details': "تفاصيل السيارة", 'VIN is': "رقم الشاصي هو", 'Color is ': "اللون هو ", - 'Make is ': "الصانع هو", - 'Model is': "النموذج هو", + 'Make is ': "الشركه الصانعه", + 'Model is': "النوع هو", 'Year is': "السنة هي", - 'Expiration Date ': "تاريخ انتهاء الصلاحية ", + 'Expiration Date ': "تاريخ الانتهاء ", 'Edit Your data': "تعديل بياناتك", 'write vin for your car': "اكتب رقم الشاصي لسيارتك", 'VIN': "رقم الشاصي", 'write Color for your car': "اكتب لون سيارتك", 'write Make for your car': "اكتب صانع سيارتك", - 'Make': "الصانع", - 'write Model for your car': "اكتب نموذج سيارتك", - 'Model': "النموذج", - 'write Year for your car': "اكتب سنة سيارتك", - 'Expiration Date': "تاريخ انتهاء الصلاحية", - 'write Expiration Date for your car': - "اكتب تاريخ انتهاء صلاحية سيارتك", + 'Make': "الشركه الصانعه", + 'write Model for your car': "اكتب نوع سيارتك", + 'Model': "النوع", + 'write Year for your car': "اكتب سنة الصنع", + 'Expiration Date': "تاريخ الانتهاء ", + 'write Expiration Date for your car': "اكتب تاريخ انتهاء رخصه سيارتك", 'Tariffs': "التعرفه", 'Minimum fare': "الحد الأدنى للأجرة", 'Maximum fare': "الحد الأقصى للأجرة", 'JOD': "د.أ", 'Flag-down fee': "رسوم التشغيل", 'Including Tax': "بما في ذلك الضرائب", - 'BookingFee': "رسوم الحجز", + 'BookingFee': "رسوم الطلب", 'Morning': "الصباح", 'from 07:30 till 10:30 (Thursday, Friday, Saturday, Monday)': "من 07:30 إلى 10:30 (يوم الخميس، الجمعة، السبت، الإثنين)", @@ -565,7 +572,8 @@ class MyTranslation extends Translations { "من 12:00 إلى 15:00 (يوم الخميس، الجمعة، السبت، الإثنين)", 'Night': "الليل", 'You have in account': 'يوجد في حسابك ', - 'Ride Today :': 'عدد الرحلات : ', + 'Select Country': 'اختر الدوله', + 'Ride Today : ': 'عدد الرحلات : ', 'After this period\nYou can\'t cancel!': 'بعد هذه الفتره \nلا تستطيع الغاء الرحله', 'from 23:59 till 05:30': "من 23:59 إلى 05:30", @@ -583,6 +591,9 @@ class MyTranslation extends Translations { 'OrderId': 'رقم الرحله', 'created time': "وقت الرحله", 'Map Passenger': 'خارطه الراكب', + "If you want to make Google Map App run directly when you apply order": + "إذا كنت تريد أن تفتح تطبيق خرائط جوجل مباشرة عند طلب الخدمة", + "You can change the language of the app": "يمكنك تغيير لغة التطبيق", 'Your Budget less than needed': 'القيمه المدخله اقل من رصيدك', }, "tr": { diff --git a/lib/controller/payment/driver_payment_controller.dart b/lib/controller/payment/driver_payment_controller.dart index 6e4879a..dad1bc1 100644 --- a/lib/controller/payment/driver_payment_controller.dart +++ b/lib/controller/payment/driver_payment_controller.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:SEFER/views/widgets/elevated_btn.dart'; import 'package:get/get.dart'; import 'package:SEFER/constant/box_name.dart'; import 'package:SEFER/constant/links.dart'; @@ -16,7 +17,19 @@ class DriverWalletHistoryController extends GetxController { var res = await CRUD().get( link: AppLink.getWalletByDriver, payload: {'driverID': box.read(BoxName.driverID)}); - + if (res == 'failure') { + Get.defaultDialog( + barrierDismissible: false, + title: 'There is no data yet.'.tr, + middleText: '', + confirm: MyElevatedButton( + title: 'Back'.tr, + onPressed: () { + Get.back(); + Get.back(); + }, + )); + } archive = jsonDecode(res)['message']; print(archive); isLoading = false; diff --git a/lib/controller/profile/captain_profile_controller.dart b/lib/controller/profile/captain_profile_controller.dart index 04824bb..6c8f5d6 100644 --- a/lib/controller/profile/captain_profile_controller.dart +++ b/lib/controller/profile/captain_profile_controller.dart @@ -17,15 +17,36 @@ class CaptainProfileController extends GetxController { TextEditingController expirationDate = TextEditingController(); Future updateFields() async { - var res = await CRUD().post(link: AppLink.updateRegisrationCar, payload: { + var payload = { 'driverID': box.read(BoxName.driverID), - 'vin': vin.text, - 'color': color.text, - 'model': model.text, - 'make': make.text, - 'year': year.text, - 'expirationDate': expirationDate.text, - }); + }; + + if (vin.text.isNotEmpty) { + payload['vin'] = vin.text; + } + + if (color.text.isNotEmpty) { + payload['color'] = color.text; + } + + if (model.text.isNotEmpty) { + payload['model'] = model.text; + } + + if (make.text.isNotEmpty) { + payload['make'] = make.text; + } + + if (year.text.isNotEmpty) { + payload['year'] = year.text; + } + + if (expirationDate.text.isNotEmpty) { + payload['expiration_date'] = expirationDate.text; + } + + var res = + await CRUD().post(link: AppLink.updateRegisrationCar, payload: payload); if (jsonDecode(res)['status'] == 'success') { box.write(BoxName.vin, vin.text); @@ -34,7 +55,7 @@ class CaptainProfileController extends GetxController { box.write(BoxName.make, make.text); box.write(BoxName.year, year.text); box.write(BoxName.expirationDate, expirationDate.text); - + update(); Get.back(); } } @@ -56,7 +77,7 @@ class CaptainProfileController extends GetxController { @override void onInit() { - if (box.read(BoxName.dobDriver).toString().isEmpty) { + if (box.read(BoxName.dobDriver) == null) { getProfileData(); } diff --git a/lib/controller/profile/setting_controller.dart b/lib/controller/profile/setting_controller.dart new file mode 100644 index 0000000..e42b784 --- /dev/null +++ b/lib/controller/profile/setting_controller.dart @@ -0,0 +1,26 @@ +import 'package:SEFER/constant/box_name.dart'; +import 'package:SEFER/main.dart'; +import 'package:get/get.dart'; + +class SettingController extends GetxController { + bool isGoogleMapsEnabled = false; + + void onChangMapApp() { + if (!isGoogleMapsEnabled) { + isGoogleMapsEnabled = true; + box.write(BoxName.googlaMapApp, true); + update(); + } else { + isGoogleMapsEnabled = false; + box.write(BoxName.googlaMapApp, false); + update(); + } + } + + @override + void onInit() { + isGoogleMapsEnabled = box.read(BoxName.googlaMapApp); + update(); + super.onInit(); + } +} diff --git a/lib/main.dart b/lib/main.dart index 70155e3..ef15bab 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,5 @@ import 'dart:io'; -import 'package:SEFER/constant/box_name.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/material.dart'; diff --git a/lib/views/admin/admin_home_page.dart b/lib/views/admin/admin_home_page.dart index 6376e71..9349afd 100644 --- a/lib/views/admin/admin_home_page.dart +++ b/lib/views/admin/admin_home_page.dart @@ -51,12 +51,12 @@ class AdminHomePage extends StatelessWidget { title: 'Static', onPressed: () => Get.to(() => StaticDash())), AdminWidgetsDashBoard( - title: 'Gemeni', - onPressed: () => ContentController().generateContent()), + title: 'Gemeni', onPressed: () => AI().generateContent()), AdminWidgetsDashBoard( - title: 'GemeniCarRegistration', - onPressed: () => - ContentController().getFromCarRegistration()), + title: 'CarLicenseJordan', + onPressed: () => AI().carLicenseJordan()), + AdminWidgetsDashBoard( + title: 'JordanID', onPressed: () => AI().jordanID()), AdminWidgetsDashBoard( title: 'Llama', onPressed: () => diff --git a/lib/views/auth/captin/ai_page.dart b/lib/views/auth/captin/ai_page.dart index 1e21fca..32410be 100644 --- a/lib/views/auth/captin/ai_page.dart +++ b/lib/views/auth/captin/ai_page.dart @@ -1,3 +1,4 @@ +import 'package:SEFER/constant/box_name.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:SEFER/constant/colors.dart'; @@ -16,13 +17,13 @@ class AiPage extends StatelessWidget { ScanDocumentsByApi scanDocumentsByApi = Get.put(ScanDocumentsByApi()); RegisterCaptainController registerCaptainController = Get.put(RegisterCaptainController()); - ContentController contentController = Get.put(ContentController()); + AI contentController = Get.put(AI()); @override Widget build(BuildContext context) { return MyScafolld( title: 'AI Page'.tr, body: [ - Get.deviceLocale!.countryCode != 'US' + box.read(BoxName.countryCode) == 'USA' ? Positioned( top: 3, left: Get.width * .2, @@ -33,611 +34,931 @@ class AiPage extends StatelessWidget { scanDocumentsByApi.scanDocumentsByApi(); }, )) - : Positioned( - top: 3, - left: Get.width * .1, - right: Get.width * .1, - child: MyElevatedButton( - title: 'Take Picture Of Driver License Card'.tr, - onPressed: () { - contentController.generateDriverLicenseJordanContent(); - }, - )), - Get.deviceLocale!.countryCode != 'US' - ? GetBuilder( - builder: (scanDocumentsByApi) => scanDocumentsByApi - .responseMap.isNotEmpty - ? Positioned( - top: Get.height * .06, - left: Get.width * .051, - right: Get.width * .051, - child: scanDocumentsByApi.isLoading - ? Column( - children: [ - const MyCircularProgressIndicator(), - Text( - 'We are process picture please wait '.tr, - style: AppStyle.title, - ) - ], - ) - : Column( - children: [ - Container( - decoration: AppStyle.boxDecoration, - height: Get.height * .4, - child: Padding( - padding: const EdgeInsets.all(5), - child: scanDocumentsByApi - .responseMap.isEmpty - ? Center( - child: Text( - 'There is no data yet.'.tr, - style: AppStyle.title, - ), - ) - : Column( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment - .start, - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Text( - '${'Name :'.tr}${scanDocumentsByApi.name}', - style: AppStyle - .subtitle, - ), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Text( - '${'Drivers License Class: '.tr}${scanDocumentsByApi.licenseClass}', - style: AppStyle - .title, - ), - Image.memory( - scanDocumentsByApi - .imageSignature, - width: 100, - height: 30, - ), - ], - ), - ], - ), - ], - ), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Text( - '${'Document Number: '.tr}${scanDocumentsByApi.documentNo}', - style: AppStyle.title, - ), - Image.memory( - scanDocumentsByApi - .imagePortrait, - width: 60, - ), - ]), - Text( - '${'Address: '.tr}${scanDocumentsByApi.address}', - style: AppStyle.title, - ), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Text( - '${'Height: '.tr}${scanDocumentsByApi.height}', - style: - AppStyle.subtitle, - ), - Text( - 'Postal Code: ${scanDocumentsByApi.postalCode}', - style: - AppStyle.subtitle, - ), - Text( - 'Sex: ${scanDocumentsByApi.sex}', - style: - AppStyle.subtitle, - ), - ], - ), - Text( - 'Territorial Code: ${scanDocumentsByApi.stateCode}', - style: AppStyle.subtitle, - ), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Text( - '${'Expiry Date: '.tr}${scanDocumentsByApi.expireDate}', - style: DateTime.parse(scanDocumentsByApi - .responseMap['data'] - ['ocr'][ - 'dateOfExpiry'] - .toString()) - .isBefore( - scanDocumentsByApi - .now) - ? AppStyle.title - .copyWith( - color: AppColor - .redColor) - : AppStyle.title.copyWith( - color: AppColor - .greenColor), - ), - Text( - '${'Date of Birth: '.tr}${scanDocumentsByApi.dob}', - style: AppStyle.title, - ), - ], - ), - ], - ), - ), - ), - DateTime.parse(scanDocumentsByApi - .responseMap['data']['ocr'] - ['dateOfExpiry'] - .toString()) - .isBefore(scanDocumentsByApi.now) - ? Text( - 'You can\'t continue with us .\nYou should renew Driver license', - style: AppStyle.title.copyWith( - color: AppColor.redColor), - ) - : MyElevatedButton( - title: 'Detect Your Face '.tr, - onPressed: () => scanDocumentsByApi - .checkMatchFaceApi(), - ), - scanDocumentsByApi.res.isEmpty - ? const SizedBox() - : scanDocumentsByApi.res['data'] - ['result'] - .toString() == - 'Same' - ? MyElevatedButton( - onPressed: () async { - await registerCaptainController - .register(); - await registerCaptainController - .addLisence(); - // await scanDocumentsByApi - // .uploadImagePortrate(); - }, - title: - 'Go to next step\nscan Car License.' - .tr, - kolor: AppColor.greenColor, - ) - : const SizedBox(), - MyElevatedButton( - title: 'get sql data', - kolor: AppColor.yellowColor, - onPressed: () { - sql.deleteAllData( - TableName.faceDetectTimes); - sql - .getAllData( - TableName.faceDetectTimes) - .then((value) => print( - value[0]['faceDetectTimes'])); - }, - ) - ], - ), - ) - : Positioned( - top: Get.height * .06, - left: Get.width * .051, - right: Get.width * .051, - child: scanDocumentsByApi.isLoading - ? Column( - children: [ - const MyCircularProgressIndicator(), - Text( - 'We are process picture please wait '.tr, - style: AppStyle.title, - ) - ], - ) - : Column( - children: [ - Container( - decoration: AppStyle.boxDecoration, - height: Get.height * .35, - child: Padding( - padding: const EdgeInsets.all(5), - child: Center( - child: Text( - 'There is no data yet.'.tr, - style: AppStyle.title, - ), - )), - ), - ], - ), - ), - ) - : GetBuilder( - builder: (contentController) => contentController - .responseMap.isNotEmpty - ? Positioned( - top: Get.height * .09, - left: Get.width * .051, - right: Get.width * .051, - child: contentController.isloading - ? Column( - children: [ - const MyCircularProgressIndicator(), - Text( - 'We are process picture please wait '.tr, - style: AppStyle.title, - ) - ], - ) - : SizedBox( - height: Get.height * .7, - child: ListView( - children: [ - Container( - decoration: AppStyle.boxDecoration, - // height: Get.height * .4, - child: Padding( - padding: const EdgeInsets.all(5), - child: contentController - .responseMap.isEmpty - ? Center( - child: Text( - 'There is no data yet.'.tr, - style: AppStyle.title, - ), - ) - : Column( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment - .start, - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Row( - children: [ - Text( - '${'Name'.tr} :${contentController.responseMap['first_name']}', - style: AppStyle - .subtitle, - ), - Text( - ' ${contentController.responseMap['last_name']}', - style: AppStyle - .subtitle, - ), - ], - ), - Text( - '${'Name in arabic'.tr}: ${contentController.responseMap['name_in_arabic']}', - style: AppStyle - .title, - ), - Text( - '${'Drivers License Class'.tr}: ${contentController.responseMap['class']}', - style: AppStyle - .title, - ), - ], - ), - ], - ), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Text( - '${'National Number'.tr}: ${contentController.responseMap['id']}', - style: - AppStyle.title, - ), - // Image.memory( - // scanDocumentsByApi - // .imagePortrait, - // width: 60, - // ), - ]), - Text( - '${'Address'.tr}: ${contentController.responseMap['address']}', - style: AppStyle.title, - ), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Text( - '${'Date of Birth'.tr}: ${contentController.responseMap['dob']}', - style: AppStyle.title, - ), - Text( - '${'Age'.tr} : ${contentController.responseMap['age_in_years']}', - style: AppStyle.title, - ), - ], - ), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Text( - '${'Expiry Date'.tr}: ${contentController.responseMap['expiration_date']}', - style: DateTime.parse(contentController - .responseMap[ - 'expiration_date'] - .toString()) - .isBefore( - contentController - .now) - ? AppStyle.title.copyWith( - color: AppColor - .redColor) - : AppStyle.title.copyWith( - color: AppColor - .greenColor), - ), - ], - ), - ], - ), - ), - ), - const SizedBox( - height: 10, - ), - DateTime.parse(contentController - .responseMap[ - 'expiration_date'] - .toString()) - .isBefore(contentController.now) - ? Text( - 'You can\'t continue with us .\nYou should renew Driver license' - .tr, - style: AppStyle.title.copyWith( - color: AppColor.redColor), - ) - : MyElevatedButton( - kolor: AppColor.greenColor, - title: - 'Lets check Car license '.tr, - onPressed: () => contentController - .generateCarLicenseJordanContent()), - const SizedBox( - height: 10, - ), - contentController - .responseCarLicenseMap.isNotEmpty - ? Container( - decoration: - AppStyle.boxDecoration, - // height: Get.height * .3, - width: Get.width * .9, - child: Column( - children: [ - Text( - '${'Name'.tr} ${contentController.responseCarLicenseMap['name']}', - style: AppStyle.title, - ), - Text( - '${'Address'.tr} ${contentController.responseCarLicenseMap['address']}', - style: AppStyle.title, - ), - Text( - '${'Car Kind'.tr} ${contentController.responseCarLicenseMap['car_kind']}', - style: AppStyle.title, - ), - Text( - '${'Color'.tr} ${contentController.responseCarLicenseMap['car_color']}', - style: AppStyle.title, - ), - Text( - '${'Year'.tr} ${contentController.responseCarLicenseMap['car_year']}', - style: AppStyle.title, - ), - Text( - '${'Car Plate'.tr} ${contentController.responseCarLicenseMap['car_plate']}', - style: AppStyle.title, - ), - Text( - '${'Car Expire'.tr} ${contentController.responseCarLicenseMap['expire_date_of_license']}', - style: contentController - .responseCarLicenseMap - .isNotEmpty - ? DateTime.parse(contentController - .responseCarLicenseMap[ - 'expire_date_of_license'] - .toString()) - .isBefore(contentController - .now) - ? AppStyle.title.copyWith( - color: AppColor - .redColor) - : AppStyle.title.copyWith( - color: AppColor - .greenColor) - : null, - ), - ], - ), - ) - : const SizedBox(), - const SizedBox( - height: 10, - ), - // DateTime.parse(contentController - // .responseCarLicenseMap[ - // 'expire_date_of_license'] - // .toString()) - // .isBefore(contentController.now) - // ? Text( - // 'You can\'t continue with us .\nYou should renew Car license' - // .tr, - // style: AppStyle.title.copyWith( - // color: AppColor.redColor), - // ) - // : - MyElevatedButton( - kolor: AppColor.greenColor, - title: - 'Lets check License Back Face'.tr, - onPressed: () => contentController - .generateBackCarLicenseJordanContent()), - const SizedBox( - height: 10, - ), - contentController - .responseBackCarLicenseMap - .isNotEmpty - ? Container( - decoration: - AppStyle.boxDecoration, - // height: 300, - child: Column(children: [ - Text( - 'VIN ${contentController.responseBackCarLicenseMap['vin']}', - style: AppStyle.title, - ), - Text( - 'Fuel Type ${contentController.responseBackCarLicenseMap['fuelType']}', - style: AppStyle.title, - ), - Text( - 'Insurance Company ${contentController.responseBackCarLicenseMap['insuranceCompany']}', - style: AppStyle.title, - ), - Text( - 'Policy Number ${contentController.responseBackCarLicenseMap['policyNumber']}', - style: AppStyle.title, - ), - Text( - 'Insurance Type ${contentController.responseBackCarLicenseMap['insuranceType']}', - style: AppStyle.title, - ) - ])) - : const SizedBox() - // MyElevatedButton( - // title: 'Detect Your Face '.tr, - // onPressed: () => scanDocumentsByApi - // .checkMatchFaceApi(), - // ), - // scanDocumentsByApi.res.isEmpty - // ? const SizedBox() - // : scanDocumentsByApi.res['data'] - // ['result'] - // .toString() == - // 'Same' - // ? MyElevatedButton( - // onPressed: () async { - // await registerCaptainController - // .register(); - // await registerCaptainController - // .addLisence(); - // // await scanDocumentsByApi - // // .uploadImagePortrate(); - // }, - // title: - // 'Go to next step\nscan Car License.' - // .tr, - // kolor: AppColor.greenColor, - // ) - // : const SizedBox(), - // MyElevatedButton( - // title: 'get sql data', - // kolor: AppColor.yellowColor, - // onPressed: () { - // sql.deleteAllData( - // TableName.faceDetectTimes); - // sql - // .getAllData( - // TableName.faceDetectTimes) - // .then((value) => print( - // value[0]['faceDetectTimes'])); - // }, - // ), - ], - ), - ), - ) - : Positioned( - top: Get.height * .06, - left: Get.width * .051, - right: Get.width * .051, - child: scanDocumentsByApi.isLoading - ? Column( - children: [ - const MyCircularProgressIndicator(), - Text( - 'We are process picture please wait '.tr, - style: AppStyle.title, - ) - ], - ) - : Column( - children: [ - Container( - decoration: AppStyle.boxDecoration, - height: Get.height * .35, - child: Padding( - padding: const EdgeInsets.all(5), - child: Center( - child: Text( - 'There is no data yet.'.tr, - style: AppStyle.title, - ), - )), - ), - ], - ), - ), - ) + : box.read(BoxName.countryCode) == 'Jordan' + ? Positioned( + top: 3, + left: Get.width * .1, + right: Get.width * .1, + child: MyElevatedButton( + title: 'Take Picture Of Driver License Card'.tr, + onPressed: () { + contentController.getDriverLicenseJordanContent(); + }, + )) + : Positioned( + top: 3, + left: Get.width * .1, + right: Get.width * .1, + child: MyElevatedButton( + title: 'Take Picture Of Driver License Card'.tr, //egypt + onPressed: () { + contentController + .getDriverLicenseJordanContent(); //egypt + }, + )), + box.read(BoxName.countryCode) == 'USA' + ? usaDriverLicensWidget() + : box.read(BoxName.countryCode) == 'Jordan' + ? jordanDriverLicenseWidget() + : egyptDriverLicenseWidget() ], isleading: true); } + + GetBuilder egyptDriverLicenseWidget() { + return GetBuilder( + builder: (contentController) => contentController.responseMap.isNotEmpty + ? Positioned( + top: Get.height * .09, + left: Get.width * .051, + right: Get.width * .051, + child: contentController.isloading + ? Column( + children: [ + const MyCircularProgressIndicator(), + Text( + 'We are process picture please wait '.tr, + style: AppStyle.title, + ) + ], + ) + : SizedBox( + height: Get.height * .7, + child: ListView( + children: [ + Container( + decoration: AppStyle.boxDecoration, + // height: Get.height * .4, + child: Padding( + padding: const EdgeInsets.all(5), + child: contentController.responseMap.isEmpty + ? Center( + child: Text( + 'There is no data yet.'.tr, + style: AppStyle.title, + ), + ) + : Column( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + '${'Name'.tr} :${contentController.responseMap['first_name']}', + style: AppStyle.subtitle, + ), + Text( + ' ${contentController.responseMap['last_name']}', + style: AppStyle.subtitle, + ), + ], + ), + Text( + '${'Name in arabic'.tr}: ${contentController.responseMap['name_in_arabic']}', + style: AppStyle.title, + ), + Text( + '${'Drivers License Class'.tr}: ${contentController.responseMap['class']}', + style: AppStyle.title, + ), + ], + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'National Number'.tr}: ${contentController.responseMap['id']}', + style: AppStyle.title, + ), + // Image.memory( + // scanDocumentsByApi + // .imagePortrait, + // width: 60, + // ), + ]), + Text( + '${'Address'.tr}: ${contentController.responseMap['address']}', + style: AppStyle.title, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'Date of Birth'.tr}: ${contentController.responseMap['dob']}', + style: AppStyle.title, + ), + Text( + '${'Age'.tr} : ${contentController.responseMap['age_in_years']}', + style: AppStyle.title, + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'Expiry Date'.tr}: ${contentController.responseMap['expiration_date']}', + style: DateTime.parse( + contentController + .responseMap[ + 'expiration_date'] + .toString()) + .isBefore( + contentController.now) + ? AppStyle.title.copyWith( + color: AppColor.redColor) + : AppStyle.title.copyWith( + color: + AppColor.greenColor), + ), + ], + ), + ], + ), + ), + ), + const SizedBox( + height: 10, + ), + DateTime.parse(contentController + .responseMap['expiration_date'] + .toString()) + .isBefore(contentController.now) + ? Text( + 'You can\'t continue with us .\nYou should renew Driver license' + .tr, + style: AppStyle.title + .copyWith(color: AppColor.redColor), + ) + : MyElevatedButton( + kolor: AppColor.greenColor, + title: 'Lets check Car license '.tr, + onPressed: () => contentController + .getCarLicenseJordanContent()), + const SizedBox( + height: 10, + ), + contentController.responseCarLicenseMap.isNotEmpty + ? Container( + decoration: AppStyle.boxDecoration, + // height: Get.height * .3, + width: Get.width * .9, + child: Column( + children: [ + Text( + '${'Name'.tr} ${contentController.responseCarLicenseMap['name']}', + style: AppStyle.title, + ), + Text( + '${'Address'.tr} ${contentController.responseCarLicenseMap['address']}', + style: AppStyle.title, + ), + Text( + '${'Car Kind'.tr} ${contentController.responseCarLicenseMap['car_kind']}', + style: AppStyle.title, + ), + Text( + '${'Color'.tr} ${contentController.responseCarLicenseMap['car_color']}', + style: AppStyle.title, + ), + Text( + '${'Year'.tr} ${contentController.responseCarLicenseMap['car_year']}', + style: AppStyle.title, + ), + Text( + '${'Car Plate'.tr} ${contentController.responseCarLicenseMap['car_plate']}', + style: AppStyle.title, + ), + Text( + '${'Car Expire'.tr} ${contentController.responseCarLicenseMap['expire_date_of_license']}', + style: contentController + .responseCarLicenseMap + .isNotEmpty + ? DateTime.parse(contentController + .responseCarLicenseMap[ + 'expire_date_of_license'] + .toString()) + .isBefore( + contentController.now) + ? AppStyle.title.copyWith( + color: AppColor.redColor) + : AppStyle.title.copyWith( + color: AppColor.greenColor) + : null, + ), + ], + ), + ) + : const SizedBox(), + const SizedBox( + height: 10, + ), + // DateTime.parse(contentController + // .responseCarLicenseMap[ + // 'expire_date_of_license'] + // .toString()) + // .isBefore(contentController.now) + // ? Text( + // 'You can\'t continue with us .\nYou should renew Car license' + // .tr, + // style: AppStyle.title.copyWith( + // color: AppColor.redColor), + // ) + // : + MyElevatedButton( + kolor: AppColor.greenColor, + title: 'Lets check License Back Face'.tr, + onPressed: () => contentController + .generateBackCarLicenseJordanContent()), + const SizedBox( + height: 10, + ), + contentController.responseBackCarLicenseMap.isNotEmpty + ? Container( + decoration: AppStyle.boxDecoration, + // height: 300, + child: Column(children: [ + Text( + 'VIN ${contentController.responseBackCarLicenseMap['vin']}', + style: AppStyle.title, + ), + Text( + 'Fuel Type ${contentController.responseBackCarLicenseMap['fuelType']}', + style: AppStyle.title, + ), + Text( + 'Insurance Company ${contentController.responseBackCarLicenseMap['insuranceCompany']}', + style: AppStyle.title, + ), + Text( + 'Policy Number ${contentController.responseBackCarLicenseMap['policyNumber']}', + style: AppStyle.title, + ), + Text( + 'Insurance Type ${contentController.responseBackCarLicenseMap['insuranceType']}', + style: AppStyle.title, + ) + ])) + : const SizedBox() + // MyElevatedButton( + // title: 'Detect Your Face '.tr, + // onPressed: () => scanDocumentsByApi + // .checkMatchFaceApi(), + // ), + // scanDocumentsByApi.res.isEmpty + // ? const SizedBox() + // : scanDocumentsByApi.res['data'] + // ['result'] + // .toString() == + // 'Same' + // ? MyElevatedButton( + // onPressed: () async { + // await registerCaptainController + // .register(); + // await registerCaptainController + // .addLisence(); + // // await scanDocumentsByApi + // // .uploadImagePortrate(); + // }, + // title: + // 'Go to next step\nscan Car License.' + // .tr, + // kolor: AppColor.greenColor, + // ) + // : const SizedBox(), + // MyElevatedButton( + // title: 'get sql data', + // kolor: AppColor.yellowColor, + // onPressed: () { + // sql.deleteAllData( + // TableName.faceDetectTimes); + // sql + // .getAllData( + // TableName.faceDetectTimes) + // .then((value) => print( + // value[0]['faceDetectTimes'])); + // }, + // ), + ], + ), + ), + ) + : Positioned( + top: Get.height * .06, + left: Get.width * .051, + right: Get.width * .051, + child: scanDocumentsByApi.isLoading + ? Column( + children: [ + const MyCircularProgressIndicator(), + Text( + 'We are process picture please wait '.tr, + style: AppStyle.title, + ) + ], + ) + : Column( + children: [ + Container( + decoration: AppStyle.boxDecoration, + height: Get.height * .35, + child: Padding( + padding: const EdgeInsets.all(5), + child: Center( + child: Text( + 'There is no data yet.'.tr, + style: AppStyle.title, + ), + )), + ), + ], + ), + ), + ); + } + + GetBuilder jordanDriverLicenseWidget() { + return GetBuilder( + builder: (contentController) => contentController.responseMap.isNotEmpty + ? Positioned( + top: Get.height * .09, + left: Get.width * .051, + right: Get.width * .051, + child: contentController.isloading + ? Column( + children: [ + const MyCircularProgressIndicator(), + Text( + 'We are process picture please wait '.tr, + style: AppStyle.title, + ) + ], + ) + : SizedBox( + height: Get.height * .7, + child: ListView( + children: [ + Container( + decoration: AppStyle.boxDecoration, + // height: Get.height * .4, + child: Padding( + padding: const EdgeInsets.all(5), + child: contentController.responseMap.isEmpty + ? Center( + child: Text( + 'There is no data yet.'.tr, + style: AppStyle.title, + ), + ) + : Column( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + '${'Name'.tr} :${contentController.responseMap['first_name']}', + style: AppStyle.subtitle, + ), + Text( + ' ${contentController.responseMap['last_name']}', + style: AppStyle.subtitle, + ), + ], + ), + Text( + '${'Name in arabic'.tr}: ${contentController.responseMap['name_in_arabic']}', + style: AppStyle.title, + ), + Text( + '${'Drivers License Class'.tr}: ${contentController.responseMap['class']}', + style: AppStyle.title, + ), + ], + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'National Number'.tr}: ${contentController.responseMap['id']}', + style: AppStyle.title, + ), + // Image.memory( + // scanDocumentsByApi + // .imagePortrait, + // width: 60, + // ), + ]), + Text( + '${'Address'.tr}: ${contentController.responseMap['address']}', + style: AppStyle.title, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'Date of Birth'.tr}: ${contentController.responseMap['dob']}', + style: AppStyle.title, + ), + Text( + '${'Age'.tr} : ${contentController.responseMap['age_in_years']}', + style: AppStyle.title, + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'Expiry Date'.tr}: ${contentController.responseMap['expiration_date']}', + style: DateTime.parse( + contentController + .responseMap[ + 'expiration_date'] + .toString()) + .isBefore( + contentController.now) + ? AppStyle.title.copyWith( + color: AppColor.redColor) + : AppStyle.title.copyWith( + color: + AppColor.greenColor), + ), + ], + ), + ], + ), + ), + ), + const SizedBox( + height: 10, + ), + DateTime.parse(contentController + .responseMap['expiration_date'] + .toString()) + .isBefore(contentController.now) + ? Text( + 'You can\'t continue with us .\nYou should renew Driver license' + .tr, + style: AppStyle.title + .copyWith(color: AppColor.redColor), + ) + : MyElevatedButton( + kolor: AppColor.greenColor, + title: 'Lets check Car license '.tr, + onPressed: () => contentController + .getTextFromCard( + '''Extract the following information from the front face of the car license card in Jordan: + +* name +* Address +* Vehicle type +* car_kind +* car_color +* Vehicle category +* car_year +* car_plate +* Registration type +* Usage type +* expire_date_of_license + +Output the extracted information in the following JSON formate and make date format like YYYY-MM-DD''')), + const SizedBox( + height: 10, + ), + contentController.responseCarLicenseMap.isNotEmpty + ? Container( + decoration: AppStyle.boxDecoration, + // height: Get.height * .3, + width: Get.width * .9, + child: Column( + children: [ + Text( + '${'Name'.tr} ${contentController.responseCarLicenseMap['name']}', + style: AppStyle.title, + ), + Text( + '${'Address'.tr} ${contentController.responseCarLicenseMap['address']}', + style: AppStyle.title, + ), + Text( + '${'Car Kind'.tr} ${contentController.responseCarLicenseMap['car_kind']}', + style: AppStyle.title, + ), + Text( + '${'Color'.tr} ${contentController.responseCarLicenseMap['car_color']}', + style: AppStyle.title, + ), + Text( + '${'Year'.tr} ${contentController.responseCarLicenseMap['car_year']}', + style: AppStyle.title, + ), + Text( + '${'Car Plate'.tr} ${contentController.responseCarLicenseMap['car_plate']}', + style: AppStyle.title, + ), + Text( + '${'ُExpire Date'.tr} ${contentController.responseCarLicenseMap['expire_date_of_license']}', + style: contentController + .responseCarLicenseMap + .isNotEmpty + ? DateTime.parse(contentController + .responseCarLicenseMap[ + 'expire_date_of_license'] + .toString()) + .isBefore( + contentController.now) + ? AppStyle.title.copyWith( + color: AppColor.redColor) + : AppStyle.title.copyWith( + color: AppColor.greenColor) + : null, + ), + ], + ), + ) + : const SizedBox(), + const SizedBox( + height: 10, + ), + //todo temporary + // DateTime.parse(contentController + // .responseCarLicenseMap[ + // 'expire_date_of_license'] + // .toString()) + // .isBefore(contentController.now) + // ? Text( + // 'You can\'t continue with us .\nYou should renew Car license' + // .tr, + // style: AppStyle.title.copyWith( + // color: AppColor.redColor), + // ) + // : + MyElevatedButton( + kolor: AppColor.greenColor, + title: 'Lets check License Back Face'.tr, + onPressed: () => + contentController.getTextFromCard( + 'write json output from extracting car license back face for these key ,vin,fuelType,passengerType,curbWeight,insuranceCompany,policyNumber,notes,insuranceType and output it json .dont add data else this image', + )), + const SizedBox( + height: 10, + ), + contentController.responseBackCarLicenseMap.isNotEmpty + ? Container( + decoration: AppStyle.boxDecoration, + // height: 300, + child: Column(children: [ + Text( + 'VIN ${contentController.responseBackCarLicenseMap['vin']}', + style: AppStyle.title, + ), + Text( + 'Fuel Type ${contentController.responseBackCarLicenseMap['fuelType']}', + style: AppStyle.title, + ), + Text( + 'Insurance Company ${contentController.responseBackCarLicenseMap['insuranceCompany']}', + style: AppStyle.title, + ), + Text( + 'Policy Number ${contentController.responseBackCarLicenseMap['policyNumber']}', + style: AppStyle.title, + ), + Text( + 'Insurance Type ${contentController.responseBackCarLicenseMap['insuranceType']}', + style: AppStyle.title, + ) + ])) + : const SizedBox() + // MyElevatedButton( + // title: 'Detect Your Face '.tr, + // onPressed: () => scanDocumentsByApi + // .checkMatchFaceApi(), + // ), + // scanDocumentsByApi.res.isEmpty + // ? const SizedBox() + // : scanDocumentsByApi.res['data'] + // ['result'] + // .toString() == + // 'Same' + // ? MyElevatedButton( + // onPressed: () async { + // await registerCaptainController + // .register(); + // await registerCaptainController + // .addLisence(); + // // await scanDocumentsByApi + // // .uploadImagePortrate(); + // }, + // title: + // 'Go to next step\nscan Car License.' + // .tr, + // kolor: AppColor.greenColor, + // ) + // : const SizedBox(), + // MyElevatedButton( + // title: 'get sql data', + // kolor: AppColor.yellowColor, + // onPressed: () { + // sql.deleteAllData( + // TableName.faceDetectTimes); + // sql + // .getAllData( + // TableName.faceDetectTimes) + // .then((value) => print( + // value[0]['faceDetectTimes'])); + // }, + // ), + ], + ), + ), + ) + : Positioned( + top: Get.height * .06, + left: Get.width * .051, + right: Get.width * .051, + child: scanDocumentsByApi.isLoading + ? Column( + children: [ + const MyCircularProgressIndicator(), + Text( + 'We are process picture please wait '.tr, + style: AppStyle.title, + ) + ], + ) + : Column( + children: [ + Container( + decoration: AppStyle.boxDecoration, + height: Get.height * .35, + child: Padding( + padding: const EdgeInsets.all(5), + child: Center( + child: Text( + 'There is no data yet.'.tr, + style: AppStyle.title, + ), + )), + ), + ], + ), + ), + ); + } + + GetBuilder usaDriverLicensWidget() { + return GetBuilder( + builder: (scanDocumentsByApi) => scanDocumentsByApi.responseMap.isNotEmpty + ? Positioned( + top: Get.height * .06, + left: Get.width * .051, + right: Get.width * .051, + child: scanDocumentsByApi.isLoading + ? Column( + children: [ + const MyCircularProgressIndicator(), + Text( + 'We are process picture please wait '.tr, + style: AppStyle.title, + ) + ], + ) + : Column( + children: [ + Container( + decoration: AppStyle.boxDecoration, + height: Get.height * .4, + child: Padding( + padding: const EdgeInsets.all(5), + child: scanDocumentsByApi.responseMap.isEmpty + ? Center( + child: Text( + 'There is no data yet.'.tr, + style: AppStyle.title, + ), + ) + : Column( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + '${'Name :'.tr}${scanDocumentsByApi.name}', + style: AppStyle.subtitle, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + '${'Drivers License Class: '.tr}${scanDocumentsByApi.licenseClass}', + style: AppStyle.title, + ), + Image.memory( + scanDocumentsByApi + .imageSignature, + width: 100, + height: 30, + ), + ], + ), + ], + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'Document Number: '.tr}${scanDocumentsByApi.documentNo}', + style: AppStyle.title, + ), + Image.memory( + scanDocumentsByApi.imagePortrait, + width: 60, + ), + ]), + Text( + '${'Address: '.tr}${scanDocumentsByApi.address}', + style: AppStyle.title, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'Height: '.tr}${scanDocumentsByApi.height}', + style: AppStyle.subtitle, + ), + Text( + 'Postal Code: ${scanDocumentsByApi.postalCode}', + style: AppStyle.subtitle, + ), + Text( + 'Sex: ${scanDocumentsByApi.sex}', + style: AppStyle.subtitle, + ), + ], + ), + Text( + 'Territorial Code: ${scanDocumentsByApi.stateCode}', + style: AppStyle.subtitle, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + '${'Expiry Date: '.tr}${scanDocumentsByApi.expireDate}', + style: DateTime.parse( + scanDocumentsByApi + .responseMap['data'] + ['ocr'] + ['dateOfExpiry'] + .toString()) + .isBefore( + scanDocumentsByApi.now) + ? AppStyle.title.copyWith( + color: AppColor.redColor) + : AppStyle.title.copyWith( + color: AppColor.greenColor), + ), + Text( + '${'Date of Birth: '.tr}${scanDocumentsByApi.dob}', + style: AppStyle.title, + ), + ], + ), + ], + ), + ), + ), + DateTime.parse(scanDocumentsByApi.responseMap['data'] + ['ocr']['dateOfExpiry'] + .toString()) + .isBefore(scanDocumentsByApi.now) + ? Text( + 'You can\'t continue with us .\nYou should renew Driver license', + style: AppStyle.title + .copyWith(color: AppColor.redColor), + ) + : MyElevatedButton( + title: 'Detect Your Face '.tr, + onPressed: () => + scanDocumentsByApi.checkMatchFaceApi(), + ), + scanDocumentsByApi.res.isEmpty + ? const SizedBox() + : scanDocumentsByApi.res['data']['result'] + .toString() == + 'Same' + ? MyElevatedButton( + onPressed: () async { + await registerCaptainController + .register(); + await registerCaptainController + .addLisence(); + // await scanDocumentsByApi + // .uploadImagePortrate(); + }, + title: + 'Go to next step\nscan Car License.'.tr, + kolor: AppColor.greenColor, + ) + : const SizedBox(), + MyElevatedButton( + title: 'get sql data', + kolor: AppColor.yellowColor, + onPressed: () { + sql.deleteAllData(TableName.faceDetectTimes); + sql.getAllData(TableName.faceDetectTimes).then( + (value) => print(value[0]['faceDetectTimes'])); + }, + ) + ], + ), + ) + : Positioned( + top: Get.height * .06, + left: Get.width * .051, + right: Get.width * .051, + child: scanDocumentsByApi.isLoading + ? Column( + children: [ + const MyCircularProgressIndicator(), + Text( + 'We are process picture please wait '.tr, + style: AppStyle.title, + ) + ], + ) + : Column( + children: [ + Container( + decoration: AppStyle.boxDecoration, + height: Get.height * .35, + child: Padding( + padding: const EdgeInsets.all(5), + child: Center( + child: Text( + 'There is no data yet.'.tr, + style: AppStyle.title, + ), + )), + ), + ], + ), + ), + ); + } } diff --git a/lib/views/auth/captin/login_captin.dart b/lib/views/auth/captin/login_captin.dart index eef7021..dd6cb48 100644 --- a/lib/views/auth/captin/login_captin.dart +++ b/lib/views/auth/captin/login_captin.dart @@ -11,6 +11,7 @@ import '../../../constant/style.dart'; import '../../../controller/auth/captin/login_captin_controller.dart'; import '../../../controller/auth/login_controller.dart'; import '../../../main.dart'; +import '../../home/profile/passenger_profile_page.dart'; import '../../widgets/elevated_btn.dart'; import '../../widgets/my_scafold.dart'; import '../../widgets/mycircular.dart'; @@ -32,6 +33,8 @@ class LoginCaptin extends StatelessWidget { body: [ if (box.read(BoxName.agreeTerms) != 'agreed') agreedPage() + else if (box.read(BoxName.countryCode) == null) + CountryPicker() else SingleChildScrollView( child: Column( diff --git a/lib/views/auth/captin/register_captin.dart b/lib/views/auth/captin/register_captin.dart index 73e7985..c1b909b 100644 --- a/lib/views/auth/captin/register_captin.dart +++ b/lib/views/auth/captin/register_captin.dart @@ -1,3 +1,5 @@ +import 'package:SEFER/constant/box_name.dart'; +import 'package:SEFER/main.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:SEFER/controller/auth/captin/register_captin_controller.dart'; @@ -33,234 +35,126 @@ class RegisterCaptin extends StatelessWidget { ), child: Padding( padding: const EdgeInsets.all(16), - child: Column(children: [ - // Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // SizedBox( - // width: Get.width * .4, - // child: TextFormField( - // keyboardType: TextInputType.text, - // controller: controller.firstNameController, - // decoration: InputDecoration( - // focusedBorder: OutlineInputBorder( - // borderSide: const BorderSide( - // color: AppColor.primaryColor, - // width: 2.0, - // ), - // borderRadius: BorderRadius.circular(10), - // ), - // fillColor: AppColor.accentColor, - // hoverColor: AppColor.accentColor, - // focusColor: AppColor.accentColor, - // border: const OutlineInputBorder( - // borderRadius: BorderRadius.all( - // Radius.circular(12))), - // labelText: 'First name'.tr, - // hintText: 'Enter your first name'.tr, - // ), - // validator: (value) { - // if (value!.isEmpty) { - // return 'Please enter your first name.'.tr; - // } - // return null; - // }, - // ), - // ), - // SizedBox( - // width: Get.width * .4, - // child: TextFormField( - // keyboardType: TextInputType.text, - // controller: controller.lastNameController, - // decoration: InputDecoration( - // focusedBorder: OutlineInputBorder( - // borderSide: const BorderSide( - // color: AppColor.primaryColor, - // width: 2.0, - // ), - // borderRadius: BorderRadius.circular(10), - // ), - // focusColor: AppColor.accentColor, - // fillColor: AppColor.accentColor, - // border: const OutlineInputBorder( - // borderRadius: BorderRadius.all( - // Radius.circular(12))), - // labelText: 'Last name'.tr, - // hintText: 'Enter your last name'.tr, - // ), - // validator: (value) { - // if (value!.isEmpty) { - // return 'Please enter your last name.'.tr; - // } - // return null; - // }, - // ), - // ), - // ], - // ), - // const SizedBox( - // height: 15, - // ), - SizedBox( - width: Get.width * .8, - child: TextFormField( - keyboardType: TextInputType.emailAddress, - controller: controller.emailController, - decoration: InputDecoration( - focusedBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: AppColor.primaryColor, - width: 2.0, + child: Column( + children: [ + SizedBox( + width: Get.width * .8, + child: TextFormField( + keyboardType: TextInputType.emailAddress, + controller: controller.emailController, + decoration: InputDecoration( + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: AppColor.primaryColor, + width: 2.0, + ), + borderRadius: BorderRadius.circular(10), ), - borderRadius: BorderRadius.circular(10), + fillColor: AppColor.accentColor, + hoverColor: AppColor.accentColor, + focusColor: AppColor.accentColor, + border: const OutlineInputBorder( + borderRadius: + BorderRadius.all(Radius.circular(12))), + labelText: 'Email'.tr, + hintText: 'Enter your email address'.tr, ), - fillColor: AppColor.accentColor, - hoverColor: AppColor.accentColor, - focusColor: AppColor.accentColor, - border: const OutlineInputBorder( - borderRadius: - BorderRadius.all(Radius.circular(12))), - labelText: 'Email'.tr, - hintText: 'Enter your email address'.tr, + validator: (value) { + if (value!.isEmpty || + (!value.contains('@') || + !value.contains('.'))) { + return 'Please enter Your Email.'.tr; + } + return null; + }, ), - validator: (value) { - if (value!.isEmpty || - (!value.contains('@') || - !value.contains('.'))) { - return 'Please enter Your Email.'.tr; - } - return null; - }, ), - ), - const SizedBox( - height: 15, - ), - SizedBox( - width: Get.width * .8, - child: TextFormField( - obscureText: true, - keyboardType: TextInputType.emailAddress, - controller: controller.passwordController, - decoration: InputDecoration( - focusedBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: AppColor.primaryColor, - width: 2.0, + const SizedBox( + height: 15, + ), + SizedBox( + width: Get.width * .8, + child: TextFormField( + obscureText: true, + keyboardType: TextInputType.emailAddress, + controller: controller.passwordController, + decoration: InputDecoration( + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: AppColor.primaryColor, + width: 2.0, + ), + borderRadius: BorderRadius.circular(10), ), - borderRadius: BorderRadius.circular(10), + fillColor: AppColor.accentColor, + hoverColor: AppColor.accentColor, + focusColor: AppColor.accentColor, + border: const OutlineInputBorder( + borderRadius: + BorderRadius.all(Radius.circular(12))), + labelText: 'Password'.tr, + hintText: 'Enter your Password'.tr, ), - fillColor: AppColor.accentColor, - hoverColor: AppColor.accentColor, - focusColor: AppColor.accentColor, - border: const OutlineInputBorder( - borderRadius: - BorderRadius.all(Radius.circular(12))), - labelText: 'Password'.tr, - hintText: 'Enter your Password'.tr, + validator: (value) { + if (value!.isEmpty) { + return 'Please enter Your Password.'.tr; + } + if (value.length < 6) { + return 'Password must br at least 6 character.' + .tr; + } + return null; + }, ), - validator: (value) { - if (value!.isEmpty) { - return 'Please enter Your Password.'.tr; - } - if (value.length < 6) { - return 'Password must br at least 6 character.' - .tr; - } - return null; - }, ), - ), - const SizedBox( - height: 15, - ), - SizedBox( - width: Get.width * .8, - child: TextFormField( - keyboardType: TextInputType.phone, - cursorColor: AppColor.accentColor, - controller: controller.phoneController, - decoration: InputDecoration( - focusedBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: AppColor.primaryColor, - width: 2.0, + const SizedBox( + height: 15, + ), + SizedBox( + width: Get.width * .8, + child: TextFormField( + keyboardType: TextInputType.phone, + cursorColor: AppColor.accentColor, + controller: controller.phoneController, + decoration: InputDecoration( + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: AppColor.primaryColor, + width: 2.0, + ), + borderRadius: BorderRadius.circular(10), ), - borderRadius: BorderRadius.circular(10), + focusColor: AppColor.accentColor, + fillColor: AppColor.accentColor, + border: const OutlineInputBorder( + borderRadius: + BorderRadius.all(Radius.circular(12))), + labelText: 'Phone'.tr, + hintText: 'Enter your phone number'.tr, ), - focusColor: AppColor.accentColor, - fillColor: AppColor.accentColor, - border: const OutlineInputBorder( - borderRadius: - BorderRadius.all(Radius.circular(12))), - labelText: 'Phone'.tr, - hintText: 'Enter your phone number'.tr, + validator: (value) { + if (value!.isEmpty || value.length != 10) { + return 'Please enter your phone number.'.tr; + } + return null; + }, ), - validator: (value) { - if (value!.isEmpty || value.length != 10) { - return 'Please enter your phone number.'.tr; - } - return null; - }, ), - ), - const SizedBox( - height: 15, - ), - // Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // InkWell( - // onTap: () => controller.getBirthDate(), - // child: Container( - // height: 50, - // width: Get.width * .4, - // decoration: BoxDecoration( - // border: Border.all(), - // borderRadius: BorderRadius.circular(13)), - // child: Padding( - // padding: const EdgeInsets.symmetric( - // horizontal: 20), - // child: Text( - // controller.birthDate, - // style: AppStyle.title, - // ), - // ), - // ), - // ), - // DropdownButton( - // value: controller.gender, - // items: [ - // DropdownMenuItem( - // value: 'Male', - // child: Text('Male'.tr), - // ), - // DropdownMenuItem( - // value: 'Female', - // child: Text('Female'.tr), - // ), - // ], - // onChanged: (value) { - // controller.changeGender(value!); - // }, - // ) - // ], - // ), - MyElevatedButton( - title: 'Next'.tr, - onPressed: () => controller.nextToAIDetection()), - // MyElevatedButton( - // //todo remove it for test - // title: 'Car registration ai '.tr, - // kolor: AppColor.blueColor, - // onPressed: () => Get.to(() => CarLicensePage())), - - // controller.isloading - // ? const MyCircularProgressIndicator() - // : MyElevatedButton( - // title: 'Register Captain'.tr, - // onPressed: () => controller.register()) - ]), + const SizedBox( + height: 15, + ), + MyElevatedButton( + title: 'Next'.tr, + onPressed: () => controller.nextToAIDetection()), + IconButton( + onPressed: () { + print(box.write(BoxName.countryCode, 'Jordan')); + print(box.read(BoxName.countryCode)); + }, + icon: const Icon(Icons.add), + ) + ], + ), ), ), ), diff --git a/lib/views/auth/login_page.dart b/lib/views/auth/login_page.dart index 1ce87a0..5e26963 100644 --- a/lib/views/auth/login_page.dart +++ b/lib/views/auth/login_page.dart @@ -236,21 +236,31 @@ class LoginPage extends StatelessWidget { ), // const Spacer(), const SizedBox( - height: 40, + height: 100, ), GestureDetector( onTap: () => Get.to(LoginCaptin()), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - const Icon(Icons.drive_eta_rounded), + const Icon( + Icons.drive_eta_rounded, + size: 50, + ), Text( - 'If You Want be Driver Click Here.'.tr, + 'If You Want be Driver \nClick Here.'.tr, style: AppStyle.headTitle2, + textAlign: TextAlign.center, ), ], ), - ) + ), + IconButton( + onPressed: () { + box.remove(BoxName.countryCode); + }, + icon: const Icon(Icons.delete), + ), ], ), ) @@ -287,7 +297,8 @@ class LoginPage extends StatelessWidget { RichText( text: TextSpan( text: - 'By selecting "I Agree" below, I have reviewed and agree to the Terms of Use and acknowledge the ', + 'By selecting "I Agree" below, I have reviewed and agree to the Terms of Use and acknowledge the ' + .tr, style: AppStyle.title, children: [ TextSpan( @@ -308,8 +319,8 @@ class LoginPage extends StatelessWidget { ), )); }), - const TextSpan( - text: '. I am at least 18 years of age.', + TextSpan( + text: '. I am at least 18 years of age.'.tr, ), ], ), diff --git a/lib/views/home/Captin/driver_map_page.dart b/lib/views/home/Captin/driver_map_page.dart index e2a43eb..9804a8d 100644 --- a/lib/views/home/Captin/driver_map_page.dart +++ b/lib/views/home/Captin/driver_map_page.dart @@ -26,6 +26,6 @@ class PassengerLocationMapPage extends StatelessWidget { const SosConnect(), const GoogleMapApp(), ], - isleading: true); + isleading: false); } } diff --git a/lib/views/home/Captin/home_captain/drawer_captain.dart b/lib/views/home/Captin/home_captain/drawer_captain.dart index cab469d..694e187 100644 --- a/lib/views/home/Captin/home_captain/drawer_captain.dart +++ b/lib/views/home/Captin/home_captain/drawer_captain.dart @@ -1,4 +1,13 @@ +import 'package:SEFER/constant/api_key.dart'; +import 'package:SEFER/constant/links.dart'; +import 'package:SEFER/constant/style.dart'; +import 'package:SEFER/controller/home/captin/home_captain_controller.dart'; +import 'package:SEFER/views/widgets/mycircular.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_rating_bar/flutter_rating_bar.dart'; +import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:get/get.dart'; import 'package:SEFER/constant/box_name.dart'; import 'package:SEFER/constant/colors.dart'; @@ -11,9 +20,17 @@ import 'package:SEFER/views/home/my_wallet/walet_captain.dart'; import 'package:SEFER/views/home/profile/profile_captain.dart'; import 'package:SEFER/views/notification/notification_captain.dart'; +import '../../../../controller/functions/upload_image.dart'; + class DrawerCaptain extends StatelessWidget { + ImageController imageController = Get.put(ImageController()); + @override Widget build(BuildContext context) { + String writeText(int times) { + return '*' * times; + } + return Drawer( child: Column( children: [ @@ -24,18 +41,84 @@ class DrawerCaptain extends StatelessWidget { gradient: LinearGradient( colors: [ AppColor.greenColor, - AppColor.yellowColor - ], // Define your gradient colors + AppColor.yellowColor, + ], begin: Alignment.topLeft, end: Alignment.bottomRight, ), ), - accountName: Text(box.read(BoxName.nameDriver)), - accountEmail: Text(box.read(BoxName.emailDriver)), - currentAccountPicture: const CircleAvatar( - backgroundImage: AssetImage('path_to_profile_image'), - ), //todo image from server + currentAccountPictureSize: const Size.square(100), + arrowColor: AppColor.deepPurpleAccent, + accountName: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Row( + children: [ + Text( + box.read(BoxName.nameDriver), + style: AppStyle.title, + ), + const Spacer(), + Column( + children: [ + Text( + Get.find().rating, + style: AppStyle.number.copyWith(color: Colors.amber), + ), + Container( + // width: Get.width * .4, + padding: const EdgeInsets.symmetric( + horizontal: 4, vertical: 1), + color: AppColor.greenColor, + child: RatingBar.builder( + initialRating: double.parse( + Get.find().rating), + minRating: 1, + direction: Axis.horizontal, + itemCount: 5, + itemSize: 20, + itemPadding: + const EdgeInsets.symmetric(horizontal: 2), + itemBuilder: (context, _) => const Icon( + Icons.star, + color: Colors.amber, + ), + onRatingUpdate: (rating) {}), + ), + ], + ), + ], + ), + ), + accountEmail: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Text( + box.read(BoxName.emailDriver), + style: AppStyle.title, + ), + ), + currentAccountPicture: Stack( + children: [ + GetBuilder(builder: (imageController) { + return imageController.isloading + ? const MyCircularProgressIndicator() + : ClipOval( + child: Image.network( + '${AK.serverPHP}/portrate_captain_image/${box.read(BoxName.driverID)}.jpg')); + }), + Positioned( + right: 0, + top: 0, + child: IconButton( + onPressed: () { + imageController.choosImage(AppLink.uploadImage1); + }, + icon: const Icon(Icons.edit), + ), + ), + ], + ), ), + ListTile( leading: const Icon(Icons.account_balance_wallet), title: Text('Wallet'.tr), diff --git a/lib/views/home/Captin/home_captain/home_captin.dart b/lib/views/home/Captin/home_captain/home_captin.dart index 0e37af6..42995de 100644 --- a/lib/views/home/Captin/home_captain/home_captin.dart +++ b/lib/views/home/Captin/home_captain/home_captin.dart @@ -27,7 +27,7 @@ class HomeCaptain extends StatelessWidget { @override Widget build(BuildContext context) { Get.put(OrderRequestController()); - + Get.put(HomeCaptainController()); return Scaffold( appBar: AppBar( backgroundColor: AppColor.greenColor, @@ -135,7 +135,7 @@ class HomeCaptain extends StatelessWidget { ], ), Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisAlignment: MainAxisAlignment.center, children: [ const Icon( Entypo.wallet, @@ -156,15 +156,19 @@ class HomeCaptain extends StatelessWidget { style: AppStyle.title, ), Container( - color: AppColor.greenColor, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6), + color: AppColor.greenColor, + ), child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 8), + padding: const EdgeInsets.symmetric( + horizontal: 8, vertical: 2), child: Text( - 'Ride Today :'.tr + + 'Ride Today : '.tr + Get.find() .countRideToday, - style: AppStyle.title, + style: AppStyle.title + .copyWith(color: AppColor.secondaryColor), ), ), ), diff --git a/lib/views/home/Captin/mapDriverWidgets/google_driver_map_page.dart b/lib/views/home/Captin/mapDriverWidgets/google_driver_map_page.dart index bb685ff..63c9067 100644 --- a/lib/views/home/Captin/mapDriverWidgets/google_driver_map_page.dart +++ b/lib/views/home/Captin/mapDriverWidgets/google_driver_map_page.dart @@ -16,6 +16,7 @@ class GoogleDriverMap extends StatelessWidget { @override Widget build(BuildContext context) { + // Get.put(MapDriverController()); return Padding( padding: const EdgeInsets.all(8.0), child: GetBuilder( @@ -24,11 +25,12 @@ class GoogleDriverMap extends StatelessWidget { initialCameraPosition: CameraPosition( // bearing: 45, target: locationController.myLocation, - zoom: 15, + zoom: 16, tilt: 40, ), + onCameraMoveStarted: () {}, onCameraMove: (position) { - locationController.myLocation = position.target; + // locationController.myLocation = position.target; print(position); }, minMaxZoomPreference: const MinMaxZoomPreference(6, 18), diff --git a/lib/views/home/Captin/mapDriverWidgets/passenger_info_window.dart b/lib/views/home/Captin/mapDriverWidgets/passenger_info_window.dart index 91b4192..3703358 100644 --- a/lib/views/home/Captin/mapDriverWidgets/passenger_info_window.dart +++ b/lib/views/home/Captin/mapDriverWidgets/passenger_info_window.dart @@ -1,5 +1,7 @@ +import 'package:SEFER/controller/functions/location_controller.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; +import 'package:flutter_font_icons/flutter_font_icons.dart'; import 'package:get/get.dart'; import 'package:SEFER/constant/box_name.dart'; import 'package:SEFER/constant/colors.dart'; @@ -8,10 +10,12 @@ import 'package:SEFER/controller/firebase/firbase_messge.dart'; import 'package:SEFER/controller/home/captin/map_driver_controller.dart'; import 'package:SEFER/main.dart'; import 'package:SEFER/views/widgets/elevated_btn.dart'; +import 'package:url_launcher/url_launcher.dart'; import '../../../../constant/style.dart'; import '../../../../controller/functions/launch.dart'; import '../../../../controller/home/captin/widget/call_page.dart'; +import 'google_map_app.dart'; class PassengerInfoWindow extends StatelessWidget { const PassengerInfoWindow({ @@ -87,6 +91,24 @@ class PassengerInfoWindow extends StatelessWidget { Icons.email, color: AppColor.redColor, )), + const SizedBox( + width: 25, + ), + Container( + decoration: + AppStyle.boxDecoration, + child: IconButton( + onPressed: () { + controller + .openGoogleMapFromDriverToPassenger(); + }, + icon: const Icon( + MaterialCommunityIcons + .map_marker_radius, + size: 35, + color: AppColor.blueColor, + ), + )), ], ), ], @@ -165,7 +187,7 @@ class PassengerInfoWindow extends StatelessWidget { 60 ? AppColor.redColor : AppColor.greenColor, - minHeight: 50, + minHeight: 35, borderRadius: BorderRadius.circular(15), value: controller.progressToPassenger .toDouble(), diff --git a/lib/views/home/Captin/settings_captain.dart b/lib/views/home/Captin/settings_captain.dart index 542f957..96d465b 100644 --- a/lib/views/home/Captin/settings_captain.dart +++ b/lib/views/home/Captin/settings_captain.dart @@ -1,4 +1,8 @@ +import 'package:SEFER/constant/colors.dart'; +import 'package:SEFER/controller/profile/setting_controller.dart'; +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 'package:SEFER/constant/style.dart'; import 'package:SEFER/views/lang/languages.dart'; @@ -9,6 +13,7 @@ class SettingsCaptain extends StatelessWidget { @override Widget build(BuildContext context) { + Get.put(SettingController()); return MyScafolld( title: 'Settings'.tr, body: [ @@ -20,14 +25,39 @@ class SettingsCaptain extends StatelessWidget { 'Language'.tr, style: AppStyle.headTitle2, ), + subtitle: Text('you can change languge of app'.tr), onTap: () => Get.to(const Language()), ), - // ListTile( - // leading: const Icon(Icons.notifications), - // title: const Text('Notifications'), - // onTap: () => - // Navigator.pushNamed(context, '/notification-settings'), - // ), + const Divider( + endIndent: 44, + indent: 44, + ), + ListTile( + leading: const Icon( + MaterialCommunityIcons.map_marker_radius, + color: AppColor.redColor, + ), + title: Text( + 'Google Map App'.tr, + style: AppStyle.headTitle2, + ), + subtitle: Text( + 'If you want to make Google Map App run dirctly when you apply order' + .tr), + trailing: + GetBuilder(builder: (settingController) { + return CupertinoSwitch( + value: settingController.isGoogleMapsEnabled, + onChanged: (bool value) { + settingController.onChangMapApp(); + }, + ); + }), + ), + const Divider( + endIndent: 44, + indent: 44, + ), // ListTile( // leading: const Icon(Icons.account_circle), // title: const Text('Account'), diff --git a/lib/views/home/map_widget.dart/buttom_sheet_map_show.dart b/lib/views/home/map_widget.dart/buttom_sheet_map_show.dart index f56ff5d..192986f 100644 --- a/lib/views/home/map_widget.dart/buttom_sheet_map_show.dart +++ b/lib/views/home/map_widget.dart/buttom_sheet_map_show.dart @@ -14,476 +14,496 @@ import '../../../controller/home/map_passenger_controller.dart'; GetBuilder buttomSheetMapPage() { Get.put(PaymentController()); return GetBuilder( - builder: (controller) => - controller.isBottomSheetShown && controller.rideConfirm == false - ? Positioned( - left: 5, - bottom: 0, - right: 5, - child: Column( + builder: (controller) => controller.isBottomSheetShown && + controller.rideConfirm == false + ? Positioned( + left: 5, + bottom: 0, + right: 5, + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - double.parse(box.read(BoxName.passengerWalletTotal)) < - 0 && - controller.data.isNotEmpty - ? Container( - decoration: AppStyle.boxDecoration.copyWith( - color: AppColor.redColor.withOpacity(.5)), - height: 50, - width: Get.width * .94, - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 8), - child: Text( - 'Your trip cost is'.tr + - ' ${controller.totalCostPassenger.toStringAsFixed(2)} ' - 'But you have a negative salary of' - .tr + - '${double.parse(box.read(BoxName.passengerWalletTotal)).toStringAsFixed(2)}' - ' in your' - .tr + - ' ${AppInformation.appName}' - ' wallet due to a previous trip.' - .tr, - style: AppStyle.subtitle, - ), - )) - : const SizedBox(), - ], - ), - const SizedBox( - height: 5, - ), - AnimatedContainer( - // clipBehavior: Clip.antiAliasWithSaveLayer, - curve: Curves.easeInCirc, - onEnd: () { - controller.height = 250; - }, - height: controller.heightBottomSheetShown, - duration: const Duration(seconds: 2), - child: Column( - children: [ - controller.data.isEmpty - ? const SizedBox() - : Container( - // width: Get.width * .9, - height: 100, - decoration: BoxDecoration( - color: AppColor.secondaryColor, - boxShadow: [ - const BoxShadow( - color: AppColor.accentColor, - offset: Offset(2, 2)), - BoxShadow( - color: AppColor.accentColor - .withOpacity(.4), - offset: const Offset(-2, -2)) - ], - borderRadius: const BorderRadius.all( - Radius.circular(15))), - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - SizedBox( - width: Get.width * .15, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Image.asset( - 'assets/images/jeep.png', - width: 50, - fit: BoxFit.fill, - repeat: ImageRepeat.repeatX, + double.parse(box.read(BoxName.passengerWalletTotal)) < + 0 && + controller.data.isNotEmpty + ? Container( + decoration: AppStyle.boxDecoration.copyWith( + color: AppColor.redColor.withOpacity(.5)), + height: 50, + width: Get.width * .94, + child: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 8), + child: Text( + 'Your trip cost is'.tr + + ' ${controller.totalCostPassenger.toStringAsFixed(2)} ' + 'But you have a negative salary of' + .tr + + '${double.parse(box.read(BoxName.passengerWalletTotal)).toStringAsFixed(2)}' + ' in your' + .tr + + ' ${AppInformation.appName}' + ' wallet due to a previous trip.' + .tr, + style: AppStyle.subtitle, + ), + )) + : const SizedBox(), + ], + ), + const SizedBox( + height: 5, + ), + AnimatedContainer( + // clipBehavior: Clip.antiAliasWithSaveLayer, + curve: Curves.easeInCirc, + onEnd: () { + controller.height = 250; + }, + height: controller.heightBottomSheetShown, + duration: const Duration(seconds: 2), + child: Column( + children: [ + controller.data.isEmpty + ? const SizedBox() + : Container( + // width: Get.width * .9, + height: 100, + decoration: BoxDecoration( + color: AppColor.secondaryColor, + boxShadow: [ + const BoxShadow( + color: AppColor.accentColor, + offset: Offset(2, 2)), + BoxShadow( + color: AppColor.accentColor + .withOpacity(.4), + offset: const Offset(-2, -2)) + ], + borderRadius: const BorderRadius.all( + Radius.circular(15))), + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: controller + .dataCarsLocationByPassenger.length, + itemBuilder: + (BuildContext context, int index) { + return Container( + color: controller.gender == 'Female' + ? const Color.fromARGB( + 255, 246, 52, 181) + : AppColor.secondaryColor, + width: Get.width, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + SizedBox( + width: Get.width * .15, + child: Padding( + padding: + const EdgeInsets.all(8.0), + child: Image.asset( + 'assets/images/jeep.png', + width: 50, + fit: BoxFit.fill, + repeat: ImageRepeat.repeatX, + ), ), ), - ), - SizedBox( - width: Get.width * .55, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, - children: [ - Text( - controller.hours > 1 - ? '${'Your Ride Duration is '.tr}${controller.hours} H and ${controller.minutes} m' - : '${'Your Ride Duration is '.tr} ${controller.minutes} m', - style: AppStyle.subtitle, - ), - // Text( - // '${'You will be thier in'.tr} ${DateFormat('h:mm a').format(controller.newTime)}', - // style: AppStyle.subtitle, - // ), - Text( - '${'Your trip distance is'.tr} ${controller.distance.toStringAsFixed(2)} KM', - style: AppStyle.subtitle, - ) - ], - ), - ), - SizedBox( - width: Get.width * .2, - child: Padding( - padding: const EdgeInsets.only( - right: 5, left: 5), + SizedBox( + width: Get.width * .55, child: Column( crossAxisAlignment: - CrossAxisAlignment.center, + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, children: [ - Container( - width: Get.width * .14, - height: Get.height * .06, - decoration: BoxDecoration( - color: AppColor - .secondaryColor, - shape: BoxShape.rectangle, - border: Border.all( - width: 2, - color: AppColor - .greenColor)), - child: Center( - child: Text( - '${'Fee is'.tr} \n${controller.totalPassenger.toStringAsFixed(2)}', - style: AppStyle.subtitle, - ), - ), - ), - controller.promoTaken - ? const Icon( - Icons - .filter_vintage_rounded, - color: - AppColor.redColor, - ) - : const SizedBox( - height: 0, - ) - ], - ), - ), - ), - ], - )), - const SizedBox( - height: 5, - ), - Container( - // height: 130, - decoration: BoxDecoration( - color: AppColor.secondaryColor, - boxShadow: [ - const BoxShadow( - color: AppColor.accentColor, - offset: Offset(2, 2)), - BoxShadow( - color: AppColor.accentColor - .withOpacity(.4), - offset: const Offset(-2, -2)) - ], - borderRadius: const BorderRadius.all( - Radius.circular(15))), - child: controller.data.isEmpty - ? const SizedBox() - : Center( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 5), - child: Column( - children: [ - Row( - children: [ - const Icon( - Icons.location_on, - color: AppColor.redColor, - ), - const SizedBox( - width: 10, - ), Text( - 'From : '.tr, + controller.hours > 1 + ? '${'Your Ride Duration is '.tr}${controller.hours} H and ${controller.minutes} m' + : '${'Your Ride Duration is '.tr} ${controller.minutes} m', style: AppStyle.subtitle, ), + // Text( + // '${'You will be thier in'.tr} ${DateFormat('h:mm a').format(controller.newTime)}', + // style: AppStyle.subtitle, + // ), Text( - controller.data[0] - ['start_address'] - .toString(), + '${'Your trip distance is'.tr} ${controller.distance.toStringAsFixed(2)} KM', style: AppStyle.subtitle, ) ], ), - Row( - children: [ - const Icon(Icons - .location_searching_rounded), - const SizedBox( - width: 10, - ), - Text( - 'To : '.tr, - style: AppStyle.subtitle, - ), - Text( - controller.data[0] - ['end_address'], - style: AppStyle.subtitle, - ), - ], - ), - const Divider( - color: AppColor.accentColor, - thickness: 1, - height: 2, - indent: 1, - ), - SizedBox( - height: 40, - child: Row( - mainAxisAlignment: - MainAxisAlignment.center, + ), + SizedBox( + width: Get.width * .2, + child: Padding( + padding: const EdgeInsets.only( + right: 5, left: 5), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.center, children: [ Container( + width: Get.width * .14, + height: Get.height * .06, decoration: BoxDecoration( - color: AppColor - .secondaryColor, - borderRadius: - BorderRadius.circular( - 12), - // border: Border.all(), + color: AppColor + .secondaryColor, + shape: + BoxShape.rectangle, + border: Border.all( + width: 2, + color: AppColor + .greenColor)), + child: Center( + child: Text( + '${'Fee is'.tr} \n${controller.totalPassenger.toStringAsFixed(2)}', + style: + AppStyle.subtitle, + ), ), - child: Row( - children: [ - Icon( - Icons.monetization_on, + ), + controller.promoTaken + ? const Icon( + Icons + .filter_vintage_rounded, color: - Colors.green[400], - ), - InkWell( - onTap: () async { - controller - .changeCashConfirmPageShown(); - Get.find< - PaymentController>() - .getPassengerWallet(); - }, - child: GetBuilder< - PaymentController>( - builder: (paymentController) => - paymentController - .isCashChecked - ? Text( - 'CASH', - style: AppStyle - .title, - ) - : Text( - '${AppInformation.appName} Wallet', - style: AppStyle - .title, - ), - ), - ), - ], - ), - ), - const SizedBox( - width: 40, - ), - GetBuilder( - builder: - (paymentController) => - Container( - decoration: - BoxDecoration( - color: AppColor - .secondaryColor, - borderRadius: - BorderRadius - .circular( - 12), - ), - child: Row( - children: [ - Icon( - Icons - .qr_code_2_rounded, - color: Colors - .green[ - 400], - ), - InkWell( - onTap: - () { - if (controller.promoTaken == - false) { - Get.defaultDialog( - title: 'Add Promo'.tr, - content: Column( - children: [ - SizedBox( - width: Get.width * .7, - child: TextFormField( - controller: controller.promo, - decoration: InputDecoration( - labelText: 'Promo Code'.tr, - hintText: 'Enter promo code'.tr, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - ), - filled: true, - fillColor: Colors.grey[200], - focusedBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: AppColor.primaryColor, - width: 2.0, - ), - borderRadius: BorderRadius.circular(10), - ), - errorBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Colors.red, - width: 2.0, - ), - borderRadius: BorderRadius.circular(10), - ), - enabledBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Colors.grey, - width: 1.0, - ), - borderRadius: BorderRadius.circular(10), - ), - ), - ), - ), - MyElevatedButton( - title: 'Add Promo'.tr, - onPressed: () async { - controller.applyPromoCodeToPassenger(); - }, - ) - ], - )); - } else { - Get.snackbar( - 'You have promo!'.tr, - '', - backgroundColor: AppColor.redColor); - } - }, - child: - Text( - 'Add Promo' - .tr, - style: AppStyle - .title, - ), - ), - ], - ), - )), + AppColor.redColor, + ) + : const SizedBox( + height: 0, + ) ], ), ), - SizedBox( - width: Get.width * .95, - child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - controller.isCashSelectedBeforeConfirmRide == - false - ? MyElevatedButton( - title: 'Next'.tr, - onPressed: () { - controller - .changeCashConfirmPageShown(); - }, - ) - : controller.isPassengerChosen == - false - ? MyElevatedButton( - title: 'Next'.tr, - onPressed: () { - controller - .onChangedPassengersChoose(); - Get.defaultDialog( - barrierDismissible: - false, - title: - 'How Many Passengers?' - .tr, - titleStyle: - AppStyle - .title, - content: - Column( - children: [ - Text( - 'Allowed up to 4 Passengers.' - .tr, - style: AppStyle - .title, - ), - SizedBox( - height: - 200, // Set the desired height here - child: - CupertinoPicker( - itemExtent: - 32, - onSelectedItemChanged: - (index) { - controller.onChangedPassengerCount(index + - 1); - }, - children: [ - Text('1 Passenger'.tr), - Text('2 Passengers'.tr), - Text('3 Passengers'.tr), - Text('4 Passengers'.tr), - ], - ), - ), - MyElevatedButton( - title: - 'Back', - onPressed: - () => - Get.back(), - ) - ], - ), - ); - }, - ) - : MyElevatedButton( - title: - 'Confirm Selection' - .tr, - onPressed: () { - controller - .changeConfirmRide(); - }, - ), - ], - ), + ), + ], + ), + ); + }, + ), + ), + const SizedBox( + height: 5, + ), + Container( + // height: 130, + decoration: BoxDecoration( + color: AppColor.secondaryColor, + boxShadow: [ + const BoxShadow( + color: AppColor.accentColor, + offset: Offset(2, 2)), + BoxShadow( + color: AppColor.accentColor.withOpacity(.4), + offset: const Offset(-2, -2)) + ], + borderRadius: + const BorderRadius.all(Radius.circular(15))), + child: controller.data.isEmpty + ? const SizedBox() + : Center( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 5), + child: Column( + children: [ + Row( + children: [ + const Icon( + Icons.location_on, + color: AppColor.redColor, + ), + const SizedBox( + width: 10, + ), + Text( + 'From : '.tr, + style: AppStyle.subtitle, + ), + Text( + controller.data[0] + ['start_address'] + .toString(), + style: AppStyle.subtitle, ) ], ), - ), + Row( + children: [ + const Icon(Icons + .location_searching_rounded), + const SizedBox( + width: 10, + ), + Text( + 'To : '.tr, + style: AppStyle.subtitle, + ), + Text( + controller.data[0]['end_address'], + style: AppStyle.subtitle, + ), + ], + ), + const Divider( + color: AppColor.accentColor, + thickness: 1, + height: 2, + indent: 1, + ), + SizedBox( + height: 40, + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Container( + decoration: BoxDecoration( + color: + AppColor.secondaryColor, + borderRadius: + BorderRadius.circular(12), + // border: Border.all(), + ), + child: Row( + children: [ + Icon( + Icons.monetization_on, + color: Colors.green[400], + ), + InkWell( + onTap: () async { + controller + .changeCashConfirmPageShown(); + Get.find< + PaymentController>() + .getPassengerWallet(); + }, + child: GetBuilder< + PaymentController>( + builder: (paymentController) => + paymentController + .isCashChecked + ? Text( + 'CASH', + style: AppStyle + .title, + ) + : Text( + '${AppInformation.appName} Wallet', + style: AppStyle + .title, + ), + ), + ), + ], + ), + ), + const SizedBox( + width: 40, + ), + GetBuilder( + builder: + (paymentController) => + Container( + decoration: + BoxDecoration( + color: AppColor + .secondaryColor, + borderRadius: + BorderRadius + .circular( + 12), + ), + child: Row( + children: [ + Icon( + Icons + .qr_code_2_rounded, + color: Colors + .green[ + 400], + ), + InkWell( + onTap: () { + if (controller + .promoTaken == + false) { + Get.defaultDialog( + title: 'Add Promo'.tr, + titleStyle: AppStyle.title, + content: Column( + children: [ + SizedBox( + width: Get.width * .7, + child: TextFormField( + controller: controller.promo, + decoration: InputDecoration( + labelText: 'Promo Code'.tr, + hintText: 'Enter promo code'.tr, + labelStyle: AppStyle.subtitle, + hintStyle: AppStyle.subtitle, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + ), + filled: true, + fillColor: Colors.grey[200], + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: AppColor.primaryColor, + width: 2.0, + ), + borderRadius: BorderRadius.circular(10), + ), + errorBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: Colors.red, + width: 2.0, + ), + borderRadius: BorderRadius.circular(10), + ), + enabledBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: Colors.grey, + width: 1.0, + ), + borderRadius: BorderRadius.circular(10), + ), + ), + ), + ), + MyElevatedButton( + title: 'Add Promo'.tr, + onPressed: () async { + controller.applyPromoCodeToPassenger(); + }, + ) + ], + )); + } else { + Get.snackbar( + 'You have promo!' + .tr, + '', + backgroundColor: + AppColor.redColor); + } + }, + child: Text( + 'Add Promo' + .tr, + style: AppStyle + .title, + ), + ), + ], + ), + )), + ], + ), + ), + SizedBox( + width: Get.width * .95, + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + controller.isCashSelectedBeforeConfirmRide == + false + ? MyElevatedButton( + title: 'Next'.tr, + onPressed: () { + controller + .changeCashConfirmPageShown(); + }, + ) + : + // controller.isPassengerChosen == + // false + // ? MyElevatedButton( + // title: 'Next'.tr, + // onPressed: () { + // controller + // .onChangedPassengersChoose(); + // Get.defaultDialog( + // barrierDismissible: + // false, + // title: + // 'How Many Passengers?' + // .tr, + // titleStyle: + // AppStyle + // .title, + // content: + // Column( + // children: [ + // Text( + // 'Allowed up to 4 Passengers.' + // .tr, + // style: AppStyle + // .title, + // ), + // SizedBox( + // height: + // 200, // Set the desired height here + // child: + // CupertinoPicker( + // itemExtent: + // 32, + // onSelectedItemChanged: + // (index) { + // controller.onChangedPassengerCount(index + + // 1); + // }, + // children: [ + // Text('1 Passenger'.tr), + // Text('2 Passengers'.tr), + // Text('3 Passengers'.tr), + // Text('4 Passengers'.tr), + // ], + // ), + // ), + // MyElevatedButton( + // title: + // 'Back', + // onPressed: + // () => + // Get.back(), + // ) + // ], + // ), + // ); + // }, + // ) + // : + MyElevatedButton( + title: 'Confirm Selection' + .tr, + onPressed: () { + controller + .changeConfirmRide(); + }, + ), + ], + ), + ) + ], ), - ), - ], + ), + ), ), - ), - ], + ], + ), ), - ) - : const SizedBox()); + ], + ), + ) + : const SizedBox()); } class Details extends StatelessWidget { diff --git a/lib/views/home/map_widget.dart/driver_card_from_passenger.dart b/lib/views/home/map_widget.dart/driver_card_from_passenger.dart index 0489463..660c009 100644 --- a/lib/views/home/map_widget.dart/driver_card_from_passenger.dart +++ b/lib/views/home/map_widget.dart/driver_card_from_passenger.dart @@ -9,9 +9,9 @@ GetBuilder hexagonClipper() { return GetBuilder( builder: ((controller) => controller.rideConfirm ? Positioned( - top: Get.height * .2, - left: Get.width * .2, - right: Get.width * .2, + top: Get.height * .1, + left: Get.width * .1, + right: Get.width * .1, child: ClipPath( clipper: HexagonClipper(), // CustomClipper to create a hexagon shape @@ -19,7 +19,7 @@ GetBuilder hexagonClipper() { duration: const Duration(microseconds: 300), height: 250, width: 250, - decoration: AppStyle.boxDecoration, + // decoration: AppStyle.boxDecoration, // gradient: const LinearGradient( // colors: [AppColor.greenColor, AppColor.secondaryColor], // begin: Alignment.topLeft, @@ -80,12 +80,6 @@ GetBuilder hexagonClipper() { .toString(), style: AppStyle.title, ), - // Text( - // controller.dataCarsLocationByPassenger['message'] - // [controller.carsOrder]['seats'] - // .toString(), - // style: AppStyle.title, - // ), ], ), Text( @@ -95,6 +89,15 @@ GetBuilder hexagonClipper() { .toString(), style: AppStyle.title, ), + Container( + decoration: BoxDecoration(border: Border.all(width: 2)), + child: Text( + controller.dataCarsLocationByPassenger['message'] + [controller.carsOrder]['car_plate'] + .toString(), + style: AppStyle.title, + ), + ), ], ), ), diff --git a/lib/views/home/map_widget.dart/form_search_start.dart b/lib/views/home/map_widget.dart/form_search_start.dart index 0d49884..a3b799d 100644 --- a/lib/views/home/map_widget.dart/form_search_start.dart +++ b/lib/views/home/map_widget.dart/form_search_start.dart @@ -19,7 +19,7 @@ GetBuilder formSearchPlacesStart() { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - width: Get.width * .8, + width: Get.width * .75, height: 40, decoration: const BoxDecoration(color: AppColor.secondaryColor), diff --git a/lib/views/home/map_widget.dart/left_main_menu_icons.dart b/lib/views/home/map_widget.dart/left_main_menu_icons.dart index cf9a683..8a59919 100644 --- a/lib/views/home/map_widget.dart/left_main_menu_icons.dart +++ b/lib/views/home/map_widget.dart/left_main_menu_icons.dart @@ -61,27 +61,30 @@ GetBuilder leftMainMenuIcons() { const SizedBox( height: 5, ), - if (Platform.isIOS) - AnimatedContainer( - duration: const Duration(microseconds: 200), - width: controller.widthMapTypeAndTraffic, - decoration: BoxDecoration( - color: AppColor.secondaryColor, - border: Border.all(), - borderRadius: BorderRadius.circular(15)), - child: IconButton( - onPressed: () { - controller.mapController?.animateCamera( - CameraUpdate.newLatLng(LatLng( - controller.passengerLocation.latitude, - controller.passengerLocation.longitude))); - }, - icon: const Icon( - Icons.location_on, - size: 29, - ), + // if (Platform.isIOS) + AnimatedContainer( + duration: const Duration(microseconds: 200), + width: controller.widthMapTypeAndTraffic, + decoration: BoxDecoration( + color: AppColor.secondaryColor, + border: Border.all(), + borderRadius: BorderRadius.circular(15)), + child: IconButton( + onPressed: () { + controller.mapController?.animateCamera( + CameraUpdate.newLatLng(LatLng( + controller.passengerLocation.latitude, + controller.passengerLocation.longitude))); + }, + icon: const Icon( + Icons.location_on, + size: 29, ), ), + ), + const SizedBox( + height: 5, + ), AnimatedContainer( duration: const Duration(microseconds: 200), width: controller.widthMapTypeAndTraffic, @@ -118,6 +121,7 @@ GetBuilder leftMainMenuIcons() { // remoteID: '', // ) // Get.to(() => const CallPage()); + print(box.read(BoxName.lang)); }, icon: const Icon( Icons.call, diff --git a/lib/views/home/map_widget.dart/timer_to_passenger_from_driver.dart b/lib/views/home/map_widget.dart/timer_to_passenger_from_driver.dart index 508181b..179ff8d 100644 --- a/lib/views/home/map_widget.dart/timer_to_passenger_from_driver.dart +++ b/lib/views/home/map_widget.dart/timer_to_passenger_from_driver.dart @@ -130,6 +130,11 @@ class TimerToPassengerFromDriver extends StatelessWidget { ) ], ), + Text( + 'Please go to Car now '.tr, + style: AppStyle.title, + textAlign: TextAlign.center, + ), ], ), ), diff --git a/lib/views/home/my_wallet/passenger_wallet_dialoge.dart b/lib/views/home/my_wallet/passenger_wallet_dialoge.dart index c8f4a33..159586b 100644 --- a/lib/views/home/my_wallet/passenger_wallet_dialoge.dart +++ b/lib/views/home/my_wallet/passenger_wallet_dialoge.dart @@ -1,3 +1,4 @@ +import 'package:SEFER/constant/box_name.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:SEFER/constant/colors.dart'; @@ -6,6 +7,8 @@ import 'package:SEFER/controller/functions/toast.dart'; import 'package:SEFER/controller/payment/payment_controller.dart'; import 'package:SEFER/views/widgets/elevated_btn.dart'; +import '../../../main.dart'; + class PassengerWalletDialoge extends StatelessWidget { const PassengerWalletDialoge({ super.key, @@ -145,9 +148,9 @@ class PassengerWalletDialoge extends StatelessWidget { controller.makePaymentStripe( controller.selectedAmount! .toDouble(), // Convert int to double - // 'EGP', () { - // 'USD', () { - 'JOD', () { + box.read(BoxName.countryCode) == 'Jordan'.tr + ? 'USD' + : 'EGP', () { controller.addPassengerWallet(); controller.changePromoSheetDialogue(); controller.getPassengerWallet(); diff --git a/lib/views/home/my_wallet/walet_captain.dart b/lib/views/home/my_wallet/walet_captain.dart index 36f6500..207896e 100644 --- a/lib/views/home/my_wallet/walet_captain.dart +++ b/lib/views/home/my_wallet/walet_captain.dart @@ -51,11 +51,24 @@ class WaletCaptain extends StatelessWidget { ? AppColor.redColor : AppColor.greenColor, ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 4), - child: Text( - '${'Total Points is'.tr} ${captainWalletController.totalPoints.toString()} 💎', - style: AppStyle.headTitle2, + child: InkWell( + onTap: () { + Get.snackbar( + 'the 500 points equal 30 JOD'.tr, + 'the 500 points equal 30 JOD for you \nSo go and gain your money' + .tr, + backgroundColor: AppColor.greenColor, + snackPosition: SnackPosition.BOTTOM, + duration: const Duration(seconds: 4), + ); + }, + child: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4), + child: Text( + '${'Total Points is'.tr} ${captainWalletController.totalPoints.toString()} 💎', + style: AppStyle.headTitle2, + ), ), ), ), diff --git a/lib/views/home/profile/passenger_profile_page.dart b/lib/views/home/profile/passenger_profile_page.dart index e1a9587..2693e2f 100644 --- a/lib/views/home/profile/passenger_profile_page.dart +++ b/lib/views/home/profile/passenger_profile_page.dart @@ -1,3 +1,4 @@ +import 'package:SEFER/views/auth/login_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -11,6 +12,7 @@ import 'package:SEFER/views/widgets/my_scafold.dart'; import 'package:SEFER/views/widgets/my_textField.dart'; import 'package:SEFER/views/widgets/mycircular.dart'; +import '../../../controller/auth/login_controller.dart'; import '../../../controller/functions/log_out.dart'; class PassengerProfilePage extends StatelessWidget { @@ -317,33 +319,51 @@ class CountryPicker extends StatelessWidget { @override Widget build(BuildContext context) { - return Column( - children: [ - SizedBox( - height: 300, - child: CupertinoPicker( - itemExtent: 32, - onSelectedItemChanged: (int index) { - controller.setCountry(countryOptions[index]); - }, - children: List.generate( - countryOptions.length, - (index) => Center( - child: Text( - countryOptions[index], - style: AppStyle.title, + return GetBuilder(builder: (controller) { + return Column( + children: [ + const SizedBox( + height: 20, + ), + Text("Select Your Country".tr), + const SizedBox( + height: 20, + ), + Padding( + padding: const EdgeInsets.all(10), + child: Text( + "To ensure you receive the most accurate information for your location, please select your country below. This will help tailor the app experience and content to your country." + .tr), + ), + SizedBox( + height: 300, + child: CupertinoPicker( + itemExtent: 32, + onSelectedItemChanged: (int index) { + controller.setCountry(countryOptions[index]); + }, + children: List.generate( + countryOptions.length, + (index) => Center( + child: Text( + countryOptions[index], + style: AppStyle.title, + ), ), ), ), ), - ), - MyElevatedButton( - title: controller.selectedCountry.toString(), - onPressed: () { - box.write( - BoxName.countryCode, controller.selectedCountry.toString()); - }) - ], - ); + MyElevatedButton( + title: 'Select Country'.tr, + onPressed: () { + Get.find() + .saveCountryCode(controller.selectedCountry.toString()); + box.write( + BoxName.countryCode, controller.selectedCountry.toString()); + Get.off(LoginPage()); + }) + ], + ); + }); } } diff --git a/lib/views/home/profile/profile_captain.dart b/lib/views/home/profile/profile_captain.dart index f08021f..5bc44c1 100644 --- a/lib/views/home/profile/profile_captain.dart +++ b/lib/views/home/profile/profile_captain.dart @@ -9,6 +9,7 @@ import 'package:SEFER/main.dart'; import 'package:SEFER/views/widgets/elevated_btn.dart'; import 'package:SEFER/views/widgets/my_scafold.dart'; +import '../../../constant/api_key.dart'; import '../../widgets/my_textField.dart'; class ProfileCaptain extends StatelessWidget { @@ -32,7 +33,7 @@ class ProfileCaptain extends StatelessWidget { radius: Get.width * 0.26, backgroundColor: Colors.white, backgroundImage: CachedNetworkImageProvider( - "${Env.serverPHP}/card_image/${box.read(BoxName.driverID)}.jpg", + '${AK.serverPHP}/portrate_captain_image/${box.read(BoxName.driverID)}.jpg', ), ), const SizedBox(height: 8.0), diff --git a/pubspec.lock b/pubspec.lock index 1f95283..b2330f1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -832,6 +832,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.4" + google_generative_ai: + dependency: "direct main" + description: + name: google_generative_ai + sha256: "946f37c947bbc3591ed1c2878f8a41a0f75e74468dae791f84f14db3df3f3551" + url: "https://pub.dev" + source: hosted + version: "0.0.1-dev" google_identity_services_web: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index bc550cf..91e14aa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -53,6 +53,7 @@ dependencies: agora_rtc_engine: ^6.2.6 flutter_tts: ^3.8.5 permission_handler: ^11.3.0 + google_generative_ai: ^0.0.1-dev