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 '../../../controller/functions/gemeni.dart'; class AiPage extends StatelessWidget { ScanDocumentsByApi scanDocumentsByApi = Get.put(ScanDocumentsByApi()); RegisterCaptainController registerCaptainController = Get.put(RegisterCaptainController()); ContentController contentController = Get.put(ContentController()); @override Widget build(BuildContext context) { return MyScafolld( title: 'AI Page'.tr, body: [ Get.deviceLocale!.countryCode != 'US' ? Positioned( top: 3, left: Get.width * .2, right: Get.width * .2, child: MyElevatedButton( title: 'Take Picture Of ID Card'.tr, onPressed: () { scanDocumentsByApi.scanDocumentsByApi(); }, )) : Positioned( top: 3, left: Get.width * .1, right: Get.width * .1, child: MyElevatedButton( title: 'Take Picture Of Driver License Card'.tr, onPressed: () { contentController.generateDriverLicenseJordanContent(); }, )), Get.deviceLocale!.countryCode != 'US' ? GetBuilder( builder: (scanDocumentsByApi) => scanDocumentsByApi .responseMap.isNotEmpty ? Positioned( top: Get.height * .06, left: Get.width * .051, right: Get.width * .051, child: scanDocumentsByApi.isLoading ? Column( children: [ const MyCircularProgressIndicator(), Text( 'We are process picture please wait '.tr, style: AppStyle.title, ) ], ) : Column( children: [ Container( decoration: AppStyle.boxDecoration, height: Get.height * .4, child: Padding( padding: const EdgeInsets.all(5), child: scanDocumentsByApi .responseMap.isEmpty ? Center( child: Text( 'There is no data yet.'.tr, style: AppStyle.title, ), ) : Column( mainAxisAlignment: MainAxisAlignment .spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, children: [ Column( mainAxisAlignment: MainAxisAlignment .start, crossAxisAlignment: CrossAxisAlignment .start, children: [ Text( 'Name :${scanDocumentsByApi.name}', style: AppStyle .subtitle, ), Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, children: [ Text( 'Drivers License Class: ${scanDocumentsByApi.licenseClass}', style: AppStyle .title, ), Image.memory( scanDocumentsByApi .imageSignature, width: 100, height: 30, ), ], ), ], ), ], ), Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, children: [ Text( 'Document Number: ${scanDocumentsByApi.documentNo}', style: AppStyle.title, ), Image.memory( scanDocumentsByApi .imagePortrait, width: 60, ), ]), Text( 'Address: ${scanDocumentsByApi.address}', style: AppStyle.title, ), Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, children: [ Text( 'Height: ${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: ${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: ${scanDocumentsByApi.dob}', style: AppStyle.title, ), ], ), ], ), ), ), DateTime.parse(scanDocumentsByApi .responseMap['data']['ocr'] ['dateOfExpiry'] .toString()) .isBefore(scanDocumentsByApi.now) ? Text( 'You can\'t continue with us .\nYou should renew Driver license', style: AppStyle.title.copyWith( color: AppColor.redColor), ) : MyElevatedButton( title: 'Detect Your Face '.tr, onPressed: () => scanDocumentsByApi .checkMatchFaceApi(), ), scanDocumentsByApi.res.isEmpty ? const SizedBox() : scanDocumentsByApi.res['data'] ['result'] .toString() == 'Same' ? MyElevatedButton( onPressed: () async { await registerCaptainController .register(); await registerCaptainController .addLisence(); // await scanDocumentsByApi // .uploadImagePortrate(); }, title: 'Go to next step\nscan Car License.' .tr, kolor: AppColor.greenColor, ) : const SizedBox(), MyElevatedButton( title: 'get sql data', kolor: AppColor.yellowColor, onPressed: () { sql.deleteAllData( TableName.faceDetectTimes); sql .getAllData( TableName.faceDetectTimes) .then((value) => print( value[0]['faceDetectTimes'])); }, ) ], ), ) : Positioned( top: Get.height * .06, left: Get.width * .051, right: Get.width * .051, child: scanDocumentsByApi.isLoading ? Column( children: [ const MyCircularProgressIndicator(), Text( 'We are process picture please wait '.tr, style: AppStyle.title, ) ], ) : Column( children: [ Container( decoration: AppStyle.boxDecoration, height: Get.height * .35, child: Padding( padding: const EdgeInsets.all(5), child: Center( child: Text( 'There is no data yet.'.tr, style: AppStyle.title, ), )), ), ], ), ), ) : GetBuilder( builder: (contentController) => contentController .responseMap.isNotEmpty ? Positioned( top: Get.height * .09, left: Get.width * .051, right: Get.width * .051, child: contentController.isloading ? Column( children: [ const MyCircularProgressIndicator(), Text( 'We are process picture please wait '.tr, style: AppStyle.title, ) ], ) : SizedBox( height: Get.height * .7, child: ListView( children: [ Container( decoration: AppStyle.boxDecoration, // height: Get.height * .4, child: Padding( padding: const EdgeInsets.all(5), child: contentController .responseMap.isEmpty ? Center( child: Text( 'There is no data yet.'.tr, style: AppStyle.title, ), ) : Column( mainAxisAlignment: MainAxisAlignment .spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, children: [ Column( mainAxisAlignment: MainAxisAlignment .start, crossAxisAlignment: CrossAxisAlignment .start, children: [ Row( children: [ Text( '${'Name'.tr} :${contentController.responseMap['first_name']}', style: AppStyle .subtitle, ), Text( ' ${contentController.responseMap['last_name']}', style: AppStyle .subtitle, ), ], ), Text( '${'Name in arabic'.tr}: ${contentController.responseMap['name_in_arabic']}', style: AppStyle .title, ), Text( '${'Drivers License Class'.tr}: ${contentController.responseMap['class']}', style: AppStyle .title, ), ], ), ], ), Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, children: [ Text( '${'National Number'.tr}: ${contentController.responseMap['id']}', style: AppStyle.title, ), // Image.memory( // scanDocumentsByApi // .imagePortrait, // width: 60, // ), ]), Text( '${'Address'.tr}: ${contentController.responseMap['address']}', style: AppStyle.title, ), Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, children: [ Text( '${'Date of Birth'.tr}: ${contentController.responseMap['dob']}', style: AppStyle.title, ), Text( '${'Age'.tr} : ${contentController.responseMap['age_in_years']}', style: AppStyle.title, ), ], ), Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, children: [ Text( '${'Expiry Date'.tr}: ${contentController.responseMap['expiration_date']}', style: DateTime.parse(contentController .responseMap[ 'expiration_date'] .toString()) .isBefore( contentController .now) ? AppStyle.title.copyWith( color: AppColor .redColor) : AppStyle.title.copyWith( color: AppColor .greenColor), ), ], ), ], ), ), ), const SizedBox( height: 10, ), DateTime.parse(contentController .responseMap[ 'expiration_date'] .toString()) .isBefore(contentController.now) ? Text( 'You can\'t continue with us .\nYou should renew Driver license' .tr, style: AppStyle.title.copyWith( color: AppColor.redColor), ) : MyElevatedButton( kolor: AppColor.greenColor, title: 'Lets check Car license '.tr, onPressed: () => contentController .generateCarLicenseJordanContent()), const SizedBox( height: 10, ), contentController .responseCarLicenseMap.isNotEmpty ? Container( decoration: AppStyle.boxDecoration, // height: Get.height * .3, width: Get.width * .9, child: Column( children: [ Text( '${'Name'.tr} ${contentController.responseCarLicenseMap['name']}', style: AppStyle.title, ), Text( '${'Address'.tr} ${contentController.responseCarLicenseMap['address']}', style: AppStyle.title, ), Text( '${'Car Kind'.tr} ${contentController.responseCarLicenseMap['car_kind']}', style: AppStyle.title, ), Text( '${'Color'.tr} ${contentController.responseCarLicenseMap['car_color']}', style: AppStyle.title, ), Text( '${'Year'.tr} ${contentController.responseCarLicenseMap['car_year']}', style: AppStyle.title, ), Text( '${'Car Plate'.tr} ${contentController.responseCarLicenseMap['car_plate']}', style: AppStyle.title, ), Text( '${'Car Expire'.tr} ${contentController.responseCarLicenseMap['expire_date_of_license']}', style: contentController .responseCarLicenseMap .isNotEmpty ? DateTime.parse(contentController .responseCarLicenseMap[ 'expire_date_of_license'] .toString()) .isBefore(contentController .now) ? AppStyle.title.copyWith( color: AppColor .redColor) : AppStyle.title.copyWith( color: AppColor .greenColor) : null, ), ], ), ) : const SizedBox(), const SizedBox( height: 10, ), // DateTime.parse(contentController // .responseCarLicenseMap[ // 'expire_date_of_license'] // .toString()) // .isBefore(contentController.now) // ? Text( // 'You can\'t continue with us .\nYou should renew Car license' // .tr, // style: AppStyle.title.copyWith( // color: AppColor.redColor), // ) // : MyElevatedButton( kolor: AppColor.greenColor, title: 'Lets check License Back Face'.tr, onPressed: () => contentController .generateBackCarLicenseJordanContent()), const SizedBox( height: 10, ), contentController .responseBackCarLicenseMap .isNotEmpty ? Container( decoration: AppStyle.boxDecoration, // height: 300, child: Column(children: [ Text( 'VIN ${contentController.responseBackCarLicenseMap['vin']}', style: AppStyle.title, ), Text( 'Fuel Type ${contentController.responseBackCarLicenseMap['fuelType']}', style: AppStyle.title, ), Text( 'Insurance Company ${contentController.responseBackCarLicenseMap['insuranceCompany']}', style: AppStyle.title, ), Text( 'Policy Number ${contentController.responseBackCarLicenseMap['policyNumber']}', style: AppStyle.title, ), Text( 'Insurance Type ${contentController.responseBackCarLicenseMap['insuranceType']}', style: AppStyle.title, ) ])) : const SizedBox() // MyElevatedButton( // title: 'Detect Your Face '.tr, // onPressed: () => scanDocumentsByApi // .checkMatchFaceApi(), // ), // scanDocumentsByApi.res.isEmpty // ? const SizedBox() // : scanDocumentsByApi.res['data'] // ['result'] // .toString() == // 'Same' // ? MyElevatedButton( // onPressed: () async { // await registerCaptainController // .register(); // await registerCaptainController // .addLisence(); // // await scanDocumentsByApi // // .uploadImagePortrate(); // }, // title: // 'Go to next step\nscan Car License.' // .tr, // kolor: AppColor.greenColor, // ) // : const SizedBox(), // MyElevatedButton( // title: 'get sql data', // kolor: AppColor.yellowColor, // onPressed: () { // sql.deleteAllData( // TableName.faceDetectTimes); // sql // .getAllData( // TableName.faceDetectTimes) // .then((value) => print( // value[0]['faceDetectTimes'])); // }, // ), ], ), ), ) : Positioned( top: Get.height * .06, left: Get.width * .051, right: Get.width * .051, child: scanDocumentsByApi.isLoading ? Column( children: [ const MyCircularProgressIndicator(), Text( 'We are process picture please wait '.tr, style: AppStyle.title, ) ], ) : Column( children: [ Container( decoration: AppStyle.boxDecoration, height: Get.height * .35, child: Padding( padding: const EdgeInsets.all(5), child: Center( child: Text( 'There is no data yet.'.tr, style: AppStyle.title, ), )), ), ], ), ), ) ], isleading: true); } }