diff --git a/android/app/build.gradle b/android/app/build.gradle index bfde579..f94e208 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -55,8 +55,8 @@ android { // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdkVersion 23 targetSdkVersion flutter.targetSdkVersion - versionCode 8 - versionName '1.0.8' + versionCode 10 + versionName '1.1.0' } signingConfigs { diff --git a/assets/tessdata/ara.traineddata b/assets/tessdata/ara.traineddata deleted file mode 100644 index 42e5c4b..0000000 Binary files a/assets/tessdata/ara.traineddata and /dev/null differ diff --git a/assets/tessdata/eng.traineddata b/assets/tessdata/eng.traineddata deleted file mode 100644 index f4744c2..0000000 Binary files a/assets/tessdata/eng.traineddata and /dev/null differ diff --git a/assets/tessdata_config.json b/assets/tessdata_config.json deleted file mode 100644 index 8cb9787..0000000 --- a/assets/tessdata_config.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "files": [ - "eng.traineddata", - "ara.traineddata" - - ] -} \ No newline at end of file diff --git a/lib/constant/box_name.dart b/lib/constant/box_name.dart index 93ab4f2..4cd6fe5 100644 --- a/lib/constant/box_name.dart +++ b/lib/constant/box_name.dart @@ -6,6 +6,7 @@ class BoxName { static const String password = "password"; static const String passwordDriver = "passwordDriver"; static const String agreeTerms = "agreeTerms"; + static const String faceDetectTimes = "faceDetectTimes"; static const String sosPhonePassenger = "sosPhonePassenger"; static const String passengerID = "pasengerID"; static const String phone = "phone"; diff --git a/lib/constant/credential.dart b/lib/constant/credential.dart index 5aeefb7..b7ad957 100644 --- a/lib/constant/credential.dart +++ b/lib/constant/credential.dart @@ -10,13 +10,18 @@ class AppCredintials { static const String twilloRecoveryCode = 'TQF13XUVU2NJ3VFU8JWBWYBS'; static const String accountSIDTwillo = 'ACb4ad857efe0903bfd6238a763a2ce4d1'; static const String authTokenTwillo = '14f39ef4628bb8a4f18469f462f8af75'; - static const String Publishablekey = '14f39ef4628bb8a4f18469f462f8af75'; + static const String publishablekey = '14f39ef4628bb8a4f18469f462f8af75'; + static const String chatGPTkey = + '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'; + static const String chatGPTkeySefer = + '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'; String getBasicAuthCredentials() { return base64Encode(utf8.encode(basicAuthCredentials)); } static const String transactionCloude = 'Authorization:API_EMDJX6BHQ67DBGT6WV:DG2XPU7YEN02M0VJ2F'; + static const String visionApi = '0vQRyaYYDWpsv73A5CZOknseK7S2sgwE'; } class StripeKey { diff --git a/lib/constant/links.dart b/lib/constant/links.dart index 1da8429..8bf458b 100644 --- a/lib/constant/links.dart +++ b/lib/constant/links.dart @@ -42,6 +42,7 @@ class AppLink { //-----------------DriverPayment------------------ static const String addDriverpayment = "$ride/payment/add.php"; static const String getDriverpaymentToday = "$ride/payment/get.php"; + static const String getAllPayment = "$ride/payment/getAllPayment.php"; //-----------------DriverOrder------------------ diff --git a/lib/constant/table_names.dart b/lib/constant/table_names.dart index ac60fb5..79f96d5 100644 --- a/lib/constant/table_names.dart +++ b/lib/constant/table_names.dart @@ -2,4 +2,5 @@ class TableName { static const String placesFavorite = "placesFavorite"; static const String carLocations = "carLocations"; static const String driverOrdersRefuse = "driverOrdersRefuse"; + static const String faceDetectTimes = "faceDetectTimes"; } diff --git a/lib/controller/auth/captin/login_captin_controller.dart b/lib/controller/auth/captin/login_captin_controller.dart index 2304a90..758a610 100644 --- a/lib/controller/auth/captin/login_captin_controller.dart +++ b/lib/controller/auth/captin/login_captin_controller.dart @@ -60,7 +60,7 @@ class LoginCaptinController extends GetxController { box.write(BoxName.phoneDriver, jsonDecoeded['data'][0]['phone']); SecureStorage() .saveData(BoxName.passwordDriver, passwordController.text); - Get.offAll(() => const HomeCaptain()); + Get.offAll(() => HomeCaptain()); isloading = false; update(); print(box.read(BoxName.driverID).toString()); @@ -101,7 +101,7 @@ class LoginCaptinController extends GetxController { } void loginByBoxData() async { - Get.to(() => const HomeCaptain()); + Get.to(() => HomeCaptain()); await CRUD().post(link: AppLink.addTokensDriver, payload: { 'token': box.read(BoxName.tokenDriver).toString(), 'captain_id': box.read(BoxName.driverID).toString() diff --git a/lib/controller/auth/register_controller.dart b/lib/controller/auth/register_controller.dart index 1a4695e..44fd381 100644 --- a/lib/controller/auth/register_controller.dart +++ b/lib/controller/auth/register_controller.dart @@ -56,7 +56,7 @@ class RegisterController extends GetxController { update(); } - sendverfications() async { + sendVerifications() async { var res = await CRUD().post(link: AppLink.verifyEmail, payload: { 'email': emailController.text, 'token': verfyCode.text, diff --git a/lib/controller/functions/camer_controller.dart b/lib/controller/functions/camer_controller.dart index 52de703..2b42729 100644 --- a/lib/controller/functions/camer_controller.dart +++ b/lib/controller/functions/camer_controller.dart @@ -2,7 +2,6 @@ import 'dart:convert'; import 'dart:io'; import 'package:camera/camera.dart'; -import 'package:flutter_tesseract_ocr/flutter_tesseract_ocr.dart'; import 'package:get/get.dart'; import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart'; import 'package:ride/constant/box_name.dart'; @@ -193,49 +192,49 @@ class CameraClassController extends GetxController { return text.split('\n'); } - Future takePictureAndTesseractScan() async { - try { - // Construct the path for the image file - final directory = await path_provider.getTemporaryDirectory(); - final imagePath = - path.join(directory.path, '${box.read(BoxName.driverID)}.png'); +// Future takePictureAndTesseractScan() async { +// try { +// // Construct the path for the image file +// final directory = await path_provider.getTemporaryDirectory(); +// final imagePath = +// path.join(directory.path, '${box.read(BoxName.driverID)}.png'); - // Capture the image and save it to the specified path - final XFile capturedImage = await cameraController.takePicture(); +// // Capture the image and save it to the specified path +// final XFile capturedImage = await cameraController.takePicture(); - // Move the captured image to the desired path - await capturedImage.saveTo(imagePath); +// // Move the captured image to the desired path +// await capturedImage.saveTo(imagePath); - // Recognize the text in the image - final languages = [ - 'eng', - 'ara' - ]; // Specify the languages you want to use for text extraction +// // Recognize the text in the image +// final languages = [ +// 'eng', +// 'ara' +// ]; // Specify the languages you want to use for text extraction - final text = await FlutterTesseractOcr.extractText(imagePath, - language: languages.join('+'), // Combine multiple languages with '+' - args: { - "psm": "4", - "preserve_interword_spaces": "1", - // "rectangle": const Rect.fromLTWH(100, 100, 200, 200), - } // Additional options if needed - ); - isloading = false; - final jsonText = getTextAsJSON(text); - final textBlocks = getTextBlocks(text); - update(); - scannedText = - textBlocks.toString(); // Convert the extracted text to JSON. +// final text = await FlutterTesseractOcr.extractText(imagePath, +// language: languages.join('+'), // Combine multiple languages with '+' +// args: { +// "psm": "4", +// "preserve_interword_spaces": "1", +// // "rectangle": const Rect.fromLTWH(100, 100, 200, 200), +// } // Additional options if needed +// ); +// isloading = false; +// final jsonText = getTextAsJSON(text); +// final textBlocks = getTextBlocks(text); +// update(); +// scannedText = +// textBlocks.toString(); // Convert the extracted text to JSON. -// Print the JSON to the console. - print(jsonText); - update(); - // print(text); - } catch (e) { - print('Error during text extraction: $e'); - scannedText = ''; - } - } +// // Print the JSON to the console. +// print(jsonText); +// update(); +// // print(text); +// } catch (e) { +// print('Error during text extraction: $e'); +// scannedText = ''; +// } +// } @override void onClose() { diff --git a/lib/controller/functions/ocr_controller.dart b/lib/controller/functions/ocr_controller.dart index 51d2c31..508c7f7 100644 --- a/lib/controller/functions/ocr_controller.dart +++ b/lib/controller/functions/ocr_controller.dart @@ -1,439 +1,659 @@ import 'dart:convert'; import 'dart:io'; -import 'dart:ui'; - -import 'package:flutter/cupertino.dart'; +import 'dart:typed_data'; import 'package:flutter/material.dart'; -import 'package:flutter_tesseract_ocr/android_ios.dart'; import 'package:get/get.dart'; import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:http/http.dart' as http; +import 'package:ride/constant/box_name.dart'; +import 'package:ride/constant/colors.dart'; +import 'package:ride/constant/credential.dart'; +import 'package:ride/constant/info.dart'; +import 'package:ride/constant/style.dart'; +import 'package:ride/constant/table_names.dart'; +import 'package:ride/main.dart'; +import 'package:ride/views/widgets/elevated_btn.dart'; -class OCRController extends GetxController { - final text = RxString(''); +import '../../views/auth/captin/car_license_page.dart'; +import 'launch.dart'; - void setText(value) { - text.value = value; - } -} +// +// class TextExtractionController extends GetxController { +// String extractedText = ''; +// bool isloading = false; +// File? _scannedImage; +// // Convert the extracted text to JSON +// // Convert the extracted text to JSON +// String getTextAsJSON(String text) { +// final lines = text.split('\n'); +// final jsonList = lines.map((line) { +// return { +// 'line_text': line, +// 'num_words': line.trim().split(' ').length, +// }; +// }).toList(); +// +// final json = { +// 'lines': jsonList, +// 'num_lines': lines.length, +// }; +// +// return jsonEncode(json); +// } +// +// // Convert the extracted text to blocks by line +// List getTextBlocks(String text) { +// return text.split('\n'); +// } +// +// // Future pickAndExtractText() async { +// // final pickedImage = await ImagePicker().pickImage( +// // source: ImageSource.camera, +// // preferredCameraDevice: CameraDevice.rear, +// // maxHeight: Get.height * .3, +// // maxWidth: Get.width * .8, +// // imageQuality: 99, +// // ); +// // if (pickedImage != null) { +// // isloading = true; +// // update(); +// // final imagePath = pickedImage.path; +// // final languages = [ +// // 'eng', +// // 'ara' +// // ]; // Specify the languages you want to use for text extraction +// +// // try { +// // final text = await FlutterTesseractOcr.extractText(imagePath, +// // language: +// // languages.join('+'), // Combine multiple languages with '+' +// // args: { +// // "psm": "4", +// // "preserve_interword_spaces": "1", +// // // "rectangle": const Rect.fromLTWH(100, 100, 200, 200), +// // } // Additional options if needed +// // ); +// // isloading = false; +// // final jsonText = getTextAsJSON(text); +// // final textBlocks = getTextBlocks(text); +// // update(); +// // extractedText = +// // textBlocks.toString(); // Convert the extracted text to JSON. +// +// // // Print the JSON to the console. +// // print(jsonText); +// // update(); +// // // print(text); +// // } catch (e) { +// // print('Error during text extraction: $e'); +// // extractedText = ''; +// // } +// // } +// // } +// } -class TextExtractionController extends GetxController { - String extractedText = ''; - bool isloading = false; - File? _scannedImage; -// Convert the extracted text to JSON -// Convert the extracted text to JSON - String getTextAsJSON(String text) { - final lines = text.split('\n'); - final jsonList = lines.map((line) { - return { - 'line_text': line, - 'num_words': line.trim().split(' ').length, - }; - }).toList(); +// class TextMLGoogleRecognizerController extends GetxController { +// @override +// void onInit() { +// scanText(); +// super.onInit(); +// } +// +// // The ImagePicker instance +// final ImagePicker _imagePicker = ImagePicker(); +// +// // The GoogleMlKit TextRecognizer instance +// final TextRecognizer _textRecognizer = TextRecognizer(); +// +// // The scanned text +// String? scannedText; +// String? jsonOutput; +// final List> lines = []; +// +// Map decode = {}; +// +// Future scanText() async { +// // Pick an image from the camera or gallery +// final XFile? image = +// await _imagePicker.pickImage(source: ImageSource.gallery); +// +// // If no image was picked, return +// if (image == null) { +// return; +// } +// +// // Convert the XFile object to an InputImage object +// final InputImage inputImage = InputImage.fromFile(File(image.path)); +// +// // Recognize the text in the image +// final RecognizedText recognizedText = +// await _textRecognizer.processImage(inputImage); +// scannedText = recognizedText.text; +// Map extractedData = {}; +// // Extract the scanned text line by line +// for (var i = 0; i < recognizedText.blocks.length; i++) { +// final block = recognizedText.blocks[i]; +// for (final line in block.lines) { +// final lineText = line.text; +// +// if (lineText.contains('DL')) { +// final dlNumber = lineText.split('DL')[1].trim(); +// extractedData['dl_number'] = dlNumber; +// } +// if (lineText.contains('USA')) { +// final usa = lineText.split('USA')[1].trim(); +// extractedData['USA'] = usa; +// } +// if (lineText.contains('DRIVER LICENSE')) { +// final driverl = lineText; +// extractedData['DRIVER_LICENSE'] = driverl; +// } +// +// if (lineText.contains('EXP')) { +// final expiryDate = lineText.split('EXP')[1].trim(); +// extractedData['expiry_date'] = expiryDate; +// } +// +// if (lineText.contains('DOB')) { +// final dob = lineText.split('DOB')[1].trim(); +// extractedData['dob'] = dob; +// } +// +// if (lineText.contains("LN")) { +// if ((lineText.indexOf("LN") == 0)) { +// final lastName = lineText.split('LN')[1].trim(); +// extractedData['lastName'] = lastName; +// } +// } +// if (lineText.contains("FN")) { +// final firstName = lineText.split('FN')[1].trim(); +// extractedData['firstName'] = firstName; +// } +// if (lineText.contains("RSTR")) { +// final rstr = lineText.split('RSTR')[1].trim(); +// extractedData['rstr'] = rstr; +// } +// if (lineText.contains("CLASS")) { +// final class1 = lineText.split('CLASS')[1].trim(); +// extractedData['class'] = class1; +// } +// if (lineText.contains("END")) { +// final end = lineText.split('END')[1].trim(); +// extractedData['end'] = end; +// } +// if (lineText.contains("DD")) { +// final dd = lineText.split('DD')[1].trim(); +// extractedData['dd'] = dd; +// } +// if (lineText.contains("EYES")) { +// final eyes = lineText.split('EYES')[1].trim(); +// extractedData['eyes'] = eyes; +// } +// if (lineText.contains("SEX")) { +// final parts = lineText.split("SEX ")[1]; +// extractedData['sex'] = parts[0]; +// } +// if (lineText.contains("HAIR")) { +// final hair = lineText.split('HAIR')[1].trim(); +// extractedData['hair'] = hair; +// } +// +// if (lineText.contains('STREET') || lineText.contains(',')) { +// final address = lineText; +// extractedData['address'] = address; +// } +// +// // Repeat this process for other relevant data fields +// } +// } +// +// // Convert the list of lines to a JSON string +// jsonOutput = jsonEncode(extractedData); +// decode = jsonDecode(jsonOutput!); +// +// update(); +// print('jsonOutput------------------------------'); +// print(scannedText); +// } +// } - final json = { - 'lines': jsonList, - 'num_lines': lines.length, - }; +class ScanDocumentsByApi extends GetxController { + bool isLoading = false; + Map responseMap = {}; + final ImagePicker imagePicker = ImagePicker(); + late Uint8List imagePortrait; + late Uint8List imageSignature; + late Uint8List imageDocumentFrontSide; + XFile? image; + XFile? imageFace; + late String imagePath; + DateTime now = DateTime.now(); - return jsonEncode(json); - } + Future scanDocumentsByApi() async { + // Pick an image from the camera or gallery + image = await imagePicker.pickImage(source: ImageSource.camera); -// Convert the extracted text to blocks by line - List getTextBlocks(String text) { - return text.split('\n'); - } + // If no image was picked, return + if (image == null) { + return; + } - Future pickAndExtractText() async { - final pickedImage = await ImagePicker().pickImage( - source: ImageSource.camera, - preferredCameraDevice: CameraDevice.rear, - maxHeight: Get.height * .3, - maxWidth: Get.width * .8, - imageQuality: 99, - ); - if (pickedImage != null) { - isloading = true; + isLoading = true; + update(); + var headers = {'X-BLOBR-KEY': AppCredintials.visionApi}; + var request = http.MultipartRequest('POST', + Uri.parse('https://api.faceonlive.com/j2y3q25y1b6maif1/api/iddoc')); + request.files.add(await http.MultipartFile.fromPath('image', image!.path)); + request.headers.addAll(headers); + + http.StreamedResponse response = await request.send(); + + if (response.statusCode == 200) { + String responseString = await response.stream.bytesToString(); + responseMap = jsonDecode(responseString); + if (responseMap['data'] != null && + responseMap['data']['image'] != null && + responseMap['data']['image']['portrait'] != null) { + imagePortrait = base64Decode(responseMap['data']['image']['portrait']); + String tempPath = Directory.systemTemp.path; + File tempFile = File('$tempPath/image.jpg'); + await tempFile.writeAsBytes(imagePortrait); + + imagePath = tempFile.path; + update(); + } else { + // Handle error or provide a default value + } + + if (responseMap['data']['image']['signature'] != null) { + imageSignature = + base64Decode(responseMap['data']['image']['signature']); + } else { + imageSignature = imagePortrait; + // Handle error or provide a default value + } + + if (responseMap['data'] != null && + responseMap['data']['image'] != null && + responseMap['data']['image']['documentFrontSide'] != null) { + imageDocumentFrontSide = + base64Decode(responseMap['data']['image']['documentFrontSide']); + } else { + // Handle error or provide a default value + } + + // print(responseMap); + isLoading = false; update(); - final imagePath = pickedImage.path; - final languages = [ - 'eng', - 'ara' - ]; // Specify the languages you want to use for text extraction - - try { - final text = await FlutterTesseractOcr.extractText(imagePath, - language: - languages.join('+'), // Combine multiple languages with '+' - args: { - "psm": "4", - "preserve_interword_spaces": "1", - // "rectangle": const Rect.fromLTWH(100, 100, 200, 200), - } // Additional options if needed - ); - isloading = false; - final jsonText = getTextAsJSON(text); - final textBlocks = getTextBlocks(text); - update(); - extractedText = - textBlocks.toString(); // Convert the extracted text to JSON. - -// Print the JSON to the console. - print(jsonText); - update(); - // print(text); - } catch (e) { - print('Error during text extraction: $e'); - extractedText = ''; - } + } else { + print(response.reasonPhrase); } } -} -class TextMLGoogleRecognizerController extends GetxController { - @override - void onInit() { - scanText(); - super.onInit(); - } - - // The ImagePicker instance - final ImagePicker _imagePicker = ImagePicker(); - - // The GoogleMlKit TextRecognizer instance - final TextRecognizer _textRecognizer = TextRecognizer(); - - // The scanned text - String? scannedText; - String? jsonOutput; - final List> lines = []; - - Map decode = {}; - - Future scanText() async { - // Pick an image from the camera or gallery - final XFile? image = - await _imagePicker.pickImage(source: ImageSource.gallery); - - // If no image was picked, return - if (image == null) { - return; - } - - // Convert the XFile object to an InputImage object - final InputImage inputImage = InputImage.fromFile(File(image.path)); - - // Recognize the text in the image - final RecognizedText recognizedText = - await _textRecognizer.processImage(inputImage); - scannedText = recognizedText.text; - Map extractedData = {}; - // Extract the scanned text line by line - for (var i = 0; i < recognizedText.blocks.length; i++) { - final block = recognizedText.blocks[i]; - for (final line in block.lines) { - final lineText = line.text; - - if (lineText.contains('DL')) { - final dlNumber = lineText.split('DL')[1].trim(); - extractedData['dl_number'] = dlNumber; - } - if (lineText.contains('USA')) { - final usa = lineText.split('USA')[1].trim(); - extractedData['USA'] = usa; - } - if (lineText.contains('DRIVER LICENSE')) { - final driverl = lineText; - extractedData['DRIVER_LICENSE'] = driverl; - } - - if (lineText.contains('EXP')) { - final expiryDate = lineText.split('EXP')[1].trim(); - extractedData['expiry_date'] = expiryDate; - } - - if (lineText.contains('DOB')) { - final dob = lineText.split('DOB')[1].trim(); - extractedData['dob'] = dob; - } - - if (lineText.contains("LN")) { - if ((lineText.indexOf("LN") == 0)) { - final lastName = lineText.split('LN')[1].trim(); - extractedData['lastName'] = lastName; - } - } - if (lineText.contains("FN")) { - final firstName = lineText.split('FN')[1].trim(); - extractedData['firstName'] = firstName; - } - if (lineText.contains("RSTR")) { - final rstr = lineText.split('RSTR')[1].trim(); - extractedData['rstr'] = rstr; - } - if (lineText.contains("CLASS")) { - final class1 = lineText.split('CLASS')[1].trim(); - extractedData['class'] = class1; - } - if (lineText.contains("END")) { - final end = lineText.split('END')[1].trim(); - extractedData['end'] = end; - } - if (lineText.contains("DD")) { - final dd = lineText.split('DD')[1].trim(); - extractedData['dd'] = dd; - } - if (lineText.contains("EYES")) { - final eyes = lineText.split('EYES')[1].trim(); - extractedData['eyes'] = eyes; - } - if (lineText.contains("SEX")) { - final parts = lineText.split("SEX ")[1]; - extractedData['sex'] = parts[0]; - } - if (lineText.contains("HAIR")) { - final hair = lineText.split('HAIR')[1].trim(); - extractedData['hair'] = hair; - } - - if (lineText.contains('STREET') || lineText.contains(',')) { - final address = lineText; - extractedData['address'] = address; - } - - // Repeat this process for other relevant data fields - } - } - - // Convert the list of lines to a JSON string - jsonOutput = jsonEncode(extractedData); - decode = jsonDecode(jsonOutput!); - - update(); - print('jsonOutput------------------------------'); - print(scannedText); - } -} - -class PassportRecognizerController extends GetxController { - @override - void onInit() { - scanText(); - super.onInit(); - } - - // The ImagePicker instance - final ImagePicker _imagePicker = ImagePicker(); - Map extractedData = {}; - - // The GoogleMlKit TextRecognizer instance - final TextRecognizer _textRecognizer = TextRecognizer(); - - // The scanned text - String? scannedText; - String? jsonOutput; - final List> lines = []; - - Map decode = {}; - // Picks an image from the camera or gallery and extracts the text - - Future scanText() async { - // Pick an image from the camera or gallery - final XFile? image = - await _imagePicker.pickImage(source: ImageSource.gallery); - - // If no image was picked, return - if (image == null) { - return; - } - - // Convert the XFile object to an InputImage object - final InputImage inputImage = InputImage.fromFile(File(image.path)); - - // Recognize the text in the image - final RecognizedText recognizedText = - await _textRecognizer.processImage(inputImage); - scannedText = recognizedText.text; - // Extract the scanned text line by line - final List> lines = []; - for (var i = 0; i < recognizedText.blocks.length; i++) { - lines.add({ - i.toString() + - '_' + - recognizedText.blocks[i].text.toString().split('\n')[0]: - recognizedText.blocks[i].text, - }); - } - // for (var i = 0; i < recognizedText.blocks.length; i++) { - // final block = recognizedText.blocks[i]; - for (final line in lines) { - final key = line.keys.first; - final value = line.values.first; - if (line.values.contains('UNITED STATES OF')) { - final title = line; - extractedData['title'] = title; - } - if (line.values.contains('PASSPORT CARD')) { - final passport = line; - extractedData['passport'] = passport; - } - if (key == "7_Surname") { - final nextItem = lines[lines.indexOf(line) + 1]; - extractedData['surname'] = nextItem.values.first; - } - if (key == "6_Nationality") { - var nationality = value.split('\n')[1]; - extractedData['nationality'] = nationality; - } - if (key.contains('CARD')) { - var passportCard = value; - extractedData['passportCard'] = passportCard; - } - if (key.contains("9_Given")) { - var givenNames = value.split('\n')[1]; - extractedData['givenNames'] = givenNames; - } - if (key.contains("13_Date of Birth")) { - final parts = value.split('\n'); - if (parts.length > 1) { - var dateOfBirth = parts[1]; - extractedData['dateOfBirth'] = dateOfBirth; - - var sex = parts[0].split(' ')[1]; - extractedData['sex'] = sex; - } - } - - // } - } - - // Convert the list of lines to a JSON string - jsonOutput = jsonEncode(extractedData); - decode = jsonDecode(jsonOutput!); - - update(); - print('jsonOutput------------------------------'); - print(decode); - // print(jsonEncode(lines)); - } -} - -class PassportDataExtractor extends GetxController { - @override - void onInit() { - extractPassportData(); - super.onInit(); - } - - final ImagePicker _imagePicker = ImagePicker(); - late final XFile? image; - final TextRecognizer _textRecognizer = TextRecognizer(); - - Future> extractPassportData() async { - image = await _imagePicker.pickImage(source: ImageSource.gallery); - update(); - if (image == null) { - throw Exception('No image picked'); - } - - final InputImage inputImage = InputImage.fromFile(File(image!.path)); - final RecognizedText recognisedText = - await _textRecognizer.processImage(inputImage); - - final Map extractedData = {}; - final List> extractedTextWithCoordinates = []; - - for (TextBlock block in recognisedText.blocks) { - for (TextLine line in block.lines) { - final String lineText = line.text; - final Rect lineBoundingBox = line.boundingBox!; - - extractedTextWithCoordinates.add({ - 'text': lineText, - 'boundingBox': { - 'left': lineBoundingBox.left, - 'top': lineBoundingBox.top, - 'width': lineBoundingBox.width, - 'height': lineBoundingBox.height, - }, + late int times; + Future checkMatchFaceApi() async { + sql.getAllData(TableName.faceDetectTimes).then((value) { + if (value.isEmpty || value == null) { + sql.insertData({'faceDetectTimes': 1}, TableName.faceDetectTimes); + sql.getAllData(TableName.faceDetectTimes).then((value) { + times = value[0]['faceDetectTimes']; + update(); }); + } else { + if (times < 4) { + times++; - // if (lineText.contains('Passport Number')) { - // final String passportNumber = - // lineText.split('Passport Number')[1].trim(); - // extractedData['passportNumber'] = passportNumber; - // } - // if (lineText.contains('Given Names')) { - // final String givenNames = lineText.split('Given Names')[1].trim(); - // extractedData['givenNames'] = givenNames; - // } - // if (lineText.contains('Surname')) { - // final String surname = lineText.split('Surname')[1].trim(); - // extractedData['surname'] = surname; - // } - // if (lineText.contains('Nationality')) { - // final String nationality = lineText.split('Nationality')[1].trim(); - // extractedData['nationality'] = nationality; - // } - // if (lineText.contains('Date of Birth')) { - // final String dob = lineText.split('Date of Birth')[1].trim(); - // extractedData['dateOfBirth'] = dob; - // } - // Add more field extraction conditions as needed + sql.updateData( + {'faceDetectTimes': times}, TableName.faceDetectTimes, 1); + matchFaceApi(); + } else { + Get.defaultDialog( + barrierDismissible: false, + title: 'You have finished all times '.tr, + titleStyle: AppStyle.title, + middleText: 'if you want help you can email us here'.tr, + middleTextStyle: AppStyle.title, + cancel: MyElevatedButton( + title: 'Thanks', + kolor: AppColor.greenColor, + onPressed: () => Get.back(), + ), + confirm: MyElevatedButton( + title: 'Email Us', + kolor: AppColor.yellowColor, // + onPressed: () { + launchCommunication('email', 'support@mobile-app.store', + 'Hi ${AppInformation.appName}\nI cant register in your app in face detection '); + Get.back(); + }, + )); + } } - } - - extractedData['extractedTextWithCoordinates'] = - extractedTextWithCoordinates; - print(jsonEncode(extractedData)); - return extractedData; + }); } -} -class PassportDataController extends GetxController { - PassportDataExtractor passportDataExtractor = PassportDataExtractor(); - List> extractedTextWithCoordinates = []; + Map res = {}; + Future matchFaceApi() async { + imageFace = await imagePicker.pickImage( + source: ImageSource.camera, + preferredCameraDevice: CameraDevice.front, + ); - Future extractDataAndDrawBoundingBoxes() async { - try { - Map extractedData = - await passportDataExtractor.extractPassportData(); - extractedTextWithCoordinates = - extractedData['extractedTextWithCoordinates']; - update(); // Notify GetX that the state has changed - print(extractedTextWithCoordinates); - } catch (e) { - print('Passport data extraction failed: $e'); + // If no image was picked, return + if (image == null) { + return; } - } -} + final imageFile = File(imageFace!.path); + // Uint8List imageBytes = await imageFile.readAsBytes(); + var headers = {'X-BLOBR-KEY': AppCredintials.visionApi}; + var request = http.MultipartRequest( + 'POST', + Uri.parse( + 'https://api.faceonlive.com/sntzbspfsdupgid1/api/face_compare')); + request.files + .add(await http.MultipartFile.fromPath('image1', imageFace!.path)); + request.files.add(await http.MultipartFile.fromPath('image2', imagePath)); + request.headers.addAll(headers); -class BoundingBoxPainter extends CustomPainter { - final List> boundingBoxes; + http.StreamedResponse response = await request.send(); + print('Request: ${request.toString()}'); + print('Response Status Code: ${response.statusCode}'); + print('Response Reason Phrase: ${response.reasonPhrase}'); - BoundingBoxPainter(this.boundingBoxes); + if (response.statusCode == 200) { + res = jsonDecode(await response.stream.bytesToString()); + print(res); - @override - void paint(Canvas canvas, Size size) { - final Paint paint = Paint() - ..color = Colors.red - ..style = PaintingStyle.stroke - ..strokeWidth = 2.0; - - for (Map boundingBox in boundingBoxes) { - double left = boundingBox['left']; - double top = boundingBox['top']; - double width = boundingBox['width']; - double height = boundingBox['height']; - - Rect rect = Rect.fromLTWH(left, top, width, height); - canvas.drawRect(rect, paint); + update(); + res['data']['result'].toString() == 'No face detected in image2' + ? Get.defaultDialog( + barrierDismissible: false, + title: 'No face detected'.tr, + titleStyle: AppStyle.title, + confirm: MyElevatedButton( + kolor: AppColor.yellowColor, + title: 'Back'.tr, + onPressed: () { + Get.back(); + }, + )) + : Get.defaultDialog( + barrierDismissible: false, + title: 'Image detecting result is '.tr, + titleStyle: AppStyle.title, + content: Column( + children: [ + Text( + res['data']['result'].toString(), + style: res['data']['result'].toString() == 'Different' + ? AppStyle.title.copyWith(color: AppColor.redColor) + : AppStyle.title.copyWith(color: AppColor.greenColor), + ), + res['data']['result'].toString() == 'Different' + ? Text( + 'Be sure for take accurate images please\nYou have $times from 3 times Take Attention' + .tr, + style: AppStyle.title, + ) + : Text( + 'image verified'.tr, + style: AppStyle.title, + ) + ], + ), + confirm: res['data']['result'].toString() == 'Different' + ? MyElevatedButton( + title: 'Back'.tr, + onPressed: () => Get.back(), + kolor: AppColor.redColor, + ) + : MyElevatedButton( + title: 'Next'.tr, + onPressed: () => Get.to(() => CarLicensePage()), + kolor: AppColor.greenColor, + )); + } else { + print(response.reasonPhrase); } } @override - bool shouldRepaint(covariant CustomPainter oldDelegate) { - return false; + void onInit() { + // scanDocumentsByApi(); + sql.getAllData(TableName.faceDetectTimes).then((value) { + if (value.isEmpty || value == null) { + print(value); + times = 0; + print(times); + update(); + // sql.insertData({'faceDetectTimes': 1}, TableName.faceDetectTimes); + } else { + times = value[0]['faceDetectTimes']; + } + }); + super.onInit(); } } +// +// class PassportRecognizerController extends GetxController { +// @override +// void onInit() { +// scanText(); +// super.onInit(); +// } +// +// // The ImagePicker instance +// final ImagePicker _imagePicker = ImagePicker(); +// Map extractedData = {}; +// +// // The GoogleMlKit TextRecognizer instance +// final TextRecognizer _textRecognizer = TextRecognizer(); +// +// // The scanned text +// String? scannedText; +// String? jsonOutput; +// final List> lines = []; +// +// Map decode = {}; +// // Picks an image from the camera or gallery and extracts the text +// +// Future scanText() async { +// // Pick an image from the camera or gallery +// final XFile? image = +// await _imagePicker.pickImage(source: ImageSource.gallery); +// +// // If no image was picked, return +// if (image == null) { +// return; +// } +// +// // Convert the XFile object to an InputImage object +// final InputImage inputImage = InputImage.fromFile(File(image.path)); +// +// // Recognize the text in the image +// final RecognizedText recognizedText = +// await _textRecognizer.processImage(inputImage); +// scannedText = recognizedText.text; +// // Extract the scanned text line by line +// final List> lines = []; +// for (var i = 0; i < recognizedText.blocks.length; i++) { +// lines.add({ +// i.toString() + +// '_' + +// recognizedText.blocks[i].text.toString().split('\n')[0]: +// recognizedText.blocks[i].text, +// }); +// } +// // for (var i = 0; i < recognizedText.blocks.length; i++) { +// // final block = recognizedText.blocks[i]; +// for (final line in lines) { +// final key = line.keys.first; +// final value = line.values.first; +// if (line.values.contains('UNITED STATES OF')) { +// final title = line; +// extractedData['title'] = title; +// } +// if (line.values.contains('PASSPORT CARD')) { +// final passport = line; +// extractedData['passport'] = passport; +// } +// if (key == "7_Surname") { +// final nextItem = lines[lines.indexOf(line) + 1]; +// extractedData['surname'] = nextItem.values.first; +// } +// if (key == "6_Nationality") { +// var nationality = value.split('\n')[1]; +// extractedData['nationality'] = nationality; +// } +// if (key.contains('CARD')) { +// var passportCard = value; +// extractedData['passportCard'] = passportCard; +// } +// if (key.contains("9_Given")) { +// var givenNames = value.split('\n')[1]; +// extractedData['givenNames'] = givenNames; +// } +// if (key.contains("13_Date of Birth")) { +// final parts = value.split('\n'); +// if (parts.length > 1) { +// var dateOfBirth = parts[1]; +// extractedData['dateOfBirth'] = dateOfBirth; +// +// var sex = parts[0].split(' ')[1]; +// extractedData['sex'] = sex; +// } +// } +// +// // } +// } +// +// // Convert the list of lines to a JSON string +// jsonOutput = jsonEncode(extractedData); +// decode = jsonDecode(jsonOutput!); +// +// update(); +// print('jsonOutput------------------------------'); +// print(decode); +// // print(jsonEncode(lines)); +// } +// } +// +// class PassportDataExtractor extends GetxController { +// @override +// void onInit() { +// extractPassportData(); +// super.onInit(); +// } +// +// final ImagePicker _imagePicker = ImagePicker(); +// late final XFile? image; +// final TextRecognizer _textRecognizer = TextRecognizer(); +// +// Future> extractPassportData() async { +// image = await _imagePicker.pickImage(source: ImageSource.gallery); +// update(); +// if (image == null) { +// throw Exception('No image picked'); +// } +// +// final InputImage inputImage = InputImage.fromFile(File(image!.path)); +// final RecognizedText recognisedText = +// await _textRecognizer.processImage(inputImage); +// +// final Map extractedData = {}; +// final List> extractedTextWithCoordinates = []; +// +// for (TextBlock block in recognisedText.blocks) { +// for (TextLine line in block.lines) { +// final String lineText = line.text; +// final Rect lineBoundingBox = line.boundingBox!; +// +// extractedTextWithCoordinates.add({ +// 'text': lineText, +// 'boundingBox': { +// 'left': lineBoundingBox.left, +// 'top': lineBoundingBox.top, +// 'width': lineBoundingBox.width, +// 'height': lineBoundingBox.height, +// }, +// }); +// +// // if (lineText.contains('Passport Number')) { +// // final String passportNumber = +// // lineText.split('Passport Number')[1].trim(); +// // extractedData['passportNumber'] = passportNumber; +// // } +// // if (lineText.contains('Given Names')) { +// // final String givenNames = lineText.split('Given Names')[1].trim(); +// // extractedData['givenNames'] = givenNames; +// // } +// // if (lineText.contains('Surname')) { +// // final String surname = lineText.split('Surname')[1].trim(); +// // extractedData['surname'] = surname; +// // } +// // if (lineText.contains('Nationality')) { +// // final String nationality = lineText.split('Nationality')[1].trim(); +// // extractedData['nationality'] = nationality; +// // } +// // if (lineText.contains('Date of Birth')) { +// // final String dob = lineText.split('Date of Birth')[1].trim(); +// // extractedData['dateOfBirth'] = dob; +// // } +// // Add more field extraction conditions as needed +// } +// } +// +// extractedData['extractedTextWithCoordinates'] = +// extractedTextWithCoordinates; +// print(jsonEncode(extractedData)); +// return extractedData; +// } +// } +// +// class PassportDataController extends GetxController { +// PassportDataExtractor passportDataExtractor = PassportDataExtractor(); +// List> extractedTextWithCoordinates = []; +// +// Future extractDataAndDrawBoundingBoxes() async { +// try { +// Map extractedData = +// await passportDataExtractor.extractPassportData(); +// extractedTextWithCoordinates = +// extractedData['extractedTextWithCoordinates']; +// update(); // Notify GetX that the state has changed +// print(extractedTextWithCoordinates); +// } catch (e) { +// print('Passport data extraction failed: $e'); +// } +// } +// } +// +// class BoundingBoxPainter extends CustomPainter { +// final List> boundingBoxes; +// +// BoundingBoxPainter(this.boundingBoxes); +// +// @override +// void paint(Canvas canvas, Size size) { +// final Paint paint = Paint() +// ..color = Colors.red +// ..style = PaintingStyle.stroke +// ..strokeWidth = 2.0; +// +// for (Map boundingBox in boundingBoxes) { +// double left = boundingBox['left']; +// double top = boundingBox['top']; +// double width = boundingBox['width']; +// double height = boundingBox['height']; +// +// Rect rect = Rect.fromLTWH(left, top, width, height); +// canvas.drawRect(rect, paint); +// } +// } +// +// @override +// bool shouldRepaint(covariant CustomPainter oldDelegate) { +// return false; +// } +// } diff --git a/lib/controller/home/captin/home_captain_controller.dart b/lib/controller/home/captin/home_captain_controller.dart index 34c7cfc..2194eef 100644 --- a/lib/controller/home/captin/home_captain_controller.dart +++ b/lib/controller/home/captin/home_captain_controller.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:get/get.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:ride/constant/box_name.dart'; import 'dart:async'; @@ -15,13 +16,24 @@ class HomeCaptainController extends GetxController { Duration activeDuration = Duration.zero; Timer? activeTimer; Map data = {}; + bool isLoading = true; String totalMoneyToday = '0'; String totalMoneyInSEFER = '0'; String totalDurationToday = '0'; Timer? timer; + bool mapType = false; + bool mapTrafficON = false; + double widthMapTypeAndTraffic = 50; // Inject the LocationController class - final locationController = Get.find(); + final locationController = Get.put(LocationController()); + String formatDuration(Duration duration) { + String twoDigits(int n) => n.toString().padLeft(2, "0"); + String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60)); + String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60)); + return "${duration.inHours}:$twoDigitMinutes:$twoDigitSeconds"; + } + String stringActiveDuration = ''; void onButtonSelected() { isActive = !isActive; if (isActive) { @@ -29,6 +41,7 @@ class HomeCaptainController extends GetxController { activeStartTime = DateTime.now(); activeTimer = Timer.periodic(const Duration(seconds: 1), (timer) { activeDuration = DateTime.now().difference(activeStartTime!); + stringActiveDuration = formatDuration(activeDuration); update(); }); } else { @@ -42,6 +55,27 @@ class HomeCaptainController extends GetxController { update(); } + void changeMapType() { + mapType = !mapType; + // heightButtomSheetShown = isButtomSheetShown == true ? 240 : 0; + update(); + } + + void changeMapTraffic() { + mapTrafficON = !mapTrafficON; + update(); + } + + GoogleMapController? mapHomeCaptaiController; + void onMapCreated(GoogleMapController controller) { + mapHomeCaptaiController = controller; + controller.getVisibleRegion(); + controller.animateCamera( + CameraUpdate.newLatLng(locationController.myLocation), + ); + update(); + } + void savePeriod(Duration period) { final periods = box.read>(BoxName.periods) ?? []; periods.add(period.inSeconds); @@ -72,7 +106,9 @@ class HomeCaptainController extends GetxController { @override void onInit() async { addToken(); + onButtonSelected(); getPaymentToday(); + getAllPayment(); startPeriodicExecution(); super.onInit(); } @@ -91,6 +127,16 @@ class HomeCaptainController extends GetxController { payload: {'driverID': box.read(BoxName.driverID).toString()}); data = jsonDecode(res); totalMoneyToday = data['message'][0]['todayAmount']; + + update(); + } + + getAllPayment() async { + var res = await CRUD().get( + link: AppLink.getAllPayment, + payload: {'driverID': box.read(BoxName.driverID).toString()}); + data = jsonDecode(res); + totalMoneyInSEFER = data['message'][0]['total_amount']; update(); } diff --git a/lib/controller/home/captin/widget/left_menu_map_captain.dart b/lib/controller/home/captin/widget/left_menu_map_captain.dart new file mode 100644 index 0000000..c780f26 --- /dev/null +++ b/lib/controller/home/captin/widget/left_menu_map_captain.dart @@ -0,0 +1,75 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_font_icons/flutter_font_icons.dart'; +import 'package:get/get.dart'; +import 'package:ride/controller/home/captin/home_captain_controller.dart'; + +import '../../../../constant/colors.dart'; +import '../../../../views/Rate/ride_calculate_driver.dart'; + +GetBuilder leftMainMenuCaptainIcons() { + return GetBuilder( + builder: (controller) => Positioned( + bottom: Get.height * .17, + left: 6, + child: Column( + children: [ + AnimatedContainer( + duration: const Duration(microseconds: 200), + width: controller.widthMapTypeAndTraffic, + decoration: BoxDecoration( + border: Border.all(), + color: AppColor.secondaryColor, + borderRadius: BorderRadius.circular(15)), + child: IconButton( + onPressed: () { + controller.changeMapType(); + // Toast.show(context, 'This is a toast message!'); + }, + icon: const Icon( + Icons.satellite_alt, + size: 29, + ), + ), + ), + const SizedBox( + height: 5, + ), + 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.changeMapTraffic(); + // Toast.show(context, 'This is a toast message!'); + }, + icon: const Icon( + Icons.streetview_sharp, + size: 29, + ), + ), + ), + const SizedBox( + height: 5, + ), + AnimatedContainer( + duration: const Duration(microseconds: 200), + width: controller.widthMapTypeAndTraffic, + decoration: BoxDecoration( + color: AppColor.secondaryColor, + border: Border.all(), + borderRadius: BorderRadius.circular(15)), + child: IconButton( + onPressed: () { + Get.to(() => const RideCalculateDriver()); + }, + icon: const Icon(FontAwesome5.chart_bar), + ), + ), + ], + )), + ); +} diff --git a/lib/controller/home/splash_screen_controlle.dart b/lib/controller/home/splash_screen_controlle.dart index d867b2b..e282c90 100644 --- a/lib/controller/home/splash_screen_controlle.dart +++ b/lib/controller/home/splash_screen_controlle.dart @@ -52,7 +52,7 @@ class SplashScreenController extends GetxController : box.read(BoxName.emailDriver) == null ? Get.off(() => LoginPage()) : box.read(BoxName.emailDriver) != null - ? Get.off(() => const HomeCaptain()) + ? Get.off(() => HomeCaptain()) : Get.off(() => LoginCaptin()); }); } diff --git a/lib/controller/rate/rate_conroller.dart b/lib/controller/rate/rate_conroller.dart index fc1c560..f79dd23 100644 --- a/lib/controller/rate/rate_conroller.dart +++ b/lib/controller/rate/rate_conroller.dart @@ -10,7 +10,7 @@ import 'package:ride/views/home/Captin/home_captin.dart'; import 'package:ride/views/home/map_page.dart'; import 'package:ride/views/widgets/elevated_btn.dart'; -import '../home/captin/home_captain_controller.dart'; +// import '../home/captin/home_captain_controller.dart'; class RateController extends GetxController { double selectedRateItemId = -1; @@ -33,8 +33,8 @@ class RateController extends GetxController { } void addRateToPassenger() async { - HomeCaptainController homeCaptainController = - Get.find(); + // HomeCaptainController homeCaptainController = + // Get.find(); if (selectedRateItemId < 1) { Get.defaultDialog( title: 'You Should choose rate figure'.tr, @@ -49,9 +49,10 @@ class RateController extends GetxController { 'rating': selectedRateItemId.toString(), 'comment': comment.text, }); - Get.offAll(const HomeCaptain()); - homeCaptainController.isActive = true; - homeCaptainController.getPaymentToday(); + // homeCaptainController.isActive = true; + // update(); + // homeCaptainController.getPaymentToday(); + Get.offAll(HomeCaptain()); } } diff --git a/lib/models/db_sql.dart b/lib/models/db_sql.dart index 8b384a1..5307457 100644 --- a/lib/models/db_sql.dart +++ b/lib/models/db_sql.dart @@ -48,6 +48,12 @@ class DbSql { driver_id TEXT ) '''); + await db.execute(''' + CREATE TABLE IF NOT EXISTS ${TableName.faceDetectTimes}( + id INTEGER PRIMARY KEY AUTOINCREMENT, + faceDetectTimes INTEGER + ) + '''); }, ); } diff --git a/lib/views/auth/captin/ai_page.dart b/lib/views/auth/captin/ai_page.dart new file mode 100644 index 0000000..56c260f --- /dev/null +++ b/lib/views/auth/captin/ai_page.dart @@ -0,0 +1,257 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:ride/constant/colors.dart'; +import 'package:ride/constant/style.dart'; +import 'package:ride/constant/table_names.dart'; +import 'package:ride/controller/functions/ocr_controller.dart'; +import 'package:ride/main.dart'; +import 'package:ride/views/auth/captin/car_license_page.dart'; +import 'package:ride/views/widgets/elevated_btn.dart'; +import 'package:ride/views/widgets/my_scafold.dart'; +import 'package:ride/views/widgets/mycircular.dart'; + +class AiPage extends StatelessWidget { + ScanDocumentsByApi scanDocumentsByApi = Get.put(ScanDocumentsByApi()); + + AiPage({super.key}); + @override + Widget build(BuildContext context) { + return MyScafolld( + title: 'AI Page'.tr, + body: [ + Positioned( + top: 3, + left: Get.width * .2, + right: Get.width * .2, + child: MyElevatedButton( + title: 'Take Picture Of ID Card'.tr, + onPressed: () { + scanDocumentsByApi.scanDocumentsByApi(); + }, + )), + 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 * .35, + 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 :${scanDocumentsByApi.responseMap['data']['ocr']['name'].toString()}', + style: AppStyle.subtitle, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + 'Drivers License Class: ${scanDocumentsByApi.responseMap['data']['ocr']['dlClass'].toString()}', + style: AppStyle.title, + ), + Image.memory( + scanDocumentsByApi + .imageSignature, + width: 100, + height: 30, + ), + ], + ), + ], + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + 'Document Number: ${scanDocumentsByApi.responseMap['data']['ocr']['documentNumber'].toString()}', + style: AppStyle.title, + ), + Image.memory( + scanDocumentsByApi + .imagePortrait, + width: 60, + ), + ]), + Text( + 'Address: ${scanDocumentsByApi.responseMap['data']['ocr']['address'].toString()}', + style: AppStyle.title, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + 'Height: ${scanDocumentsByApi.responseMap['data']['ocr']['height'].toString()}', + style: AppStyle.subtitle, + ), + Text( + 'Postal Code: ${scanDocumentsByApi.responseMap['data']['ocr']['addressPostalCode'].toString()}', + style: AppStyle.subtitle, + ), + Text( + 'Sex: ${scanDocumentsByApi.responseMap['data']['ocr']['sex'].toString()}', + style: AppStyle.subtitle, + ), + ], + ), + Text( + 'Jurisdiction Code: ${scanDocumentsByApi.responseMap['data']['ocr']['addressJurisdictionCode'].toString()}', + style: AppStyle.subtitle, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + 'Expiry Date: ${scanDocumentsByApi.responseMap['data']['ocr']['dateOfExpiry'].toString()}', + 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: ${scanDocumentsByApi.responseMap['data']['ocr']['dateOfBirth'].toString()}', + 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: () => + Get.to(() => CarLicensePage()), + title: + 'Go to next step\nscan Car License.' + .tr, + kolor: AppColor.greenColor, + ) + : const SizedBox(), + MyElevatedButton( + title: 'title', + 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, + ), + )), + ), + ], + ), + ), + ), + ], + isleading: true); + } +} diff --git a/lib/views/auth/captin/car_license_page.dart b/lib/views/auth/captin/car_license_page.dart new file mode 100644 index 0000000..58dea7e --- /dev/null +++ b/lib/views/auth/captin/car_license_page.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:ride/views/widgets/my_scafold.dart'; + +import '../../../controller/functions/ocr_controller.dart'; +import '../../widgets/elevated_btn.dart'; + +class CarLicensePage extends StatelessWidget { + CarLicensePage({super.key}); + ScanDocumentsByApi scanDocumentsByApi = Get.put(ScanDocumentsByApi()); + + @override + Widget build(BuildContext context) { + return MyScafolld( + title: 'Car License Card'.tr, + body: [ + Positioned( + top: 3, + left: Get.width * .2, + right: Get.width * .2, + child: MyElevatedButton( + title: 'Take Picture Of ID Card'.tr, + onPressed: () { + scanDocumentsByApi.scanDocumentsByApi(); + }, + )), + ], + isleading: true); + } +} diff --git a/lib/views/auth/captin/login_captin.dart b/lib/views/auth/captin/login_captin.dart index 0728a6a..218b540 100644 --- a/lib/views/auth/captin/login_captin.dart +++ b/lib/views/auth/captin/login_captin.dart @@ -171,7 +171,7 @@ class LoginCaptin extends StatelessWidget { ), )), Text( - 'if you dont have account'.tr, + 'if you don\'t have account'.tr, style: AppStyle.subtitle, ), AnimatedTextKit( diff --git a/lib/views/auth/captin/register_captin.dart b/lib/views/auth/captin/register_captin.dart index 6c8c2a5..2884378 100644 --- a/lib/views/auth/captin/register_captin.dart +++ b/lib/views/auth/captin/register_captin.dart @@ -7,6 +7,7 @@ import 'package:ride/views/widgets/my_scafold.dart'; import 'package:ride/views/widgets/mycircular.dart'; import '../../../constant/colors.dart'; +import 'ai_page.dart'; class RegisterCaptin extends StatelessWidget { const RegisterCaptin({super.key}); @@ -272,10 +273,13 @@ class RegisterCaptin extends StatelessWidget { ) ], ), + MyElevatedButton( + title: 'Next'.tr, + onPressed: () => Get.to(() => AiPage())), controller.isloading ? const MyCircularProgressIndicator() : MyElevatedButton( - title: 'Register Captin'.tr, + title: 'Register Captain'.tr, onPressed: () => controller.register()) ]), ), diff --git a/lib/views/auth/verify_email_page.dart b/lib/views/auth/verify_email_page.dart index 668e6a4..fb40eb7 100644 --- a/lib/views/auth/verify_email_page.dart +++ b/lib/views/auth/verify_email_page.dart @@ -52,7 +52,7 @@ class VerifyEmailPage extends StatelessWidget { ), MyElevatedButton( title: 'Send Verfication Code'.tr, - onPressed: () => controller.sendverfications()) + onPressed: () => controller.sendVerifications()) ], ), ), diff --git a/lib/views/home/Captin/bottom_bar.dart b/lib/views/home/Captin/bottom_bar.dart index e2ff554..b197946 100644 --- a/lib/views/home/Captin/bottom_bar.dart +++ b/lib/views/home/Captin/bottom_bar.dart @@ -1,6 +1,8 @@ +import 'package:chat_gpt_flutter/chat_gpt_flutter.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:ride/constant/colors.dart'; +import 'package:ride/constant/credential.dart'; class BottomBarController extends GetxController { var currentIndex = 0.obs; @@ -23,11 +25,11 @@ class HomeScreen extends StatelessWidget { ), body: Obx(() => IndexedStack( index: controller.currentIndex.value, - children: const [ - HomeView(), - ProfileView(), - StatisticsView(), - WalletView(), + children: [ + HomeView(chatGpt: ChatGpt(apiKey: AppCredintials.chatGPTkey)), + const ProfileView(), + const StatisticsView(), + const WalletView(), ], )), bottomNavigationBar: Obx(() => BottomNavigationBar( @@ -70,12 +72,17 @@ class HomeScreen extends StatelessWidget { } class HomeView extends StatelessWidget { - const HomeView({super.key}); - + const HomeView({super.key, required this.chatGpt}); + final ChatGpt chatGpt; @override Widget build(BuildContext context) { - return const Center( - child: Text('Home View'), + Map data; + return Center( + child: Column( + children: [ + Text('Home View'), + ], + ), ); } } diff --git a/lib/views/home/Captin/camer_widget.dart b/lib/views/home/Captin/camer_widget.dart index 60f1c6c..a1a2a94 100644 --- a/lib/views/home/Captin/camer_widget.dart +++ b/lib/views/home/Captin/camer_widget.dart @@ -169,9 +169,7 @@ class CameraWidgetCardId extends StatelessWidget { onPressed: () => cameraClassController.takePictureAndMLGoogleScan()), MyElevatedButton( - title: 'Scan ID Tesseract'.tr, - onPressed: () => - cameraClassController.takePictureAndTesseractScan()), + title: 'Scan ID Tesseract'.tr, onPressed: () {}), ], ), MyElevatedButton( @@ -289,9 +287,7 @@ class CameraWidgetPassPort extends StatelessWidget { onPressed: () => cameraClassController.takePictureAndMLGoogleScan()), MyElevatedButton( - title: 'Scan ID Tesseract'.tr, - onPressed: () => - cameraClassController.takePictureAndTesseractScan()), + title: 'Scan ID Tesseract'.tr, onPressed: () {}), ], ), MyElevatedButton( diff --git a/lib/views/home/Captin/home_captin.dart b/lib/views/home/Captin/home_captin.dart index 61abffc..920ce31 100644 --- a/lib/views/home/Captin/home_captin.dart +++ b/lib/views/home/Captin/home_captin.dart @@ -1,13 +1,13 @@ -import 'package:camera/camera.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:ride/constant/colors.dart'; import 'package:ride/constant/info.dart'; import 'package:ride/constant/style.dart'; import 'package:ride/constant/table_names.dart'; -import 'package:ride/controller/functions/camer_controller.dart'; import 'package:ride/controller/home/captin/home_captain_controller.dart'; import 'package:ride/controller/home/captin/order_request_controller.dart'; +import 'package:ride/controller/home/captin/widget/left_menu_map_captain.dart'; import 'package:ride/controller/payment/payment_controller.dart'; import 'package:ride/main.dart'; import 'package:ride/views/Rate/ride_calculate_driver.dart'; @@ -19,21 +19,24 @@ import 'package:ride/views/widgets/elevated_btn.dart'; import 'package:flutter_font_icons/flutter_font_icons.dart'; import '../../../controller/functions/location_controller.dart'; -import '../../../controller/functions/ocr_controller.dart'; import '../../../controller/home/captin/widget/connect.dart'; +import '../../widgets/mycircular.dart'; import 'passportimage.dart'; class HomeCaptain extends StatelessWidget { - const HomeCaptain({super.key}); - + HomeCaptain({super.key}); + final LocationController locationController = LocationController(); + // final HomeCaptainController homeCaptainController = HomeCaptainController(); +// final LocationController locationController=LocationController(); @override Widget build(BuildContext context) { - Get.put(LocationController()); Get.put(OrderRequestController()); Get.put(HomeCaptainController()); + // Get.put(HomeCaptainController()); return Scaffold( appBar: AppBar( - backgroundColor: AppColor.blueColor, + backgroundColor: AppColor.greenColor, + elevation: 0, title: Text('Captain Home'.tr), actions: [ GetBuilder( @@ -71,212 +74,208 @@ class HomeCaptain extends StatelessWidget { ], ), ), - body: Column( + body: Stack( children: [ - GetBuilder( - builder: (locationController) => Column( - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '${locationController.myLocation}', - style: AppStyle.subtitle, - ), - Text( - '${DateTime.now()}', - style: AppStyle.subtitle, - ) - ], - ), - ), - // TextButton( - // onPressed: () { - // MyClass().exampleUsage(); - // }, - // child: Text( - // "Text Button", - // ), - // ), - ], - )), - const ConnectWidget(), - const SizedBox( - height: 10, - ), GetBuilder( - builder: (homeCaptainController) => Container( - decoration: AppStyle.boxDecoration, - width: Get.width * .8, - height: 80, - child: Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Icon( - Entypo.wallet, - color: AppColor.greenColor, - ), - Text( - ' You Earn today is '.tr + - homeCaptainController.totalMoneyToday, - style: AppStyle.title, - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Icon( - Entypo.loop, - color: AppColor.yellowColor, - ), - Text( - ' You Have in ${AppInformation.appName} '.tr + - homeCaptainController.totalMoneyInSEFER, - style: AppStyle.title, - ), - ], - ), - ], - ))), - ), - GetBuilder( - builder: (homeCaptainController) => Column( - children: [ - Text( - 'Active Duration:'.tr + - ' ${homeCaptainController.activeDuration.inSeconds} seconds', - style: const TextStyle(fontSize: 20), - ), - Text( - 'Total Duration:'.tr + - ' ${homeCaptainController.totalDurationToday} ', - style: const TextStyle(fontSize: 20), - ), - TextButton( - onPressed: () { - Get.to(() => const RideCalculateDriver()); - }, - child: const Text('Chart')), - const Wrap( - children: [ - Icon(AntDesign.facebook_square), - Icon(AntDesign.wallet), - Icon(Entypo.wallet), - Icon( - Entypo.google__with_circle, - color: AppColor.redColor, - ), - Icon(EvilIcons.camera), - Icon(Feather.activity), - Icon( - FontAwesome.whatsapp, - color: AppColor.greenColor, - ), - Icon(FontAwesome5.square), - Icon(FontAwesome5Solid.address_book), - Icon(FontAwesome5Brands.$500px), - Icon(Fontisto.google_play), - Icon(Foundation.hearing_aid), - Icon(Ionicons.logo_whatsapp), - Icon(MaterialCommunityIcons.home_city), - Icon(MaterialIcons.ac_unit), - Icon(Octicons.watch), - Icon(SimpleLineIcons.wrench), - Icon(WeatherIcons.wi_day_sleet), - Icon(Zocial.github), - ], - ), - InkWell( - onTap: () async { - // TwilioSMS().sendSMS( - // recipientPhoneNumber: '+962 7 9858 3052', - // message: 'Hello, this is a test message.', - // ); - }, - child: const Icon(MaterialIcons.message)), - // TextButton( - // onPressed: () { - // Get.to(() => TextExtractionView()); - // }, - // child: const Text( - // "Text FlutterTesseractsOcr", - // ), - // ), - TextButton( - onPressed: () { - Get.to(() => PassportPage()); - }, - child: Text( - 'Passport '.tr, - ), - ), - TextButton( - onPressed: () { - Get.to(() => PassportDataExtractorWidget()); - }, - child: Text( - 'Passport new'.tr, - ), - ), + builder: (controller) => GoogleMap( + onMapCreated: controller.onMapCreated, + // cameraTargetBounds: CameraTargetBounds(controller.boundsdata), + minMaxZoomPreference: const MinMaxZoomPreference(6, 18), - TextButton( - onPressed: () { - Get.to(() => const TextRecognizerWidget()); - }, - child: const Text( - "Driver License ML", - ), - ), - TextButton( - onPressed: () { - Get.to( - () => CameraWidgetCardId(), - ); - }, - child: const Text( - "Text IdCamera", - ), - ), - TextButton( - onPressed: () { - Get.to( - () => CameraWidgetPassPort(), - ); - }, - child: const Text( - " CameraWidgetPassPort", - ), - ), - TextButton( - onPressed: () { - Get.to(() => HomeScreen()); - }, - child: const Text( - "Home Screen", - ), - ), - TextButton( - onPressed: () { - PaymentController().makePayment( - 14, - 'USD', - () => Get.snackbar('Yes you pay success', '', - backgroundColor: Colors.greenAccent)); - }, - child: const Text( - "Pay 18 dollar", - ), - ), - ], + initialCameraPosition: CameraPosition( + target: locationController.myLocation, + zoom: 15, + ), + + mapType: controller.mapType ? MapType.satellite : MapType.normal, + myLocationButtonEnabled: true, + // liteModeEnabled: true, tiltGesturesEnabled: false, + + // indoorViewEnabled: true, + trafficEnabled: controller.mapTrafficON, + buildingsEnabled: true, + mapToolbarEnabled: true, + + myLocationEnabled: true, + // liteModeEnabled: true, ), ), + + // GetBuilder( + // builder: (locationController) => Column( + // children: [ + // Padding( + // padding: const EdgeInsets.all(8.0), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // '${locationController.myLocation}', + // style: AppStyle.subtitle, + // ), + // Text( + // '${DateTime.now()}', + // style: AppStyle.subtitle, + // ) + // ], + // ), + // ), + // // TextButton( + // // onPressed: () { + // // MyClass().exampleUsage(); + // // }, + // // child: Text( + // // "Text Button", + // // ), + // // ), + // ], + // )), + + Positioned( + bottom: 10, + right: Get.width * .1, + left: Get.width * .1, + child: const ConnectWidget()), + + Positioned( + top: 5, + right: Get.width * .17, + left: Get.width * .17, + child: GetBuilder( + builder: (homeCaptainController) => Container( + decoration: AppStyle.boxDecoration, + width: Get.width * .8, + height: 80, + child: Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon( + Entypo.wallet, + color: AppColor.greenColor, + ), + Text( + ' You Earn today is '.tr + + homeCaptainController.totalMoneyToday, + style: AppStyle.title, + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon( + Entypo.loop, + color: AppColor.yellowColor, + ), + Text( + ' You Have in ${AppInformation.appName} '.tr + + homeCaptainController.totalMoneyInSEFER, + style: AppStyle.title, + ), + ], + ), + ], + ))), + ), + ), + Positioned( + bottom: 65, + right: Get.width * .1, + left: Get.width * .1, + child: GetBuilder( + builder: (homeCaptainController) => Container( + decoration: AppStyle.boxDecoration, + child: Column( + children: [ + Text( + 'Active Duration:'.tr + + ' ${homeCaptainController.stringActiveDuration} ', + style: AppStyle.title, + ), + Text( + 'Total Connection Duration:'.tr + + ' ${homeCaptainController.totalDurationToday} ', + style: AppStyle.title, + ), + ], + ), + ), + ), + ), + Positioned( + bottom: Get.height * .17, + right: Get.width * .01, + child: AnimatedContainer( + duration: const Duration(microseconds: 200), + width: Get.width * .12, + decoration: BoxDecoration( + color: AppColor.secondaryColor, + border: Border.all(), + borderRadius: BorderRadius.circular(15)), + child: IconButton( + onPressed: () { + // Get.to( + // () => CameraWidgetCardId(), + // ); + }, + icon: const Icon(Fontisto.history), + ), + ), + ), + // TextButton( + // onPressed: () { + // Get.to( + // () => CameraWidgetCardId(), + // ); + // }, + // child: const Text( + // "Text IdCamera", + // ), + // ), + // TextButton( + // onPressed: () { + // Get.to( + // () => CameraWidgetPassPort(), + // ); + // }, + // child: const Text( + // " CameraWidgetPassPort", + // ), + // ), + // TextButton( + // onPressed: () { + // Get.to(() => HomeScreen()); + // }, + // child: const Text( + // "Home Screen", + // ), + // ), + TextButton( + onPressed: () { + Get.to(() => const TextRecognizerAPI()); + }, + child: const Text( + "scan licnse", + ), + ), + // TextButton( + // onPressed: () { + // PaymentController().makePayment( + // 14, + // 'USD', + // () => Get.snackbar('Yes you pay success', '', + // backgroundColor: Colors.greenAccent)); + // }, + // child: const Text( + // "Pay 18 dollar", + // ), + // ), + + leftMainMenuCaptainIcons(), ], ), ); diff --git a/lib/views/home/Captin/passportimage.dart b/lib/views/home/Captin/passportimage.dart index 72a1619..61c4791 100644 --- a/lib/views/home/Captin/passportimage.dart +++ b/lib/views/home/Captin/passportimage.dart @@ -1,46 +1,46 @@ -import 'dart:io'; - -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import '../../../controller/functions/ocr_controller.dart'; - -class PassportDataExtractorWidget extends StatelessWidget { - final PassportDataExtractor passportDataExtractor = - Get.put(PassportDataExtractor()); - final PassportDataController controller = Get.put(PassportDataController()); - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text('Passport Data Extractor'), - ), - body: Column( - children: [ - ElevatedButton( - onPressed: controller.extractDataAndDrawBoundingBoxes, - child: const Text('Extract Data'), - ), - Expanded( - child: Center( - child: Stack( - children: [ - GetBuilder( - builder: (controller) => CustomPaint( - painter: BoundingBoxPainter( - controller.extractedTextWithCoordinates), - child: GetBuilder( - builder: (controller) => - Image.file(File(passportDataExtractor.image!.path)), - ), - ), - ), - ], - ), - ), - ), - ], - ), - ); - } -} +// import 'dart:io'; +// +// import 'package:flutter/material.dart'; +// import 'package:get/get.dart'; +// import '../../../controller/functions/ocr_controller.dart'; +// +// class PassportDataExtractorWidget extends StatelessWidget { +// final PassportDataExtractor passportDataExtractor = +// Get.put(PassportDataExtractor()); +// final PassportDataController controller = Get.put(PassportDataController()); +// +// @override +// Widget build(BuildContext context) { +// return Scaffold( +// appBar: AppBar( +// title: const Text('Passport Data Extractor'), +// ), +// body: Column( +// children: [ +// ElevatedButton( +// onPressed: controller.extractDataAndDrawBoundingBoxes, +// child: const Text('Extract Data'), +// ), +// Expanded( +// child: Center( +// child: Stack( +// children: [ +// GetBuilder( +// builder: (controller) => CustomPaint( +// painter: BoundingBoxPainter( +// controller.extractedTextWithCoordinates), +// child: GetBuilder( +// builder: (controller) => +// Image.file(File(passportDataExtractor.image!.path)), +// ), +// ), +// ), +// ], +// ), +// ), +// ), +// ], +// ), +// ); +// } +// } diff --git a/lib/views/home/Captin/text_scanner.dart b/lib/views/home/Captin/text_scanner.dart index fdfa8b8..dac7e97 100644 --- a/lib/views/home/Captin/text_scanner.dart +++ b/lib/views/home/Captin/text_scanner.dart @@ -6,82 +6,170 @@ import 'package:ride/views/widgets/mycircular.dart'; import '../../../controller/functions/ocr_controller.dart'; -class TextExtractionView extends StatelessWidget { - TextExtractionView({super.key}); +class TextRecognizerAPI extends StatelessWidget { + const TextRecognizerAPI({super.key}); @override Widget build(BuildContext context) { - Get.put(TextExtractionController()); - return Scaffold( - appBar: AppBar( - title: const Text('Text Extraction'), - ), - body: GetBuilder(builder: (controller) { - return Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - ElevatedButton( - onPressed: () => controller.pickAndExtractText(), - child: const Text('Pick Image and Extract Text'), - ), - const SizedBox(height: 20), - controller.isloading - ? const MyCircularProgressIndicator() - : Text(controller.extractedText), - ], - ), - ); - }), - ); - } -} - -class TextRecognizerWidget extends StatelessWidget { - const TextRecognizerWidget({super.key}); - - @override - Widget build(BuildContext context) { - Get.put(TextMLGoogleRecognizerController()); - return GetBuilder( + Get.put(ScanDocumentsByApi()); + return GetBuilder( builder: (controller) => Scaffold( - appBar: AppBar(), - body: Center( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('${controller.decode['DRIVER_LICENSE'].toString()}'), - Text('DL: ${controller.decode['dl_number'].toString()}'), - Text( - 'Expiry Date: ${controller.decode['expiry_date'].toString()}'), - Text('Last Name: ${controller.decode['lastName'].toString()}'), - Text( - 'First Name: ${controller.decode['firstName'].toString()}'), - Text('Address: ${controller.decode['address'].toString()}'), - Text('Date of Birth: ${controller.decode['dob'].toString()}'), - Text('RSTR: ${controller.decode['rstr'].toString()}'), - Text('Class: ${controller.decode['class'].toString()}'), - Text('End: ${controller.decode['end'].toString()}'), - Text('DD: ${controller.decode['dd'].toString()}'), - Text('Sex: ${controller.decode['sex'].toString()}'), - Text('Hair: ${controller.decode['hair'].toString()}'), - Text('Eyes: ${controller.decode['eyes'].toString()}'), - // and so on for other fields + appBar: AppBar( + title: Text('Api'), + actions: [ + IconButton( + onPressed: () { + controller.matchFaceApi(); + }, + icon: const Icon(Icons.face), + ), ], - )))); + ), + body: Center( + child: controller.isLoading + ? const MyCircularProgressIndicator() + : SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Image.memory( + controller.imagePortrait, + width: 60, + ), + Image.memory( + controller.imageSignature, + width: 60, + ), + Image.memory( + controller.imageDocumentFrontSide, + width: 250, + ), + ], + ), + Text(controller.responseMap['authenticity_meta'] + .toString()), + Text( + 'countryName: ${controller.responseMap['data']['countryName'].toString()}'), + Text( + 'Expiry Date: ${controller.responseMap['data']['ocr']['dateOfExpiry'].toString()}'), + // Add more Text widgets to display other record values + Text( + 'Address: ${controller.responseMap['data']['ocr']['address'].toString()}'), + Text( + 'City: ${controller.responseMap['data']['ocr']['addressCity'].toString()}'), + Text( + 'Jurisdiction Code: ${controller.responseMap['data']['ocr']['addressJurisdictionCode'].toString()}'), + Text( + 'Postal Code: ${controller.responseMap['data']['ocr']['addressPostalCode'].toString()}'), + Text( + 'Street: ${controller.responseMap['data']['ocr']['addressStreet'].toString()}'), + Text( + 'Date of Birth: ${controller.responseMap['data']['ocr']['dateOfBirth'].toString()}'), + Text( + 'Date of Issue: ${controller.responseMap['data']['ocr']['dateOfIssue'].toString()}'), + Text( + 'Drivers License Class: ${controller.responseMap['data']['ocr']['dlClass'].toString()}'), + Text( + 'Document Number: ${controller.responseMap['data']['ocr']['documentNumber'].toString()}'), + Text( + 'Eye Color: ${controller.responseMap['data']['ocr']['eyesColor'].toString()}'), + Text( + 'Given Names: ${controller.responseMap['data']['ocr']['givenNames'].toString()}'), + Text( + 'Height: ${controller.responseMap['data']['ocr']['height'].toString()}'), + Text( + 'Issuing State Code: ${controller.responseMap['data']['ocr']['issuingStateCode'].toString()}'), + Text( + 'Name: ${controller.responseMap['data']['ocr']['name'].toString()}'), + Text( + 'Sex: ${controller.responseMap['data']['ocr']['sex'].toString()}'), + Text( + 'Surname: ${controller.responseMap['data']['ocr']['surname'].toString()}'), + Text( + 'Valid State: ${controller.responseMap['data']['ocr']['validState'].toString()}'), + ], + ), + )))); } } +// class TextExtractionView extends StatelessWidget { +// TextExtractionView({super.key}); +// +// @override +// Widget build(BuildContext context) { +// Get.put(TextExtractionController()); +// return Scaffold( +// appBar: AppBar( +// title: const Text('Text Extraction'), +// ), +// body: GetBuilder(builder: (controller) { +// return Center( +// child: Column( +// mainAxisAlignment: MainAxisAlignment.center, +// children: [ +// ElevatedButton( +// onPressed: () {}, +// child: const Text('Pick Image and Extract Text'), +// ), +// const SizedBox(height: 20), +// controller.isloading +// ? const MyCircularProgressIndicator() +// : Text(controller.extractedText), +// ], +// ), +// ); +// }), +// ); +// } +// } -class PassportPage extends StatelessWidget { - PassportPage({super.key}); - PassportRecognizerController passportRecognizerController = - Get.put(PassportRecognizerController()); - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text('Driver License'), - ), - body: const Center(child: Text('data'))); - } -} +// class TextRecognizerWidget extends StatelessWidget { +// const TextRecognizerWidget({super.key}); +// +// @override +// Widget build(BuildContext context) { +// Get.put(TextMLGoogleRecognizerController()); +// return GetBuilder( +// builder: (controller) => Scaffold( +// appBar: AppBar(), +// body: Center( +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// Text('${controller.decode['DRIVER_LICENSE'].toString()}'), +// Text('DL: ${controller.decode['dl_number'].toString()}'), +// Text( +// 'Expiry Date: ${controller.decode['expiry_date'].toString()}'), +// Text('Last Name: ${controller.decode['lastName'].toString()}'), +// Text( +// 'First Name: ${controller.decode['firstName'].toString()}'), +// Text('Address: ${controller.decode['address'].toString()}'), +// Text('Date of Birth: ${controller.decode['dob'].toString()}'), +// Text('RSTR: ${controller.decode['rstr'].toString()}'), +// Text('Class: ${controller.decode['class'].toString()}'), +// Text('End: ${controller.decode['end'].toString()}'), +// Text('DD: ${controller.decode['dd'].toString()}'), +// Text('Sex: ${controller.decode['sex'].toString()}'), +// Text('Hair: ${controller.decode['hair'].toString()}'), +// Text('Eyes: ${controller.decode['eyes'].toString()}'), +// // and so on for other fields +// ], +// )))); +// } +// } + +// class PassportPage extends StatelessWidget { +// PassportPage({super.key}); +// PassportRecognizerController passportRecognizerController = +// Get.put(PassportRecognizerController()); +// @override +// Widget build(BuildContext context) { +// return Scaffold( +// appBar: AppBar( +// title: const Text('Driver License'), +// ), +// body: const Center(child: Text('data'))); +// } +// } diff --git a/pubspec.lock b/pubspec.lock index 59beed3..4b048b9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051 + url: "https://pub.dev" + source: hosted + version: "64.0.0" _flutterfire_internals: dependency: transitive description: @@ -9,6 +17,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.5" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893" + url: "https://pub.dev" + source: hosted + version: "6.2.0" animated_text_kit: dependency: "direct main" description: @@ -57,6 +73,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + build: + dependency: transitive + description: + name: build + sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + build_config: + dependency: transitive + description: + name: build_config + sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + url: "https://pub.dev" + source: hosted + version: "1.1.1" cached_network_image: dependency: transitive description: @@ -129,6 +161,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + chat_gpt_flutter: + dependency: "direct main" + description: + name: chat_gpt_flutter + sha256: "38d56435c16e9d8743fcdcc9d361a315e6c0e15b4eb91a8638cca235ffbb03bc" + url: "https://pub.dev" + source: hosted + version: "1.0.13" checked_yaml: dependency: transitive description: @@ -217,6 +257,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: abd7625e16f51f554ea244d090292945ec4d4be7bfbaf2ec8cccea568919d334 + url: "https://pub.dev" + source: hosted + version: "2.3.3" dbus: dependency: transitive description: @@ -241,6 +289,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" + dio: + dependency: transitive + description: + name: dio + sha256: "7d328c4d898a61efc3cd93655a0955858e29a0aa647f0f9e02d59b3bb275e2e8" + url: "https://pub.dev" + source: hosted + version: "4.0.6" fake_async: dependency: transitive description: @@ -502,14 +558,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.9" - flutter_tesseract_ocr: - dependency: "direct main" - description: - name: flutter_tesseract_ocr - sha256: "4a8d0e3f562ee01d94a464ff9d31d9e907b1e374aeff29bf696f979417c70bcf" - url: "https://pub.dev" - source: hosted - version: "0.4.24" flutter_test: dependency: "direct dev" description: flutter @@ -656,6 +704,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" google_fonts: dependency: "direct main" description: @@ -920,6 +976,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.8.1" + json_serializable: + dependency: transitive + description: + name: json_serializable + sha256: aa1f5a8912615733e0fdc7a02af03308933c93235bdc8d50d0b0c8a8ccb0b969 + url: "https://pub.dev" + source: hosted + version: "6.7.1" just_audio: dependency: transitive description: @@ -1040,6 +1104,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" package_info_plus: dependency: transitive description: @@ -1152,6 +1224,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.7.3" + pretty_dio_logger: + dependency: transitive + description: + name: pretty_dio_logger + sha256: "948f7eeb36e7aa0760b51c1a8e3331d4b21e36fabd39efca81f585ed93893544" + url: "https://pub.dev" + source: hosted + version: "1.2.0-beta-1" provider: dependency: transitive description: @@ -1160,6 +1240,22 @@ packages: url: "https://pub.dev" source: hosted version: "6.0.5" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 + url: "https://pub.dev" + source: hosted + version: "1.2.3" quiver: dependency: transitive description: @@ -1189,6 +1285,22 @@ packages: description: flutter source: sdk version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: fc0da689e5302edb6177fdd964efcb7f58912f43c28c2047a808f5bfff643d16 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + source_helper: + dependency: transitive + description: + name: source_helper + sha256: "6adebc0006c37dd63fe05bca0a929b99f06402fc95aa35bf36d67f5c06de01fd" + url: "https://pub.dev" + source: hosted + version: "1.3.4" source_span: dependency: transitive description: @@ -1469,6 +1581,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" + watcher: + dependency: transitive + description: + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" web: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index dd679da..1c22b7f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,11 +40,11 @@ dependencies: flutter_font_icons: ^2.2.5 device_info_plus: ^9.1.0 image_picker: ^1.0.4 - flutter_tesseract_ocr: ^0.4.24 google_mlkit_text_recognition: # ^0.10.0 flutter_stripe: ^9.5.0+1 camera: ^0.10.5+5 flutter_widget_from_html: ^0.14.6 + chat_gpt_flutter: @@ -80,7 +80,6 @@ flutter: - assets/images/ - assets/lottie/ - assets/fonts/ - - assets/tessdata/ - shorebird.yaml fonts: