This commit is contained in:
Hamza-Ayed
2024-12-22 01:36:07 +03:00
parent 90d4ca39bf
commit 2910750483
32 changed files with 1804 additions and 1231 deletions

View File

@@ -10,160 +10,160 @@ import '../../../controller/auth/captin/register_captin_controller.dart';
import '../../widgets/elevated_btn.dart';
import '../../widgets/my_scafold.dart';
class CarLicensePage extends StatelessWidget {
CarLicensePage({super.key});
CarRegistrationRecognizerController carRegistrationRecognizerController =
Get.put(CarRegistrationRecognizerController());
RegisterCaptainController registerCaptainController =
Get.put(RegisterCaptainController());
// class CarLicensePage extends StatelessWidget {
// CarLicensePage({super.key});
// // CarRegistrationRecognizerController carRegistrationRecognizerController =
// // Get.put(CarRegistrationRecognizerController());
// RegisterCaptainController registerCaptainController =
// Get.put(RegisterCaptainController());
@override
Widget build(BuildContext context) {
Get.find<ScanDocumentsByApi>().uploadImagePortrate();
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: () async {
//0vQRyaYYDWpsv73A5CZOknseK7S2sgwE
//3vQRyaYYSWpmv69A58ZOkxmeK6M1mgwEDlXrXlBl
//0pALdqDDYHvzp73Q59SIgbzjG7Z2zkhJXr
// String? visionApi = AK.serverPHP;
await carRegistrationRecognizerController.scanText();
},
)),
Positioned(
top: 50,
child: SizedBox(
height: Get.height * .6,
width: Get.width,
child: buildImageWithBoundingBoxes(),
),
),
Positioned(
bottom: Get.height * .2,
left: Get.width * .2,
right: Get.width * .2,
child: MyElevatedButton(
title: 'Register'.tr,
onPressed: () async {
// registerCaptainController.addLisence();
// registerCaptainController.register();
registerCaptainController.addRegisrationCarForDriver(
carRegistrationRecognizerController.extracted['vin'],
carRegistrationRecognizerController.extracted['make'],
carRegistrationRecognizerController.extracted['model'],
carRegistrationRecognizerController.extracted['year'],
carRegistrationRecognizerController.extracted['color'],
carRegistrationRecognizerController.extracted['owner'],
carRegistrationRecognizerController
.extracted['expiration_date'],
carRegistrationRecognizerController
.extracted['registration_date'],
);
},
)),
],
isleading: true);
}
}
// @override
// Widget build(BuildContext context) {
// Get.find<ScanDocumentsByApi>().uploadImagePortrate();
// 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: () async {
// //0vQRyaYYDWpsv73A5CZOknseK7S2sgwE
// //3vQRyaYYSWpmv69A58ZOkxmeK6M1mgwEDlXrXlBl
// //0pALdqDDYHvzp73Q59SIgbzjG7Z2zkhJXr
// // String? visionApi = AK.serverPHP;
// await carRegistrationRecognizerController.scanText();
// },
// )),
// Positioned(
// top: 50,
// child: SizedBox(
// height: Get.height * .6,
// width: Get.width,
// child: buildImageWithBoundingBoxes(),
// ),
// ),
// Positioned(
// bottom: Get.height * .2,
// left: Get.width * .2,
// right: Get.width * .2,
// child: MyElevatedButton(
// title: 'Register'.tr,
// onPressed: () async {
// // registerCaptainController.addLisence();
// // registerCaptainController.register();
// registerCaptainController.addRegisrationCarForDriver(
// carRegistrationRecognizerController.extracted['vin'],
// carRegistrationRecognizerController.extracted['make'],
// carRegistrationRecognizerController.extracted['model'],
// carRegistrationRecognizerController.extracted['year'],
// carRegistrationRecognizerController.extracted['color'],
// carRegistrationRecognizerController.extracted['owner'],
// carRegistrationRecognizerController
// .extracted['expiration_date'],
// carRegistrationRecognizerController
// .extracted['registration_date'],
// );
// },
// )),
// ],
// isleading: true);
// }
// }
Widget buildImageWithBoundingBoxes() {
Get.put(CarRegistrationRecognizerController());
return GetBuilder<CarRegistrationRecognizerController>(
builder: (carRegistrationRecognizerController) =>
carRegistrationRecognizerController.image == null ||
carRegistrationRecognizerController.extracted.isEmpty
? Center(
child: Text(
'No image selected yet'.tr,
style: AppStyle.headTitle2,
))
: Column(
children: [
SizedBox(
width: Get.width * .8,
height: Get.width * .5,
child: Image.file(
File(carRegistrationRecognizerController
.croppedFile!.path),
// fit: BoxFit.fill,
)),
const SizedBox(
height: 20,
),
Container(
decoration: AppStyle.boxDecoration,
height: Get.width * .5,
width: Get.width * .9,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
'${'Made :'.tr}${carRegistrationRecognizerController.extracted['make']}',
style: AppStyle.title,
),
Text(
'${'model :'.tr}${carRegistrationRecognizerController.extracted['model']}',
style: AppStyle.title,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
'${'VIN :'.tr}${carRegistrationRecognizerController.extracted['vin']}',
style: AppStyle.title,
),
Text(
'${'year :'.tr}${carRegistrationRecognizerController.extracted['year']}',
style: AppStyle.title,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [
Text(
'expiration date :${carRegistrationRecognizerController.extracted['expiration_date']}',
style: AppStyle.title,
),
Text(
'registration date :${carRegistrationRecognizerController.extracted['registration_date']}',
style: AppStyle.title,
),
],
),
Text(
'color :${carRegistrationRecognizerController.extracted['color']}',
style: AppStyle.title,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
'owner :${carRegistrationRecognizerController.extracted['owner']}',
style: AppStyle.title,
),
],
),
],
),
)
],
));
}
// Widget buildImageWithBoundingBoxes() {
// Get.put(CarRegistrationRecognizerController());
// return GetBuilder<CarRegistrationRecognizerController>(
// builder: (carRegistrationRecognizerController) =>
// carRegistrationRecognizerController.image == null ||
// carRegistrationRecognizerController.extracted.isEmpty
// ? Center(
// child: Text(
// 'No image selected yet'.tr,
// style: AppStyle.headTitle2,
// ))
// : Column(
// children: [
// SizedBox(
// width: Get.width * .8,
// height: Get.width * .5,
// child: Image.file(
// File(carRegistrationRecognizerController
// .croppedFile!.path),
// // fit: BoxFit.fill,
// )),
// const SizedBox(
// height: 20,
// ),
// Container(
// decoration: AppStyle.boxDecoration,
// height: Get.width * .5,
// width: Get.width * .9,
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// Text(
// '${'Made :'.tr}${carRegistrationRecognizerController.extracted['make']}',
// style: AppStyle.title,
// ),
// Text(
// '${'model :'.tr}${carRegistrationRecognizerController.extracted['model']}',
// style: AppStyle.title,
// ),
// ],
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// Text(
// '${'VIN :'.tr}${carRegistrationRecognizerController.extracted['vin']}',
// style: AppStyle.title,
// ),
// Text(
// '${'year :'.tr}${carRegistrationRecognizerController.extracted['year']}',
// style: AppStyle.title,
// ),
// ],
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// Column(
// children: [
// Text(
// 'expiration date :${carRegistrationRecognizerController.extracted['expiration_date']}',
// style: AppStyle.title,
// ),
// Text(
// 'registration date :${carRegistrationRecognizerController.extracted['registration_date']}',
// style: AppStyle.title,
// ),
// ],
// ),
// Text(
// 'color :${carRegistrationRecognizerController.extracted['color']}',
// style: AppStyle.title,
// ),
// ],
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// Text(
// 'owner :${carRegistrationRecognizerController.extracted['owner']}',
// style: AppStyle.title,
// ),
// ],
// ),
// ],
// ),
// )
// ],
// ));
// }

View File

@@ -3,7 +3,6 @@ import 'package:sefer_driver/controller/functions/gemeni.dart';
import 'package:sefer_driver/controller/functions/tts.dart';
import 'package:sefer_driver/views/widgets/elevated_btn.dart';
import 'package:sefer_driver/views/widgets/my_circular_indicator_timer.dart';
import 'package:sefer_driver/views/widgets/my_textField.dart';
import 'package:sefer_driver/views/widgets/mydialoug.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@@ -52,41 +51,70 @@ class EgyptCardAI extends StatelessWidget {
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
(controller.responseIdCardDriverEgyptBack.isNotEmpty &&
controller.responseIdCardDriverEgyptFront
.isNotEmpty &&
controller.responseIdEgyptFront.isNotEmpty &&
controller.responseIdEgyptBack.isNotEmpty &&
controller
.responseIdEgyptDriverLicense.isNotEmpty
// &&
// controller
// .responseCriminalRecordEgypt.isNotEmpty
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
(controller.responseIdCardDriverEgyptBack
.isNotEmpty &&
controller.responseIdCardDriverEgyptFront
.isNotEmpty &&
(controller
.responseIdEgyptFront.isNotEmpty ||
controller.responseNonIdCardFront
.isNotEmpty) &&
(controller
.responseIdEgyptBack.isNotEmpty ||
controller.responseNonIdCardBack
.isNotEmpty) &&
controller
.responseIdEgyptDriverLicense.isNotEmpty
// &&
// controller
// .responseCriminalRecordEgypt.isNotEmpty
)
? MyElevatedButton(
title: 'Next'.tr,
kolor: AppColor.greenColor,
onPressed: () {
controller.addDriverAndCarEgypt();
})
: const SizedBox(),
Row(
children: [
controller.isEgypt
? MyElevatedButton(
title: 'For Egypt'.tr,
onPressed: () {
controller.changeNationality();
})
: MyElevatedButton(
title: 'Non Egypt'.tr,
onPressed: () {
controller.changeNationality();
}),
],
)
? MyElevatedButton(
title: 'Next'.tr,
onPressed: () {
controller.addDriverAndCarEgypt();
})
: const SizedBox(),
],
),
SizedBox(
height:
(controller.responseIdCardDriverEgyptBack
.isNotEmpty &&
controller.responseIdCardDriverEgyptFront
.isNotEmpty &&
controller
.responseIdEgyptFront.isNotEmpty &&
controller
.responseIdEgyptBack.isNotEmpty &&
controller.responseIdEgyptDriverLicense
.isNotEmpty
// &&
// controller.responseCriminalRecordEgypt
// .isNotEmpty
)
? Get.height * .7
: Get.height * .85,
// (controller.responseIdCardDriverEgyptBack
// .isNotEmpty &&
// controller.responseIdCardDriverEgyptFront
// .isNotEmpty &&
// controller
// .responseIdEgyptFront.isNotEmpty &&
// controller
// .responseIdEgyptBack.isNotEmpty &&
// controller.responseIdEgyptDriverLicense
// .isNotEmpty
// &&
// controller.responseCriminalRecordEgypt
// .isNotEmpty
// )
// ?
Get.height * .7,
// : Get.height * .85,
child: ListView(
children: [
Padding(
@@ -109,8 +137,12 @@ class EgyptCardAI extends StatelessWidget {
egyptDriverLicense(),
egyptCarLicenceFront(),
egyptCarLicenceBack(),
egyptDriverIDFront(),
egyptDriverIDBack(),
controller.isEgypt
? egyptDriverIDFront()
: nonEgyptDriverIDFront(),
controller.isEgypt
? egyptDriverIDBack()
: nonEgyptDriverIDBack(),
// egyptCriminalRecord(),
],
),
@@ -498,6 +530,109 @@ class EgyptCardAI extends StatelessWidget {
);
}
GetBuilder<AI> nonEgyptDriverIDBack() {
return GetBuilder<AI>(
builder: (ai) {
if (ai.responseNonIdCardBack.isNotEmpty) {
final residencyExpiryDate =
ai.responseNonIdCardBack['residencyExpirationDate'];
final today = DateTime.now();
final residencyExpiryDateTime =
DateTime.tryParse(residencyExpiryDate);
final isExpired = residencyExpiryDateTime != null &&
residencyExpiryDateTime.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: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Non-Egyptian ID Back'.tr, style: AppStyle.title),
IconButton(
onPressed: () async {
await ai.allMethodForAI(
ai.prompts[7]['prompt'].toString(),
AppLink.uploadEgypt,
'non_id_back');
},
icon: const Icon(Icons.refresh),
),
],
),
const SizedBox(height: 8.0),
const Divider(color: AppColor.accentColor),
const SizedBox(height: 8.0),
Text(
'${'Country'.tr}: ${ai.responseNonIdCardBack['country']}',
style: AppStyle.title,
),
const SizedBox(height: 8.0),
Text(
'${'Residency Type'.tr}: ${ai.responseNonIdCardBack['residencyType']}',
),
const SizedBox(height: 8.0),
Text(
'${'Work Status'.tr}: ${ai.responseNonIdCardBack['workStatus']}',
),
const SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Issue Date'.tr}: ${ai.responseNonIdCardBack['issueDate']}',
),
Text(
'${'Birth Date'.tr}: ${ai.responseNonIdCardBack['birthDate']}',
),
],
),
const SizedBox(height: 8.0),
Text(
'${'Residency Expiration Date'.tr}: ${ai.responseNonIdCardBack['residencyExpirationDate']}',
style: AppStyle.title.copyWith(
color: !isExpired
? AppColor.greenColor
: AppColor.redColor),
),
],
),
),
);
}
return Card(
child: InkWell(
onTap: () async {
await ai.allMethodForAI(ai.prompts[7]['prompt'].toString(),
AppLink.uploadEgypt, 'non_id_back');
},
child: Column(
children: [
Image.asset(
'assets/images/7.png',
height: Get.height * .25,
width: double.maxFinite,
fit: BoxFit.fitHeight,
),
Text(
'Capture Image of Non-Egyptian ID Back'.tr,
style: AppStyle.title,
),
],
),
),
);
},
);
}
GetBuilder<AI> egyptDriverIDFront() {
return GetBuilder<AI>(
builder: (ai) {
@@ -597,6 +732,105 @@ class EgyptCardAI extends StatelessWidget {
);
}
GetBuilder<AI> nonEgyptDriverIDFront() {
return GetBuilder<AI>(
builder: (ai) {
if (ai.responseNonIdCardFront.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: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Non-Egyptian ID Front'.tr, style: AppStyle.title),
IconButton(
onPressed: () async {
await ai.allMethodForAI(
ai.prompts[6]['prompt'].toString(),
AppLink.uploadEgypt,
'non_id_front');
},
icon: const Icon(Icons.refresh),
),
],
),
const SizedBox(height: 8.0),
const Divider(color: AppColor.accentColor),
const SizedBox(height: 8.0),
Text(
'${'Full Name'.tr}: ${ai.responseNonIdCardFront['full_name']}',
style: AppStyle.title,
),
const SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Passport No'.tr}: ${ai.responseNonIdCardFront['passport_no']}',
),
Text(
'${'Card ID'.tr}: ${ai.responseNonIdCardFront['card_id']}',
),
],
),
const SizedBox(height: 8.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${'Country'.tr}: ${ai.responseNonIdCardFront['country']}',
),
Text(
'${'Gender'.tr}: ${ai.responseNonIdCardFront['gender']}',
),
],
),
const SizedBox(height: 8.0),
Text(
'${'Birth Date'.tr}: ${ai.responseNonIdCardFront['birthdate']}',
),
const SizedBox(height: 8.0),
Text(
'${'Address'.tr}: ${ai.responseNonIdCardFront['address']}',
),
],
),
),
);
}
return Card(
child: InkWell(
onTap: () async {
await ai.allMethodForAI(ai.prompts[6]['prompt'].toString(),
AppLink.uploadEgypt, 'non_id_front');
},
child: Column(
children: [
Image.asset(
'assets/images/7.jpeg',
height: Get.height * .25,
width: double.maxFinite,
fit: BoxFit.fitHeight,
),
Text(
'Capture Image of Non-Egyptian ID Front'.tr,
style: AppStyle.title,
),
],
),
),
);
},
);
}
GetBuilder<AI> egyptCarLicenceFront() {
return GetBuilder<AI>(
builder: (ai) {