This commit is contained in:
Hamza-Ayed
2024-07-15 11:37:06 +03:00
parent 65a8084c92
commit 4ffaa591fa
22 changed files with 739 additions and 42 deletions

View File

@@ -1,5 +1,8 @@
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/controller/functions/crud.dart';
import 'package:SEFER/controller/functions/gemeni.dart';
import 'package:SEFER/controller/functions/tts.dart';
import 'package:SEFER/main.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@@ -814,7 +817,7 @@ Please fill in the JSON object with the extracted information, following these g
final inspectionDate =
ai.responseIdCardDriverEgyptBack['inspection_date'];
final year = int.parse(inspectionDate.split('-')[0]);
final inspectionDateTime = DateTime(year, 1, 1);
final inspectionDateTime = DateTime(year, 12, 31);
// Check if the tax expiry date is before today
final today = DateTime.now();

View File

@@ -0,0 +1,210 @@
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/main.dart';
import 'package:SEFER/views/widgets/my_scafold.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../constant/colors.dart';
import '../../../constant/links.dart';
import '../../../controller/functions/gemeni.dart';
import '../../../controller/functions/tts.dart';
import '../../widgets/elevated_btn.dart';
class CriminalDocumemtPage extends StatelessWidget {
const CriminalDocumemtPage({super.key});
@override
Widget build(BuildContext context) {
Get.put(AI());
return MyScafolld(
title: "Criminal Document".tr,
isleading: false,
body: [
GetBuilder<AI>(builder: (controller) {
return Column(
children: [
Container(
decoration: AppStyle.boxDecoration,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text('You have upload Criminal documents'.tr),
)),
egyptCriminalRecord(),
controller.responseCriminalRecordEgypt.isNotEmpty
? MyElevatedButton(
title: 'Next'.tr,
onPressed: () async {
if (controller
.responseCriminalRecordEgypt['FullName'] !=
box.read(BoxName.nameArabic)) //todo get from server
{
Get.defaultDialog(
barrierDismissible: false,
title: 'Criminal Record Mismatch',
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.warning,
size: 48, color: Colors.red),
const SizedBox(height: 16),
Text(
'The full name on your criminal record does not match the one on your drivers license. Please verify and provide the correct documents.'
.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
const SizedBox(height: 16),
IconButton(
onPressed: () async {
await Get.find<TextToSpeechController>()
.speakText(
'The full name on your criminal record does not match the one on your drivers license. Please verify and provide the correct documents.'
.tr,
);
},
icon: const Icon(Icons.volume_up),
),
],
),
actions: [
TextButton(
onPressed: () {
Get.back();
},
child: const Text('OK'),
),
],
);
} else {
await controller.addCriminalDeocuments();
}
})
: const SizedBox(),
],
);
})
],
);
}
GetBuilder<AI> egyptCriminalRecord() {
return GetBuilder<AI>(
builder: (ai) {
if (ai.responseCriminalRecordEgypt.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('Criminal Record'.tr, style: AppStyle.headTitle2),
IconButton(
onPressed: () async {
await ai.allMethodForAI(
"""
Write a JSON object from the following information extracted from the provided Arabic text:
{
"InspectionResult": "",
"NationalID": "",
"FullName": "",
"IssueDate": "" // Format: YYYY-MM-DD
}
Important notes:
1. For the IssueDate, ensure the date is in YYYY-MM-DD format using Latin numerals (0-9).
2. Add appropriate spaces in all text fields to ensure readability.
3. If any information is missing, leave the corresponding field as an empty string.
4. Ensure all text is properly formatted and spaces are used correctly.
5. Convert any Arabic numerals to Latin numerals (0-9) where applicable.
Please fill in the JSON object with the extracted information, following these guidelines.
""",
AppLink.uploadEgypt,
'criminalRecord',
);
},
icon: const Icon(Icons.refresh),
),
],
),
const SizedBox(height: 8.0),
const Divider(color: AppColor.accentColor),
const SizedBox(height: 8.0),
Text(
'${'InspectionResult'.tr}: ${ai.responseCriminalRecordEgypt['InspectionResult']}'),
const SizedBox(height: 8.0),
Text(
'${'FullName'.tr}: ${ai.responseCriminalRecordEgypt['FullName']}',
style: AppStyle.title.copyWith(
color: ai.responseCriminalRecordEgypt['FullName'] ==
ai.responseIdEgyptDriverLicense['name_arabic']
? AppColor.greenColor
: AppColor.redColor),
),
const SizedBox(height: 8.0),
Text(
'${'NationalID'.tr}: ${ai.responseCriminalRecordEgypt['NationalID']}'),
const SizedBox(height: 8.0),
Text(
'${'IssueDate'.tr}: ${ai.responseCriminalRecordEgypt['IssueDate']}'),
],
),
),
);
}
return Card(
child: InkWell(
onTap: () async {
await ai.allMethodForAI(
"""
Write a JSON object from the following information extracted from the provided Arabic text:
{
"InspectionResult": "",
"NationalID": "",
"FullName": "",
"IssueDate": "" // Format: YYYY-MM-DD
}
Important notes:
1. For the IssueDate, ensure the date is in YYYY-MM-DD format using Latin numerals (0-9).
2. Add appropriate spaces in all text fields to ensure readability.
3. If any information is missing, leave the corresponding field as an empty string.
4. Ensure all text is properly formatted and spaces are used correctly.
5. Convert any Arabic numerals to Latin numerals (0-9) where applicable.
Please fill in the JSON object with the extracted information, following these guidelines.
""",
AppLink.uploadEgypt,
'criminalRecord',
);
},
child: Column(
children: [
Image.asset(
'assets/images/6.png',
height: Get.height * .25,
width: double.maxFinite,
fit: BoxFit.fitHeight,
),
Text(
'Capture an Image of Your Criminal Record'.tr,
style: AppStyle.title,
),
],
),
),
);
},
);
}
}

View File

@@ -0,0 +1,122 @@
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:SEFER/views/widgets/my_textField.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../controller/auth/captin/invit_controller.dart';
class InviteDriverScreen extends StatelessWidget {
final InviteController controller = Get.put(InviteController());
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Invite a Driver'.tr)),
body: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Invite another driver and both get a gift after he completes 100 trips!"
.tr,
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
MyTextForm(
controller: controller.invitePhoneController,
label: 'Enter driver\'s phone'.tr,
hint: 'Enter driver\'s phone'.tr,
type: TextInputType.phone),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
MyElevatedButton(
title: 'Send Invite'.tr,
onPressed: controller.sendInvite,
),
MyElevatedButton(
title: 'Show Invitations'.tr,
onPressed: () async {
controller.fetchDriverStats();
},
),
],
),
const SizedBox(height: 20),
GetBuilder<InviteController>(builder: (controller) {
return SizedBox(
// decoration: AppStyle.boxDecoration,
height: Get.height * .4,
child: controller.driverInvitationData.isEmpty
? Center(
child: Text(
"No invitation found yet!".tr,
style: AppStyle.title,
),
)
: ListView.builder(
itemCount: controller.driverInvitationData.length,
itemBuilder: (context, index) {
// Ensure the 'countOfInvitDriver' key exists and is parseable as an int
int countOfInvitDriver = 0;
if (controller.driverInvitationData[index]
.containsKey('countOfInvitDriver')) {
countOfInvitDriver = int.tryParse(controller
.driverInvitationData[index]
['countOfInvitDriver']
.toString()) ??
0;
}
// Calculate the progress value, ensuring it is between 0 and 1
double progressValue = countOfInvitDriver / 100.0;
if (progressValue > 1.0) progressValue = 1.0;
if (progressValue < 0.0) progressValue = 0.0;
return Container(
margin: const EdgeInsets.symmetric(vertical: 8.0),
child: Stack(
alignment: AlignmentDirectional.center,
children: [
InkWell(
onTap: () async {
controller.onSelectDriverInvitation(index);
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: AppColor.accentColor.withOpacity(
.5), // Background color of the container
),
width: Get.width * .85,
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: LinearProgressIndicator(
value: progressValue,
color: AppColor.blueColor,
backgroundColor: AppColor.accentColor
.withOpacity(.3),
minHeight: 35,
),
),
),
),
Text(
'${controller.driverInvitationData[index]['invitorName']} ${controller.driverInvitationData[index]['countOfInvitDriver']} / 100 ${'Trip'.tr}'),
],
),
);
},
),
);
})
],
),
),
);
}
}

View File

@@ -2,6 +2,7 @@ import 'package:SEFER/constant/api_key.dart';
import 'package:SEFER/constant/links.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
import 'package:SEFER/views/auth/captin/invite_driver_screen.dart';
import 'package:SEFER/views/notification/available_rides_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
@@ -72,6 +73,13 @@ class DrawerCaptain extends StatelessWidget {
Get.to(() => HelpCaptain(), transition: Transition.size),
),
_buildDivider(),
_buildDrawerItem(
icon: Icons.share_outlined,
text: 'Share App'.tr,
onTap: () =>
Get.to(() => InviteDriverScreen(), transition: Transition.size),
),
_buildDivider(),
_buildDrawerItem(
icon: Icons.settings,
text: 'Settings'.tr,

View File

@@ -34,6 +34,7 @@ class HomeCaptain extends StatelessWidget {
Get.put(HomeCaptainController());
WidgetsBinding.instance.addPostFrameCallback((_) {
checkForUpdate(context);
_showFirstTimeOfferNotification(context);
});
return Scaffold(
appBar: AppBar(
@@ -276,7 +277,7 @@ class HomeCaptain extends StatelessWidget {
),
),
)
: SizedBox()
: const SizedBox()
// callPage(),
// Positioned(
@@ -297,35 +298,131 @@ class HomeCaptain extends StatelessWidget {
}
}
// class CameraContainer extends StatelessWidget {
// TextMLGoogleRecognizerController controller =
// Get.put(TextMLGoogleRecognizerController());
void _showFirstTimeOfferNotification(BuildContext context) {
bool isFirstTime = _checkIfFirstTime();
// CameraContainer({super.key});
// @override
// Widget build(BuildContext context) {
// return Stack(
// children: [
// // The camera preview
// SizedBox(
// height: Get.height * 0.3,
// width: Get.width * 0.9,
// child: CameraPreview(controller.imagePicker as CameraController),
// ),
if (isFirstTime) {
WidgetsBinding.instance.addPostFrameCallback((_) {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
elevation: 0,
backgroundColor: Colors.transparent,
child: Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.white,
borderRadius: BorderRadius.circular(20),
boxShadow: const [
BoxShadow(
color: Colors.black26,
blurRadius: 10.0,
offset: Offset(0.0, 10.0),
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
'Welcome Offer!'.tr,
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.w700,
),
),
const SizedBox(height: 15),
Text(
'As a new driver, you\'re eligible for a special offer!'.tr,
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 16),
),
const SizedBox(height: 20),
Stack(
children: <Widget>[
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(15),
),
child: Text(
'3000 LE'.tr,
style: const TextStyle(
color: Colors.white,
fontSize: 25,
fontWeight: FontWeight.bold,
),
),
),
Positioned(
right: -10,
top: -10,
child: Container(
padding: const EdgeInsets.all(5),
decoration: const BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
),
child: const Icon(
Icons.attach_money,
color: Colors.white,
size: 20,
),
),
),
],
),
const SizedBox(height: 20),
Text(
'for your first registration!'.tr,
style: const TextStyle(fontSize: 16),
),
const SizedBox(height: 20),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
),
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20, vertical: 10),
child: Text(
"Get it Now!".tr,
style:
const TextStyle(fontSize: 18, color: Colors.white),
),
),
onPressed: () {
Navigator.of(context).pop();
_markAsNotFirstTime();
},
),
],
),
),
);
},
);
});
}
}
// // The lines on the side of the name and national number
// const Positioned(
// bottom: 0,
// left: 0,
// right: 0,
// child: Column(
// children: [
// Text('Name'),
// Text('National Number'),
// ],
// ),
// ),
// ],
// );
// }
// }
bool _checkIfFirstTime() {
if (box.read(BoxName.isFirstTime) == null) {
return true;
} else {
return false;
}
}
void _markAsNotFirstTime() {
box.write(BoxName.isFirstTime, true);
}

View File

@@ -190,7 +190,7 @@ GetBuilder<HomeCaptainController> leftMainMenuCaptainIcons() {
// borderRadius: BorderRadius.circular(15)),
// child: IconButton(
// onPressed: () {
// print(box.read(BoxName.rideStatus));
// print(box.read(BoxName.tokenDriver));
// },
// icon: const Icon(
// FontAwesome5.grin_tears,

View File

@@ -1,6 +1,4 @@
import 'package:SEFER/constant/links.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/controller/functions/crud.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:SEFER/views/widgets/my_scafold.dart';
import 'package:SEFER/views/widgets/my_textField.dart';