5/2/passnew
This commit is contained in:
@@ -1,109 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
|
||||
import '../../constant/colors.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../functions/crud.dart';
|
||||
|
||||
class CaptainAdminController extends GetxController {
|
||||
bool isLoading = false;
|
||||
Map captainData = {};
|
||||
Map captain = {};
|
||||
final captainController = TextEditingController();
|
||||
final captainPrizeController = TextEditingController();
|
||||
final titleNotify = TextEditingController();
|
||||
final bodyNotify = TextEditingController();
|
||||
final formCaptainKey = GlobalKey<FormState>();
|
||||
final formCaptainPrizeKey = GlobalKey<FormState>();
|
||||
|
||||
Future getCaptainCount() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().get(link: AppLink.getCaptainDetails, payload: {});
|
||||
var d = jsonDecode(res);
|
||||
if (d['status'] == 'success') {
|
||||
captainData = d;
|
||||
print(captainData);
|
||||
}
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
Future addCaptainPrizeToWallet() async {
|
||||
String? paymentId;
|
||||
//todo link to add wallet to captain
|
||||
for (var i = 0; i < captainData['message'].length; i++) {
|
||||
await CRUD().post(link: AppLink.addDriverPaymentPoints, payload: {
|
||||
'driverID': captainData['message'][i]['id'],
|
||||
'amount': captainPrizeController.text,
|
||||
'paymentMethod': 'Prize',
|
||||
}).then((value) {
|
||||
paymentId = value['message'].toString();
|
||||
});
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'driverID': captainData['message'][i]['id'],
|
||||
'amount': captainPrizeController.text,
|
||||
'paymentMethod': 'Prize',
|
||||
'paymentID': paymentId.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
Get.back();
|
||||
}
|
||||
|
||||
void addCaptainsPrizeToWalletSecure() async {
|
||||
try {
|
||||
// Check if local authentication is available
|
||||
bool isAvailable = await LocalAuthentication().isDeviceSupported();
|
||||
if (isAvailable) {
|
||||
// Authenticate the user
|
||||
bool didAuthenticate = await LocalAuthentication().authenticate(
|
||||
localizedReason: 'Use Touch ID or Face ID to confirm payment',
|
||||
);
|
||||
if (didAuthenticate) {
|
||||
// User authenticated successfully, proceed with payment
|
||||
await addCaptainPrizeToWallet();
|
||||
Get.snackbar('Prize Added', '', backgroundColor: AppColor.greenColor);
|
||||
} else {
|
||||
// Authentication failed, handle accordingly
|
||||
Get.snackbar('Authentication failed', '',
|
||||
backgroundColor: AppColor.redColor);
|
||||
// print(
|
||||
// 'Authentication failed');
|
||||
}
|
||||
} else {
|
||||
// Local authentication not available, proceed with payment without authentication
|
||||
await addCaptainPrizeToWallet();
|
||||
Get.snackbar('Prize Added', '', backgroundColor: AppColor.greenColor);
|
||||
}
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future getCaptains() async {
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.getCaptainDetailsByEmailOrIDOrPhone, payload: {
|
||||
'driver_id': captainController.text,
|
||||
'driverEmail': captainController.text,
|
||||
'driverPhone': captainController.text,
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
// print(d['message']);
|
||||
if (d['status'] == 'success') {
|
||||
captain = d;
|
||||
}
|
||||
// print(passengers);
|
||||
update();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
getCaptainCount();
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:SEFER/constant/colors.dart';
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/controller/functions/crud.dart';
|
||||
|
||||
class PassengerAdminController extends GetxController {
|
||||
bool isLoading = false;
|
||||
Map passengersData = {};
|
||||
Map passengers = {};
|
||||
double height = 150;
|
||||
final formPassKey = GlobalKey<FormState>();
|
||||
final formPrizeKey = GlobalKey<FormState>();
|
||||
final titleNotify = TextEditingController();
|
||||
final bodyNotify = TextEditingController();
|
||||
final passengerController = TextEditingController();
|
||||
final passengerPrizeController = TextEditingController();
|
||||
|
||||
Future getPassengerCount() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().get(link: AppLink.getPassengerDetails, payload: {});
|
||||
var d = jsonDecode(res);
|
||||
if (d['status'] == 'success') {
|
||||
passengersData = d;
|
||||
}
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
Future addPassengerPrizeToWallet() async {
|
||||
for (var i = 0; i < passengersData['message'].length; i++) {
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': passengersData['message'][i]['id'],
|
||||
'balance': passengerPrizeController.text,
|
||||
});
|
||||
}
|
||||
|
||||
Get.back();
|
||||
}
|
||||
|
||||
void addPassengerPrizeToWalletSecure() async {
|
||||
try {
|
||||
// Check if local authentication is available
|
||||
bool isAvailable = await LocalAuthentication().isDeviceSupported();
|
||||
if (isAvailable) {
|
||||
// Authenticate the user
|
||||
bool didAuthenticate = await LocalAuthentication().authenticate(
|
||||
localizedReason: 'Use Touch ID or Face ID to confirm payment',
|
||||
);
|
||||
if (didAuthenticate) {
|
||||
// User authenticated successfully, proceed with payment
|
||||
await addPassengerPrizeToWallet();
|
||||
Get.snackbar('Prize Added', '', backgroundColor: AppColor.greenColor);
|
||||
} else {
|
||||
// Authentication failed, handle accordingly
|
||||
Get.snackbar('Authentication failed', '',
|
||||
backgroundColor: AppColor.redColor);
|
||||
// print(
|
||||
// 'Authentication failed');
|
||||
}
|
||||
} else {
|
||||
// Local authentication not available, proceed with payment without authentication
|
||||
await addPassengerPrizeToWallet();
|
||||
Get.snackbar('Prize Added', '', backgroundColor: AppColor.greenColor);
|
||||
}
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future getPassengers() async {
|
||||
var res = await CRUD().get(link: AppLink.getPassengerbyEmail, payload: {
|
||||
'passengerEmail': passengerController.text,
|
||||
'passengerId': passengerController.text,
|
||||
'passengerphone': passengerController.text,
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
// print(d['message']);
|
||||
if (d['status'] == 'success') {
|
||||
passengers = d;
|
||||
}
|
||||
// print(passengers);
|
||||
update();
|
||||
}
|
||||
|
||||
changeHeight() {
|
||||
if (passengers.isEmpty) {
|
||||
height = 0;
|
||||
update();
|
||||
}
|
||||
height = 150;
|
||||
update();
|
||||
}
|
||||
|
||||
void clearPlaces() {
|
||||
passengers = {};
|
||||
update();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
getPassengerCount();
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/controller/functions/crud.dart';
|
||||
|
||||
import '../../models/model/admin/monthly_ride.dart';
|
||||
|
||||
class RideAdminController extends GetxController {
|
||||
bool isLoading = false;
|
||||
late List<MonthlyDataModel> rideData;
|
||||
late Map<String, dynamic> jsonResponse;
|
||||
List<dynamic> ridesDetails = [];
|
||||
var chartData;
|
||||
// late List<ChartDataS> chartDatasync;
|
||||
Future getRidesAdminDash() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().get(link: AppLink.getRidesPerMonth, payload: {});
|
||||
jsonResponse = jsonDecode(res);
|
||||
rideData = (jsonResponse['message'] as List)
|
||||
.map((item) => MonthlyDataModel.fromJson(item))
|
||||
.toList();
|
||||
|
||||
chartData = rideData
|
||||
.map((data) => FlSpot(data.day.toDouble(), data.ridesCount.toDouble()))
|
||||
.toList();
|
||||
|
||||
// chartDatasync = (jsonResponse['message'] as List)
|
||||
// .map((item) => ChartDataS(
|
||||
// item['year'],
|
||||
// item['month'],
|
||||
// item['day'],
|
||||
// item['rides_count'],
|
||||
// ))
|
||||
// .toList();
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
Future getRidesDetails() async {
|
||||
// isLoading = true;
|
||||
// update();
|
||||
var res = await CRUD().get(link: AppLink.getRidesDetails, payload: {});
|
||||
|
||||
var d = jsonDecode(res);
|
||||
ridesDetails = d['message'];
|
||||
|
||||
// isLoading = false;
|
||||
// update();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
List<Future> initializationTasks = [
|
||||
getRidesAdminDash(),
|
||||
getRidesDetails(),
|
||||
];
|
||||
// cameras = await availableCameras();
|
||||
await Future.wait(initializationTasks);
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
|
||||
// class ChartDataS {
|
||||
// ChartDataS(this.year, this.month, this.day, this.ridesCount);
|
||||
|
||||
// final int year;
|
||||
// final int month;
|
||||
// final int day;
|
||||
// final int ridesCount;
|
||||
// }
|
||||
@@ -1,20 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../constant/links.dart';
|
||||
import '../functions/crud.dart';
|
||||
|
||||
class WalletAdminController extends GetxController {
|
||||
bool isLoading = false;
|
||||
|
||||
late Map<String, dynamic> jsonResponse;
|
||||
List<dynamic> walletDetails = [];
|
||||
|
||||
Future getWalletAdminDash() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().get(link: AppLink.getRidesPerMonth, payload: {});
|
||||
jsonResponse = jsonDecode(res);
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../../views/home/Captin/history/history_details_page.dart';
|
||||
import '../../functions/crud.dart';
|
||||
|
||||
class HistoryCaptainController extends GetxController {
|
||||
bool isloading = false;
|
||||
Map historyData = {};
|
||||
Map historyDetailsData = {};
|
||||
late String orderID;
|
||||
getOrderId(String orderId) {
|
||||
orderID = orderId;
|
||||
update();
|
||||
}
|
||||
|
||||
getHistory() async {
|
||||
isloading = true;
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getDriverOrder,
|
||||
payload: {'driver_id': box.read(BoxName.driverID)});
|
||||
if (res != 'failure') {
|
||||
historyData = jsonDecode(res);
|
||||
print(historyData);
|
||||
isloading = false;
|
||||
update();
|
||||
} else {
|
||||
Get.defaultDialog(
|
||||
title: 'No ride yet'.tr,
|
||||
middleText: '',
|
||||
barrierDismissible: false,
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Back'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Get.back();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
getHistoryDetails(String orderId) async {
|
||||
isloading = true;
|
||||
var res = await CRUD()
|
||||
.get(link: AppLink.getRideOrderID, payload: {'id': orderId});
|
||||
historyDetailsData = jsonDecode(res);
|
||||
print(historyDetailsData);
|
||||
isloading = false;
|
||||
update();
|
||||
Get.to(() => HistoryDetailsPage());
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
getHistory();
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/controller/functions/crud.dart';
|
||||
import 'package:SEFER/controller/functions/secure_storage.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:SEFER/views/auth/captin/verify_email_captain.dart';
|
||||
import 'package:SEFER/views/home/Captin/home_captain/home_captin.dart';
|
||||
|
||||
class LoginCaptinController extends GetxController {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
TextEditingController emailController = TextEditingController();
|
||||
TextEditingController phoneController = TextEditingController();
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
bool isAgreeTerms = false;
|
||||
bool isloading = false;
|
||||
final FlutterSecureStorage _storage = const FlutterSecureStorage();
|
||||
|
||||
void changeAgreeTerm() {
|
||||
isAgreeTerms = !isAgreeTerms;
|
||||
print(isAgreeTerms);
|
||||
update();
|
||||
}
|
||||
|
||||
void saveAgreementTerms() {
|
||||
box.write(BoxName.agreeTerms, 'agreed');
|
||||
update();
|
||||
}
|
||||
|
||||
void login() async {
|
||||
isloading = true;
|
||||
update();
|
||||
var res = await CRUD().get(link: AppLink.loginCaptin, payload: {
|
||||
'email': emailController.text,
|
||||
'phone': phoneController.text,
|
||||
'password': passwordController.text
|
||||
});
|
||||
print(res);
|
||||
if (res == 'Failure') {
|
||||
isloading = false;
|
||||
update();
|
||||
Get.snackbar('Failure', '', backgroundColor: Colors.red);
|
||||
} else {
|
||||
var jsonDecoeded = jsonDecode(res);
|
||||
// print(jsonDecoeded);
|
||||
if (jsonDecoeded.isNotEmpty) {
|
||||
if (jsonDecoeded['status'] == 'success') {
|
||||
print(jsonDecoeded['data'][0]['verified']);
|
||||
if (jsonDecoeded['data'][0]['verified'] == '1') {
|
||||
box.write(BoxName.driverID, jsonDecoeded['data'][0]['id']);
|
||||
box.write(BoxName.emailDriver, jsonDecoeded['data'][0]['email']);
|
||||
box.write(
|
||||
BoxName.nameDriver, jsonDecoeded['data'][0]['first_name']);
|
||||
box.write(BoxName.phoneDriver, jsonDecoeded['data'][0]['phone']);
|
||||
SecureStorage()
|
||||
.saveData(BoxName.passwordDriver, passwordController.text);
|
||||
Get.offAll(() => HomeCaptain());
|
||||
isloading = false;
|
||||
update();
|
||||
print(box.read(BoxName.driverID).toString());
|
||||
print(box.read(BoxName.tokenDriver));
|
||||
await CRUD().post(link: AppLink.addTokensDriver, payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id': box.read(BoxName.driverID).toString()
|
||||
}).then((value) => print('cccc'));
|
||||
} else {
|
||||
isloading = false;
|
||||
update();
|
||||
Get.defaultDialog(
|
||||
title: 'You must Verify email !.'.tr,
|
||||
middleText: '',
|
||||
backgroundColor: Colors.yellow[300],
|
||||
onConfirm: () async {
|
||||
int randomNumber = Random().nextInt(100000) + 1;
|
||||
await CRUD().post(link: AppLink.sendVerifyEmail, payload: {
|
||||
'email': emailController.text,
|
||||
'token': randomNumber.toString(),
|
||||
}).then((value) => print(value));
|
||||
Get.to(() => VerifyEmailCaptainPage());
|
||||
},
|
||||
);
|
||||
}
|
||||
} else if (jsonDecoeded['status'] == 'Failure') {
|
||||
Get.snackbar(jsonDecoeded['status'], jsonDecoeded['data'],
|
||||
backgroundColor: Colors.redAccent);
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
} else {
|
||||
print('res is null');
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loginByBoxData() async {
|
||||
Get.to(() => HomeCaptain());
|
||||
await CRUD().post(link: AppLink.addTokensDriver, payload: {
|
||||
'token': box.read(BoxName.tokenDriver).toString(),
|
||||
'captain_id': box.read(BoxName.driverID).toString()
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
|
||||
// if (box.read(BoxName.driverID).toString() != null) {
|
||||
// loginByBoxData();
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart';
|
||||
import 'package:image_cropper/image_cropper.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:SEFER/constant/colors.dart';
|
||||
import 'package:SEFER/controller/functions/llama_ai.dart';
|
||||
|
||||
class CarRegistrationRecognizerController extends GetxController {
|
||||
@override
|
||||
void onInit() {
|
||||
// scanText();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
// The ImagePicker instance
|
||||
final ImagePicker _imagePicker = ImagePicker();
|
||||
|
||||
// The GoogleMlKit TextRecognizer instance
|
||||
final TextRecognizer _textRecognizer = TextRecognizer();
|
||||
|
||||
// The scanned text
|
||||
String? scannedText;
|
||||
String? jsonOutput;
|
||||
final List<Map<String, dynamic>> lines = [];
|
||||
Map extracted = {};
|
||||
XFile? image;
|
||||
CroppedFile? croppedFile;
|
||||
// Picks an image from the camera or gallery and extracts the text
|
||||
final List<Map<String, dynamic>> extractedTextWithCoordinates = [];
|
||||
|
||||
Future<void> scanText() async {
|
||||
// Pick an image from the camera or gallery
|
||||
image = await _imagePicker.pickImage(source: ImageSource.gallery);
|
||||
update();
|
||||
|
||||
// If no image was picked, return
|
||||
if (image == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Crop the image
|
||||
croppedFile = await ImageCropper().cropImage(
|
||||
sourcePath: image!.path,
|
||||
aspectRatioPresets: [
|
||||
CropAspectRatioPreset.square,
|
||||
CropAspectRatioPreset.ratio3x2,
|
||||
CropAspectRatioPreset.original,
|
||||
CropAspectRatioPreset.ratio4x3,
|
||||
CropAspectRatioPreset.ratio16x9
|
||||
],
|
||||
uiSettings: [
|
||||
AndroidUiSettings(
|
||||
toolbarTitle: 'Cropper'.tr,
|
||||
toolbarColor: AppColor.blueColor,
|
||||
toolbarWidgetColor: AppColor.yellowColor,
|
||||
initAspectRatio: CropAspectRatioPreset.original,
|
||||
lockAspectRatio: false),
|
||||
IOSUiSettings(
|
||||
title: 'Cropper'.tr,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
// If no cropped image was obtained, return
|
||||
if (croppedFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert the cropped file to an InputImage object
|
||||
final InputImage inputImage = InputImage.fromFile(File(croppedFile!.path));
|
||||
|
||||
// Recognize the text in the image
|
||||
final RecognizedText recognizedText =
|
||||
await _textRecognizer.processImage(inputImage);
|
||||
scannedText = recognizedText.text;
|
||||
|
||||
// Extract the scanned text line by line
|
||||
final List<Map<String, dynamic>> lines = [];
|
||||
for (var i = 0; i < recognizedText.blocks.length; i++) {
|
||||
lines.add({
|
||||
i.toString(): recognizedText.blocks[i].text,
|
||||
});
|
||||
}
|
||||
|
||||
String result = lines.map((map) => map.values.first.toString()).join(' ');
|
||||
// print(result.length);
|
||||
if (result.length > 2200) {
|
||||
result = result.substring(0, 2200);
|
||||
}
|
||||
// print('jsonOutput------------------------------');
|
||||
// print(result);
|
||||
Map result2 = await LlamaAi().getCarRegistrationData(result,
|
||||
'vin,make,made,year,expiration_date,color,owner,registration_date'); //
|
||||
|
||||
// Assign the result to the extracted variable
|
||||
extracted = result2;
|
||||
|
||||
print('extracted is ' + extracted.toString());
|
||||
update();
|
||||
}
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:SEFER/controller/auth/captin/login_captin_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/controller/functions/crud.dart';
|
||||
import 'package:SEFER/controller/functions/ocr_controller.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:SEFER/views/auth/captin/login_captin.dart';
|
||||
import 'package:SEFER/views/auth/captin/verify_email_captain.dart';
|
||||
|
||||
import '../../../views/auth/captin/ai_page.dart';
|
||||
import '../../../views/auth/captin/car_license_page.dart';
|
||||
import '../../../views/home/Captin/home_captain/home_captin.dart';
|
||||
|
||||
class RegisterCaptainController extends GetxController {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
|
||||
TextEditingController emailController = TextEditingController();
|
||||
TextEditingController phoneController = TextEditingController();
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
TextEditingController verifyCode = TextEditingController();
|
||||
|
||||
String birthDate = 'Birth Date'.tr;
|
||||
String gender = 'Male'.tr;
|
||||
bool isLoading = false;
|
||||
late String name;
|
||||
late String licenseClass;
|
||||
late String documentNo;
|
||||
late String address;
|
||||
late String height;
|
||||
late String postalCode;
|
||||
late String sex;
|
||||
late String stateCode;
|
||||
late String expireDate;
|
||||
late String dob;
|
||||
|
||||
getBirthDate() {
|
||||
Get.defaultDialog(
|
||||
title: 'Select Date'.tr,
|
||||
content: SizedBox(
|
||||
width: 300,
|
||||
child: CalendarDatePicker(
|
||||
initialDate: DateTime.now().subtract(const Duration(days: 18 * 365)),
|
||||
firstDate: DateTime.parse('1940-06-01'),
|
||||
lastDate: DateTime.now().subtract(const Duration(days: 18 * 365)),
|
||||
onDateChanged: (date) {
|
||||
// Get the selected date and convert it to a DateTime object
|
||||
DateTime dateTime = date;
|
||||
// Call the getOrders() function from the controller
|
||||
birthDate = dateTime.toString().split(' ')[0];
|
||||
update();
|
||||
Get.back();
|
||||
},
|
||||
|
||||
// onDateChanged: (DateTime value) {},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void changeGender(String value) {
|
||||
gender = value;
|
||||
update();
|
||||
}
|
||||
|
||||
sendVerifications() async {
|
||||
var res = await CRUD().post(link: AppLink.verifyEmail, payload: {
|
||||
'email': emailController.text.isEmpty
|
||||
? Get.find<LoginCaptinController>().emailController.text.toString()
|
||||
: emailController.text,
|
||||
'token': verifyCode.text,
|
||||
});
|
||||
|
||||
if (res != 'failure') {
|
||||
if (Get.find<LoginCaptinController>().emailController.text.toString() !=
|
||||
'') {
|
||||
Get.offAll(() => HomeCaptain());
|
||||
} else {
|
||||
Get.to(() => CarLicensePage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nextToAIDetection() async {
|
||||
//Todo dont forget this
|
||||
if (formKey.currentState!.validate()) {
|
||||
isLoading = true;
|
||||
update();
|
||||
Get.to(() => AiPage());
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> payloadLisence = {};
|
||||
|
||||
void getFromController() {
|
||||
name = Get.find<ScanDocumentsByApi>().name;
|
||||
licenseClass = Get.find<ScanDocumentsByApi>().licenseClass.toString();
|
||||
documentNo = Get.find<ScanDocumentsByApi>().documentNo.toString();
|
||||
address = Get.find<ScanDocumentsByApi>().address.toString();
|
||||
height = Get.find<ScanDocumentsByApi>().height.toString();
|
||||
postalCode = Get.find<ScanDocumentsByApi>().address.toString();
|
||||
sex = Get.find<ScanDocumentsByApi>().sex.toString();
|
||||
stateCode = Get.find<ScanDocumentsByApi>().postalCode.toString();
|
||||
expireDate = Get.find<ScanDocumentsByApi>().expireDate.toString();
|
||||
dob = Get.find<ScanDocumentsByApi>().dob.toString();
|
||||
update();
|
||||
}
|
||||
|
||||
Future addLisence() async {
|
||||
getFromController();
|
||||
var res = await CRUD().post(link: AppLink.addLicense, payload: {
|
||||
'name': name,
|
||||
'licenseClass': licenseClass,
|
||||
'documentNo': documentNo,
|
||||
'address': address,
|
||||
'height': height,
|
||||
'postalCode': postalCode,
|
||||
'sex': sex,
|
||||
'stateCode': stateCode,
|
||||
'expireDate': expireDate,
|
||||
'dateOfBirth': dob,
|
||||
});
|
||||
print(jsonDecode(res));
|
||||
isLoading = false;
|
||||
update();
|
||||
if (jsonDecode(res)['status'] == 'success') {
|
||||
// Get.to(() => AiPage()); //todo rplace this
|
||||
}
|
||||
}
|
||||
|
||||
void addRegisrationCarForDriver(String vin, make, model, year, color, owner,
|
||||
expirationDate, registrationDate) async {
|
||||
getFromController();
|
||||
var res = await CRUD().post(link: AppLink.addRegisrationCar, payload: {
|
||||
'vin': vin,
|
||||
'make': make,
|
||||
'model': model,
|
||||
'year': year,
|
||||
'expirationDate': expirationDate,
|
||||
'color': color,
|
||||
'owner': owner,
|
||||
'registrationDate': registrationDate,
|
||||
});
|
||||
print(jsonDecode(res));
|
||||
box.write(BoxName.vin, vin);
|
||||
box.write(BoxName.make, make);
|
||||
box.write(BoxName.model, model);
|
||||
box.write(BoxName.year, year);
|
||||
box.write(BoxName.expirationDate, expirationDate);
|
||||
box.write(BoxName.color, color);
|
||||
box.write(BoxName.owner, owner);
|
||||
box.write(BoxName.registrationDate, registrationDate);
|
||||
isLoading = false;
|
||||
update();
|
||||
if (jsonDecode(res)['status'] == 'success') {
|
||||
Get.offAll(() => LoginCaptin()); //todo replace this
|
||||
}
|
||||
}
|
||||
|
||||
Future register() async {
|
||||
getFromController();
|
||||
if (formKey.currentState!.validate()) {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().post(link: AppLink.signUpCaptin, payload: {
|
||||
'first_name': name.split(' ')[1],
|
||||
'last_name': name.split(' ')[0],
|
||||
'email': emailController.text,
|
||||
'phone': phoneController.text,
|
||||
'password': passwordController.text,
|
||||
'gender': sex,
|
||||
'site': address,
|
||||
'birthdate': dob,
|
||||
});
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
if (jsonDecode(res)['status'] == 'success') {
|
||||
box.write(BoxName.driverID, jsonDecode(res)['message']);
|
||||
box.write(BoxName.dobDriver, dob);
|
||||
box.write(BoxName.sexDriver, sex);
|
||||
box.write(BoxName.phoneDriver, phoneController.text);
|
||||
box.write(BoxName.lastNameDriver, name.split(' ')[0]);
|
||||
int randomNumber = Random().nextInt(100000) + 1;
|
||||
await CRUD().post(link: AppLink.sendVerifyEmail, payload: {
|
||||
'email': emailController.text,
|
||||
'token': randomNumber.toString(),
|
||||
}).then((value) => print(value));
|
||||
Get.to(() => VerifyEmailCaptainPage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@ import 'package:SEFER/main.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_sign_in/google_sign_in.dart';
|
||||
|
||||
import '../../views/auth/captin/ai_page.dart';
|
||||
|
||||
class GoogleSignInHelper {
|
||||
static final GoogleSignIn _googleSignIn = GoogleSignIn(
|
||||
scopes: [
|
||||
@@ -17,7 +15,7 @@ class GoogleSignInHelper {
|
||||
try {
|
||||
final GoogleSignInAccount? googleUser = await _googleSignIn.signIn();
|
||||
getDriverInfo();
|
||||
Get.to(() => AiPage());
|
||||
// Get.to(() => AiPage());
|
||||
return googleUser;
|
||||
} catch (error) {
|
||||
print('Google Sign-In error: $error');
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -13,9 +12,6 @@ import 'package:SEFER/main.dart';
|
||||
import 'package:SEFER/views/auth/verify_email_page.dart';
|
||||
import 'package:SEFER/views/home/map_page_passenger.dart';
|
||||
|
||||
import '../../views/admin/admin_home_page.dart';
|
||||
import '../functions/device_info.dart';
|
||||
|
||||
class LoginController extends GetxController {
|
||||
final formKey = GlobalKey<FormState>();
|
||||
final formKeyAdmin = GlobalKey<FormState>();
|
||||
@@ -44,37 +40,37 @@ class LoginController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
void adminDashboardOpen() async {
|
||||
if (formKeyAdmin.currentState!.validate()) {
|
||||
await DeviceInfoPlus.getDeviceInfo();
|
||||
if (Platform.isAndroid) {
|
||||
// print(DeviceInfoPlus.deviceDataList['serialNumber']);
|
||||
// var res = await CRUD().get(link: AppLink.getAdminUser, payload: {
|
||||
// // 'device_number': DeviceInfoPlus.deviceData['serialNumber'].toString(),
|
||||
// });
|
||||
// var d = jsonDecode(res);
|
||||
// // print(d);
|
||||
// // if (DeviceInfoPlus.deviceData['serialNumber'] ==
|
||||
// d['message']['device_number']) {
|
||||
Get.back();
|
||||
Get.to(() => const AdminHomePage());
|
||||
// }
|
||||
}
|
||||
if (Platform.isIOS) {
|
||||
// print(DeviceInfoPlus.deviceData['identifierForVendor']);
|
||||
// var res = await CRUD().get(link: AppLink.getAdminUser, payload: {
|
||||
// 'device_number': DeviceInfoPlus.deviceData['identifierForVendor'].toString(),
|
||||
// });
|
||||
// var d = jsonDecode(res);
|
||||
// print(d);
|
||||
// if (DeviceInfoPlus.deviceData['serialNumber'] ==
|
||||
// d['message']['device_number']) {
|
||||
Get.back();
|
||||
Get.to(() => const AdminHomePage());
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
// void adminDashboardOpen() async {
|
||||
// if (formKeyAdmin.currentState!.validate()) {
|
||||
// await DeviceInfoPlus.getDeviceInfo();
|
||||
// if (Platform.isAndroid) {
|
||||
// // print(DeviceInfoPlus.deviceDataList['serialNumber']);
|
||||
// // var res = await CRUD().get(link: AppLink.getAdminUser, payload: {
|
||||
// // // 'device_number': DeviceInfoPlus.deviceData['serialNumber'].toString(),
|
||||
// // });
|
||||
// // var d = jsonDecode(res);
|
||||
// // // print(d);
|
||||
// // // if (DeviceInfoPlus.deviceData['serialNumber'] ==
|
||||
// // d['message']['device_number']) {
|
||||
// Get.back();
|
||||
// Get.to(() => const AdminHomePage());
|
||||
// // }
|
||||
// }
|
||||
// if (Platform.isIOS) {
|
||||
// // print(DeviceInfoPlus.deviceData['identifierForVendor']);
|
||||
// // var res = await CRUD().get(link: AppLink.getAdminUser, payload: {
|
||||
// // 'device_number': DeviceInfoPlus.deviceData['identifierForVendor'].toString(),
|
||||
// // });
|
||||
// // var d = jsonDecode(res);
|
||||
// // print(d);
|
||||
// // if (DeviceInfoPlus.deviceData['serialNumber'] ==
|
||||
// // d['message']['device_number']) {
|
||||
// Get.back();
|
||||
// Get.to(() => const AdminHomePage());
|
||||
// // }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
void login() async {
|
||||
isloading = true;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
|
||||
import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
|
||||
import 'package:SEFER/views/home/Captin/home_captain/widget/call_page.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -18,14 +15,10 @@ import '../../constant/links.dart';
|
||||
import '../../constant/style.dart';
|
||||
import '../../main.dart';
|
||||
import '../../views/Rate/rate_captain.dart';
|
||||
import '../../views/home/Captin/home_captain/home_captin.dart';
|
||||
import '../../views/home/Captin/orderCaptin/order_speed_request.dart';
|
||||
import '../../views/home/map_page_passenger.dart';
|
||||
import '../../views/home/map_widget.dart/call_passenger_page.dart';
|
||||
import '../../views/home/profile/promos_passenger_page.dart';
|
||||
import '../../views/home/Captin/orderCaptin/order_request_page.dart';
|
||||
import '../home/map_passenger_controller.dart';
|
||||
import '../payment/payment_controller.dart';
|
||||
import 'local_notification.dart';
|
||||
|
||||
class FirebaseMessagesController extends GetxController {
|
||||
@@ -121,25 +114,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
|
||||
void fireBaseTitles(RemoteMessage message) {
|
||||
if (message.notification!.title! == 'Order') {
|
||||
if (Platform.isAndroid) {
|
||||
NotificationController().showNotification('Order', '', 'order');
|
||||
}
|
||||
var myListString = message.data['DriverList'];
|
||||
// var points = message.data['PolylineJson'];
|
||||
|
||||
var myList = jsonDecode(myListString) as List<dynamic>;
|
||||
// var myPoints = jsonDecode(points) as List<dynamic>;
|
||||
driverToken = myList[14].toString();
|
||||
// This is for location using and uploading status
|
||||
Get.put(HomeCaptainController()).changeRideId();
|
||||
update();
|
||||
// print('driverToken==============$driverToken');
|
||||
Get.to(() => OrderRequestPage(), arguments: {
|
||||
'myListString': myListString,
|
||||
'DriverList': myList,
|
||||
// 'PolylineJson': myPoints,
|
||||
'body': message.notification!.body
|
||||
});
|
||||
} else if (message.notification!.title! == 'Apply Ride') {
|
||||
var passengerList = message.data['passengerList'];
|
||||
|
||||
@@ -153,10 +127,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
NotificationController()
|
||||
.showNotification('Promo', 'Show latest promo'.tr, 'promo');
|
||||
Get.to(const PromosPassengerPage());
|
||||
} else if (message.notification!.title == 'Cancel Trip') {
|
||||
NotificationController().showNotification(
|
||||
'Cancel Trip'.tr, 'Passenger Cancel Trip'.tr, 'cancel');
|
||||
cancelTripDialog();
|
||||
} else if (message.notification!.title! == 'DriverIsGoingToPassenger') {
|
||||
Get.find<MapPassengerController>().isDriverInPassengerWay = true;
|
||||
Get.find<MapPassengerController>().update();
|
||||
@@ -227,26 +197,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
} catch (e) {
|
||||
print('Error navigating to PassengerCallPage: $e');
|
||||
}
|
||||
} else if (message.notification!.title! == 'Call Income from Passenger') {
|
||||
try {
|
||||
var myListString = message.data['passengerList'];
|
||||
var driverList = jsonDecode(myListString) as List<dynamic>;
|
||||
// if (Platform.isAndroid) {
|
||||
NotificationController().showNotification(
|
||||
'Call Income'.tr,
|
||||
message.notification!.body!,
|
||||
'iphone_ringtone',
|
||||
);
|
||||
// }
|
||||
// Assuming GetMaterialApp is initialized and context is valid for navigation
|
||||
Get.to(() => CallPage(
|
||||
// channelName: driverList[1].toString(),
|
||||
// token: driverList[0].toString(),
|
||||
// remoteID: driverList[2].toString(),
|
||||
));
|
||||
} catch (e) {
|
||||
print('Error navigating to PassengerCallPage: $e');
|
||||
}
|
||||
} else if (message.notification!.title! == 'Call End') {
|
||||
try {
|
||||
var myListString = message.data['passengerList'];
|
||||
@@ -259,7 +209,7 @@ class FirebaseMessagesController extends GetxController {
|
||||
);
|
||||
}
|
||||
// Assuming GetMaterialApp is initialized and context is valid for navigation
|
||||
Get.off(const CallPage());
|
||||
// Get.off(const CallPage());
|
||||
} catch (e) {
|
||||
print('Error navigating to PassengerCallPage: $e');
|
||||
}
|
||||
@@ -288,21 +238,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
backgroundColor: AppColor.yellowColor,
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
);
|
||||
} else if (message.notification!.title! == 'OrderSpeed') {
|
||||
var myListString = message.data['DriverList'];
|
||||
// var points = message.data['PolylineJson'];
|
||||
|
||||
var myList = jsonDecode(myListString) as List<dynamic>;
|
||||
// var myPoints = jsonDecode(points) as List<dynamic>;
|
||||
driverToken = myList[14].toString();
|
||||
update();
|
||||
// print('driverToken==============$driverToken');
|
||||
Get.to(() => OrderSpeedRequest(), arguments: {
|
||||
'myListString': myListString,
|
||||
'DriverList': myList,
|
||||
// 'PolylineJson': myPoints,
|
||||
'body': message.notification!.body
|
||||
});
|
||||
} else if (message.notification!.title! == 'Order Applied') {
|
||||
NotificationController().showNotification(
|
||||
'The order Accepted by another Driver'.tr,
|
||||
@@ -334,18 +269,6 @@ class FirebaseMessagesController extends GetxController {
|
||||
);
|
||||
}
|
||||
|
||||
Future<dynamic> cancelTripDialog() {
|
||||
return Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: 'Passenger Cancel Trip'.tr,
|
||||
middleText: '',
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok'.tr,
|
||||
onPressed: () {
|
||||
Get.offAll(HomeCaptain());
|
||||
}));
|
||||
}
|
||||
|
||||
Future<dynamic> driverArrivePassengerDialoge() {
|
||||
return Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../firebase/firbase_messge.dart';
|
||||
import '../home/captin/map_driver_controller.dart';
|
||||
import '../../main.dart';
|
||||
|
||||
class CallController extends GetxController {
|
||||
@@ -23,15 +22,15 @@ class CallController extends GetxController {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
if (box.read(BoxName.passengerID) != null) {
|
||||
channelName = Get.find<MapPassengerController>().rideId; // 'sefer300'; //
|
||||
remoteUid = int.parse(Get.find<MapPassengerController>().driverPhone);
|
||||
uid = int.parse(box.read(BoxName.phone));
|
||||
} else {
|
||||
channelName = Get.find<MapDriverController>().rideId; // 'sefer300'; //
|
||||
remoteUid = int.parse(Get.find<MapDriverController>().passengerPhone);
|
||||
uid = int.parse(box.read(BoxName.phoneDriver));
|
||||
}
|
||||
// if (box.read(BoxName.passengerID) != null) {
|
||||
channelName = Get.find<MapPassengerController>().rideId; // 'sefer300'; //
|
||||
remoteUid = int.parse(Get.find<MapPassengerController>().driverPhone);
|
||||
uid = int.parse(box.read(BoxName.phone));
|
||||
// } else {
|
||||
// channelName = Get.find<MapDriverController>().rideId; // 'sefer300'; //
|
||||
// remoteUid = int.parse(Get.find<MapDriverController>().passengerPhone);
|
||||
// uid = int.parse(box.read(BoxName.phoneDriver));
|
||||
// }
|
||||
|
||||
initAgoraFull();
|
||||
}
|
||||
@@ -46,12 +45,8 @@ class CallController extends GetxController {
|
||||
// join();
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
'Call Income from Passenger',
|
||||
box.read(BoxName.passengerID) != null
|
||||
? '${'You have call from Passenger'.tr} ${box.read(BoxName.name)}'
|
||||
: '${'You have call from driver'.tr} ${box.read(BoxName.nameDriver)}',
|
||||
box.read(BoxName.passengerID) != null
|
||||
? Get.find<MapPassengerController>().driverToken
|
||||
: Get.find<MapDriverController>().tokenPassenger,
|
||||
'${'You have call from Passenger'.tr} ${box.read(BoxName.name)}',
|
||||
Get.find<MapPassengerController>().driverToken,
|
||||
[
|
||||
token,
|
||||
channelName,
|
||||
@@ -89,10 +84,8 @@ class CallController extends GetxController {
|
||||
},
|
||||
onUserJoined: (RtcConnection connection, int remoteUid, int elapsed) {
|
||||
// Get.snackbar("Remote user uid:$remoteUid joined the channel", '');
|
||||
status =
|
||||
'${box.read(BoxName.passengerID) != null ? Get.find<MapPassengerController>().driverName : Get.find<MapDriverController>().passengerName}'
|
||||
' joined'
|
||||
.tr;
|
||||
status = Get.find<MapPassengerController>().driverName.toString();
|
||||
' joined'.tr;
|
||||
remoteUid = remoteUid;
|
||||
update();
|
||||
},
|
||||
|
||||
@@ -1,245 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:camera/camera.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart';
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
import 'package:path_provider/path_provider.dart' as path_provider;
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../../main.dart';
|
||||
|
||||
class CameraClassController extends GetxController {
|
||||
late CameraController cameraController;
|
||||
late List<CameraDescription> cameras;
|
||||
bool isCameraInitialized = false;
|
||||
final TextRecognizer _textRecognizer = TextRecognizer();
|
||||
String? scannedText;
|
||||
bool isloading = false;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
initializeCamera();
|
||||
}
|
||||
|
||||
Future<void> initializeCamera() async {
|
||||
try {
|
||||
cameras = await availableCameras();
|
||||
//update();
|
||||
cameraController = CameraController(
|
||||
cameras[0],
|
||||
ResolutionPreset.medium,
|
||||
enableAudio: false,
|
||||
);
|
||||
await cameraController.initialize();
|
||||
isCameraInitialized = true;
|
||||
update();
|
||||
} catch (e) {
|
||||
if (e is CameraException) {
|
||||
switch (e.code) {
|
||||
case 'CameraAccessDenied':
|
||||
Get.defaultDialog(
|
||||
title: 'Camera Access Denied.'.tr,
|
||||
middleText: '',
|
||||
confirm:
|
||||
MyElevatedButton(title: 'Open Settings'.tr, onPressed: () {}),
|
||||
);
|
||||
break;
|
||||
default:
|
||||
// Handle other errors here.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var imgUrl = '';
|
||||
Future extractCardId() async {
|
||||
// Construct the path for the image file
|
||||
final directory = await path_provider.getTemporaryDirectory();
|
||||
final imagePath =
|
||||
path.join(directory.path, '${box.read(BoxName.driverID)}.png');
|
||||
|
||||
// Capture the image and save it to the specified path
|
||||
final XFile capturedImage = await cameraController.takePicture();
|
||||
|
||||
// Move the captured image to the desired path
|
||||
await capturedImage.saveTo(imagePath);
|
||||
await uploadImage(File(capturedImage.path));
|
||||
|
||||
extractByAPI('${AppLink.server}/card_image/' + box.read(BoxName.driverID));
|
||||
}
|
||||
|
||||
Future extractByAPI(String imgUrl) async {
|
||||
var headers = {'apikey': 'K89368168788957'};
|
||||
var request = http.MultipartRequest(
|
||||
'POST', Uri.parse('https://api.ocr.space/parse/image'));
|
||||
request.fields.addAll({
|
||||
'language': 'ara',
|
||||
'isOverlayRequired': 'false',
|
||||
'url': imgUrl,
|
||||
'iscreatesearchablepdf': 'false',
|
||||
'issearchablepdfhidetextlayer': 'false'
|
||||
});
|
||||
|
||||
request.headers.addAll(headers);
|
||||
|
||||
http.StreamedResponse response = await request.send();
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
print(await response.stream.bytesToString());
|
||||
} else {
|
||||
print(response.reasonPhrase);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> uploadImage(File imageFile) async {
|
||||
String? basicAuthCredentials =
|
||||
await storage.read(key: BoxName.basicAuthCredentials);
|
||||
var request = http.MultipartRequest(
|
||||
'POST',
|
||||
Uri.parse(AppLink.uploadImage),
|
||||
);
|
||||
|
||||
// Attach the image file to the request
|
||||
request.files.add(
|
||||
await http.MultipartFile.fromPath('image', imageFile.path),
|
||||
); // Add the headers to the request
|
||||
request.headers.addAll({
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(basicAuthCredentials.toString()))}',
|
||||
});
|
||||
|
||||
// Add the driverID to the request
|
||||
request.fields['driverID'] = box.read(BoxName.driverID);
|
||||
// Send the request
|
||||
var response = await request.send();
|
||||
|
||||
// Read the response
|
||||
var responseData = await response.stream.toBytes();
|
||||
var responseString = String.fromCharCodes(responseData);
|
||||
scannedText = responseString;
|
||||
update();
|
||||
// Return the link received from the server
|
||||
return responseString;
|
||||
}
|
||||
|
||||
Future<void> takePictureAndMLGoogleScan() async {
|
||||
try {
|
||||
// Construct the path for the image file
|
||||
final directory = await path_provider.getTemporaryDirectory();
|
||||
final imagePath =
|
||||
path.join(directory.path, '${box.read(BoxName.driverID)}.png');
|
||||
|
||||
// Capture the image and save it to the specified path
|
||||
final XFile capturedImage = await cameraController.takePicture();
|
||||
|
||||
// Move the captured image to the desired path
|
||||
await capturedImage.saveTo(imagePath);
|
||||
|
||||
// Recognize the text in the image
|
||||
final InputImage inputImage =
|
||||
InputImage.fromFile(File(capturedImage.path));
|
||||
final RecognizedText recognizedText =
|
||||
await _textRecognizer.processImage(inputImage);
|
||||
scannedText = recognizedText.text;
|
||||
|
||||
// Extract the scanned text line by line
|
||||
final List<Map<String, dynamic>> lines = [];
|
||||
for (var i = 0; i < recognizedText.blocks.length; i++) {
|
||||
lines.add({
|
||||
'line_number': i,
|
||||
'text': recognizedText.blocks[i].text,
|
||||
});
|
||||
}
|
||||
|
||||
// Convert the list of lines to a JSON string
|
||||
final String jsonOutput = jsonEncode(lines);
|
||||
|
||||
update();
|
||||
|
||||
// Print the JSON output
|
||||
print(jsonOutput);
|
||||
|
||||
// Get.back();
|
||||
} catch (e) {
|
||||
print('Error capturing image: $e');
|
||||
}
|
||||
}
|
||||
|
||||
String getTextAsJSON(String text) {
|
||||
final lines = text.split('\n');
|
||||
final jsonList = lines.map((line) {
|
||||
return {
|
||||
'line_text': line,
|
||||
'num_words': line.trim().split(' ').length,
|
||||
};
|
||||
}).toList();
|
||||
|
||||
final json = {
|
||||
'lines': jsonList,
|
||||
'num_lines': lines.length,
|
||||
};
|
||||
|
||||
return jsonEncode(json);
|
||||
}
|
||||
|
||||
List<String> getTextBlocks(String text) {
|
||||
return text.split('\n');
|
||||
}
|
||||
|
||||
// Future<void> takePictureAndTesseractScan() async {
|
||||
// try {
|
||||
// // Construct the path for the image file
|
||||
// final directory = await path_provider.getTemporaryDirectory();
|
||||
// final imagePath =
|
||||
// path.join(directory.path, '${box.read(BoxName.driverID)}.png');
|
||||
|
||||
// // Capture the image and save it to the specified path
|
||||
// final XFile capturedImage = await cameraController.takePicture();
|
||||
|
||||
// // Move the captured image to the desired path
|
||||
// await capturedImage.saveTo(imagePath);
|
||||
|
||||
// // Recognize the text in the image
|
||||
// final languages = [
|
||||
// 'eng',
|
||||
// 'ara'
|
||||
// ]; // Specify the languages you want to use for text extraction
|
||||
|
||||
// final text = await FlutterTesseractOcr.extractText(imagePath,
|
||||
// language: languages.join('+'), // Combine multiple languages with '+'
|
||||
// args: {
|
||||
// "psm": "4",
|
||||
// "preserve_interword_spaces": "1",
|
||||
// // "rectangle": const Rect.fromLTWH(100, 100, 200, 200),
|
||||
// } // Additional options if needed
|
||||
// );
|
||||
// isloading = false;
|
||||
// final jsonText = getTextAsJSON(text);
|
||||
// final textBlocks = getTextBlocks(text);
|
||||
// update();
|
||||
// scannedText =
|
||||
// textBlocks.toString(); // Convert the extracted text to JSON.
|
||||
|
||||
// // Print the JSON to the console.
|
||||
// print(jsonText);
|
||||
// update();
|
||||
// // print(text);
|
||||
// } catch (e) {
|
||||
// print('Error during text extraction: $e');
|
||||
// scannedText = '';
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
cameraController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,7 @@ import 'package:http/http.dart' as http;
|
||||
import 'package:SEFER/env/env.dart';
|
||||
|
||||
import '../../constant/api_key.dart';
|
||||
import 'gemeni.dart';
|
||||
import 'llama_ai.dart';
|
||||
|
||||
import 'upload_image.dart';
|
||||
|
||||
class CRUD {
|
||||
@@ -106,7 +105,7 @@ class CRUD {
|
||||
Future.delayed(const Duration(seconds: 2));
|
||||
String extracted =
|
||||
await arabicTextExtractByVisionAndAI(imagePath: imagePath);
|
||||
await AI().geminiAiExtraction(prompt, extracted);
|
||||
// await AI().geminiAiExtraction(prompt, extracted);
|
||||
}
|
||||
|
||||
Future<dynamic> arabicTextExtractByVisionAndAI({
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// import 'dart:io';
|
||||
//
|
||||
// import 'package:get/get.dart';
|
||||
// import 'package:image_picker/image_picker.dart';
|
||||
// import 'package:google_ml_kit/google_ml_kit.dart';
|
||||
//
|
||||
// class ImagePickerController extends GetxController {
|
||||
// RxBool textScanning = false.obs;
|
||||
// RxString scannedText = ''.obs;
|
||||
//
|
||||
// Future<void> getImage(ImageSource source) async {
|
||||
// try {
|
||||
// final pickedImage = await ImagePicker().pickImage(source: source);
|
||||
// if (pickedImage != null) {
|
||||
// textScanning.value = true;
|
||||
// final imageFile = File(pickedImage.path);
|
||||
// getRecognisedText(imageFile);
|
||||
// }
|
||||
// } catch (e) {
|
||||
// textScanning.value = false;
|
||||
// scannedText.value = "Error occurred while scanning";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Future<void> getRecognisedText(File image) async {
|
||||
// final inputImage = InputImage.fromFilePath(image.path);
|
||||
// final textDetector = GoogleMlKit.vision.textRecognizer();
|
||||
// final RecognizedText recognisedText =
|
||||
// await textDetector.processImage(inputImage);
|
||||
// await textDetector.close();
|
||||
//
|
||||
// scannedText.value = '';
|
||||
// for (TextBlock block in recognisedText.blocks) {
|
||||
// for (TextLine line in block.lines) {
|
||||
// scannedText.value += line.text + '\n';
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// textScanning.value = false;
|
||||
// }
|
||||
// }
|
||||
@@ -1,928 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:image_cropper/image_cropper.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:image/image.dart' as img;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import '../../constant/api_key.dart';
|
||||
import '../../constant/colors.dart';
|
||||
|
||||
class AI 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);
|
||||
|
||||
if (pickedImage != null) {
|
||||
image = File(pickedImage.path);
|
||||
// Crop the image
|
||||
croppedFile = await ImageCropper().cropImage(
|
||||
sourcePath: image!.path,
|
||||
aspectRatioPresets: [
|
||||
CropAspectRatioPreset.square,
|
||||
CropAspectRatioPreset.ratio3x2,
|
||||
CropAspectRatioPreset.original,
|
||||
CropAspectRatioPreset.ratio4x3,
|
||||
CropAspectRatioPreset.ratio16x9
|
||||
],
|
||||
uiSettings: [
|
||||
AndroidUiSettings(
|
||||
toolbarTitle: 'Cropper'.tr,
|
||||
toolbarColor: AppColor.blueColor,
|
||||
toolbarWidgetColor: AppColor.yellowColor,
|
||||
initAspectRatio: CropAspectRatioPreset.original,
|
||||
lockAspectRatio: false),
|
||||
IOSUiSettings(
|
||||
title: 'Cropper'.tr,
|
||||
),
|
||||
],
|
||||
);
|
||||
// image = croppedFile;
|
||||
|
||||
// Resize the image
|
||||
final rawImage =
|
||||
img.decodeImage(File(croppedFile!.path).readAsBytesSync());
|
||||
final resizedImage =
|
||||
img.copyResize(rawImage!, width: 800); // Adjust the width as needed
|
||||
|
||||
final appDir = await getTemporaryDirectory();
|
||||
final resizedImagePath = '${appDir.path}/resized_image.jpg';
|
||||
|
||||
final resizedImageFile = File(resizedImagePath);
|
||||
resizedImageFile.writeAsBytesSync(
|
||||
img.encodeJpg(resizedImage)); // Save the resized image as JPEG
|
||||
|
||||
image = resizedImageFile;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> generateContent() async {
|
||||
await pickImage();
|
||||
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,licenseID,expiration date,issued date asdress class type ,output json type',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'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,
|
||||
);
|
||||
|
||||
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));
|
||||
print(jsonString);
|
||||
} 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> geminiAiExtraction(String prompt, payload) async {
|
||||
var requestBody = jsonEncode({
|
||||
'contents': [
|
||||
{
|
||||
'parts': [
|
||||
// {
|
||||
// 'inlineData': {
|
||||
// 'mimeType': 'image/jpeg',
|
||||
// 'data': imageData,
|
||||
// },
|
||||
// },
|
||||
{
|
||||
'text':
|
||||
"Extract the desired information from the following passage as json decoded like $prompt just in this:\n\n$payload"
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'generationConfig': {
|
||||
'temperature': 0.4,
|
||||
'topK': 32,
|
||||
'topP': 1,
|
||||
'maxOutputTokens': 4096,
|
||||
'stopSequences': [],
|
||||
},
|
||||
'safety_settings': [
|
||||
{"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_NONE"},
|
||||
{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_NONE"},
|
||||
{
|
||||
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
||||
"threshold": "BLOCK_NONE"
|
||||
},
|
||||
{
|
||||
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
|
||||
"threshold": "BLOCK_NONE"
|
||||
},
|
||||
]
|
||||
});
|
||||
print(requestBody);
|
||||
|
||||
final response = await http.post(
|
||||
Uri.parse(
|
||||
// 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro-vision:generateContent?key=${AK.geminiApi}'),
|
||||
'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro-latest:generateContent?key=AIzaSyCyoLcSkDzK5_SMe00nhut56SSXWPR074w'),
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: requestBody,
|
||||
);
|
||||
|
||||
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));
|
||||
print(jsonString);
|
||||
} 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}');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getDriverLicenseJordanContent() 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> getCarLicenseJordanContent() 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':
|
||||
'''Extract the following information from the front face of the Jordanian ID card:
|
||||
Name
|
||||
National ID number
|
||||
Gender
|
||||
Date of birth
|
||||
Output the extracted information in the following JSON format''',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'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://${API_ENDPOINT}/v1/projects/${PROJECT_ID}/locations/${LOCATION_ID}/publishers/google/models/${MODEL_ID}:streamGenerateContent'),
|
||||
'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> jordanID() 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':
|
||||
'''Extract the following information from the front face of the Jordanian ID card:
|
||||
Name
|
||||
National ID number
|
||||
Gender
|
||||
Date of birth
|
||||
Output the extracted information in the following JSON format''',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'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> carLicenseJordan() 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':
|
||||
'''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''',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'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-1.0-pro-vision-latest: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 getTextFromCard(String prompt) 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': prompt,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'generationConfig': {
|
||||
"temperature": 1,
|
||||
"topK": 32,
|
||||
"topP": 0.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-1.0-pro-vision-latest: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> 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) {
|
||||
final imageBytes = await image.readAsBytes();
|
||||
final imageData = base64Encode(imageBytes);
|
||||
|
||||
var requestBody = jsonEncode({
|
||||
'contents': [
|
||||
{
|
||||
'parts': [
|
||||
{
|
||||
'inlineData': {
|
||||
'mimeType': 'image/jpeg',
|
||||
'data': imageData,
|
||||
},
|
||||
},
|
||||
{
|
||||
'text':
|
||||
'write output json from image for[ vin, make, model, year, expiration_date, color, owner, registration_date ],output json type ',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'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,
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
var responseData = jsonDecode(response.body);
|
||||
// Process the responseData as needed
|
||||
var result =
|
||||
responseData['candidates'][0]['content']['parts'][0]['text'];
|
||||
print(result);
|
||||
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));
|
||||
print(jsonString);
|
||||
} 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');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// generateContent();
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/controller/functions/crud.dart';
|
||||
import 'package:SEFER/controller/functions/gemeni.dart';
|
||||
|
||||
class LlamaAi {
|
||||
Future<Map> getCarRegistrationData(String input, prompt) async {
|
||||
print(true);
|
||||
Map exrtatDataFinal = {};
|
||||
String oneLine = input.replaceAll('\n', ' ');
|
||||
// print(oneLine);
|
||||
// var res = await CRUD().getLlama(link: AppLink.gemini, payload: oneLine);
|
||||
var res = await CRUD()
|
||||
.getLlama(link: AppLink.llama, payload: oneLine, prompt: prompt);
|
||||
|
||||
print(res);
|
||||
var decod = jsonDecode(res.toString());
|
||||
print(decod);
|
||||
// exrtatDataFinal = jsonDecode(extractDataFromJsonString(decod['choices']));
|
||||
extractDataFromJsonString(decod['choices'][0]['message']['content']);
|
||||
print(jsonEncode(exrtatDataFinal));
|
||||
print(false);
|
||||
return exrtatDataFinal;
|
||||
}
|
||||
|
||||
String extractDataFromJsonString(String jsonString) {
|
||||
// Remove any leading or trailing whitespace from the string
|
||||
jsonString = jsonString.trim();
|
||||
|
||||
// Extract the JSON substring from the given string
|
||||
final startIndex = jsonString.indexOf('{');
|
||||
final endIndex = jsonString.lastIndexOf('}');
|
||||
final jsonSubstring = jsonString.substring(startIndex, endIndex + 1);
|
||||
|
||||
// Parse the JSON substring into a Map
|
||||
final jsonData = jsonDecode(jsonSubstring);
|
||||
|
||||
// Return the extracted data
|
||||
|
||||
// print(jsonEncode(jsonData));
|
||||
return jsonEncode(jsonData);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:location/location.dart';
|
||||
@@ -10,8 +9,6 @@ import 'package:SEFER/controller/functions/crud.dart';
|
||||
import 'package:SEFER/controller/home/payment/captain_wallet_controller.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
|
||||
import '../home/captin/map_driver_controller.dart';
|
||||
|
||||
// LocationController.dart
|
||||
class LocationController extends GetxController {
|
||||
LocationData? _currentLocation;
|
||||
@@ -71,39 +68,6 @@ class LocationController extends GetxController {
|
||||
: totalDistance.toStringAsFixed(1),
|
||||
'status': box.read(BoxName.statusDriverLocation).toString()
|
||||
});
|
||||
// Animate camera to user location (optional)
|
||||
// if (Get.find<HomeCaptainController>().rideId == 'rideId') {
|
||||
// Get.find<MapDriverController>()
|
||||
// .mapController!
|
||||
// .animateCamera(CameraUpdate.newLatLng(LatLng(
|
||||
// Get.find<LocationController>().myLocation.latitude,
|
||||
// Get.find<LocationController>().myLocation.longitude,
|
||||
// )));
|
||||
// }
|
||||
Get.find<HomeCaptainController>()
|
||||
.mapHomeCaptainController
|
||||
.animateCamera(CameraUpdate.newLatLng(LatLng(
|
||||
Get.find<LocationController>().myLocation.latitude,
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
)));
|
||||
// if (Get.find<HomeCaptainController>().rideId == '0') {
|
||||
// await sql.insertData({
|
||||
// 'driver_id': box.read(BoxName.driverID),
|
||||
// 'latitude': myLocation.latitude.toString(),
|
||||
// 'longitude': myLocation.longitude.toString(),
|
||||
// 'created_at': DateTime.now().toString(),
|
||||
// }, TableName.carLocations);
|
||||
// } else {
|
||||
// await sql.insertData({
|
||||
// 'order_id': Get.find<MapDriverController>().rideId,
|
||||
// 'created_at': DateTime.now().toString(),
|
||||
// 'lat': myLocation.latitude.toString(),
|
||||
// 'lng': myLocation.longitude.toString(),
|
||||
// }, TableName.rideLocation);
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
// }
|
||||
@@ -157,17 +121,17 @@ class LocationController extends GetxController {
|
||||
speed = _locationData.speed!;
|
||||
heading = _locationData.heading!;
|
||||
// Calculate the distance between the current location and the previous location
|
||||
if (Get.find<HomeCaptainController>().rideId == 'rideId') {
|
||||
if (previousTime > 0) {
|
||||
double distance = calculateDistanceInKmPerHour(
|
||||
previousTime, _locationData.time, speed);
|
||||
print('distance $distance');
|
||||
totalDistance += distance;
|
||||
}
|
||||
// print('totalDistance: $totalDistance');
|
||||
// if (Get.find<HomeCaptainController>().rideId == 'rideId') {
|
||||
// if (previousTime > 0) {
|
||||
// double distance = calculateDistanceInKmPerHour(
|
||||
// previousTime, _locationData.time, speed);
|
||||
// print('distance $distance');
|
||||
// totalDistance += distance;
|
||||
// }
|
||||
// // print('totalDistance: $totalDistance');
|
||||
|
||||
previousTime = _locationData.time!;
|
||||
}
|
||||
// previousTime = _locationData.time!;
|
||||
// }
|
||||
// Print location details
|
||||
// print('myLocation: ${myLocation}');
|
||||
// print('Accuracy: ${_locationData.accuracy}');
|
||||
|
||||
@@ -1,673 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:camera/camera.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:SEFER/constant/api_key.dart';
|
||||
import 'package:SEFER/constant/colors.dart';
|
||||
import 'package:SEFER/constant/info.dart';
|
||||
import 'package:SEFER/constant/style.dart';
|
||||
import 'package:SEFER/constant/table_names.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../auth/captin/register_captin_controller.dart';
|
||||
import 'launch.dart';
|
||||
|
||||
//
|
||||
// class TextExtractionController extends GetxController {
|
||||
// String extractedText = '';
|
||||
// bool isloading = false;
|
||||
// File? _scannedImage;
|
||||
// // Convert the extracted text to JSON
|
||||
// // Convert the extracted text to JSON
|
||||
// String getTextAsJSON(String text) {
|
||||
// final lines = text.split('\n');
|
||||
// final jsonList = lines.map((line) {
|
||||
// return {
|
||||
// 'line_text': line,
|
||||
// 'num_words': line.trim().split(' ').length,
|
||||
// };
|
||||
// }).toList();
|
||||
//
|
||||
// final json = {
|
||||
// 'lines': jsonList,
|
||||
// 'num_lines': lines.length,
|
||||
// };
|
||||
//
|
||||
// return jsonEncode(json);
|
||||
// }
|
||||
//
|
||||
// // Convert the extracted text to blocks by line
|
||||
// List<String> getTextBlocks(String text) {
|
||||
// return text.split('\n');
|
||||
// }
|
||||
//
|
||||
// // Future<void> pickAndExtractText() async {
|
||||
// // final pickedImage = await ImagePicker().pickImage(
|
||||
// // source: ImageSource.camera,
|
||||
// // preferredCameraDevice: CameraDevice.rear,
|
||||
// // maxHeight: Get.height * .3,
|
||||
// // maxWidth: Get.width * .8,
|
||||
// // imageQuality: 99,
|
||||
// // );
|
||||
// // if (pickedImage != null) {
|
||||
// // isloading = true;
|
||||
// // update();
|
||||
// // final imagePath = pickedImage.path;
|
||||
// // final languages = [
|
||||
// // 'eng',
|
||||
// // 'ara'
|
||||
// // ]; // Specify the languages you want to use for text extraction
|
||||
//
|
||||
// // try {
|
||||
// // final text = await FlutterTesseractOcr.extractText(imagePath,
|
||||
// // language:
|
||||
// // languages.join('+'), // Combine multiple languages with '+'
|
||||
// // args: {
|
||||
// // "psm": "4",
|
||||
// // "preserve_interword_spaces": "1",
|
||||
// // // "rectangle": const Rect.fromLTWH(100, 100, 200, 200),
|
||||
// // } // Additional options if needed
|
||||
// // );
|
||||
// // isloading = false;
|
||||
// // final jsonText = getTextAsJSON(text);
|
||||
// // final textBlocks = getTextBlocks(text);
|
||||
// // update();
|
||||
// // extractedText =
|
||||
// // textBlocks.toString(); // Convert the extracted text to JSON.
|
||||
//
|
||||
// // // Print the JSON to the console.
|
||||
// // print(jsonText);
|
||||
// // update();
|
||||
// // // print(text);
|
||||
// // } catch (e) {
|
||||
// // print('Error during text extraction: $e');
|
||||
// // extractedText = '';
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// }
|
||||
|
||||
// class TextMLGoogleRecognizerController extends GetxController {
|
||||
// @override
|
||||
// void onInit() {
|
||||
// scanText();
|
||||
// super.onInit();
|
||||
// }
|
||||
//
|
||||
// // The ImagePicker instance
|
||||
// final ImagePicker _imagePicker = ImagePicker();
|
||||
//
|
||||
// // The GoogleMlKit TextRecognizer instance
|
||||
// final TextRecognizer _textRecognizer = TextRecognizer();
|
||||
//
|
||||
// // The scanned text
|
||||
// String? scannedText;
|
||||
// String? jsonOutput;
|
||||
// final List<Map<String, dynamic>> lines = [];
|
||||
//
|
||||
// Map decode = {};
|
||||
//
|
||||
// Future<void> scanText() async {
|
||||
// // Pick an image from the camera or gallery
|
||||
// final XFile? image =
|
||||
// await _imagePicker.pickImage(source: ImageSource.gallery);
|
||||
//
|
||||
// // If no image was picked, return
|
||||
// if (image == null) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // Convert the XFile object to an InputImage object
|
||||
// final InputImage inputImage = InputImage.fromFile(File(image.path));
|
||||
//
|
||||
// // Recognize the text in the image
|
||||
// final RecognizedText recognizedText =
|
||||
// await _textRecognizer.processImage(inputImage);
|
||||
// scannedText = recognizedText.text;
|
||||
// Map extractedData = {};
|
||||
// // Extract the scanned text line by line
|
||||
// for (var i = 0; i < recognizedText.blocks.length; i++) {
|
||||
// final block = recognizedText.blocks[i];
|
||||
// for (final line in block.lines) {
|
||||
// final lineText = line.text;
|
||||
//
|
||||
// if (lineText.contains('DL')) {
|
||||
// final dlNumber = lineText.split('DL')[1].trim();
|
||||
// extractedData['dl_number'] = dlNumber;
|
||||
// }
|
||||
// if (lineText.contains('USA')) {
|
||||
// final usa = lineText.split('USA')[1].trim();
|
||||
// extractedData['USA'] = usa;
|
||||
// }
|
||||
// if (lineText.contains('DRIVER LICENSE')) {
|
||||
// final driverl = lineText;
|
||||
// extractedData['DRIVER_LICENSE'] = driverl;
|
||||
// }
|
||||
//
|
||||
// if (lineText.contains('EXP')) {
|
||||
// final expiryDate = lineText.split('EXP')[1].trim();
|
||||
// extractedData['expiry_date'] = expiryDate;
|
||||
// }
|
||||
//
|
||||
// if (lineText.contains('DOB')) {
|
||||
// final dob = lineText.split('DOB')[1].trim();
|
||||
// extractedData['dob'] = dob;
|
||||
// }
|
||||
//
|
||||
// if (lineText.contains("LN")) {
|
||||
// if ((lineText.indexOf("LN") == 0)) {
|
||||
// final lastName = lineText.split('LN')[1].trim();
|
||||
// extractedData['lastName'] = lastName;
|
||||
// }
|
||||
// }
|
||||
// if (lineText.contains("FN")) {
|
||||
// final firstName = lineText.split('FN')[1].trim();
|
||||
// extractedData['firstName'] = firstName;
|
||||
// }
|
||||
// if (lineText.contains("RSTR")) {
|
||||
// final rstr = lineText.split('RSTR')[1].trim();
|
||||
// extractedData['rstr'] = rstr;
|
||||
// }
|
||||
// if (lineText.contains("CLASS")) {
|
||||
// final class1 = lineText.split('CLASS')[1].trim();
|
||||
// extractedData['class'] = class1;
|
||||
// }
|
||||
// if (lineText.contains("END")) {
|
||||
// final end = lineText.split('END')[1].trim();
|
||||
// extractedData['end'] = end;
|
||||
// }
|
||||
// if (lineText.contains("DD")) {
|
||||
// final dd = lineText.split('DD')[1].trim();
|
||||
// extractedData['dd'] = dd;
|
||||
// }
|
||||
// if (lineText.contains("EYES")) {
|
||||
// final eyes = lineText.split('EYES')[1].trim();
|
||||
// extractedData['eyes'] = eyes;
|
||||
// }
|
||||
// if (lineText.contains("SEX")) {
|
||||
// final parts = lineText.split("SEX ")[1];
|
||||
// extractedData['sex'] = parts[0];
|
||||
// }
|
||||
// if (lineText.contains("HAIR")) {
|
||||
// final hair = lineText.split('HAIR')[1].trim();
|
||||
// extractedData['hair'] = hair;
|
||||
// }
|
||||
//
|
||||
// if (lineText.contains('STREET') || lineText.contains(',')) {
|
||||
// final address = lineText;
|
||||
// extractedData['address'] = address;
|
||||
// }
|
||||
//
|
||||
// // Repeat this process for other relevant data fields
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Convert the list of lines to a JSON string
|
||||
// jsonOutput = jsonEncode(extractedData);
|
||||
// decode = jsonDecode(jsonOutput!);
|
||||
//
|
||||
// update();
|
||||
// print('jsonOutput------------------------------');
|
||||
// print(scannedText);
|
||||
// }
|
||||
// }
|
||||
|
||||
class ScanDocumentsByApi extends GetxController {
|
||||
bool isLoading = false;
|
||||
Map<String, dynamic> responseMap = {};
|
||||
final ImagePicker imagePicker = ImagePicker();
|
||||
late Uint8List imagePortrait;
|
||||
late Uint8List imageSignature;
|
||||
late Uint8List imageDocumentFrontSide;
|
||||
XFile? image;
|
||||
XFile? imagePortraitFile;
|
||||
XFile? imageFace;
|
||||
late File tempFile;
|
||||
late String imagePath;
|
||||
DateTime now = DateTime.now();
|
||||
late String name;
|
||||
late String licenseClass;
|
||||
late String documentNo;
|
||||
late String address;
|
||||
late String stateCode;
|
||||
late String height;
|
||||
late String sex;
|
||||
late String postalCode;
|
||||
late String dob;
|
||||
late String expireDate;
|
||||
|
||||
// ///////////////////////
|
||||
// late CameraController cameraController;
|
||||
// late List<CameraDescription> cameras;
|
||||
// bool isCameraInitialized = false;
|
||||
// // final TextRecognizer _textRecognizer = TextRecognizer();
|
||||
// String? scannedText;
|
||||
|
||||
// Future<void> initializeCamera(int cameraID) async {
|
||||
// try {
|
||||
// cameras = await availableCameras();
|
||||
// //update();
|
||||
// cameraController = CameraController(
|
||||
// cameras[cameraID],
|
||||
// ResolutionPreset.medium,
|
||||
// enableAudio: false,
|
||||
// );
|
||||
// await cameraController.initialize();
|
||||
// isCameraInitialized = true;
|
||||
// update();
|
||||
// } catch (e) {
|
||||
// if (e is CameraException) {
|
||||
// switch (e.code) {
|
||||
// case 'CameraAccessDenied':
|
||||
// Get.defaultDialog(
|
||||
// title: 'Camera Access Denied.'.tr,
|
||||
// middleText: '',
|
||||
// confirm:
|
||||
// MyElevatedButton(title: 'Open Settings', onPressed: () {}),
|
||||
// );
|
||||
// break;
|
||||
// default:
|
||||
// // Handle other errors here.
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
///
|
||||
|
||||
Future<void> scanDocumentsByApi() async {
|
||||
// String? visionApi = await storage.read(key: BoxName.visionApi);
|
||||
// String? visionApi = AK.visionApi;
|
||||
// Pick an image from the camera or gallery
|
||||
// print(visionApi);
|
||||
image = await imagePicker.pickImage(source: ImageSource.camera); //
|
||||
|
||||
// If no image was picked, return
|
||||
if (image == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
isLoading = true;
|
||||
update();
|
||||
var headers = {'X-BLOBR-KEY': AK.visionApi};
|
||||
var request = http.MultipartRequest('POST',
|
||||
Uri.parse('https://api.faceonlive.com/j2y3q25y1b6maif1/api/iddoc'));
|
||||
request.files.add(await http.MultipartFile.fromPath('image', image!.path));
|
||||
request.headers.addAll(headers);
|
||||
|
||||
http.StreamedResponse response = await request.send();
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
String responseString = await response.stream.bytesToString();
|
||||
responseMap = jsonDecode(responseString);
|
||||
var ocrData = responseMap['data']['ocr'];
|
||||
name = ocrData['name'].toString();
|
||||
licenseClass = ocrData['dlClass'].toString();
|
||||
documentNo = ocrData['documentNumber'].toString();
|
||||
address = ocrData['address'].toString();
|
||||
height = ocrData['height'].toString();
|
||||
postalCode = ocrData['addressPostalCode'].toString();
|
||||
sex = ocrData['sex'].toString();
|
||||
stateCode = ocrData['addressJurisdictionCode'].toString();
|
||||
expireDate = ocrData['dateOfExpiry'].toString();
|
||||
dob = ocrData['dateOfBirth'].toString();
|
||||
if (responseMap['data'] != null &&
|
||||
responseMap['data']['image'] != null &&
|
||||
responseMap['data']['image']['portrait'] != null) {
|
||||
imagePortrait = base64Decode(responseMap['data']['image']['portrait']);
|
||||
String tempPath = Directory.systemTemp.path;
|
||||
tempFile = File('$tempPath/image.jpg');
|
||||
await tempFile.writeAsBytes(imagePortrait);
|
||||
|
||||
imagePath = tempFile.path;
|
||||
// imagePortraitFile=File(imagePath) ;
|
||||
update();
|
||||
} else {
|
||||
// Handle error or provide a default value
|
||||
}
|
||||
|
||||
if (responseMap['data']['image']['signature'] != null) {
|
||||
imageSignature =
|
||||
base64Decode(responseMap['data']['image']['signature']);
|
||||
} else {
|
||||
imageSignature = imagePortrait;
|
||||
// Handle error or provide a default value
|
||||
}
|
||||
|
||||
if (responseMap['data'] != null &&
|
||||
responseMap['data']['image'] != null &&
|
||||
responseMap['data']['image']['documentFrontSide'] != null) {
|
||||
imageDocumentFrontSide =
|
||||
base64Decode(responseMap['data']['image']['documentFrontSide']);
|
||||
} else {
|
||||
// Handle error or provide a default value
|
||||
}
|
||||
|
||||
// print(responseMap);
|
||||
isLoading = false;
|
||||
update();
|
||||
} else {
|
||||
print(response.reasonPhrase);
|
||||
}
|
||||
}
|
||||
|
||||
late int times;
|
||||
Future checkMatchFaceApi() async {
|
||||
sql.getAllData(TableName.faceDetectTimes).then((value) {
|
||||
if (value.isEmpty || value == null) {
|
||||
sql.insertData({'faceDetectTimes': 1}, TableName.faceDetectTimes);
|
||||
sql.getAllData(TableName.faceDetectTimes).then((value) {
|
||||
times = value[0]['faceDetectTimes'];
|
||||
update();
|
||||
});
|
||||
} else {
|
||||
if (times < 4) {
|
||||
times++;
|
||||
matchFaceApi();
|
||||
sql.updateData(
|
||||
{'faceDetectTimes': times}, TableName.faceDetectTimes, 1);
|
||||
} else {
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: 'You have finished all times '.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
middleText: 'if you want help you can email us here'.tr,
|
||||
middleTextStyle: AppStyle.title,
|
||||
cancel: MyElevatedButton(
|
||||
title: 'Thanks'.tr,
|
||||
kolor: AppColor.greenColor,
|
||||
onPressed: () => Get.back(),
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Email Us'.tr,
|
||||
kolor: AppColor.yellowColor, //
|
||||
onPressed: () {
|
||||
launchCommunication('email', 'support@mobile-app.store',
|
||||
'${'Hi'.tr} ${AppInformation.appName}\n${'I cant register in your app in face detection '.tr}');
|
||||
Get.back();
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Map res = {};
|
||||
Future matchFaceApi() async {
|
||||
// String? visionApi = await storage.read(key: BoxName.visionApi);
|
||||
imageFace = await imagePicker.pickImage(
|
||||
source: ImageSource.camera,
|
||||
preferredCameraDevice: CameraDevice.front,
|
||||
);
|
||||
|
||||
// If no image was picked, return
|
||||
if (image == null) {
|
||||
return;
|
||||
}
|
||||
final imageFile = File(imageFace!.path);
|
||||
// Uint8List imageBytes = await imageFile.readAsBytes();
|
||||
var headers = {'X-BLOBR-KEY': AK.visionApi};
|
||||
var request = http.MultipartRequest(
|
||||
'POST',
|
||||
Uri.parse(
|
||||
'https://api.faceonlive.com/sntzbspfsdupgid1/api/face_compare'));
|
||||
request.files
|
||||
.add(await http.MultipartFile.fromPath('image1', imageFile.path));
|
||||
request.files.add(await http.MultipartFile.fromPath('image2', imagePath));
|
||||
request.headers.addAll(headers);
|
||||
|
||||
http.StreamedResponse response = await request.send();
|
||||
print('Request: ${request.toString()}');
|
||||
print('Response Status Code: ${response.statusCode}');
|
||||
print('Response Reason Phrase: ${response.reasonPhrase}');
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
res = jsonDecode(await response.stream.bytesToString());
|
||||
print(res);
|
||||
|
||||
update();
|
||||
res['data']['result'].toString().contains('No face detected in image')
|
||||
? Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: 'No face detected'.tr,
|
||||
middleText: ''.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
confirm: MyElevatedButton(
|
||||
kolor: AppColor.yellowColor,
|
||||
title: 'Back'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
)) //
|
||||
: Get.defaultDialog(
|
||||
// barrierDismissible: false,
|
||||
title: 'Image detecting result is '.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
content: Column(
|
||||
children: [
|
||||
Text(
|
||||
res['data']['result'].toString(),
|
||||
style: res['data']['result'].toString() == 'Different'
|
||||
? AppStyle.title.copyWith(color: AppColor.redColor)
|
||||
: AppStyle.title.copyWith(color: AppColor.greenColor),
|
||||
),
|
||||
res['data']['result'].toString() == 'Different'
|
||||
? Text(
|
||||
'${'Be sure for take accurate images please\nYou have'.tr} $times ${'from 3 times Take Attention'.tr}',
|
||||
style: AppStyle.title,
|
||||
)
|
||||
: Text(
|
||||
'image verified'.tr,
|
||||
style: AppStyle.title,
|
||||
)
|
||||
],
|
||||
),
|
||||
confirm: res['data']['result'].toString() == 'Different'
|
||||
? MyElevatedButton(
|
||||
title: 'Back'.tr,
|
||||
onPressed: () => Get.back(),
|
||||
kolor: AppColor.redColor,
|
||||
)
|
||||
: MyElevatedButton(
|
||||
title: 'Next'.tr,
|
||||
onPressed: () async {
|
||||
RegisterCaptainController registerCaptainController =
|
||||
Get.put(RegisterCaptainController());
|
||||
|
||||
await registerCaptainController.register();
|
||||
await registerCaptainController.addLisence();
|
||||
await uploadImagePortrate();
|
||||
// Get.to(() => CarLicensePage());
|
||||
},
|
||||
// {
|
||||
// await uploadImage(
|
||||
// tempFile, AppLink.uploadImagePortrate);
|
||||
// Get.to(() => CarLicensePage());
|
||||
// },
|
||||
kolor: AppColor.greenColor,
|
||||
));
|
||||
} else {
|
||||
print(response.reasonPhrase);
|
||||
}
|
||||
}
|
||||
|
||||
// Todo upload images and fields
|
||||
Future<String> uploadImagePortrate() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
|
||||
var request = http.MultipartRequest(
|
||||
'POST',
|
||||
Uri.parse(AppLink.uploadImagePortrate),
|
||||
);
|
||||
|
||||
request.files.add(
|
||||
http.MultipartFile.fromBytes('image', imagePortrait),
|
||||
);
|
||||
|
||||
request.headers.addAll({
|
||||
"Content-Type": "multipart/form-data",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
|
||||
});
|
||||
request.fields['driverID'] = box.read(BoxName.driverID).toString();
|
||||
|
||||
var response = await request.send();
|
||||
|
||||
var responseData = await response.stream.toBytes();
|
||||
var responseString = String.fromCharCodes(responseData);
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
|
||||
// Print the response string
|
||||
print(responseString);
|
||||
|
||||
return responseString;
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// scanDocumentsByApi();
|
||||
// initializeCamera(0);
|
||||
sql.getAllData(TableName.faceDetectTimes).then((value) {
|
||||
if (value.isEmpty) {
|
||||
print(value);
|
||||
times = 0;
|
||||
print(times);
|
||||
update();
|
||||
// sql.insertData({'faceDetectTimes': 1}, TableName.faceDetectTimes);
|
||||
} else {
|
||||
times = value[0]['faceDetectTimes'];
|
||||
}
|
||||
});
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
|
||||
// class PassportDataExtractor extends GetxController {
|
||||
// @override
|
||||
// void onInit() {
|
||||
// extractPassportData();
|
||||
// super.onInit();
|
||||
// }
|
||||
//
|
||||
// final ImagePicker _imagePicker = ImagePicker();
|
||||
// late final XFile? image;
|
||||
// final TextRecognizer _textRecognizer = TextRecognizer();
|
||||
//
|
||||
// Future<Map<String, dynamic>> extractPassportData() async {
|
||||
// image = await _imagePicker.pickImage(source: ImageSource.gallery);
|
||||
// update();
|
||||
// if (image == null) {
|
||||
// throw Exception('No image picked');
|
||||
// }
|
||||
//
|
||||
// final InputImage inputImage = InputImage.fromFile(File(image!.path));
|
||||
// final RecognizedText recognisedText =
|
||||
// await _textRecognizer.processImage(inputImage);
|
||||
//
|
||||
// final Map<String, dynamic> extractedData = {};
|
||||
// final List<Map<String, dynamic>> extractedTextWithCoordinates = [];
|
||||
//
|
||||
// for (TextBlock block in recognisedText.blocks) {
|
||||
// for (TextLine line in block.lines) {
|
||||
// final String lineText = line.text;
|
||||
// final Rect lineBoundingBox = line.boundingBox!;
|
||||
//
|
||||
// extractedTextWithCoordinates.add({
|
||||
// 'text': lineText,
|
||||
// 'boundingBox': {
|
||||
// 'left': lineBoundingBox.left,
|
||||
// 'top': lineBoundingBox.top,
|
||||
// 'width': lineBoundingBox.width,
|
||||
// 'height': lineBoundingBox.height,
|
||||
// },
|
||||
// });
|
||||
//
|
||||
// // if (lineText.contains('Passport Number')) {
|
||||
// // final String passportNumber =
|
||||
// // lineText.split('Passport Number')[1].trim();
|
||||
// // extractedData['passportNumber'] = passportNumber;
|
||||
// // }
|
||||
// // if (lineText.contains('Given Names')) {
|
||||
// // final String givenNames = lineText.split('Given Names')[1].trim();
|
||||
// // extractedData['givenNames'] = givenNames;
|
||||
// // }
|
||||
// // if (lineText.contains('Surname')) {
|
||||
// // final String surname = lineText.split('Surname')[1].trim();
|
||||
// // extractedData['surname'] = surname;
|
||||
// // }
|
||||
// // if (lineText.contains('Nationality')) {
|
||||
// // final String nationality = lineText.split('Nationality')[1].trim();
|
||||
// // extractedData['nationality'] = nationality;
|
||||
// // }
|
||||
// // if (lineText.contains('Date of Birth')) {
|
||||
// // final String dob = lineText.split('Date of Birth')[1].trim();
|
||||
// // extractedData['dateOfBirth'] = dob;
|
||||
// // }
|
||||
// // Add more field extraction conditions as needed
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// extractedData['extractedTextWithCoordinates'] =
|
||||
// extractedTextWithCoordinates;
|
||||
// print(jsonEncode(extractedData));
|
||||
// return extractedData;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class PassportDataController extends GetxController {
|
||||
// PassportDataExtractor passportDataExtractor = PassportDataExtractor();
|
||||
// List<Map<String, dynamic>> extractedTextWithCoordinates = [];
|
||||
//
|
||||
// Future<void> extractDataAndDrawBoundingBoxes() async {
|
||||
// try {
|
||||
// Map<String, dynamic> extractedData =
|
||||
// await passportDataExtractor.extractPassportData();
|
||||
// extractedTextWithCoordinates =
|
||||
// extractedData['extractedTextWithCoordinates'];
|
||||
// update(); // Notify GetX that the state has changed
|
||||
// print(extractedTextWithCoordinates);
|
||||
// } catch (e) {
|
||||
// print('Passport data extraction failed: $e');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class BoundingBoxPainter extends CustomPainter {
|
||||
// final List<Map<String, dynamic>> boundingBoxes;
|
||||
//
|
||||
// BoundingBoxPainter(this.boundingBoxes);
|
||||
//
|
||||
// @override
|
||||
// void paint(Canvas canvas, Size size) {
|
||||
// final Paint paint = Paint()
|
||||
// ..color = Colors.red
|
||||
// ..style = PaintingStyle.stroke
|
||||
// ..strokeWidth = 2.0;
|
||||
//
|
||||
// for (Map<String, dynamic> boundingBox in boundingBoxes) {
|
||||
// double left = boundingBox['left'];
|
||||
// double top = boundingBox['top'];
|
||||
// double width = boundingBox['width'];
|
||||
// double height = boundingBox['height'];
|
||||
//
|
||||
// Rect rect = Rect.fromLTWH(left, top, width, height);
|
||||
// canvas.drawRect(rect, paint);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// bool shouldRepaint(covariant CustomPainter oldDelegate) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
@@ -1,76 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/controller/functions/crud.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:SEFER/models/model/driver/rides_summary_model.dart';
|
||||
|
||||
class DurationController extends GetxController {
|
||||
final data = DurationData;
|
||||
// late AnimationController animationController;
|
||||
late List<MonthlyDataModel> rideData;
|
||||
Map<String, dynamic> jsonData1 = {};
|
||||
bool isLoading = false;
|
||||
String totalDurationToday = '';
|
||||
var chartData;
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
await fetchData();
|
||||
}
|
||||
|
||||
Future<void> fetchData() async {
|
||||
isLoading = true;
|
||||
update(); // Notify the observers about the loading state change
|
||||
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getTotalDriverDuration,
|
||||
payload: {'driver_id': box.read(BoxName.driverID)},
|
||||
);
|
||||
jsonData1 = jsonDecode(res);
|
||||
var jsonResponse = jsonDecode(res) as Map<String, dynamic>;
|
||||
isLoading = false;
|
||||
// print(jsonResponse);
|
||||
final List<dynamic> jsonData = jsonResponse['message'];
|
||||
rideData = jsonData.map<MonthlyDataModel>((item) {
|
||||
return MonthlyDataModel.fromJson(item);
|
||||
}).toList();
|
||||
final List<FlSpot> spots = rideData
|
||||
.map((data) => FlSpot(
|
||||
data.day.toDouble(),
|
||||
data.totalDuration.toDouble(),
|
||||
))
|
||||
.toList();
|
||||
chartData = spots;
|
||||
|
||||
update(); // Notify the observers about the data and loading state change
|
||||
}
|
||||
|
||||
List<DurationData> parseData(List<dynamic> json) {
|
||||
return json.map((entry) {
|
||||
final Map<String, dynamic> entryMap = entry;
|
||||
final day = DateTime.parse(entryMap['day']);
|
||||
final totalDuration = _parseDuration(entryMap['total_duration']);
|
||||
return DurationData(day, totalDuration);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
Duration _parseDuration(String durationString) {
|
||||
final parts = durationString.split(':');
|
||||
final hours = int.parse(parts[0]);
|
||||
final minutes = int.parse(parts[1]);
|
||||
final seconds = int.parse(parts[2]);
|
||||
return Duration(hours: hours, minutes: minutes, seconds: seconds);
|
||||
}
|
||||
}
|
||||
|
||||
class DurationData {
|
||||
final DateTime day;
|
||||
final Duration totalDuration;
|
||||
|
||||
DurationData(this.day, this.totalDuration);
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../constant/box_name.dart';
|
||||
import '../../../../constant/links.dart';
|
||||
import '../../../../constant/style.dart';
|
||||
import '../../../../main.dart';
|
||||
import '../../../../views/widgets/elevated_btn.dart';
|
||||
import '../../../functions/crud.dart';
|
||||
|
||||
class HelpController extends GetxController {
|
||||
bool isLoading = false;
|
||||
final formKey = GlobalKey<FormState>();
|
||||
final helpQuestionController = TextEditingController();
|
||||
Map helpQuestionDate = {};
|
||||
Map helpQuestionRepleyDate = {};
|
||||
String status = '';
|
||||
String qustion = '';
|
||||
late int indexQuestion = 0;
|
||||
getindex(int i, String qustion1) async {
|
||||
indexQuestion = i;
|
||||
qustion = qustion1;
|
||||
update();
|
||||
}
|
||||
|
||||
void addHelpQuestion() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().post(link: AppLink.addhelpCenter, payload: {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'helpQuestion': helpQuestionController.text
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
// print(d);
|
||||
isLoading = false;
|
||||
update();
|
||||
if (d['status'].toString() == 'success') {
|
||||
getHelpQuestion();
|
||||
// Get.snackbar('Feedback data saved successfully'.tr, '',
|
||||
// backgroundColor: AppColor.greenColor,
|
||||
// snackPosition: SnackPosition.BOTTOM);
|
||||
}
|
||||
}
|
||||
|
||||
void getHelpQuestion() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().get(link: AppLink.gethelpCenter, payload: {
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
if (res == "failure") {
|
||||
// print(res);
|
||||
isLoading = false;
|
||||
update();
|
||||
Get.defaultDialog(
|
||||
title: 'There is no help Question here'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
middleText: '',
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Back'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Get.back();
|
||||
}));
|
||||
}
|
||||
helpQuestionDate = jsonDecode(res);
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
Future getHelpRepley(String id) async {
|
||||
isLoading = true;
|
||||
update();
|
||||
var res = await CRUD().get(link: AppLink.getByIdhelpCenter, payload: {
|
||||
'id': id,
|
||||
});
|
||||
print(res);
|
||||
if (res == "failure") {
|
||||
status = 'not yet';
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
helpQuestionRepleyDate = jsonDecode(res);
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
getHelpQuestion();
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
@@ -1,332 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../constant/style.dart';
|
||||
import '../../../constant/table_names.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../../views/home/my_wallet/walet_captain.dart';
|
||||
import '../../../views/widgets/elevated_btn.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import '../../functions/location_background_controller.dart';
|
||||
import '../../functions/location_controller.dart';
|
||||
import '../payment/captain_wallet_controller.dart';
|
||||
|
||||
class HomeCaptainController extends GetxController {
|
||||
bool isActive = false;
|
||||
DateTime? activeStartTime;
|
||||
Duration activeDuration = Duration.zero;
|
||||
Timer? activeTimer;
|
||||
Map data = {};
|
||||
bool isLoading = true;
|
||||
late double kazan;
|
||||
double latePrice = 0;
|
||||
double heavyPrice = 0;
|
||||
double comfortPrice = 0,
|
||||
speedPrice = 0,
|
||||
deliveryPrice = 0,
|
||||
mashwariPrice = 0,
|
||||
fuelPrice = 0;
|
||||
double naturePrice = 0;
|
||||
bool isCallOn = false;
|
||||
String totalMoneyToday = '0';
|
||||
double? rating = 5;
|
||||
String rideId = '0';
|
||||
String countRideToday = '0';
|
||||
String totalMoneyInSEFER = '0';
|
||||
String totalDurationToday = '0';
|
||||
Timer? timer;
|
||||
late LatLng myLocation = const LatLng(32, 36);
|
||||
String totalPoints = '0';
|
||||
String countRefuse = '0';
|
||||
bool mapType = false;
|
||||
bool mapTrafficON = false;
|
||||
double widthMapTypeAndTraffic = 50;
|
||||
// Inject the LocationController class
|
||||
final locationController = Get.put(LocationController());
|
||||
// final locationBackController = Get.put(LocationBackgroundController());
|
||||
String formatDuration(Duration duration) {
|
||||
String twoDigits(int n) => n.toString().padLeft(2, "0");
|
||||
String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60));
|
||||
String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60));
|
||||
return "${duration.inHours}:$twoDigitMinutes:$twoDigitSeconds";
|
||||
}
|
||||
|
||||
void goToWalletFromConnect() {
|
||||
Get.back();
|
||||
Get.back();
|
||||
Get.to(() => WalletCaptain());
|
||||
}
|
||||
|
||||
void changeRideId() {
|
||||
rideId = 'rideId';
|
||||
update();
|
||||
}
|
||||
|
||||
String stringActiveDuration = '';
|
||||
void onButtonSelected() {
|
||||
// totalPoints = Get.find<CaptainWalletController>().totalPoints;
|
||||
|
||||
isActive = !isActive;
|
||||
if (isActive) {
|
||||
if (double.parse(totalPoints) > -300) {
|
||||
locationController.startLocationUpdates();
|
||||
// locationBackController.startBackLocation();
|
||||
activeStartTime = DateTime.now();
|
||||
activeTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
activeDuration = DateTime.now().difference(activeStartTime!);
|
||||
stringActiveDuration = formatDuration(activeDuration);
|
||||
update();
|
||||
});
|
||||
} else {
|
||||
locationController.stopLocationUpdates();
|
||||
|
||||
activeStartTime = null;
|
||||
activeTimer?.cancel();
|
||||
savePeriod(activeDuration);
|
||||
activeDuration = Duration.zero;
|
||||
update();
|
||||
}
|
||||
} else {
|
||||
locationController.stopLocationUpdates();
|
||||
|
||||
activeStartTime = null;
|
||||
activeTimer?.cancel();
|
||||
savePeriod(activeDuration);
|
||||
activeDuration = Duration.zero;
|
||||
update();
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
void getRefusedOrderByCaptain() async {
|
||||
DateTime today = DateTime.now();
|
||||
int todayDay = today.day;
|
||||
|
||||
String driverId = box.read(BoxName.driverID).toString();
|
||||
|
||||
String customQuery = '''
|
||||
SELECT COUNT(*) AS count
|
||||
FROM ${TableName.driverOrdersRefuse}
|
||||
WHERE driver_id = '$driverId'
|
||||
AND created_at LIKE '%$todayDay%'
|
||||
''';
|
||||
|
||||
try {
|
||||
List<Map<String, dynamic>> results =
|
||||
await sql.getCustomQuery(customQuery);
|
||||
countRefuse = results[0]['count'].toString();
|
||||
update();
|
||||
if (int.parse(countRefuse) > 3 || double.parse(totalPoints) <= -300) {
|
||||
print('total point is $totalPoints');
|
||||
locationController.stopLocationUpdates();
|
||||
activeStartTime = null;
|
||||
activeTimer?.cancel();
|
||||
savePeriod(activeDuration);
|
||||
activeDuration = Duration.zero;
|
||||
update();
|
||||
|
||||
Get.defaultDialog(
|
||||
// backgroundColor: CupertinoColors.destructiveRed,
|
||||
barrierDismissible: false,
|
||||
title: 'You Are Stopped For this Day !'.tr,
|
||||
content: Text(
|
||||
'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!'
|
||||
.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok , See you Tomorrow'.tr,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Get.back();
|
||||
}));
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error executing custom query: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void changeMapType() {
|
||||
mapType = !mapType;
|
||||
// heightButtomSheetShown = isButtomSheetShown == true ? 240 : 0;
|
||||
update();
|
||||
}
|
||||
|
||||
void changeMapTraffic() {
|
||||
mapTrafficON = !mapTrafficON;
|
||||
update();
|
||||
}
|
||||
|
||||
late GoogleMapController mapHomeCaptainController;
|
||||
void onMapCreated(GoogleMapController controller) {
|
||||
mapHomeCaptainController = controller;
|
||||
controller.getVisibleRegion();
|
||||
// Animate camera to user location (optional)
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(Get.find<LocationController>().myLocation),
|
||||
);
|
||||
}
|
||||
|
||||
void savePeriod(Duration period) {
|
||||
final periods = box.read<List<dynamic>>(BoxName.periods) ?? [];
|
||||
periods.add(period.inSeconds);
|
||||
box.write(BoxName.periods, periods);
|
||||
}
|
||||
|
||||
Duration calculateTotalDuration() {
|
||||
final periods = box.read<List<dynamic>>(BoxName.periods) ?? [];
|
||||
Duration totalDuration = Duration.zero;
|
||||
for (dynamic periodInSeconds in periods) {
|
||||
final periodDuration = Duration(seconds: periodInSeconds);
|
||||
totalDuration += periodDuration;
|
||||
}
|
||||
return totalDuration;
|
||||
}
|
||||
|
||||
void startPeriodicExecution() {
|
||||
Timer.periodic(const Duration(seconds: 30), (timer) async {
|
||||
await getCaptainDurationOnToday();
|
||||
});
|
||||
}
|
||||
|
||||
void stopTimer() {
|
||||
print('Stopping timer');
|
||||
timer?.cancel();
|
||||
}
|
||||
|
||||
getlocation() async {
|
||||
isLoading = true;
|
||||
print('isLoading $isLoading');
|
||||
update();
|
||||
await Get.find<LocationController>().getLocation();
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
await addToken();
|
||||
await getlocation();
|
||||
onButtonSelected();
|
||||
await getDriverRate();
|
||||
await getKazanPercent();
|
||||
await getPaymentToday();
|
||||
getCountRideToday();
|
||||
getAllPayment();
|
||||
startPeriodicExecution();
|
||||
onMapCreated(mapHomeCaptainController);
|
||||
totalPoints = Get.find<CaptainWalletController>().totalPoints;
|
||||
getRefusedOrderByCaptain();
|
||||
// LocationController().getLocation();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
addToken() async {
|
||||
await CRUD().post(link: AppLink.addTokensDriver, payload: {
|
||||
'token': box.read(BoxName.tokenDriver),
|
||||
'captain_id': box.read(BoxName.driverID).toString()
|
||||
}).then((value) => print('Token Added'));
|
||||
MapDriverController().driverCallPassenger();
|
||||
// box.write(BoxName.statusDriverLocation, 'off');
|
||||
}
|
||||
|
||||
getPaymentToday() async {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getDriverpaymentToday,
|
||||
payload: {'driverID': box.read(BoxName.driverID).toString()});
|
||||
if (res != 'failure') {
|
||||
data = jsonDecode(res);
|
||||
totalMoneyToday = data['message'][0]['todayAmount'];
|
||||
|
||||
update();
|
||||
} else {
|
||||
print(res);
|
||||
}
|
||||
}
|
||||
|
||||
getKazanPercent() async {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getKazanPercent,
|
||||
payload: {'country': box.read(BoxName.countryCode).toString()},
|
||||
);
|
||||
if (res != 'failure') {
|
||||
var json = jsonDecode(res);
|
||||
kazan = double.parse(json['message'][0]['kazan']);
|
||||
naturePrice = double.parse(json['message'][0]['naturePrice']);
|
||||
heavyPrice = double.parse(json['message'][0]['heavyPrice']);
|
||||
latePrice = double.parse(json['message'][0]['latePrice']);
|
||||
comfortPrice = double.parse(json['message'][0]['comfortPrice']);
|
||||
speedPrice = double.parse(json['message'][0]['speedPrice']);
|
||||
deliveryPrice = double.parse(json['message'][0]['deliveryPrice']);
|
||||
mashwariPrice = double.parse(json['message'][0]['freePrice']);
|
||||
fuelPrice = double.parse(json['message'][0]['fuelPrice']);
|
||||
print(json);
|
||||
}
|
||||
}
|
||||
|
||||
double mpg = 0;
|
||||
calculateConsumptionFuel() {
|
||||
mpg = fuelPrice / 12; //todo in register car add mpg in box
|
||||
}
|
||||
|
||||
getCountRideToday() async {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getCountRide,
|
||||
payload: {'driver_id': box.read(BoxName.driverID).toString()});
|
||||
data = jsonDecode(res);
|
||||
|
||||
countRideToday = data['message'][0]['count'].toString();
|
||||
// print(countRideToday);
|
||||
update();
|
||||
}
|
||||
|
||||
getDriverRate() async {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getDriverRate,
|
||||
payload: {'driver_id': box.read(BoxName.driverID).toString()});
|
||||
if (res != 'failure') {
|
||||
var decod = jsonDecode(res);
|
||||
if (decod['message'][0]['rating'] != null) {
|
||||
rating = double.parse(decod['message'][0]['rating'].toString());
|
||||
} else {
|
||||
rating = 5.0; // Set a default value (e.g., 5.0 for full rating)
|
||||
}
|
||||
} else {
|
||||
rating = 5;
|
||||
}
|
||||
}
|
||||
|
||||
getAllPayment() async {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getAllPaymentFromRide,
|
||||
payload: {'driverID': box.read(BoxName.driverID).toString()});
|
||||
data = jsonDecode(res);
|
||||
|
||||
totalMoneyInSEFER = data['message'][0]['total_amount'];
|
||||
update();
|
||||
}
|
||||
|
||||
Future<void> getCaptainDurationOnToday() async {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getTotalDriverDurationToday,
|
||||
payload: {'driver_id': box.read(BoxName.driverID).toString()});
|
||||
|
||||
data = jsonDecode(res);
|
||||
totalDurationToday = data['message'][0]['total_duration'];
|
||||
update();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
activeTimer?.cancel();
|
||||
stopTimer();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,904 +0,0 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:math' as math;
|
||||
import 'dart:math' show cos;
|
||||
import 'package:SEFER/constant/table_names.dart';
|
||||
import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
|
||||
import 'package:SEFER/constant/style.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../../constant/api_key.dart';
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../../views/Rate/rate_passenger.dart';
|
||||
import '../../../views/home/Captin/home_captain/home_captin.dart';
|
||||
import '../../firebase/firbase_messge.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import '../../functions/location_controller.dart';
|
||||
|
||||
class MapDriverController extends GetxController {
|
||||
bool isLoading = true;
|
||||
final formKey1 = GlobalKey<FormState>();
|
||||
final sosEmergincyNumberCotroller = TextEditingController();
|
||||
List data = [];
|
||||
List dataDestination = [];
|
||||
LatLngBounds? boundsData;
|
||||
BitmapDescriptor carIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor passengerIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor startIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor endIcon = BitmapDescriptor.defaultMarker;
|
||||
final List<LatLng> polylineCoordinates = [];
|
||||
final List<LatLng> polylineCoordinatesDestination = [];
|
||||
List<Polyline> polyLines = [];
|
||||
List<Polyline> polyLinesDestination = [];
|
||||
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 passengerWalletBurc;
|
||||
late String timeOfOrder;
|
||||
late String duration;
|
||||
late String totalCost;
|
||||
late String distance;
|
||||
late String passengerName;
|
||||
late String passengerEmail;
|
||||
late String totalPassenger;
|
||||
late String passengerPhone;
|
||||
late String rideId;
|
||||
late String isHaveSteps;
|
||||
late String paymentAmount;
|
||||
late String paymentMethod;
|
||||
late String passengerId;
|
||||
late String driverId;
|
||||
late String tokenPassenger;
|
||||
late String durationToPassenger;
|
||||
late String walletChecked;
|
||||
late String direction;
|
||||
late String durationOfRideValue;
|
||||
late String status;
|
||||
int timeWaitingPassenger = 5; //5 miniute
|
||||
bool isPassengerInfoWindow = false;
|
||||
bool isBtnRideBegin = false;
|
||||
bool isArrivedSend = true;
|
||||
bool isdriverWaitTimeEnd = false;
|
||||
bool isRideFinished = false;
|
||||
bool isRideStarted = false;
|
||||
bool isPriceWindow = false;
|
||||
double passengerInfoWindowHeight = Get.height * .35;
|
||||
double driverEndPage = 100;
|
||||
double progress = 0;
|
||||
double progressToPassenger = 0;
|
||||
double progressInPassengerLocationFromDriver = 0;
|
||||
bool isRideBegin = false;
|
||||
int progressTimerToShowPassengerInfoWindowFromDriver = 25;
|
||||
int remainingTimeToShowPassengerInfoWindowFromDriver = 25;
|
||||
int remainingTimeToPassenger = 60;
|
||||
int remainingTimeInPassengerLocatioWait = 60;
|
||||
bool isDriverNearPassengerStart = false;
|
||||
GoogleMapController? mapController;
|
||||
late LatLng myLocation;
|
||||
int remainingTimeTimerRideBegin = 60;
|
||||
String stringRemainingTimeRideBegin = '';
|
||||
String stringRemainingTimeRideBegin1 = '';
|
||||
double progressTimerRideBegin = 0;
|
||||
late Timer timer;
|
||||
String? mapAPIKEY;
|
||||
final zones = <Zone>[];
|
||||
String canelString = 'yet';
|
||||
late LatLng latLngpassengerLocation;
|
||||
late LatLng latLngPassengerDestination;
|
||||
|
||||
void onMapCreated(GoogleMapController controller) async {
|
||||
myLocation = Get.find<LocationController>().location as LatLng;
|
||||
myLocation = myLocation;
|
||||
mapController = controller;
|
||||
controller.getVisibleRegion();
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(Get.find<LocationController>().myLocation),
|
||||
);
|
||||
update();
|
||||
// Set up a timer or interval to trigger the marker update every 3 seconds.
|
||||
timer = Timer.periodic(const Duration(seconds: 1), (_) {
|
||||
updateMarker();
|
||||
});
|
||||
}
|
||||
|
||||
void changeStatusDriver() {
|
||||
status = 'On';
|
||||
update();
|
||||
}
|
||||
|
||||
void changeDriverEndPage() {
|
||||
remainingTimeTimerRideBegin < 60 ? driverEndPage = 160 : 100;
|
||||
update();
|
||||
}
|
||||
|
||||
takeSnapMap() {
|
||||
mapController!.takeSnapshot();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
mapController!.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future openGoogleMapFromDriverToPassenger() async {
|
||||
var endLat = latLngpassengerLocation.latitude;
|
||||
var endLng = latLngpassengerLocation.longitude;
|
||||
|
||||
var startLat = Get.find<LocationController>().myLocation.latitude;
|
||||
var startLng = Get.find<LocationController>().myLocation.longitude;
|
||||
|
||||
String url =
|
||||
'https://www.google.com/maps/dir/$startLat,$startLng/$endLat,$endLng/&directionsmode=driving';
|
||||
if (await canLaunchUrl(Uri.parse(url))) {
|
||||
await launchUrl(Uri.parse(url));
|
||||
} else {
|
||||
throw 'Could not launch google maps';
|
||||
}
|
||||
}
|
||||
|
||||
void clearPolyline() {
|
||||
polyLines = [];
|
||||
polyLinesDestination = [];
|
||||
polylineCoordinates.clear();
|
||||
polylineCoordinatesDestination.clear();
|
||||
update();
|
||||
}
|
||||
|
||||
void changeRideToBeginToPassenger() {
|
||||
isRideBegin = true;
|
||||
passengerInfoWindowHeight = Get.height * .22;
|
||||
update();
|
||||
}
|
||||
|
||||
void startTimerToShowPassengerInfoWindowFromDriver() async {
|
||||
isPassengerInfoWindow = true;
|
||||
for (int i = 0; i <= int.parse(durationToPassenger); i++) {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
progressToPassenger = i / int.parse(durationToPassenger);
|
||||
remainingTimeToPassenger = int.parse(durationToPassenger) - i;
|
||||
if (remainingTimeToPassenger == 0) {
|
||||
isBtnRideBegin = true;
|
||||
print(isBtnRideBegin);
|
||||
update();
|
||||
}
|
||||
print(isBtnRideBegin);
|
||||
print(remainingTimeToPassenger);
|
||||
|
||||
int minutes = (remainingTimeToPassenger / 60).floor();
|
||||
int seconds = remainingTimeToPassenger % 60;
|
||||
stringRemainingTimeToPassenger =
|
||||
'$minutes:${seconds.toString().padLeft(2, '0')}';
|
||||
|
||||
update();
|
||||
}
|
||||
// update();
|
||||
// startTimerToShowDriverToPassengerDuration();
|
||||
}
|
||||
|
||||
String stringRemainingTimeToPassenger = '';
|
||||
|
||||
String stringRemainingTimeWaitingPassenger = '';
|
||||
|
||||
void startTimerToShowDriverWaitPassengerDuration() async {
|
||||
for (int i = 0; i <= timeWaitingPassenger * 60; i++) {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
progressInPassengerLocationFromDriver = i / (timeWaitingPassenger * 60);
|
||||
remainingTimeInPassengerLocatioWait = (timeWaitingPassenger * 60) - i;
|
||||
if (isRideBegin == true) {
|
||||
remainingTimeInPassengerLocatioWait = 0;
|
||||
update();
|
||||
}
|
||||
if (remainingTimeInPassengerLocatioWait == 0) {
|
||||
isdriverWaitTimeEnd = true;
|
||||
print(isdriverWaitTimeEnd);
|
||||
update();
|
||||
}
|
||||
print(isdriverWaitTimeEnd);
|
||||
print(
|
||||
'remainingTimeInPassengerLocatioWait $remainingTimeInPassengerLocatioWait');
|
||||
|
||||
int minutes = (remainingTimeInPassengerLocatioWait / 60).floor();
|
||||
int seconds = remainingTimeInPassengerLocatioWait % 60;
|
||||
stringRemainingTimeWaitingPassenger =
|
||||
'$minutes:${seconds.toString().padLeft(2, '0')}';
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void driverGoToPassenger() async {
|
||||
changeRideToBeginToPassenger();
|
||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
'id': rideId,
|
||||
'driverGoToPassengerTime': DateTime.now().toString(),
|
||||
'status': 'Applied'
|
||||
});
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
'DriverIsGoingToPassenger',
|
||||
box.read(BoxName.name).toString(),
|
||||
tokenPassenger);
|
||||
if (box.read(BoxName.googlaMapApp) == true) {
|
||||
await openGoogleMapFromDriverToPassenger();
|
||||
}
|
||||
}
|
||||
|
||||
bool isSocialPressed = false;
|
||||
driverCallPassenger() async {
|
||||
String scam = await getDriverScam();
|
||||
if (scam != 'failure') {
|
||||
if (int.parse(scam) > 3) {
|
||||
box.write(BoxName.statusDriverLocation, 'on');
|
||||
Get.find<LocationController>().stopLocationUpdates();
|
||||
await CRUD().post(link: AppLink.addNotificationCaptain, payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
'title': 'scams operations'.tr,
|
||||
'body':
|
||||
'you have connect to passengers and let them cancel the order'.tr,
|
||||
});
|
||||
} else if (isSocialPressed == true) {
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
await CRUD().post(link: AppLink.adddriverScam, payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
'passengerID': passengerId,
|
||||
'rideID': rideId,
|
||||
'isDriverCalledPassenger': '$isSocialPressed'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getDriverScam() async {
|
||||
var res = await CRUD().post(link: AppLink.getdriverScam, payload: {
|
||||
'driverID': box.read(BoxName.driverID),
|
||||
});
|
||||
if (res == 'failure') {
|
||||
print('Scam is failure');
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
return '0';
|
||||
}
|
||||
var d = jsonDecode(res);
|
||||
print('Scam is ');
|
||||
print(d['message'][0]['count']);
|
||||
return d['message'][0]['count'];
|
||||
}
|
||||
|
||||
Position? currentPosition;
|
||||
|
||||
startRideFromDriver() async {
|
||||
double _distance =
|
||||
await calculateDistanceBetweenDriverAndPassengerLocation();
|
||||
|
||||
if (_distance < 50) {
|
||||
changeRideToBeginToPassenger();
|
||||
isPassengerInfoWindow = false;
|
||||
isRideStarted = true;
|
||||
isRideFinished = false;
|
||||
remainingTimeInPassengerLocatioWait = 0;
|
||||
timeWaitingPassenger = 0;
|
||||
box.write(BoxName.statusDriverLocation, 'on');
|
||||
|
||||
update();
|
||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
'id': rideId,
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Begin',
|
||||
});
|
||||
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
'RideIsBegin', box.read(BoxName.name).toString(), tokenPassenger);
|
||||
rideIsBeginPassengerTimer();
|
||||
|
||||
// var d = jsonDecode(res);
|
||||
|
||||
update();
|
||||
// Start updating location and moving camera
|
||||
// updateLocation();
|
||||
} else {
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: 'Your are far from passenger location'.tr,
|
||||
middleText:
|
||||
'go to your passenger location before\nPassenger cancel trip'.tr,
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok',
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
calculateDistanceInMeter(LatLng prev, LatLng current) async {
|
||||
double distance2 = Geolocator.distanceBetween(
|
||||
prev.latitude,
|
||||
prev.longitude,
|
||||
current.latitude,
|
||||
current.longitude,
|
||||
);
|
||||
return distance2;
|
||||
}
|
||||
|
||||
double speedoMeter = 0;
|
||||
void updateLocation() async {
|
||||
try {
|
||||
for (var i = 0; i < remainingTimeTimerRideBegin; i++) {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
|
||||
mapController!.animateCamera(
|
||||
CameraUpdate.newCameraPosition(
|
||||
CameraPosition(
|
||||
target: myLocation,
|
||||
zoom: 17, // Adjust zoom level as needed
|
||||
),
|
||||
),
|
||||
);
|
||||
// });
|
||||
update();
|
||||
}
|
||||
|
||||
// Stop listening after ride finishes
|
||||
if (!isRideBegin) {}
|
||||
} catch (error) {
|
||||
debugPrint('Error listening to GPS: $error');
|
||||
// Handle GPS errors gracefully
|
||||
}
|
||||
|
||||
// Periodically call updateLocation again
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
updateLocation();
|
||||
}
|
||||
|
||||
calculateDistanceBetweenDriverAndPassengerLocation() {
|
||||
double distance2 = Geolocator.distanceBetween(
|
||||
latLngpassengerLocation.latitude,
|
||||
latLngpassengerLocation.longitude,
|
||||
Get.find<LocationController>().myLocation.latitude,
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
);
|
||||
return distance2;
|
||||
}
|
||||
|
||||
addWaitingTimeCostFromPassengerToDriverWallet() async {
|
||||
double distance2 = calculateDistanceBetweenDriverAndPassengerLocation();
|
||||
|
||||
if (distance2 > 40) {
|
||||
Get.defaultDialog(
|
||||
title: 'Your are far from passenger location'.tr,
|
||||
middleText:
|
||||
'go to your passenger location before\nPassenger cancel trip'.tr,
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok',
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
}));
|
||||
} else {
|
||||
double costOfWaiting5Minute =
|
||||
(distanceBetweenDriverAndPassengerWhenConfirm * .08) +
|
||||
(5 * 1); //for Eygpt other like jordan .06 per minute
|
||||
var res = await CRUD().post(link: AppLink.addDriverpayment, payload: {
|
||||
'rideId': rideId,
|
||||
'amount': costOfWaiting5Minute.toString(),
|
||||
'payment_method': 'wait-cancel',
|
||||
'passengerID': passengerId,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
if (res != 'failure') {
|
||||
Get.snackbar(
|
||||
'You will get cost of your work for this trip'.tr,
|
||||
'${'you gain'.tr} $costOfWaiting5Minute \$${' in your wallet'.tr}',
|
||||
backgroundColor: AppColor.deepPurpleAccent,
|
||||
);
|
||||
}
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': passengerId,
|
||||
'balance': (costOfWaiting5Minute * -1).toString()
|
||||
});
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
Get.offAll(HomeCaptain());
|
||||
}
|
||||
}
|
||||
|
||||
void finishRideFromDriver() {
|
||||
Get.defaultDialog(
|
||||
title: 'Are you sure to exit ride ?'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
middleText: '',
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok'.tr,
|
||||
kolor: AppColor.greenColor,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
finishRideFromDriver1();
|
||||
}),
|
||||
cancel: MyElevatedButton(
|
||||
title: 'Cancel'.tr,
|
||||
kolor: Colors.red,
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
}));
|
||||
}
|
||||
|
||||
void finishRideFromDriver1() async {
|
||||
double distanceToDestination = Geolocator.distanceBetween(
|
||||
latLngPassengerDestination.latitude,
|
||||
latLngPassengerDestination.longitude,
|
||||
Get.find<LocationController>().myLocation.latitude,
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
);
|
||||
// if (carType != 'Comfort' || carType != 'Free Ride') {
|
||||
// if (distanceToDestination < 50) {
|
||||
isRideFinished = true;
|
||||
isRideStarted = false;
|
||||
isPriceWindow = false;
|
||||
totalCost = carType != 'Comfort' && carType != 'Mashwari'
|
||||
? totalPassenger
|
||||
: price < double.parse(totalPassenger)
|
||||
? totalPassenger
|
||||
: price.toStringAsFixed(2);
|
||||
paymentAmount = totalCost;
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
// changeRideToBeginToPassenger();
|
||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
'id': rideId,
|
||||
'rideTimeFinish': DateTime.now().toString(),
|
||||
'status': 'Finished',
|
||||
'price': totalCost,
|
||||
});
|
||||
print('walletChecked is $walletChecked');
|
||||
if (walletChecked == 'true') {
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': passengerId,
|
||||
'balance': ((-1) * double.parse(paymentAmount)).toString()
|
||||
});
|
||||
}
|
||||
await CRUD().post(link: AppLink.addDriverpayment, payload: {
|
||||
'rideId': rideId,
|
||||
'amount': paymentAmount,
|
||||
'payment_method': paymentMethod,
|
||||
'passengerID': passengerId,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
print('passengerWalletBurc bef ${double.parse(passengerWalletBurc)}');
|
||||
if (double.parse(passengerWalletBurc) < 0) {
|
||||
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
|
||||
'passenger_id': passengerId,
|
||||
'balance': ((-1) * double.parse(passengerWalletBurc)).toString()
|
||||
});
|
||||
print('passengerWalletBurc aft ${double.parse(passengerWalletBurc)}');
|
||||
}
|
||||
|
||||
double pointsSubstraction = 0;
|
||||
pointsSubstraction = double.parse(paymentAmount) *
|
||||
(-1) *
|
||||
double.parse(kazan) /
|
||||
100; // for eygpt /100
|
||||
var res = await CRUD().post(link: AppLink.addDriversWalletPoints, payload: {
|
||||
'paymentID': 'rideId$rideId',
|
||||
'amount': (pointsSubstraction).toStringAsFixed(0),
|
||||
'paymentMethod': paymentMethod,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
});
|
||||
print(res);
|
||||
Future.delayed(const Duration(milliseconds: 300));
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
'Driver Finish Trip',
|
||||
'${'you will pay to Driver'.tr} $paymentAmount \$',
|
||||
tokenPassenger,
|
||||
[
|
||||
box.read(BoxName.driverID),
|
||||
rideId,
|
||||
box.read(BoxName.tokenDriver),
|
||||
// carType == 'Comfort' || carType == 'Mashwari'
|
||||
// ? price.toStringAsFixed(2)
|
||||
// : totalPassenger
|
||||
paymentAmount.toString()
|
||||
],
|
||||
);
|
||||
Get.to(() => RatePassenger(), arguments: {
|
||||
'passengerId': passengerId,
|
||||
'rideId': rideId,
|
||||
'price': price.toString(),
|
||||
});
|
||||
// Get.back();
|
||||
}
|
||||
|
||||
void cancelCheckRideFromPassenger() async {
|
||||
var res = await CRUD().get(link: AppLink.getOrderCancelStatus, payload: {
|
||||
'order_id': rideId,
|
||||
}); //.then((value) {
|
||||
print('Cancel fetch--------------------');
|
||||
var response = jsonDecode(res);
|
||||
canelString = response['data']['status'];
|
||||
print('cancel is $canelString');
|
||||
update();
|
||||
if (canelString == 'Cancel') {
|
||||
remainingTimeTimerRideBegin = 0;
|
||||
remainingTimeToShowPassengerInfoWindowFromDriver = 0;
|
||||
remainingTimeToPassenger = 0;
|
||||
isRideStarted = false;
|
||||
isRideFinished = false;
|
||||
isPassengerInfoWindow = false;
|
||||
clearPolyline();
|
||||
update();
|
||||
Get.defaultDialog(
|
||||
title: 'Order Cancelled'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
middleText: 'Order Cancelled by Passenger'.tr,
|
||||
middleTextStyle: AppStyle.title,
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok'.tr,
|
||||
onPressed: () {
|
||||
Get.offAll(HomeCaptain());
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
int rideTimerFromBegin = 0;
|
||||
double price = 0;
|
||||
void rideIsBeginPassengerTimer() async {
|
||||
// print('mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm');
|
||||
// print(durationOfRideValue);
|
||||
int durationOfRide = int.parse(durationOfRideValue);
|
||||
update();
|
||||
int infinity = 40000;
|
||||
if (carType == 'Comfort' || carType == 'Mashwari') {
|
||||
durationOfRide = infinity;
|
||||
update();
|
||||
}
|
||||
for (int i = 0; i <= durationOfRide; i++) {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
recentDistanceToDash = Get.find<LocationController>().totalDistance;
|
||||
rideTimerFromBegin = i;
|
||||
price = carType == 'Comfort' // || carType == 'Free Ride'
|
||||
? (i ~/ 60) +
|
||||
(recentDistanceToDash *
|
||||
Get.find<HomeCaptainController>().comfortPrice)
|
||||
: carType == 'Speed'
|
||||
? (i ~/ 60) +
|
||||
(recentDistanceToDash *
|
||||
Get.find<HomeCaptainController>().speedPrice)
|
||||
: carType == 'Mashwari'
|
||||
? (i ~/ 60) +
|
||||
(recentDistanceToDash *
|
||||
Get.find<HomeCaptainController>().deliveryPrice)
|
||||
: (i ~/ 60) +
|
||||
(recentDistanceToDash *
|
||||
Get.find<HomeCaptainController>()
|
||||
.mashwariPrice); // $1 for each minute + $4 for each km
|
||||
price = (price * .10) + price; // Add 10% tax
|
||||
speed = Get.find<LocationController>().speed * 3.6;
|
||||
progressTimerRideBegin = i / durationOfRide;
|
||||
remainingTimeTimerRideBegin = durationOfRide - i;
|
||||
remainingTimeTimerRideBegin < 60 ? driverEndPage = 160 : 100;
|
||||
updateMarker();
|
||||
if (remainingTimeTimerRideBegin < 120) {
|
||||
// to make driver available on last 2 minute in his trip
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
}
|
||||
int minutes = (remainingTimeTimerRideBegin / 60).floor();
|
||||
int seconds = remainingTimeTimerRideBegin % 60;
|
||||
stringRemainingTimeRideBegin =
|
||||
'$minutes:${seconds.toString().padLeft(2, '0')}';
|
||||
int minutes1 = (i / 60).floor();
|
||||
int seconds1 = i % 60;
|
||||
stringRemainingTimeRideBegin1 =
|
||||
'$minutes1:${seconds1.toString().padLeft(2, '0')}';
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
double recentDistanceToDash = 0;
|
||||
double recentAngelToMarker = 0;
|
||||
double speed = 0;
|
||||
void updateMarker() async {
|
||||
// Remove the existing marker with the ID `MyLocation`.
|
||||
markers.remove(MarkerId('MyLocation'));
|
||||
|
||||
// Add a new marker with the ID `MyLocation` at the current location of the user.
|
||||
LocationController locationController = Get.find<LocationController>();
|
||||
myLocation = locationController.myLocation;
|
||||
|
||||
markers.add(
|
||||
Marker(
|
||||
markerId: MarkerId('MyLocation'.tr),
|
||||
position: myLocation,
|
||||
draggable: true,
|
||||
icon: carIcon,
|
||||
rotation: locationController.heading,
|
||||
// infoWindow: const InfoWindow(
|
||||
// title: 'Time',
|
||||
// ),
|
||||
),
|
||||
);
|
||||
|
||||
// Animate camera only once after updating the marker
|
||||
// mapController!.animateCamera(
|
||||
// CameraUpdate.newLatLng(myLocation),
|
||||
// );
|
||||
update();
|
||||
}
|
||||
|
||||
void addCustomCarIcon() {
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio
|
||||
// scale: 1.0,
|
||||
);
|
||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png',
|
||||
mipmaps: false)
|
||||
.then((value) {
|
||||
carIcon = value;
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
void addCustomStartIcon() async {
|
||||
// Create the marker with the resized image
|
||||
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/A.png',
|
||||
mipmaps: false)
|
||||
.then((value) {
|
||||
startIcon = value;
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
void addCustomEndIcon() {
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: const Size(25, 25), devicePixelRatio: Get.pixelRatio);
|
||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/b.png',
|
||||
mipmaps: false)
|
||||
.then((value) {
|
||||
endIcon = value;
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
void addCustomPassengerIcon() {
|
||||
ImageConfiguration config = ImageConfiguration(
|
||||
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio
|
||||
// scale: 1.0,
|
||||
);
|
||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/picker.png',
|
||||
mipmaps: false)
|
||||
.then((value) {
|
||||
passengerIcon = value;
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
double distanceBetweenDriverAndPassengerWhenConfirm = 0;
|
||||
getMap(String origin, destination) async {
|
||||
isLoading = false;
|
||||
|
||||
update();
|
||||
|
||||
var url =
|
||||
('${AppLink.googleMapsLink}directions/json?&language=${box.read(BoxName.lang)}&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}');
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
data = response['routes'][0]['legs'];
|
||||
print(data);
|
||||
distanceBetweenDriverAndPassengerWhenConfirm =
|
||||
(data[0]['distance']['value']) / 1000;
|
||||
final points =
|
||||
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
double lat = points[i][0].toDouble();
|
||||
double lng = points[i][1].toDouble();
|
||||
polylineCoordinates.add(LatLng(lat, lng));
|
||||
}
|
||||
if (polyLines.isNotEmpty) {
|
||||
clearPolyline();
|
||||
var polyline = Polyline(
|
||||
polylineId: PolylineId(response["routes"][0]["summary"]),
|
||||
points: polylineCoordinates,
|
||||
width: 10,
|
||||
color: AppColor.blueColor,
|
||||
);
|
||||
polyLines.add(polyline);
|
||||
// rideConfirm = false;
|
||||
update();
|
||||
} else {
|
||||
var polyline = Polyline(
|
||||
polylineId: PolylineId(response["routes"][0]["summary"]),
|
||||
points: polylineCoordinates,
|
||||
width: 10,
|
||||
color: AppColor.blueColor,
|
||||
);
|
||||
// final dataBounds = response["routes"][0]["bounds"];
|
||||
|
||||
// updateCameraFromBoundsAfterGetMap(dataBounds);
|
||||
|
||||
// Fit the camera to the bounds
|
||||
|
||||
polyLines.add(polyline);
|
||||
// rideConfirm = false;
|
||||
// Define the northeast and southwest coordinates
|
||||
final bounds = response["routes"][0]["bounds"];
|
||||
LatLng northeast =
|
||||
LatLng(bounds['northeast']['lat'], bounds['northeast']['lng']);
|
||||
LatLng southwest =
|
||||
LatLng(bounds['southwest']['lat'], bounds['southwest']['lng']);
|
||||
|
||||
// Create the LatLngBounds object
|
||||
LatLngBounds boundsData =
|
||||
LatLngBounds(northeast: northeast, southwest: southwest);
|
||||
|
||||
// Fit the camera to the bounds
|
||||
var cameraUpdate = CameraUpdate.newLatLngBounds(boundsData, 140);
|
||||
mapController!.animateCamera(cameraUpdate);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
getMapDestination(String origin, destination) async {
|
||||
var url =
|
||||
('${AppLink.googleMapsLink}directions/json?&language=${box.read(BoxName.lang)}&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}');
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
dataDestination = response['routes'][0]['legs'];
|
||||
// print(data);
|
||||
final points =
|
||||
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
double lat = points[i][0].toDouble();
|
||||
double lng = points[i][1].toDouble();
|
||||
polylineCoordinatesDestination.add(LatLng(lat, lng));
|
||||
}
|
||||
if (polyLinesDestination.isNotEmpty) {
|
||||
// clearPolyline();
|
||||
var polyline = Polyline(
|
||||
polylineId: PolylineId(response["routes"][0]["summary"]),
|
||||
points: polylineCoordinatesDestination,
|
||||
width: 10,
|
||||
color: AppColor.redColor,
|
||||
);
|
||||
polyLinesDestination.add(polyline);
|
||||
// rideConfirm = false;
|
||||
update();
|
||||
} else {
|
||||
var polyline = Polyline(
|
||||
polylineId: PolylineId(response["routes"][0]["summary"]),
|
||||
points: polylineCoordinatesDestination,
|
||||
width: 10,
|
||||
color: AppColor.redColor,
|
||||
);
|
||||
// final dataBounds = response["routes"][0]["bounds"];
|
||||
|
||||
// updateCameraFromBoundsAfterGetMap(dataBounds);
|
||||
// polyLinesDestination.add(polyline);
|
||||
// rideConfirm = false;
|
||||
// Define the northeast and southwest coordinates
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void updateCameraFromBoundsAfterGetMap(dynamic response) {
|
||||
final bounds = response["routes"][0]["bounds"];
|
||||
LatLng northeast =
|
||||
LatLng(bounds['northeast']['lat'], bounds['northeast']['lng']);
|
||||
LatLng southwest =
|
||||
LatLng(bounds['southwest']['lat'], bounds['southwest']['lng']);
|
||||
|
||||
// Create the LatLngBounds object
|
||||
LatLngBounds boundsData =
|
||||
LatLngBounds(northeast: northeast, southwest: southwest);
|
||||
|
||||
// Fit the camera to the bounds
|
||||
var cameraUpdate = CameraUpdate.newLatLngBounds(boundsData, 140);
|
||||
mapController!.animateCamera(cameraUpdate);
|
||||
}
|
||||
|
||||
void changePassengerInfoWindow() {
|
||||
isPassengerInfoWindow = !isPassengerInfoWindow;
|
||||
passengerInfoWindowHeight = isPassengerInfoWindow == true ? 200 : 0;
|
||||
update();
|
||||
}
|
||||
|
||||
double mpg = 0;
|
||||
calculateConsumptionFuel() {
|
||||
mpg = Get.find<HomeCaptainController>().fuelPrice /
|
||||
12; //todo in register car add mpg in box
|
||||
update();
|
||||
}
|
||||
|
||||
late Duration durationToAdd;
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
late String carType;
|
||||
late String kazan;
|
||||
@override
|
||||
void onInit() async {
|
||||
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
|
||||
// Get the passenger location from the arguments.
|
||||
passengerLocation = Get.arguments['passengerLocation'];
|
||||
passengerDestination = Get.arguments['passengerDestination'];
|
||||
duration = Get.arguments['Duration'];
|
||||
totalCost = Get.arguments['totalCost'];
|
||||
passengerId = Get.arguments['passengerId'];
|
||||
driverId = Get.arguments['driverId'];
|
||||
distance = Get.arguments['Distance'];
|
||||
passengerName = Get.arguments['name'];
|
||||
passengerEmail = Get.arguments['email'];
|
||||
totalPassenger = Get.arguments['totalPassenger'];
|
||||
passengerPhone = Get.arguments['phone'];
|
||||
walletChecked = Get.arguments['WalletChecked'];
|
||||
tokenPassenger = Get.arguments['tokenPassenger'];
|
||||
direction = Get.arguments['direction'];
|
||||
durationToPassenger = Get.arguments['DurationToPassenger'];
|
||||
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'];
|
||||
passengerWalletBurc = Get.arguments['passengerWalletBurc'];
|
||||
timeOfOrder = Get.arguments['timeOfOrder'];
|
||||
carType = Get.arguments['carType'];
|
||||
kazan = Get.arguments['kazan'];
|
||||
|
||||
var coords = passengerLocation.split(',');
|
||||
var coordDestination = passengerDestination.split(',');
|
||||
|
||||
// Parse to double
|
||||
double latPassengerLocation = double.parse(coords[0]);
|
||||
double lngPassengerLocation = double.parse(coords[1]);
|
||||
double latPassengerDestination = double.parse(coordDestination[0]);
|
||||
double lngPassengerDestination = double.parse(coordDestination[1]);
|
||||
latLngpassengerLocation =
|
||||
LatLng(latPassengerLocation, lngPassengerLocation);
|
||||
latLngPassengerDestination =
|
||||
LatLng(latPassengerDestination, lngPassengerDestination);
|
||||
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);
|
||||
isHaveSteps == 'haveSteps'
|
||||
? (
|
||||
await getMapDestination(step0, step1),
|
||||
await getMapDestination(step1, step2),
|
||||
step3 == '' ? await getMapDestination(step2, step3) : () {},
|
||||
step4 == '' ? await getMapDestination(step3, step4) : () {},
|
||||
)
|
||||
: await getMapDestination(passengerLocation, passengerDestination);
|
||||
addCustomCarIcon();
|
||||
addCustomPassengerIcon();
|
||||
addCustomStartIcon();
|
||||
addCustomEndIcon();
|
||||
// updateMarker();
|
||||
// updateLocation();
|
||||
startTimerToShowPassengerInfoWindowFromDriver();
|
||||
durationToAdd = Duration(seconds: int.parse(duration));
|
||||
hours = durationToAdd.inHours;
|
||||
minutes = (durationToAdd.inMinutes % 60).round();
|
||||
calculateConsumptionFuel();
|
||||
// cancelCheckRidefromPassenger();
|
||||
// checkIsDriverNearPassenger();
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:SEFER/constant/links.dart';
|
||||
import 'package:SEFER/constant/style.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../constant/table_names.dart';
|
||||
import '../../functions/crud.dart';
|
||||
import '../../functions/location_controller.dart';
|
||||
import 'home_captain_controller.dart';
|
||||
|
||||
class OrderRequestController extends GetxController {
|
||||
double progress = 0;
|
||||
double progressSpeed = 0;
|
||||
int duration = 11;
|
||||
int durationSpeed = 20;
|
||||
int remainingTime = 0;
|
||||
int remainingTimeSpeed = 0;
|
||||
String countRefuse = '0';
|
||||
bool applied = false;
|
||||
final locationController = Get.put(LocationController());
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
getRefusedOrderByCaptain();
|
||||
// calculateConsumptionFuel();
|
||||
update();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
void changeApplied() {
|
||||
applied = true;
|
||||
update();
|
||||
}
|
||||
|
||||
double mpg = 0;
|
||||
calculateConsumptionFuel() {
|
||||
mpg = Get.find<HomeCaptainController>().fuelPrice /
|
||||
12; //todo in register car add mpg in box
|
||||
}
|
||||
|
||||
void getRefusedOrderByCaptain() async {
|
||||
DateTime today = DateTime.now();
|
||||
int todayDay = today.day;
|
||||
|
||||
String driverId = box.read(BoxName.driverID).toString();
|
||||
|
||||
String customQuery = '''
|
||||
SELECT COUNT(*) AS count
|
||||
FROM ${TableName.driverOrdersRefuse}
|
||||
WHERE driver_id = '$driverId'
|
||||
AND created_at LIKE '%$todayDay%'
|
||||
''';
|
||||
|
||||
try {
|
||||
List<Map<String, dynamic>> results =
|
||||
await sql.getCustomQuery(customQuery);
|
||||
countRefuse = results[0]['count'].toString();
|
||||
update();
|
||||
if (int.parse(countRefuse) > 3) {
|
||||
locationController.stopLocationUpdates();
|
||||
Get.defaultDialog(
|
||||
// backgroundColor: CupertinoColors.destructiveRed,
|
||||
barrierDismissible: false,
|
||||
title: 'You Are Stopped For this Day !'.tr,
|
||||
content: Text(
|
||||
'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!'
|
||||
.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Ok , See you Tomorrow'.tr,
|
||||
onPressed: () => Get.back()));
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error executing custom query: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void startTimer(String driverID, orderID) async {
|
||||
for (int i = 0; i <= duration; i++) {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
progress = i / duration;
|
||||
remainingTime = duration - i;
|
||||
|
||||
update();
|
||||
}
|
||||
if (remainingTime == 0) {
|
||||
if (applied == false) {
|
||||
print('applied=========================');
|
||||
print(applied);
|
||||
refuseOrder(orderID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void startTimerSpeed(String driverID, orderID) async {
|
||||
for (int i = 0; i <= durationSpeed; i++) {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
progressSpeed = i / durationSpeed;
|
||||
remainingTimeSpeed = durationSpeed - i;
|
||||
|
||||
update();
|
||||
}
|
||||
// if (remainingTimeSpeed == 0) {
|
||||
// if (applied == false) {
|
||||
// print('applied=========================');
|
||||
// print(applied);
|
||||
// Get.back();
|
||||
// // refuseOrder(box.read(BoxName.driverID), orderID);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void refuseOrder(
|
||||
orderID,
|
||||
) async {
|
||||
await CRUD().postFromDialogue(link: AppLink.addDriverOrder, payload: {
|
||||
//TODO need review
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
// box.read(BoxName.driverID).toString(),
|
||||
'order_id': orderID,
|
||||
'status': 'Refused'
|
||||
});
|
||||
await CRUD().post(link: AppLink.updateRides, payload: {
|
||||
'id': orderID,
|
||||
'rideTimeStart': DateTime.now().toString(),
|
||||
'status': 'Refused',
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
});
|
||||
|
||||
// applied = true;
|
||||
sql.insertData({
|
||||
'order_id': orderID,
|
||||
'created_at': DateTime.now().toString(),
|
||||
'driver_id': box.read(BoxName.driverID).toString(),
|
||||
}, TableName.driverOrdersRefuse);
|
||||
getRefusedOrderByCaptain();
|
||||
box.write(BoxName.statusDriverLocation, 'off');
|
||||
update();
|
||||
Get.back();
|
||||
// Get.offAll(HomeCaptain());
|
||||
}
|
||||
|
||||
addRideToNotificationDriverString(
|
||||
orderID,
|
||||
String startLocation,
|
||||
String endLocation,
|
||||
String date,
|
||||
String time,
|
||||
String price,
|
||||
String passengerId,
|
||||
String status,
|
||||
String carType,
|
||||
String passengerRate,
|
||||
String priceForPassenger,
|
||||
String distance,
|
||||
String duration,
|
||||
) async {
|
||||
await CRUD().post(link: AppLink.addWaitingRide, payload: {
|
||||
'id': orderID,
|
||||
'start_location': startLocation,
|
||||
'end_location': endLocation,
|
||||
'date': date,
|
||||
'time': time,
|
||||
'price': price,
|
||||
'passenger_id': passengerId,
|
||||
'status': status,
|
||||
'carType': carType,
|
||||
'passengerRate': passengerRate,
|
||||
'price_for_passenger': priceForPassenger,
|
||||
'distance': distance,
|
||||
'duration': duration,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,6 @@ import 'package:SEFER/views/auth/login_page.dart';
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../main.dart';
|
||||
import '../../onbording_page.dart';
|
||||
import '../../views/auth/captin/login_captin.dart';
|
||||
import '../../views/home/Captin/home_captain/home_captin.dart';
|
||||
import '../../views/home/map_page_passenger.dart';
|
||||
|
||||
class SplashScreenController extends GetxController
|
||||
@@ -50,11 +48,7 @@ class SplashScreenController extends GetxController
|
||||
? Get.off(() => OnBoardingPage())
|
||||
: box.read(BoxName.email) != null
|
||||
? Get.off(() => const MapPagePassenger())
|
||||
: box.read(BoxName.emailDriver) == null
|
||||
? Get.off(() => LoginPage())
|
||||
: box.read(BoxName.emailDriver) != null
|
||||
? Get.off(() => HomeCaptain())
|
||||
: Get.off(() => LoginCaptin());
|
||||
: Get.off(() => LoginPage());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
|
||||
import 'package:SEFER/views/home/home_page.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
@@ -8,7 +6,6 @@ import 'package:SEFER/constant/style.dart';
|
||||
import 'package:SEFER/controller/functions/crud.dart';
|
||||
import 'package:SEFER/controller/home/map_passenger_controller.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:SEFER/views/home/Captin/home_captain/home_captin.dart';
|
||||
import 'package:SEFER/views/home/map_page_passenger.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
|
||||
@@ -37,42 +34,42 @@ class RateController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
void addRateToPassenger() async {
|
||||
// HomeCaptainController homeCaptainController =
|
||||
// Get.find<HomeCaptainController>();
|
||||
// Get.put(MapDriverController());
|
||||
if (selectedRateItemId < 1) {
|
||||
Get.defaultDialog(
|
||||
title: 'You Should choose rate figure'.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
middleText: '',
|
||||
confirm: MyElevatedButton(title: 'Ok', onPressed: () => Get.back()));
|
||||
} else {
|
||||
await CRUD().post(link: AppLink.addRateToPassenger, payload: {
|
||||
'passenger_id': passengerId,
|
||||
'driverID': box.read(BoxName.driverID).toString(),
|
||||
'rideId': rideId,
|
||||
'rating': selectedRateItemId.toString(),
|
||||
'comment': comment.text,
|
||||
});
|
||||
await CRUD().sendEmail(AppLink.sendEmailToPassengerForTripDetails, {
|
||||
'startLocation':
|
||||
Get.find<MapDriverController>().passengerLocation.toString(),
|
||||
'endLocation':
|
||||
Get.find<MapDriverController>().passengerDestination.toString(),
|
||||
'name': Get.find<MapDriverController>().passengerName.toString(),
|
||||
'timeOfTrip': Get.find<MapDriverController>().timeOfOrder.toString(),
|
||||
'fee': Get.find<MapDriverController>().totalPassenger.toString(),
|
||||
'duration': Get.find<MapDriverController>().duration.toString(),
|
||||
'phone': Get.find<MapDriverController>().passengerPhone.toString(),
|
||||
'email': Get.find<MapDriverController>().passengerEmail.toString(),
|
||||
});
|
||||
// homeCaptainController.isActive = true;
|
||||
// update();
|
||||
// homeCaptainController.getPaymentToday();
|
||||
Get.offAll(HomeCaptain());
|
||||
}
|
||||
}
|
||||
// void addRateToPassenger() async {
|
||||
// // HomeCaptainController homeCaptainController =
|
||||
// // Get.find<HomeCaptainController>();
|
||||
// // Get.put(MapDriverController());
|
||||
// if (selectedRateItemId < 1) {
|
||||
// Get.defaultDialog(
|
||||
// title: 'You Should choose rate figure'.tr,
|
||||
// titleStyle: AppStyle.title,
|
||||
// middleText: '',
|
||||
// confirm: MyElevatedButton(title: 'Ok', onPressed: () => Get.back()));
|
||||
// } else {
|
||||
// await CRUD().post(link: AppLink.addRateToPassenger, payload: {
|
||||
// 'passenger_id': passengerId,
|
||||
// 'driverID': box.read(BoxName.driverID).toString(),
|
||||
// 'rideId': rideId,
|
||||
// 'rating': selectedRateItemId.toString(),
|
||||
// 'comment': comment.text,
|
||||
// });
|
||||
// await CRUD().sendEmail(AppLink.sendEmailToPassengerForTripDetails, {
|
||||
// 'startLocation':
|
||||
// Get.find<MapDriverController>().passengerLocation.toString(),
|
||||
// 'endLocation':
|
||||
// Get.find<MapDriverController>().passengerDestination.toString(),
|
||||
// 'name': Get.find<MapDriverController>().passengerName.toString(),
|
||||
// 'timeOfTrip': Get.find<MapDriverController>().timeOfOrder.toString(),
|
||||
// 'fee': Get.find<MapDriverController>().totalPassenger.toString(),
|
||||
// 'duration': Get.find<MapDriverController>().duration.toString(),
|
||||
// 'phone': Get.find<MapDriverController>().passengerPhone.toString(),
|
||||
// 'email': Get.find<MapDriverController>().passengerEmail.toString(),
|
||||
// });
|
||||
// // homeCaptainController.isActive = true;
|
||||
// // update();
|
||||
// // homeCaptainController.getPaymentToday();
|
||||
// Get.offAll(HomeCaptain());
|
||||
// }
|
||||
// }
|
||||
|
||||
void addRateToDriver() async {
|
||||
if (selectedRateItemId < 1) {
|
||||
|
||||
Reference in New Issue
Block a user