Files
driver_tripz/lib/views/auth/captin/ai_page.dart
Hamza-Ayed 81080ce292 5/15/1
2024-05-15 11:02:55 +03:00

1477 lines
69 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:SEFER/controller/functions/crud.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/constant/table_names.dart';
import 'package:SEFER/controller/auth/captin/register_captin_controller.dart';
import 'package:SEFER/controller/functions/ocr_controller.dart';
import 'package:SEFER/main.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:SEFER/views/widgets/my_scafold.dart';
import 'package:SEFER/views/widgets/mycircular.dart';
import '../../../constant/links.dart';
import '../../../controller/functions/gemeni.dart';
class AiPage extends StatelessWidget {
ScanDocumentsByApi scanDocumentsByApi = Get.put(ScanDocumentsByApi());
RegisterCaptainController registerCaptainController =
Get.put(RegisterCaptainController());
@override
Widget build(BuildContext context) {
Get.put(AI());
String text = '';
return MyScafolld(
title: 'Documents check'.tr,
body: [
GetBuilder<AI>(builder: (controller) {
return controller.isLoading
? const MyCircularProgressIndicator()
: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView(
children: [
egyptDriverLicense(),
egyptCarLicenceFront(),
egyptCarLicenceBack(),
egyptDriverIDFront(),
egyptDriverIDBack(),
],
),
);
}),
],
isleading: true);
}
GetBuilder<AI> egyptDriverLicense() {
return GetBuilder<AI>(
builder: (ai) {
if (ai.responseIdEgyptDriverLicense.isNotEmpty) {
final expiryDate = ai.responseIdEgyptDriverLicense['expiry_date'];
// Check if the expiry date is before today
final today = DateTime.now();
// Try parsing the expiry date. If it fails, set it to null.
final expiryDateTime = DateTime.tryParse(expiryDate);
final isExpired =
expiryDateTime != null && expiryDateTime.isBefore(today);
return Card(
elevation: 4.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Driver\'s License'.tr, style: AppStyle.headTitle2),
const SizedBox(height: 8.0),
const Divider(color: AppColor.accentColor),
const SizedBox(height: 8.0),
Text(
'${'License Type'.tr}: ${ai.responseIdEgyptDriverLicense['license_type']}',
style: AppStyle.title,
),
const SizedBox(height: 8.0),
Text(
'${'National Number'.tr}: ${ai.responseIdEgyptDriverLicense['national_number']}',
style: AppStyle.title.copyWith(
color: ai.responseIdEgyptDriverLicense[
'national_number'] ==
ai.responseIdEgyptBack['nationalID']
? AppColor.greenColor
: AppColor.redColor),
),
const SizedBox(height: 8.0),
Text(
'${'Name (Arabic)'.tr}: ${ai.responseIdEgyptDriverLicense['name_arabic']}',
),
const SizedBox(height: 8.0),
Text(
'${'Name (English)'.tr}: ${ai.responseIdEgyptDriverLicense['name_english']}',
),
const SizedBox(height: 8.0),
Text(
'${'Address'.tr}: ${ai.responseIdEgyptDriverLicense['address']}',
),
const SizedBox(height: 8.0),
Text(
'${'Issue Date'.tr}: ${ai.responseIdEgyptDriverLicense['issue_date']}',
),
const SizedBox(height: 8.0),
Text(
'${'Expiry Date'.tr}: ${ai.responseIdEgyptDriverLicense['expiry_date']}',
style: AppStyle.title.copyWith(
color:
!isExpired ? AppColor.greenColor : AppColor.redColor,
),
),
const SizedBox(height: 8.0),
Text(
'${'License Categories'.tr}: ${ai.responseIdEgyptDriverLicense['license_categories']}',
),
],
),
),
);
}
return Card(
child: InkWell(
onTap: () async {
await ai.allMethodForAI(
'''Write a JSON object from the following information extracted from the provided Arabic text:license_type,national_number,name_arabic,name_english,address,issue_date,expiry_date,license_categories.and (date formate year-month-day in latin numbers) ''',
AppLink.uploadEgypt,
'driver_license'); //egypt
},
child: Column(
children: [
Image.asset(
'assets/images/5.png',
height: Get.height * .25,
width: double.maxFinite,
fit: BoxFit.fitHeight,
),
Text(
'Capture an Image of Your Driver License'.tr,
style: AppStyle.title,
),
],
),
),
);
},
);
}
GetBuilder<AI> egyptDriverIDBack() {
return GetBuilder<AI>(
builder: (ai) {
if (ai.responseIdEgyptBack.isNotEmpty) {
final taxExpiryDate = ai.responseIdEgyptBack['expirationDate'];
// Check if the tax expiry date is before today
final today = DateTime.now();
// Try parsing the tax expiry date. If it fails, set it to null.
final taxExpiryDateTime = DateTime.tryParse(taxExpiryDate);
final isExpired =
taxExpiryDateTime != null && taxExpiryDateTime.isBefore(today);
return Card(
elevation: 4.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('ID Documents Back'.tr, style: AppStyle.headTitle2),
const SizedBox(height: 8.0),
const Divider(color: AppColor.accentColor),
const SizedBox(height: 8.0),
// Assuming these keys exist in ai.responseIdEgyptFront
Text(
'${'National ID'.tr}: ${ai.responseIdEgyptBack['nationalID']}',
style: AppStyle.title),
const SizedBox(height: 8.0),
Text(
'${'Occupation'.tr}: ${ai.responseIdEgyptBack['occupation']}', // Assuming 'occupation' exists
),
const SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Issue Date'.tr}: ${ai.responseIdEgyptBack['issueDate']}', // Assuming 'issueDate' exists
),
Text(
'${'Gender'.tr}: ${ai.responseIdEgyptBack['gender']}', // Assuming 'gender' exists
),
],
),
const SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Religion'.tr}: ${ai.responseIdEgyptBack['religion']}', // Assuming 'religion' exists
),
Text(
'${'Marital Status'.tr}: ${ai.responseIdEgyptBack['maritalStatus']}', // Assuming 'maritalStatus' exists
),
],
),
const SizedBox(height: 8.0),
Text(
'${'Full Name (Marital)'.tr}: ${ai.responseIdEgyptBack['fullNameMaritial']}', // Assuming 'fullNameMaritial' exists
),
const SizedBox(height: 8.0),
Text(
'${'Expiration Date'.tr}: ${ai.responseIdEgyptBack['expirationDate']}', // Assuming 'expirationDate' exists
style: AppStyle.title.copyWith(
color: !isExpired
? AppColor.greenColor
: AppColor.redColor),
),
],
),
),
);
}
return Card(
child: InkWell(
onTap: () async {
await ai.allMethodForAI(
'''Write a JSON from the following information extracted from the provided Arabic text:nationalID,issueDate,occupation,gender,religion,maritalStatus,fullNameMaritial if(أعزب)=none ,expirationDate.and (date formate year-month-day in latin numbers) ''',
AppLink.uploadEgypt,
'id_back'); //egypt
},
child: Column(
children: [
Image.asset(
'assets/images/2.png',
height: Get.height * .25,
width: double.maxFinite,
fit: BoxFit.fitHeight,
),
Text(
'Capture an Image of Your ID Document Back'.tr,
style: AppStyle.title,
),
],
),
),
);
},
);
}
GetBuilder<AI> egyptDriverIDFront() {
return GetBuilder<AI>(
builder: (ai) {
if (ai.responseIdEgyptFront.isNotEmpty) {
return Card(
elevation: 4.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('ID Documents Front'.tr, style: AppStyle.headTitle2),
const SizedBox(height: 8.0),
const Divider(color: AppColor.accentColor),
const SizedBox(height: 8.0),
// Removed Make, Model, etc. as they are not available
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'First Name'.tr}: ${ai.responseIdEgyptFront['first_name']}',
),
Text(
'${'CardID'.tr}: ${ai.responseIdEgyptFront['card_id']}',
),
],
),
const SizedBox(height: 8.0),
Text(
'${'Full Name'.tr}: ${ai.responseIdEgyptFront['full_name']}',
),
const SizedBox(height: 8.0),
Text(
'${'Address'.tr}: ${ai.responseIdEgyptFront['address']}',
),
const SizedBox(height: 8.0),
Text(
'${'National Number'.tr}: ${ai.responseIdEgyptFront['national_number']}',
),
const SizedBox(height: 8.0),
// Removed Inspection Date as it's not available
],
),
),
);
}
return Card(
child: InkWell(
onTap: () async {
await ai.allMethodForAI(
'''Write a JSON object from the following information extracted from the provided Arabic text:first_name: The word next to "بطاقة تحقيق الشخصية" (National Identification Card).full_name: The full name on the next line after the first name.address: The complete address spanning the next two lines.national_number: The Arabic numeral representing the National ID number before the last line.card_id: The card ID in English on the last line ''',
AppLink.uploadEgypt,
'id_front'); //egypt
},
child: Column(
children: [
Image.asset(
'assets/images/1.png',
height: Get.height * .25,
width: double.maxFinite,
fit: BoxFit.fitHeight,
),
Text(
'Capture an Image of Your ID Document front'.tr,
style: AppStyle.title,
),
],
),
),
);
},
);
}
GetBuilder<AI> egyptCarLicenceFront() {
return GetBuilder<AI>(
builder: (ai) {
if (ai.responseIdCardDriverEgyptFront.isNotEmpty) {
// No need to access ai.responseIdCardDriverEgyptBack anymore
final licenseExpiryDate = DateTime.parse(
ai.responseIdCardDriverEgyptFront['LicenseExpirationDate']);
// Check if license has expired
final today = DateTime.now();
final isLicenseExpired = licenseExpiryDate.isBefore(today);
return Card(
elevation: 4.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Vehicle Details Front'.tr, style: AppStyle.headTitle2),
const SizedBox(height: 8.0),
const Divider(color: AppColor.accentColor),
const SizedBox(height: 8.0),
// Removed Make, Model, etc. as they are not available
Text(
'${'Plate Number'.tr}: ${ai.responseIdCardDriverEgyptFront['car_plate']}',
),
const SizedBox(height: 8.0),
Text(
'${'Owner Name'.tr}: ${ai.responseIdCardDriverEgyptFront['owner']}',
),
const SizedBox(height: 8.0),
Text(
'${'Address'.tr}: ${ai.responseIdCardDriverEgyptFront['address']}',
),
const SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'License Expiry Date'.tr}: ${licenseExpiryDate.toString().substring(0, 10)}',
style: TextStyle(
color: isLicenseExpired ? Colors.red : Colors.green,
),
),
// Removed Fuel as it's not available
],
),
// Removed Inspection Date as it's not available
],
),
),
);
}
return Card(
child: InkWell(
onTap: () async {
ai.allMethodForAI(
'extract all fields as json for keys[LicenseExpirationDate,car_plate,owner,address] replace | by space,and date formate year-month-day',
AppLink.uploadEgypt,
'car_front');
},
child: Column(
children: [
Image.asset(
'assets/images/3.png',
height: Get.height * .25,
width: double.maxFinite,
fit: BoxFit.fitHeight,
),
Text(
'Capture an Image of Your car license front '.tr,
style: AppStyle.title,
),
],
),
),
);
},
);
}
GetBuilder<AI> egyptCarLicenceBack() {
return GetBuilder<AI>(
builder: (ai) {
if (ai.responseIdCardDriverEgyptBack.isNotEmpty) {
// print(ai.responseIdCardDriverEgyptBack);
// Get the tax expiry date from the response
final taxExpiryDate = ai.responseIdCardDriverEgyptBack['tax_expiry'];
// Get the inspection date from the response
final inspectionDate =
ai.responseIdCardDriverEgyptBack['inspection_date'];
// Check if the tax expiry date is before today
final today = DateTime.now();
// Try parsing the tax expiry date. If it fails, set it to null.
final taxExpiryDateTime = DateTime.tryParse(taxExpiryDate);
final isExpired =
taxExpiryDateTime != null && taxExpiryDateTime.isBefore(today);
// Check if the inspection date is before today
final inspectionDateTime = DateTime(int.parse(inspectionDate), 1, 1);
final isInspectionExpired = inspectionDateTime.isBefore(today);
return Card(
elevation: 4.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Vehicle Details Back'.tr, style: AppStyle.headTitle2),
const SizedBox(height: 8.0),
const Divider(color: AppColor.accentColor),
const SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Make'.tr}: ${ai.responseIdCardDriverEgyptBack['make']}'),
Text(
'${'Model'.tr}: ${ai.responseIdCardDriverEgyptBack['model']}'),
],
),
const SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Year'.tr}: ${ai.responseIdCardDriverEgyptBack['year']}'),
Text(
'${'Chassis'.tr}: ${ai.responseIdCardDriverEgyptBack['chassis']}'),
],
),
const SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Color'.tr}: ${ai.responseIdCardDriverEgyptBack['color']}'),
Text(
'${'Displacement'.tr}: ${ai.responseIdCardDriverEgyptBack['displacement']} cc'),
],
),
const SizedBox(height: 8.0),
Text(
'${'Fuel'.tr}: ${ai.responseIdCardDriverEgyptBack['fuel']}'),
const SizedBox(height: 8.0),
Text(
'${'Tax Expiry Date'.tr}: ${taxExpiryDateTime != null ? taxExpiryDate : 'N/A'}',
style: TextStyle(
color: isExpired ? Colors.red : Colors.green,
),
),
const SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Inspection Date'.tr}: $inspectionDate',
style: TextStyle(
color:
isInspectionExpired ? Colors.red : Colors.green,
),
),
// Text(
// '${'Cylinders'.tr}: ${ai.responseIdCardDriverEgypt['cylinders']}'),
],
),
],
),
),
);
}
return Card(
child: InkWell(
onTap: () async {
ai.allMethodForAI(
'this extracted car license analyze it to get Json just without any text for keys[make, year, chassis, model, engine, displacement, cylinders, fuel, color, inspection_date,assurnceNumber, tax_expiry,make date format year-month-day',
AppLink.uploadEgypt,
'car_back');
},
child: Column(
children: [
Image.asset(
'assets/images/4.png',
height: Get.height * .25,
width: double.maxFinite,
fit: BoxFit.fitHeight,
),
Text(
'Capture an Image of Your car license back'.tr,
style: AppStyle.title,
),
],
),
),
);
},
);
}
GetBuilder<AI> egyptDriverLicenseWidget() {
return GetBuilder<AI>(
builder: (contentController) => contentController.responseMap.isNotEmpty
? contentController.isloading
? Column(
children: [
const MyCircularProgressIndicator(),
Text(
'We are process picture please wait '.tr,
style: AppStyle.title,
)
],
)
: SizedBox(
height: Get.height * .7,
child: ListView(
children: [
Container(
decoration: AppStyle.boxDecoration1,
// height: Get.height * .4,
child: Padding(
padding: const EdgeInsets.all(5),
child: contentController.responseMap.isEmpty
? Center(
child: Text(
'Capture an Image of Your Drivers License'
.tr,
style: AppStyle.title,
),
)
: Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
'${'Name'.tr} :${contentController.responseMap['first_name']}',
style: AppStyle.subtitle,
),
Text(
' ${contentController.responseMap['last_name']}',
style: AppStyle.subtitle,
),
],
),
Text(
'${'Name in arabic'.tr}: ${contentController.responseMap['name_in_arabic']}',
style: AppStyle.title,
),
Text(
'${'Drivers License Class'.tr}: ${contentController.responseMap['class']}',
style: AppStyle.title,
),
],
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'${'National Number'.tr}: ${contentController.responseMap['id']}',
style: AppStyle.title,
),
// Image.memory(
// scanDocumentsByApi
// .imagePortrait,
// width: 60,
// ),
]),
Text(
'${'Address'.tr}: ${contentController.responseMap['address']}',
style: AppStyle.title,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Date of Birth'.tr}: ${contentController.responseMap['dob']}',
style: AppStyle.title,
),
Text(
'${'Age'.tr} : ${contentController.responseMap['age_in_years']}',
style: AppStyle.title,
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Expiry Date'.tr}: ${contentController.responseMap['expiration_date']}',
style: DateTime.parse(
contentController
.responseMap[
'expiration_date']
.toString())
.isBefore(
contentController.now)
? AppStyle.title.copyWith(
color: AppColor.redColor)
: AppStyle.title.copyWith(
color: AppColor.greenColor),
),
],
),
],
),
),
),
const SizedBox(
height: 10,
),
DateTime.parse(contentController
.responseMap['expiration_date']
.toString())
.isBefore(contentController.now)
? Text(
'You can\'t continue with us .\nYou should renew Driver license'
.tr,
style: AppStyle.title
.copyWith(color: AppColor.redColor),
)
: MyElevatedButton(
kolor: AppColor.greenColor,
title: 'Lets check Car license '.tr,
onPressed: () => contentController
.getCarLicenseJordanContent()),
const SizedBox(
height: 10,
),
contentController.responseCarLicenseMap.isNotEmpty
? Container(
decoration: AppStyle.boxDecoration,
// height: Get.height * .3,
width: Get.width * .9,
child: Column(
children: [
Text(
'${'Name'.tr} ${contentController.responseCarLicenseMap['name']}',
style: AppStyle.title,
),
Text(
'${'Address'.tr} ${contentController.responseCarLicenseMap['address']}',
style: AppStyle.title,
),
Text(
'${'Car Kind'.tr} ${contentController.responseCarLicenseMap['car_kind']}',
style: AppStyle.title,
),
Text(
'${'Color'.tr} ${contentController.responseCarLicenseMap['car_color']}',
style: AppStyle.title,
),
Text(
'${'Year'.tr} ${contentController.responseCarLicenseMap['car_year']}',
style: AppStyle.title,
),
Text(
'${'Car Plate'.tr} ${contentController.responseCarLicenseMap['car_plate']}',
style: AppStyle.title,
),
Text(
'${'Car Expire'.tr} ${contentController.responseCarLicenseMap['expire_date_of_license']}',
style: contentController
.responseCarLicenseMap.isNotEmpty
? DateTime.parse(contentController
.responseCarLicenseMap[
'expire_date_of_license']
.toString())
.isBefore(contentController.now)
? AppStyle.title.copyWith(
color: AppColor.redColor)
: AppStyle.title.copyWith(
color: AppColor.greenColor)
: null,
),
],
),
)
: const SizedBox(),
const SizedBox(
height: 10,
),
// DateTime.parse(contentController
// .responseCarLicenseMap[
// 'expire_date_of_license']
// .toString())
// .isBefore(contentController.now)
// ? Text(
// 'You can\'t continue with us .\nYou should renew Car license'
// .tr,
// style: AppStyle.title.copyWith(
// color: AppColor.redColor),
// )
// :
MyElevatedButton(
kolor: AppColor.greenColor,
title: 'Lets check License Back Face'.tr,
onPressed: () => contentController
.generateBackCarLicenseJordanContent()),
const SizedBox(
height: 10,
),
contentController.responseBackCarLicenseMap.isNotEmpty
? Container(
decoration: AppStyle.boxDecoration,
// height: 300,
child: Column(children: [
Text(
'VIN ${contentController.responseBackCarLicenseMap['vin']}',
style: AppStyle.title,
),
Text(
'Fuel Type ${contentController.responseBackCarLicenseMap['fuelType']}',
style: AppStyle.title,
),
Text(
'Insurance Company ${contentController.responseBackCarLicenseMap['insuranceCompany']}',
style: AppStyle.title,
),
Text(
'Policy Number ${contentController.responseBackCarLicenseMap['policyNumber']}',
style: AppStyle.title,
),
Text(
'Insurance Type ${contentController.responseBackCarLicenseMap['insuranceType']}',
style: AppStyle.title,
)
]))
: const SizedBox()
],
),
)
: 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.boxDecoration1,
height: Get.height * .35,
child: Padding(
padding: const EdgeInsets.all(5),
child: Center(
child: InkWell(
onTap: () async {
await CRUD().allMethodForAI(
'name,address,dob,nationalNo,',
AppLink.uploadEgypt,
'idFront'); //egypt
},
child: Text(
'Take Picture Of ID Card'.tr,
style: AppStyle.title,
),
),
)),
),
],
),
),
);
}
GetBuilder<AI> jordanDriverLicenseWidget() {
return GetBuilder<AI>(
builder: (contentController) => contentController.responseMap.isNotEmpty
? Positioned(
top: Get.height * .09,
left: Get.width * .051,
right: Get.width * .051,
child: contentController.isloading
? Column(
children: [
const MyCircularProgressIndicator(),
Text(
'We are process picture please wait '.tr,
style: AppStyle.title,
)
],
)
: SizedBox(
height: Get.height * .7,
child: ListView(
children: [
Container(
decoration: AppStyle.boxDecoration,
// height: Get.height * .4,
child: Padding(
padding: const EdgeInsets.all(5),
child: contentController.responseMap.isEmpty
? Center(
child: Text(
'There is no data yet.'.tr,
style: AppStyle.title,
),
)
: Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
'${'Name'.tr} :${contentController.responseMap['first_name']}',
style: AppStyle.subtitle,
),
Text(
' ${contentController.responseMap['last_name']}',
style: AppStyle.subtitle,
),
],
),
Text(
'${'Name in arabic'.tr}: ${contentController.responseMap['name_in_arabic']}',
style: AppStyle.title,
),
Text(
'${'Drivers License Class'.tr}: ${contentController.responseMap['class']}',
style: AppStyle.title,
),
],
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'${'National Number'.tr}: ${contentController.responseMap['id']}',
style: AppStyle.title,
),
// Image.memory(
// scanDocumentsByApi
// .imagePortrait,
// width: 60,
// ),
]),
Text(
'${'Address'.tr}: ${contentController.responseMap['address']}',
style: AppStyle.title,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Date of Birth'.tr}: ${contentController.responseMap['dob']}',
style: AppStyle.title,
),
Text(
'${'Age'.tr} : ${contentController.responseMap['age_in_years']}',
style: AppStyle.title,
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Expiry Date'.tr}: ${contentController.responseMap['expiration_date']}',
style: DateTime.parse(
contentController
.responseMap[
'expiration_date']
.toString())
.isBefore(
contentController.now)
? AppStyle.title.copyWith(
color: AppColor.redColor)
: AppStyle.title.copyWith(
color:
AppColor.greenColor),
),
],
),
],
),
),
),
const SizedBox(
height: 10,
),
DateTime.parse(contentController
.responseMap['expiration_date']
.toString())
.isBefore(contentController.now)
? Text(
'You can\'t continue with us .\nYou should renew Driver license'
.tr,
style: AppStyle.title
.copyWith(color: AppColor.redColor),
)
: MyElevatedButton(
kolor: AppColor.greenColor,
title: 'Lets check Car license '.tr,
onPressed: () => contentController
.getTextFromCard(
'''Extract the following information from the front face of the car license card in Jordan:
* name
* Address
* Vehicle type
* car_kind
* car_color
* Vehicle category
* car_year
* car_plate
* Registration type
* Usage type
* expire_date_of_license
Output the extracted information in the following JSON formate and make date format like YYYY-MM-DD''')),
const SizedBox(
height: 10,
),
contentController.responseCarLicenseMap.isNotEmpty
? Container(
decoration: AppStyle.boxDecoration,
// height: Get.height * .3,
width: Get.width * .9,
child: Column(
children: [
Text(
'${'Name'.tr} ${contentController.responseCarLicenseMap['name']}',
style: AppStyle.title,
),
Text(
'${'Address'.tr} ${contentController.responseCarLicenseMap['address']}',
style: AppStyle.title,
),
Text(
'${'Car Kind'.tr} ${contentController.responseCarLicenseMap['car_kind']}',
style: AppStyle.title,
),
Text(
'${'Color'.tr} ${contentController.responseCarLicenseMap['car_color']}',
style: AppStyle.title,
),
Text(
'${'Year'.tr} ${contentController.responseCarLicenseMap['car_year']}',
style: AppStyle.title,
),
Text(
'${'Car Plate'.tr} ${contentController.responseCarLicenseMap['car_plate']}',
style: AppStyle.title,
),
Text(
'${'ُExpire Date'.tr} ${contentController.responseCarLicenseMap['expire_date_of_license']}',
style: contentController
.responseCarLicenseMap
.isNotEmpty
? DateTime.parse(contentController
.responseCarLicenseMap[
'expire_date_of_license']
.toString())
.isBefore(
contentController.now)
? AppStyle.title.copyWith(
color: AppColor.redColor)
: AppStyle.title.copyWith(
color: AppColor.greenColor)
: null,
),
],
),
)
: const SizedBox(),
const SizedBox(
height: 10,
),
//todo temporary
// DateTime.parse(contentController
// .responseCarLicenseMap[
// 'expire_date_of_license']
// .toString())
// .isBefore(contentController.now)
// ? Text(
// 'You can\'t continue with us .\nYou should renew Car license'
// .tr,
// style: AppStyle.title.copyWith(
// color: AppColor.redColor),
// )
// :
MyElevatedButton(
kolor: AppColor.greenColor,
title: 'Lets check License Back Face'.tr,
onPressed: () =>
contentController.getTextFromCard(
'write json output from extracting car license back face for these key ,vin,fuelType,passengerType,curbWeight,insuranceCompany,policyNumber,notes,insuranceType and output it json .dont add data else this image',
)),
const SizedBox(
height: 10,
),
contentController.responseBackCarLicenseMap.isNotEmpty
? Container(
decoration: AppStyle.boxDecoration,
// height: 300,
child: Column(children: [
Text(
'VIN ${contentController.responseBackCarLicenseMap['vin']}',
style: AppStyle.title,
),
Text(
'Fuel Type ${contentController.responseBackCarLicenseMap['fuelType']}',
style: AppStyle.title,
),
Text(
'Insurance Company ${contentController.responseBackCarLicenseMap['insuranceCompany']}',
style: AppStyle.title,
),
Text(
'Policy Number ${contentController.responseBackCarLicenseMap['policyNumber']}',
style: AppStyle.title,
),
Text(
'Insurance Type ${contentController.responseBackCarLicenseMap['insuranceType']}',
style: AppStyle.title,
)
]))
: const SizedBox()
// MyElevatedButton(
// title: 'Detect Your Face '.tr,
// onPressed: () => scanDocumentsByApi
// .checkMatchFaceApi(),
// ),
// scanDocumentsByApi.res.isEmpty
// ? const SizedBox()
// : scanDocumentsByApi.res['data']
// ['result']
// .toString() ==
// 'Same'
// ? MyElevatedButton(
// onPressed: () async {
// await registerCaptainController
// .register();
// await registerCaptainController
// .addLisence();
// // await scanDocumentsByApi
// // .uploadImagePortrate();
// },
// title:
// 'Go to next step\nscan Car License.'
// .tr,
// kolor: AppColor.greenColor,
// )
// : const SizedBox(),
// MyElevatedButton(
// title: 'get sql data',
// kolor: AppColor.yellowColor,
// onPressed: () {
// sql.deleteAllData(
// TableName.faceDetectTimes);
// sql
// .getAllData(
// TableName.faceDetectTimes)
// .then((value) => print(
// value[0]['faceDetectTimes']));
// },
// ),
],
),
),
)
: Positioned(
top: Get.height * .06,
left: Get.width * .051,
right: Get.width * .051,
child: scanDocumentsByApi.isLoading
? Column(
children: [
const MyCircularProgressIndicator(),
Text(
'We are process picture please wait '.tr,
style: AppStyle.title,
)
],
)
: Column(
children: [
Container(
decoration: AppStyle.boxDecoration,
height: Get.height * .35,
child: Padding(
padding: const EdgeInsets.all(5),
child: Center(
child: Text(
'There is no data yet.'.tr,
style: AppStyle.title,
),
)),
),
],
),
),
);
}
GetBuilder<ScanDocumentsByApi> usaDriverLicensWidget() {
return GetBuilder<ScanDocumentsByApi>(
builder: (scanDocumentsByApi) => scanDocumentsByApi.responseMap.isNotEmpty
? Positioned(
top: Get.height * .06,
left: Get.width * .051,
right: Get.width * .051,
child: scanDocumentsByApi.isLoading
? Column(
children: [
const MyCircularProgressIndicator(),
Text(
'We are process picture please wait '.tr,
style: AppStyle.title,
)
],
)
: Column(
children: [
Container(
decoration: AppStyle.boxDecoration,
height: Get.height * .4,
child: Padding(
padding: const EdgeInsets.all(5),
child: scanDocumentsByApi.responseMap.isEmpty
? Center(
child: Text(
'There is no data yet.'.tr,
style: AppStyle.title,
),
)
: Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'${'Name :'.tr}${scanDocumentsByApi.name}',
style: AppStyle.subtitle,
),
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
'${'Drivers License Class: '.tr}${scanDocumentsByApi.licenseClass}',
style: AppStyle.title,
),
Image.memory(
scanDocumentsByApi
.imageSignature,
width: 100,
height: 30,
),
],
),
],
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Document Number: '.tr}${scanDocumentsByApi.documentNo}',
style: AppStyle.title,
),
Image.memory(
scanDocumentsByApi.imagePortrait,
width: 60,
),
]),
Text(
'${'Address: '.tr}${scanDocumentsByApi.address}',
style: AppStyle.title,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Height: '.tr}${scanDocumentsByApi.height}',
style: AppStyle.subtitle,
),
Text(
'Postal Code: ${scanDocumentsByApi.postalCode}',
style: AppStyle.subtitle,
),
Text(
'Sex: ${scanDocumentsByApi.sex}',
style: AppStyle.subtitle,
),
],
),
Text(
'Territorial Code: ${scanDocumentsByApi.stateCode}',
style: AppStyle.subtitle,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Expiry Date: '.tr}${scanDocumentsByApi.expireDate}',
style: DateTime.parse(
scanDocumentsByApi
.responseMap['data']
['ocr']
['dateOfExpiry']
.toString())
.isBefore(
scanDocumentsByApi.now)
? AppStyle.title.copyWith(
color: AppColor.redColor)
: AppStyle.title.copyWith(
color: AppColor.greenColor),
),
Text(
'${'Date of Birth: '.tr}${scanDocumentsByApi.dob}',
style: AppStyle.title,
),
],
),
],
),
),
),
DateTime.parse(scanDocumentsByApi.responseMap['data']
['ocr']['dateOfExpiry']
.toString())
.isBefore(scanDocumentsByApi.now)
? Text(
'You can\'t continue with us .\nYou should renew Driver license',
style: AppStyle.title
.copyWith(color: AppColor.redColor),
)
: MyElevatedButton(
title: 'Detect Your Face '.tr,
onPressed: () =>
scanDocumentsByApi.checkMatchFaceApi(),
),
scanDocumentsByApi.res.isEmpty
? const SizedBox()
: scanDocumentsByApi.res['data']['result']
.toString() ==
'Same'
? MyElevatedButton(
onPressed: () async {
await registerCaptainController
.register();
await registerCaptainController
.addLisence();
// await scanDocumentsByApi
// .uploadImagePortrate();
},
title:
'Go to next step\nscan Car License.'.tr,
kolor: AppColor.greenColor,
)
: const SizedBox(),
MyElevatedButton(
title: 'get sql data',
kolor: AppColor.yellowColor,
onPressed: () {
sql.deleteAllData(TableName.faceDetectTimes);
sql.getAllData(TableName.faceDetectTimes).then(
(value) => print(value[0]['faceDetectTimes']));
},
)
],
),
)
: Positioned(
top: Get.height * .06,
left: Get.width * .051,
right: Get.width * .051,
child: scanDocumentsByApi.isLoading
? Column(
children: [
const MyCircularProgressIndicator(),
Text(
'We are process picture please wait '.tr,
style: AppStyle.title,
)
],
)
: Column(
children: [
Container(
decoration: AppStyle.boxDecoration,
height: Get.height * .35,
child: Padding(
padding: const EdgeInsets.all(5),
child: Center(
child: Text(
'There is no data yet.'.tr,
style: AppStyle.title,
),
)),
),
],
),
),
);
}
}
class EgyptDocuments extends StatelessWidget {
const EgyptDocuments({
super.key,
required this.contentController,
});
final AI contentController;
@override
Widget build(BuildContext context) {
return Positioned(
top: 3,
left: Get.width * .1,
right: Get.width * .1,
child: MyElevatedButton(
title: 'Take Picture Of ID Card'.tr, //egypt
onPressed: () async {
await CRUD().allMethodForAI('name,address,dob,nationalNo,',
AppLink.uploadEgypt, 'idFront'); //egypt
},
));
}
}
class JordanDocumants extends StatelessWidget {
const JordanDocumants({
super.key,
required this.contentController,
});
final AI contentController;
@override
Widget build(BuildContext context) {
return Positioned(
top: 3,
left: Get.width * .1,
right: Get.width * .1,
child: MyElevatedButton(
title: 'Take Picture Of Driver License Card'.tr,
onPressed: () {
contentController.getDriverLicenseJordanContent();
},
));
}
}
class UsaAiDocuments extends StatelessWidget {
const UsaAiDocuments({
super.key,
required this.scanDocumentsByApi,
});
final ScanDocumentsByApi scanDocumentsByApi;
@override
Widget build(BuildContext context) {
return Positioned(
top: 3,
left: Get.width * .2,
right: Get.width * .2,
child: MyElevatedButton(
title: 'Take Picture Of ID Card'.tr,
onPressed: () {
scanDocumentsByApi.scanDocumentsByApi();
},
));
}
}