11/1/9
This commit is contained in:
@@ -60,7 +60,7 @@ class LoginCaptinController extends GetxController {
|
||||
box.write(BoxName.phoneDriver, jsonDecoeded['data'][0]['phone']);
|
||||
SecureStorage()
|
||||
.saveData(BoxName.passwordDriver, passwordController.text);
|
||||
Get.offAll(() => const HomeCaptain());
|
||||
Get.offAll(() => HomeCaptain());
|
||||
isloading = false;
|
||||
update();
|
||||
print(box.read(BoxName.driverID).toString());
|
||||
@@ -101,7 +101,7 @@ class LoginCaptinController extends GetxController {
|
||||
}
|
||||
|
||||
void loginByBoxData() async {
|
||||
Get.to(() => const HomeCaptain());
|
||||
Get.to(() => HomeCaptain());
|
||||
await CRUD().post(link: AppLink.addTokensDriver, payload: {
|
||||
'token': box.read(BoxName.tokenDriver).toString(),
|
||||
'captain_id': box.read(BoxName.driverID).toString()
|
||||
|
||||
@@ -56,7 +56,7 @@ class RegisterController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
sendverfications() async {
|
||||
sendVerifications() async {
|
||||
var res = await CRUD().post(link: AppLink.verifyEmail, payload: {
|
||||
'email': emailController.text,
|
||||
'token': verfyCode.text,
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:camera/camera.dart';
|
||||
import 'package:flutter_tesseract_ocr/flutter_tesseract_ocr.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart';
|
||||
import 'package:ride/constant/box_name.dart';
|
||||
@@ -193,49 +192,49 @@ class CameraClassController extends GetxController {
|
||||
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');
|
||||
// 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();
|
||||
// // 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);
|
||||
// // 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
|
||||
// // 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.
|
||||
// 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 = '';
|
||||
}
|
||||
}
|
||||
// // Print the JSON to the console.
|
||||
// print(jsonText);
|
||||
// update();
|
||||
// // print(text);
|
||||
// } catch (e) {
|
||||
// print('Error during text extraction: $e');
|
||||
// scannedText = '';
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:ride/constant/box_name.dart';
|
||||
import 'dart:async';
|
||||
|
||||
@@ -15,13 +16,24 @@ class HomeCaptainController extends GetxController {
|
||||
Duration activeDuration = Duration.zero;
|
||||
Timer? activeTimer;
|
||||
Map data = {};
|
||||
bool isLoading = true;
|
||||
String totalMoneyToday = '0';
|
||||
String totalMoneyInSEFER = '0';
|
||||
String totalDurationToday = '0';
|
||||
Timer? timer;
|
||||
bool mapType = false;
|
||||
bool mapTrafficON = false;
|
||||
double widthMapTypeAndTraffic = 50;
|
||||
// Inject the LocationController class
|
||||
final locationController = Get.find<LocationController>();
|
||||
final locationController = Get.put(LocationController());
|
||||
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";
|
||||
}
|
||||
|
||||
String stringActiveDuration = '';
|
||||
void onButtonSelected() {
|
||||
isActive = !isActive;
|
||||
if (isActive) {
|
||||
@@ -29,6 +41,7 @@ class HomeCaptainController extends GetxController {
|
||||
activeStartTime = DateTime.now();
|
||||
activeTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
activeDuration = DateTime.now().difference(activeStartTime!);
|
||||
stringActiveDuration = formatDuration(activeDuration);
|
||||
update();
|
||||
});
|
||||
} else {
|
||||
@@ -42,6 +55,27 @@ class HomeCaptainController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
void changeMapType() {
|
||||
mapType = !mapType;
|
||||
// heightButtomSheetShown = isButtomSheetShown == true ? 240 : 0;
|
||||
update();
|
||||
}
|
||||
|
||||
void changeMapTraffic() {
|
||||
mapTrafficON = !mapTrafficON;
|
||||
update();
|
||||
}
|
||||
|
||||
GoogleMapController? mapHomeCaptaiController;
|
||||
void onMapCreated(GoogleMapController controller) {
|
||||
mapHomeCaptaiController = controller;
|
||||
controller.getVisibleRegion();
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(locationController.myLocation),
|
||||
);
|
||||
update();
|
||||
}
|
||||
|
||||
void savePeriod(Duration period) {
|
||||
final periods = box.read<List<dynamic>>(BoxName.periods) ?? [];
|
||||
periods.add(period.inSeconds);
|
||||
@@ -72,7 +106,9 @@ class HomeCaptainController extends GetxController {
|
||||
@override
|
||||
void onInit() async {
|
||||
addToken();
|
||||
onButtonSelected();
|
||||
getPaymentToday();
|
||||
getAllPayment();
|
||||
startPeriodicExecution();
|
||||
super.onInit();
|
||||
}
|
||||
@@ -91,6 +127,16 @@ class HomeCaptainController extends GetxController {
|
||||
payload: {'driverID': box.read(BoxName.driverID).toString()});
|
||||
data = jsonDecode(res);
|
||||
totalMoneyToday = data['message'][0]['todayAmount'];
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
getAllPayment() async {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getAllPayment,
|
||||
payload: {'driverID': box.read(BoxName.driverID).toString()});
|
||||
data = jsonDecode(res);
|
||||
|
||||
totalMoneyInSEFER = data['message'][0]['total_amount'];
|
||||
update();
|
||||
}
|
||||
|
||||
75
lib/controller/home/captin/widget/left_menu_map_captain.dart
Normal file
75
lib/controller/home/captin/widget/left_menu_map_captain.dart
Normal file
@@ -0,0 +1,75 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_font_icons/flutter_font_icons.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:ride/controller/home/captin/home_captain_controller.dart';
|
||||
|
||||
import '../../../../constant/colors.dart';
|
||||
import '../../../../views/Rate/ride_calculate_driver.dart';
|
||||
|
||||
GetBuilder<HomeCaptainController> leftMainMenuCaptainIcons() {
|
||||
return GetBuilder<HomeCaptainController>(
|
||||
builder: (controller) => Positioned(
|
||||
bottom: Get.height * .17,
|
||||
left: 6,
|
||||
child: Column(
|
||||
children: [
|
||||
AnimatedContainer(
|
||||
duration: const Duration(microseconds: 200),
|
||||
width: controller.widthMapTypeAndTraffic,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(),
|
||||
color: AppColor.secondaryColor,
|
||||
borderRadius: BorderRadius.circular(15)),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
controller.changeMapType();
|
||||
// Toast.show(context, 'This is a toast message!');
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.satellite_alt,
|
||||
size: 29,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
AnimatedContainer(
|
||||
duration: const Duration(microseconds: 200),
|
||||
width: controller.widthMapTypeAndTraffic,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.secondaryColor,
|
||||
border: Border.all(),
|
||||
borderRadius: BorderRadius.circular(15)),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
controller.changeMapTraffic();
|
||||
// Toast.show(context, 'This is a toast message!');
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.streetview_sharp,
|
||||
size: 29,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
AnimatedContainer(
|
||||
duration: const Duration(microseconds: 200),
|
||||
width: controller.widthMapTypeAndTraffic,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.secondaryColor,
|
||||
border: Border.all(),
|
||||
borderRadius: BorderRadius.circular(15)),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Get.to(() => const RideCalculateDriver());
|
||||
},
|
||||
icon: const Icon(FontAwesome5.chart_bar),
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class SplashScreenController extends GetxController
|
||||
: box.read(BoxName.emailDriver) == null
|
||||
? Get.off(() => LoginPage())
|
||||
: box.read(BoxName.emailDriver) != null
|
||||
? Get.off(() => const HomeCaptain())
|
||||
? Get.off(() => HomeCaptain())
|
||||
: Get.off(() => LoginCaptin());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:ride/views/home/Captin/home_captin.dart';
|
||||
import 'package:ride/views/home/map_page.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../home/captin/home_captain_controller.dart';
|
||||
// import '../home/captin/home_captain_controller.dart';
|
||||
|
||||
class RateController extends GetxController {
|
||||
double selectedRateItemId = -1;
|
||||
@@ -33,8 +33,8 @@ class RateController extends GetxController {
|
||||
}
|
||||
|
||||
void addRateToPassenger() async {
|
||||
HomeCaptainController homeCaptainController =
|
||||
Get.find<HomeCaptainController>();
|
||||
// HomeCaptainController homeCaptainController =
|
||||
// Get.find<HomeCaptainController>();
|
||||
if (selectedRateItemId < 1) {
|
||||
Get.defaultDialog(
|
||||
title: 'You Should choose rate figure'.tr,
|
||||
@@ -49,9 +49,10 @@ class RateController extends GetxController {
|
||||
'rating': selectedRateItemId.toString(),
|
||||
'comment': comment.text,
|
||||
});
|
||||
Get.offAll(const HomeCaptain());
|
||||
homeCaptainController.isActive = true;
|
||||
homeCaptainController.getPaymentToday();
|
||||
// homeCaptainController.isActive = true;
|
||||
// update();
|
||||
// homeCaptainController.getPaymentToday();
|
||||
Get.offAll(HomeCaptain());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user