11/19/1
This commit is contained in:
@@ -82,7 +82,7 @@ class LoginCaptinController extends GetxController {
|
||||
'email': emailController.text,
|
||||
'token': randomNumber.toString(),
|
||||
}).then((value) => print(value));
|
||||
Get.to(() => const VerifyEmailPage());
|
||||
Get.to(() => VerifyEmailPage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
87
lib/controller/auth/captin/ml_google_doc.dart
Normal file
87
lib/controller/auth/captin/ml_google_doc.dart
Normal file
@@ -0,0 +1,87 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class CarRegistrationRecognizerController 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<Map<String, dynamic>> lines = [];
|
||||
XFile? image;
|
||||
Map decode = {};
|
||||
// Picks an image from the camera or gallery and extracts the text
|
||||
final List<Map<String, dynamic>> extractedTextWithCoordinates = [];
|
||||
Future<void> scanText() async {
|
||||
// Pick an image from the camera or gallery
|
||||
image = await _imagePicker.pickImage(source: ImageSource.gallery);
|
||||
update();
|
||||
// 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;
|
||||
final Map<String, dynamic> extractedData = {};
|
||||
|
||||
for (TextBlock block in recognizedText.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,
|
||||
},
|
||||
});
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
print(jsonEncode(extractedTextWithCoordinates));
|
||||
|
||||
// Extract the scanned text line by line
|
||||
final List<Map<String, dynamic>> lines = [];
|
||||
for (var i = 0; i < recognizedText.blocks.length; i++) {
|
||||
lines.add({
|
||||
i.toString(): recognizedText.blocks[i].text,
|
||||
});
|
||||
}
|
||||
// print(jsonEncode(lines));
|
||||
|
||||
// Convert the list of lines to a JSON string
|
||||
jsonOutput = jsonEncode(extractedData);
|
||||
decode = jsonDecode(jsonOutput!);
|
||||
|
||||
update();
|
||||
print('jsonOutput------------------------------');
|
||||
print(decode);
|
||||
// print(jsonEncode(lines));
|
||||
}
|
||||
}
|
||||
@@ -5,24 +5,34 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:ride/constant/links.dart';
|
||||
import 'package:ride/controller/functions/crud.dart';
|
||||
import 'package:ride/controller/functions/ocr_controller.dart';
|
||||
import 'package:ride/views/auth/captin/login_captin.dart';
|
||||
import 'package:ride/views/auth/captin/verify_email_captain.dart';
|
||||
|
||||
import '../../../views/auth/captin/ai_page.dart';
|
||||
import '../../../views/auth/verify_email_page.dart';
|
||||
|
||||
class RegisterCaptinController extends GetxController {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
|
||||
TextEditingController firstNameController = TextEditingController();
|
||||
TextEditingController lastNameController = TextEditingController();
|
||||
TextEditingController emailController = TextEditingController();
|
||||
TextEditingController phoneController = TextEditingController();
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
TextEditingController siteController = TextEditingController();
|
||||
TextEditingController verifyCode = TextEditingController();
|
||||
|
||||
String birthDate = 'Birth Date'.tr;
|
||||
String gender = 'Male'.tr;
|
||||
bool isloading = false;
|
||||
bool isLoading = false;
|
||||
late String name;
|
||||
late String licenseClass;
|
||||
late String documentNo;
|
||||
late String address;
|
||||
late String height;
|
||||
late String postalCode;
|
||||
late String sex;
|
||||
late String stateCode;
|
||||
late String expireDate;
|
||||
late String dob;
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -57,7 +67,7 @@ class RegisterCaptinController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
sendverfications() async {
|
||||
sendVerifications() async {
|
||||
var res = await CRUD().post(link: AppLink.verifyEmail, payload: {
|
||||
'email': emailController.text,
|
||||
'token': verifyCode.text,
|
||||
@@ -68,22 +78,70 @@ class RegisterCaptinController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void register() async {
|
||||
void nextToAIDetection() async {
|
||||
//Todo dont forget this
|
||||
if (formKey.currentState!.validate()) {
|
||||
isloading = true;
|
||||
isLoading = true;
|
||||
update();
|
||||
Get.to(() => AiPage());
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> payloadLisence = {};
|
||||
|
||||
void getFromController() {
|
||||
name = Get.find<ScanDocumentsByApi>().name;
|
||||
licenseClass = Get.find<ScanDocumentsByApi>().licenseClass.toString();
|
||||
documentNo = Get.find<ScanDocumentsByApi>().documentNo.toString();
|
||||
address = Get.find<ScanDocumentsByApi>().address.toString();
|
||||
height = Get.find<ScanDocumentsByApi>().height.toString();
|
||||
postalCode = Get.find<ScanDocumentsByApi>().address.toString();
|
||||
sex = Get.find<ScanDocumentsByApi>().sex.toString();
|
||||
stateCode = Get.find<ScanDocumentsByApi>().postalCode.toString();
|
||||
expireDate = Get.find<ScanDocumentsByApi>().expireDate.toString();
|
||||
dob = Get.find<ScanDocumentsByApi>().dob.toString();
|
||||
update();
|
||||
}
|
||||
|
||||
void addLisence() async {
|
||||
getFromController();
|
||||
var res = await CRUD().post(link: AppLink.addLicense, payload: {
|
||||
'name': name,
|
||||
'licenseClass': licenseClass,
|
||||
'documentNo': documentNo,
|
||||
'address': address,
|
||||
'height': height,
|
||||
'postalCode': postalCode,
|
||||
'sex': sex == 'M' ? 'Male' : 'Female',
|
||||
'stateCode': stateCode,
|
||||
'expireDate': expireDate,
|
||||
'dateOfBirth': dob,
|
||||
});
|
||||
print(jsonDecode(res));
|
||||
isLoading = false;
|
||||
update();
|
||||
if (jsonDecode(res)['status'] == 'success') {
|
||||
// Get.to(() => AiPage()); //todo rplace this
|
||||
}
|
||||
}
|
||||
|
||||
void register() async {
|
||||
getFromController();
|
||||
if (formKey.currentState!.validate()) {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().post(link: AppLink.signUpCaptin, payload: {
|
||||
'first_name': firstNameController.text,
|
||||
'last_name': lastNameController.text,
|
||||
'first_name': name.split(' ')[1],
|
||||
'last_name': name.split(' ')[0],
|
||||
'email': emailController.text,
|
||||
'phone': phoneController.text,
|
||||
'password': passwordController.text,
|
||||
'gender': gender,
|
||||
'site': siteController.text,
|
||||
'birthdate': birthDate,
|
||||
'gender': sex,
|
||||
'site': address,
|
||||
'birthdate': dob,
|
||||
});
|
||||
print(jsonDecode(res));
|
||||
isloading = false;
|
||||
isLoading = false;
|
||||
update();
|
||||
if (jsonDecode(res)['status'] == 'success') {
|
||||
print('sdfffffffffff');
|
||||
@@ -92,7 +150,7 @@ class RegisterCaptinController extends GetxController {
|
||||
'email': emailController.text,
|
||||
'token': randomNumber.toString(),
|
||||
}).then((value) => print(value));
|
||||
Get.to(() => const VerifyEmailPage());
|
||||
Get.to(() => VerifyEmailCaptainPage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user