This commit is contained in:
Hamza-Ayed
2024-01-18 00:49:00 +03:00
parent 358bb904ab
commit 7af7e71b30
17 changed files with 1028 additions and 269 deletions

View File

@@ -2,7 +2,7 @@ import UIKit
import Flutter
import FirebaseCore
import GoogleMaps
import Constants
// import Constants
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
@@ -11,7 +11,7 @@ import Constants
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GMSServices.provideAPIKey(mapsApiKey)
GMSServices.provideAPIKey("AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0")
FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
return true

View File

@@ -12,10 +12,14 @@ import '../../constant/colors.dart';
class ContentController extends GetxController {
final picker = ImagePicker();
Map<String, dynamic> responseMap = {};
Map<String, dynamic> responseCarLicenseMap = {};
Map<String, dynamic> responseBackCarLicenseMap = {};
Map<String, dynamic> responseIdCardeMap = {};
bool isloading = false;
var image;
CroppedFile? croppedFile;
DateTime now = DateTime.now();
Future<void> pickImage() async {
final pickedImage = await picker.pickImage(source: ImageSource.gallery);
@@ -153,6 +157,294 @@ class ContentController extends GetxController {
}
}
Future<void> generateDriverLicenseJordanContent() async {
await pickImage();
isloading = true;
update();
if (image != null) {
final imageBytes = await image.readAsBytes();
final imageData = base64Encode(imageBytes);
var requestBody = jsonEncode({
'contents': [
{
'parts': [
{
'inlineData': {
'mimeType': 'image/jpeg',
'data': imageData,
},
},
{
'text':
'write json for all data as first name ,last name,dob,id ,expiration date,issued date asdress class type,age in years ,output json type in arabic value and stay engish key and make date format like YYYY-MM-DD , for name please extract name in arabic in Name in json plus first_name ',
},
],
},
],
'generationConfig': {
'temperature': 0.4,
'topK': 32,
'topP': 1,
'maxOutputTokens': 4096,
'stopSequences': [],
},
'safetySettings': [
{
'category': 'HARM_CATEGORY_HARASSMENT',
'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
},
{
'category': 'HARM_CATEGORY_HATE_SPEECH',
'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
},
{
'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
},
{
'category': 'HARM_CATEGORY_DANGEROUS_CONTENT',
'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
},
],
});
print(requestBody);
final response = await http.post(
Uri.parse(
'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro-vision:generateContent?key=${AK.geminiApi}'),
headers: {'Content-Type': 'application/json'},
body: requestBody,
);
isloading = false;
update();
if (response.statusCode == 200) {
var responseData = jsonDecode(response.body);
// Process the responseData as needed
// print(responseData);
var result =
responseData['candidates'][0]['content']['parts'][0]['text'];
// print(jsonEncode(result));
// print((result));
// print(result['dob']);
RegExp regex = RegExp(r"```json([^`]*)```");
String? jsonString =
regex.firstMatch(responseData.toString())?.group(1)?.trim();
if (jsonString != null) {
// Convert the JSON object to a String
jsonString = jsonEncode(json.decode(jsonString));
responseMap = jsonDecode(jsonString);
print(jsonString);
print(responseMap);
print(responseMap['dob']);
} else {
print("JSON string not found");
}
// Rest of your code...
} else {
print('Request failed with status: ${response.statusCode}');
print('Request failed with status: ${response.body}');
}
} else {
print('No image selected');
}
}
Future<void> generateCarLicenseJordanContent() async {
await pickImage();
isloading = true;
update();
if (image != null) {
final imageBytes = await image.readAsBytes();
final imageData = base64Encode(imageBytes);
var requestBody = jsonEncode({
'contents': [
{
'parts': [
{
'inlineData': {
'mimeType': 'image/jpeg',
'data': imageData,
},
},
{
'text':
'write json output of this car license in jordan json contain name , address , car kind ,car color , car year , car plate ,registration adjective , using ,expire date of license and make date format like YYYY-MM-DD .dont add data else this image',
},
],
},
],
'generationConfig': {
'temperature': 0.4,
'topK': 32,
'topP': 1,
'maxOutputTokens': 4096,
'stopSequences': [],
},
'safetySettings': [
{
'category': 'HARM_CATEGORY_HARASSMENT',
'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
},
{
'category': 'HARM_CATEGORY_HATE_SPEECH',
'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
},
{
'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
},
{
'category': 'HARM_CATEGORY_DANGEROUS_CONTENT',
'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
},
],
});
print(requestBody);
final response = await http.post(
Uri.parse(
'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro-vision:generateContent?key=${AK.geminiApi}'),
headers: {'Content-Type': 'application/json'},
body: requestBody,
);
isloading = false;
update();
if (response.statusCode == 200) {
var responseData = jsonDecode(response.body);
// Process the responseData as needed
// print(responseData);
var result =
responseData['candidates'][0]['content']['parts'][0]['text'];
// print(jsonEncode(result));
// print((result));
// print(result['dob']);
RegExp regex = RegExp(r"```json([^`]*)```");
String? jsonString =
regex.firstMatch(responseData.toString())?.group(1)?.trim();
if (jsonString != null) {
// Convert the JSON object to a String
jsonString = jsonEncode(json.decode(jsonString));
responseCarLicenseMap = jsonDecode(jsonString);
print(jsonString);
print(responseCarLicenseMap);
print(responseCarLicenseMap['plate_number']);
} else {
print("JSON string not found");
}
// Rest of your code...
} else {
print('Request failed with status: ${response.statusCode}');
print('Request failed with status: ${response.body}');
}
} else {
print('No image selected');
}
}
Future<void> generateBackCarLicenseJordanContent() async {
await pickImage();
isloading = true;
update();
if (image != null) {
final imageBytes = await image.readAsBytes();
final imageData = base64Encode(imageBytes);
var requestBody = jsonEncode({
'contents': [
{
'parts': [
{
'inlineData': {
'mimeType': 'image/jpeg',
'data': imageData,
},
},
{
'text':
'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',
},
],
},
],
'generationConfig': {
'temperature': 0.4,
'topK': 343,
'topP': 1,
'maxOutputTokens': 4096,
'stopSequences': [],
},
'safetySettings': [
{
'category': 'HARM_CATEGORY_HARASSMENT',
'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
},
{
'category': 'HARM_CATEGORY_HATE_SPEECH',
'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
},
{
'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
},
{
'category': 'HARM_CATEGORY_DANGEROUS_CONTENT',
'threshold': 'BLOCK_MEDIUM_AND_ABOVE',
},
],
});
print(requestBody);
final response = await http.post(
Uri.parse(
'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro-vision:generateContent?key=${AK.geminiApi}'),
headers: {'Content-Type': 'application/json'},
body: requestBody,
);
isloading = false;
update();
if (response.statusCode == 200) {
var responseData = jsonDecode(response.body);
// Process the responseData as needed
// print(responseData);
var result =
responseData['candidates'][0]['content']['parts'][0]['text'];
// print(jsonEncode(result));
// print((result));
// print(result['dob']);
RegExp regex = RegExp(r"```json([^`]*)```");
String? jsonString =
regex.firstMatch(responseData.toString())?.group(1)?.trim();
if (jsonString != null) {
// Convert the JSON object to a String
jsonString = jsonEncode(json.decode(jsonString));
responseBackCarLicenseMap = jsonDecode(jsonString);
// print(jsonString);
print(responseBackCarLicenseMap);
// print(responseCarLicenseMap['plate_number']);
} else {
print("JSON string not found");
}
// Rest of your code...
} else {
print('Request failed with status: ${response.statusCode}');
print('Request failed with status: ${response.body}');
}
} else {
print('No image selected');
}
}
Future<void> getFromCarRegistration() async {
await pickImage();
if (image != null) {

View File

@@ -24,6 +24,7 @@ class LocationController extends GetxController {
void onInit() async {
super.onInit();
location = Location();
totalPoints = Get.find<CaptainWalletController>().totalPoints;
getLocation();
}

View File

@@ -185,6 +185,7 @@ class HomeCaptainController extends GetxController {
getPaymentToday();
getAllPayment();
startPeriodicExecution();
onMapCreated(mapHomeCaptaiController!);
getRefusedOrderByCaptain();
totalPoints = Get.find<CaptainWalletController>().totalPoints;
super.onInit();

View File

@@ -31,11 +31,17 @@ class MapDriverController extends GetxController {
Set<Marker> markers = {};
late String passengerLocation;
late String passengerDestination;
late String step0;
late String step1;
late String step2;
late String step3;
late String step4;
late String duration;
late String distance;
late String name;
late String phone;
late String rideId;
late String isHaveSteps;
late String paymentAmount;
late String paymentMethod;
late String passengerId;
@@ -311,20 +317,15 @@ class MapDriverController extends GetxController {
),
);
// Update the `markers` set and call the `update()` method on the controller to notify the view that the marker position has changed.
update();
// No recursive call here. The marker update will be triggered externally.
// Optionally, you can animate the camera to the new location after updating the marker.
mapController!.animateCamera(
CameraUpdate.newLatLng(locationController.myLocation),
);
update();
}
void addCustomCarIcon() {
ImageConfiguration config = ImageConfiguration(
size: Size(Get.width * .6, Get.height * .6),
ImageConfiguration config = const ImageConfiguration(
size: Size(20, 20),
// scale: 1.0,
);
BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png')
@@ -441,13 +442,25 @@ class MapDriverController extends GetxController {
rideId = Get.arguments['rideId'];
durationOfRideValue = Get.arguments['durationOfRideValue'];
paymentAmount = Get.arguments['paymentAmount'];
paymentMethod = Get.arguments['paymentMethod'];
isHaveSteps = Get.arguments['isHaveSteps'];
step0 = Get.arguments['step0'];
step1 = Get.arguments['step1'];
step2 = Get.arguments['step2'];
step3 = Get.arguments['step3'];
step4 = Get.arguments['step4'];
String lat = Get.find<LocationController>().myLocation.latitude.toString();
String lng = Get.find<LocationController>().myLocation.longitude.toString();
String origin = '$lat,$lng';
// Set the origin and destination coordinates for the Google Maps directions request.
getMap(origin, passengerLocation);
await getMapDestination(passengerLocation, passengerDestination);
isHaveSteps == 'haveSteps'
? (
await getMapDestination(step0, step1),
await getMapDestination(step1, step2),
await getMapDestination(step2, step3),
await getMapDestination(step3, step4),
)
: await getMapDestination(passengerLocation, passengerDestination);
addCustomCarIcon();
// updateMarker();
startTimerToShowPassengerInfoWindowFromDriver();

View File

@@ -67,12 +67,12 @@ class MapPassengerController extends GetxController {
late LatLng newPointLocation3 = const LatLng(32.115295, 36.064773);
late LatLng newPointLocation4 = const LatLng(32.115295, 36.064773);
LatLng myDestination = const LatLng(32.115295, 36.064773);
final List<LatLng> polylineCoordinates = [];
final List<LatLng> polylineCoordinates0 = [];
final List<LatLng> polylineCoordinates1 = [];
final List<LatLng> polylineCoordinates2 = [];
final List<LatLng> polylineCoordinates3 = [];
final List<LatLng> polylineCoordinates4 = [];
List<LatLng> polylineCoordinates = [];
List<LatLng> polylineCoordinates0 = [];
List<LatLng> polylineCoordinates1 = [];
List<LatLng> polylineCoordinates2 = [];
List<LatLng> polylineCoordinates3 = [];
List<LatLng> polylineCoordinates4 = [];
List<List<LatLng>> polylineCoordinatesPointsAll = [];
List<LatLng> carsLocationByPassenger = [];
List<LatLng> driverCarsLocationToPassengerAfterApplied = [];
@@ -187,7 +187,8 @@ class MapPassengerController extends GetxController {
late Duration durationToAdd;
late DateTime newTime = DateTime.now();
int hours = 0;
int minutes = 0;
void onChangedPassengerCount(int newValue) {
selectedPassengerCount = newValue;
update();
@@ -573,7 +574,15 @@ class MapPassengerController extends GetxController {
rideTimerBegin.toString(),
dataCarsLocationByPassenger['message'][carsOrder]['driver_id']
.toString(),
durationToRide.toString()
durationToRide.toString(),
Get.find<WayPointController>().wayPoints.length > 1
? 'haveSteps'
: 'startEnd',
placesCoordinate[0],
placesCoordinate[1],
placesCoordinate[2],
placesCoordinate[3],
placesCoordinate[4],
];
FirebaseMessagesController().sendNotificationToDriverMAP(
'Order',
@@ -636,6 +645,14 @@ class MapPassengerController extends GetxController {
cancelRideAfterRejectFromAll();
}
} else if (decod['data'].toString() == 'Cancel') {
remainingTime = 0;
shouldFetch = false;
rideConfirm = false;
FirebaseMessagesController().sendNotificationToDriverMAP(
'Trip Canceled'.tr, '', driverToken, []);
update();
} else {
delayAndFetchRideStatus(
rideId); // Repeat the delay and fetch operation
@@ -807,6 +824,7 @@ class MapPassengerController extends GetxController {
"status": 'Cancel'
});
rideConfirm = false;
totalStepDurations = 0;
shouldFetch = false;
isPassengerChosen = false;
isCashConfirmPageShown = false;
@@ -825,6 +843,7 @@ class MapPassengerController extends GetxController {
if (rideConfirm == false) {
clearPlacesDestination();
clearPolyline();
// clearPolylineAll();
data = [];
changeCancelRidePageShow();
rideConfirm = false;
@@ -834,6 +853,7 @@ class MapPassengerController extends GetxController {
isCashSelectedBeforeConfirmRide = false;
isPickerShown = false;
totalStepDurations = 0;
totalStepDurations = 0;
timeToPassengerFromDriverAfterApplied = 0;
update();
} else {
@@ -852,7 +872,9 @@ class MapPassengerController extends GetxController {
isCashSelectedBeforeConfirmRide = false;
timeToPassengerFromDriverAfterApplied = 0;
totalStepDurations = 0;
totalStepDurations = 0;
changeCancelRidePageShow();
// clearPolylineAll();
remainingTime = 0;
update();
@@ -1073,9 +1095,27 @@ class MapPassengerController extends GetxController {
void clearPolyline() {
polyLines = [];
polylineCoordinates.clear();
// polylineCoordinates = [];
polylineCoordinatesPointsAll[0].clear();
polylineCoordinatesPointsAll[1].clear();
polylineCoordinatesPointsAll[2].clear();
polylineCoordinatesPointsAll[3].clear();
polylineCoordinatesPointsAll[4].clear();
update();
}
// void clearPolylineAll() {
// polylineCoordinatesPointsAll[0].clear();
// polylineCoordinatesPointsAll[1].clear();
// polylineCoordinatesPointsAll[2].clear();
// polylineCoordinatesPointsAll[3].clear();
// polylineCoordinatesPointsAll[4].clear();
// polyLines = [];
// polylineCoordinates.clear();
// update();
// }
void addCustomPicker() {
ImageConfiguration config = const ImageConfiguration(
size: Size(20, 20),
@@ -1111,9 +1151,9 @@ class MapPassengerController extends GetxController {
}
void addCustomCarIcon() {
ImageConfiguration config = ImageConfiguration(
size: Size(Get.width * .6, Get.height * .6),
// size: Size(20, 20),
ImageConfiguration config = const ImageConfiguration(
// size: Size(Get.width * .6, Get.height * .6),
size: Size(20, 20),
// scale: 1.0,
);
BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png')
@@ -1414,19 +1454,23 @@ class MapPassengerController extends GetxController {
int totalStepDurations = 0;
getMapPoints(String origin, String destination, int index) async {
isWayPointStopsSheetUtilGetMap = false;
await getCarsLocationByPassenger();
isLoading = false;
update();
var url =
('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}');
print(url);
// print(url);
var response = await CRUD().getGoogleApi(link: url, payload: {});
data = response['routes'][0]['legs'];
// print(data);
isLoading = false;
int durationToRide0 = data[0]['duration']['value'];
durationToRide = durationToRide + durationToRide0;
print('durationToRide is ${data[0]['duration']['value']}');
print('totalStepDurations is $durationToRide');
update();
durationToRide = durationToRide + int.parse(data[0]['duration']['value']);
// totalStepDurations = totalStepDurations + durationToRide;
final points =
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
for (int i = 0; i < points.length; i++) {
@@ -1452,20 +1496,20 @@ class MapPassengerController extends GetxController {
// Animate the camera to the adjusted bounds
if (distanceOfDestnation <= 5) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 14));
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 15));
} else if (distanceOfDestnation > 5 && distanceOfDestnation <= 8) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 13));
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 14));
} else if (distanceOfDestnation > 8 && distanceOfDestnation < 16) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 12));
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 13));
} else if (distanceOfDestnation >= 16 && distanceOfDestnation < 30) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 11));
} else if (distanceOfDestnation >= 30 && distanceOfDestnation < 100) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 10));
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 9));
} else if (distanceOfDestnation >= 100) {
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 7));
}
if (polyLines.isNotEmpty) {
clearPolyline();
// clearPolyline();
} else {
var polyline = Polyline(
polylineId: PolylineId(response["routes"][0]["summary"]),
@@ -1540,18 +1584,21 @@ class MapPassengerController extends GetxController {
print('=================================');
distance = getDistanceFromText(distanceText);
duration = getDistanceFromText(durationText);
durationToAdd = Duration(minutes: duration.toInt());
durationToAdd = Duration(seconds: durationToRide);
print('durationToRide----- $durationToRide');
hours = durationToAdd.inHours;
minutes = (durationToAdd.inMinutes % 60).round();
DateTime currentTime = DateTime.now();
newTime = currentTime.add(durationToAdd);
averageDuration = duration / distance;
costDuration = duration * averageDuration * 0.016;
averageDuration = (durationToRide / 60) / distance;
costDuration = (durationToRide / 60) * averageDuration * 0.016;
var totalDriver1 = cost + costDuration;
totalPassenger = totalDriver1 + (totalDriver1 * .16);
totalDriver = totalDriver1 + (totalDriver1 * .16);
tax = totalPassenger * .04;
totalME = totalPassenger - totalDriver - tax;
tax = totalPassenger * .16;
totalME = totalPassenger - tax;
update();
if (currentTime.hour >= 21) {
if (currentTime.hour >= 22) {
if (distanceText.contains('km')) {
cost = distance * 0.23;
update();
@@ -1570,7 +1617,7 @@ class MapPassengerController extends GetxController {
} else if (currentTime.hour >= 13 && currentTime.hour <= 16) {
if (averageDuration > 2.5) {
if (distanceText.contains('km')) {
cost = distance * 0.23;
cost = distance * 0.25;
update();
} else {
cost = distance * 0.25 / 1000;
@@ -1599,8 +1646,8 @@ class MapPassengerController extends GetxController {
totalPassenger = 1;
update();
if (totalDriver < .5) {
totalDriver = .80;
totalME = .16;
totalDriver = .75;
totalME = .21;
update();
} else {
totalDriver = .90;

View File

@@ -20,6 +20,7 @@ class SplashScreenController extends GetxController
@override
void onInit() {
super.onInit();
animationController = AnimationController(
vsync: this,
duration: const Duration(seconds: 7),

View File

@@ -7,6 +7,7 @@ import '../themes/themes.dart';
class LocaleController extends GetxController {
Locale? language;
String countryCode = '';
void restartApp() {
runApp(const MyApp());
}
@@ -30,11 +31,13 @@ class LocaleController extends GetxController {
break;
default:
locale = Locale(Get.deviceLocale!.languageCode);
appTheme = themeEnglish;
break;
}
box.write(BoxName.lang, langcode);
// box.write(BoxName.lang, langcode);
Get.changeTheme(appTheme);
Get.updateLocale(locale);
restartApp();

View File

@@ -35,7 +35,8 @@ void main() async {
await GetStorage.init();
await AC().gAK();
print(
'local is ${WidgetsBinding.instance.platformDispatcher.locale.countryCode}');
'local is t ${WidgetsBinding.instance.platformDispatcher.locale.countryCode}');
print(Get.deviceLocale!.countryCode);
Stripe.publishableKey = AK.publishableKey;
//StripeKey.publishableKey;

View File

@@ -1,90 +1,391 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ride/constant/colors.dart';
import 'package:ride/constant/links.dart';
import 'package:ride/constant/style.dart';
import 'package:ride/constant/table_names.dart';
import 'package:ride/controller/auth/captin/register_captin_controller.dart';
import 'package:ride/controller/functions/ocr_controller.dart';
import 'package:ride/main.dart';
import 'package:ride/views/auth/captin/car_license_page.dart';
import 'package:ride/views/widgets/elevated_btn.dart';
import 'package:ride/views/widgets/my_scafold.dart';
import 'package:ride/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: [
Positioned(
top: 3,
left: Get.width * .2,
right: Get.width * .2,
child: MyElevatedButton(
title: 'Take Picture Of ID Card'.tr,
onPressed: () {
scanDocumentsByApi.scanDocumentsByApi();
},
)),
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,
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<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 :${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(),
),
)
: Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: <Widget>[
Column(
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<ContentController>(
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.start,
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(
'Name :${scanDocumentsByApi.name}',
style: AppStyle.subtitle,
'${'Address'.tr}: ${contentController.responseMap['address']}',
style: AppStyle.title,
),
Row(
mainAxisAlignment:
@@ -92,177 +393,250 @@ class AiPage extends StatelessWidget {
.spaceBetween,
children: [
Text(
'Drivers License Class: ${scanDocumentsByApi.licenseClass}',
'${'Date of Birth'.tr}: ${contentController.responseMap['dob']}',
style: AppStyle.title,
),
Image.memory(
scanDocumentsByApi
.imageSignature,
width: 100,
height: 30,
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),
),
],
),
],
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
),
),
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(
'Document Number: ${scanDocumentsByApi.documentNo}',
'${'Name'.tr} ${contentController.responseCarLicenseMap['name']}',
style: AppStyle.title,
),
Image.memory(
scanDocumentsByApi
.imagePortrait,
width: 60,
Text(
'${'Address'.tr} ${contentController.responseCarLicenseMap['address']}',
style: AppStyle.title,
),
]),
Text(
'Address: ${scanDocumentsByApi.address}',
style: AppStyle.title,
),
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
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(
'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}',
'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']));
// },
// ),
],
),
),
),
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),
)
: 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,
)
: MyElevatedButton(
title: 'Detect Your Face '.tr,
onPressed: () => scanDocumentsByApi
.checkMatchFaceApi(),
],
)
: 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,
),
)),
),
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);
}

View File

@@ -24,6 +24,7 @@ class LoginCaptin extends StatelessWidget {
@override
Widget build(BuildContext context) {
Get.put(LoginCaptinController());
return GetBuilder<LoginCaptinController>(
builder: (controller) => MyScafolld(
title: 'Login Captin'.tr,

View File

@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ride/controller/auth/captin/register_captin_controller.dart';
import 'package:ride/views/auth/captin/car_license_page.dart';
import 'package:ride/views/widgets/elevated_btn.dart';
import 'package:ride/views/widgets/my_scafold.dart';

View File

@@ -13,6 +13,7 @@ import '../../../../controller/home/captin/home_captain_controller.dart';
import '../../../../controller/home/captin/order_request_controller.dart';
import '../../../../controller/home/captin/widget/connect.dart';
import '../../../../controller/home/captin/widget/left_menu_map_captain.dart';
import '../../../../controller/local/local_controller.dart';
import '../../../../main.dart';
import '../../../widgets/circle_container.dart';
@@ -26,6 +27,7 @@ class HomeCaptain extends StatelessWidget {
Get.put(OrderRequestController());
Get.put(HomeCaptainController());
// Get.put(HomeCaptainController());
print('local is ${Get.find<LocaleController>().language!.countryCode}');
return Scaffold(
appBar: AppBar(
backgroundColor: AppColor.greenColor,

View File

@@ -45,7 +45,12 @@ class OrderRequestPage extends StatelessWidget {
launchUrl1(mapUrl);
},
icon: const Icon(Icons.map),
label: Text('Rouats of Trip'.tr)),
label: myList[20].toString() == 'haveSteps'
? Text(
'Trip has Steps'.tr,
style: AppStyle.title,
)
: Text('Rouats of Trip'.tr, style: AppStyle.title)),
myList[13].toString() ==
'true' //Visa or Cash Method from notify to driver
? Text(
@@ -206,7 +211,13 @@ class OrderRequestPage extends StatelessWidget {
'durationOfRideValue': myList[19].toString(),
'paymentAmount': myList[3].toString(),
'paymentMethod':
myList[13].toString() == 'true' ? 'visa' : 'cash'
myList[13].toString() == 'true' ? 'visa' : 'cash',
'isHaveSteps': myList[20].toString(),
'step0': myList[21].toString(),
'step1': myList[22].toString(),
'step2': myList[23].toString(),
'step3': myList[24].toString(),
'step4': myList[25].toString(),
});
},
),

View File

@@ -71,7 +71,9 @@ GetBuilder<MapPassengerController> buttomSheetMapPage() {
MainAxisAlignment.spaceEvenly,
children: [
Text(
'${'Your Ride Duration is '.tr}${controller.duration} minutes',
controller.hours > 1
? '${'Your Ride Duration is '.tr}${controller.hours} H and ${controller.minutes} m'
: '${'Your Ride Duration is '.tr} ${controller.minutes} m',
style: AppStyle.subtitle,
),
Text(

View File

@@ -57,18 +57,28 @@ class PointsPageForRider extends StatelessWidget {
controller.clearPolyline();
controller.isWayPointStopsSheetUtilGetMap =
false;
mapPassengerController.durationToRide = 0;
for (var i = 0;
i < wayPointController.wayPoints.length;
i++) {
mapPassengerController.getMapPoints(
mapPassengerController.placesCoordinate[i]
.toString(),
mapPassengerController
.placesCoordinate[i + 1]
.toString(),
i,
);
if (mapPassengerController
.placesCoordinate[i + 1]
.toString() !=
'') {
mapPassengerController.getMapPoints(
mapPassengerController
.placesCoordinate[i]
.toString(),
mapPassengerController
.placesCoordinate[i + 1]
.toString(),
i,
);
}
}
controller.bottomSheet();
controller.showBottomSheet1();
},
child: const Text('Get Map'),
)

View File

@@ -74,8 +74,9 @@ class RideBeginPassenger extends StatelessWidget {
.phone, // Set the keyboard type to phone
validator: (value) {
if (value!.isEmpty ||
value.length < 10) {
return 'Please enter a phone number';
value.length != 10) {
return 'Please enter a valid phone number'
.tr;
}
// Add additional validation if needed
return null;