From 7af7e71b30f9e9947760719e36bc68925b139ea3 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Thu, 18 Jan 2024 00:49:00 +0300 Subject: [PATCH] 1/18/1 --- ios/Runner/AppDelegate.swift | 4 +- lib/controller/functions/gemeni.dart | 294 ++++++- .../functions/location_controller.dart | 1 + .../home/captin/home_captain_controller.dart | 1 + .../home/captin/map_driver_controller.dart | 33 +- .../home/map_passenger_controller.dart | 103 ++- .../home/splash_screen_controlle.dart | 1 + lib/controller/local/local_controller.dart | 3 + lib/main.dart | 3 +- lib/views/auth/captin/ai_page.dart | 800 +++++++++++++----- lib/views/auth/captin/login_captin.dart | 1 + lib/views/auth/captin/register_captin.dart | 1 - .../home/Captin/home_captain/home_captin.dart | 2 + .../orderCaptin/order_request_page.dart | 15 +- .../buttom_sheet_map_show.dart | 4 +- .../points_page_for_rider.dart | 26 +- .../map_widget.dart/ride_begin_passenger.dart | 5 +- 17 files changed, 1028 insertions(+), 269 deletions(-) diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index d75847c..265f9be 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -2,7 +2,7 @@ import UIKit import Flutter import FirebaseCore import GoogleMaps -import Constants +// import Constants @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { @@ -11,7 +11,7 @@ import Constants _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { - GMSServices.provideAPIKey(mapsApiKey) + GMSServices.provideAPIKey("AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0") FirebaseApp.configure() GeneratedPluginRegistrant.register(with: self) return true diff --git a/lib/controller/functions/gemeni.dart b/lib/controller/functions/gemeni.dart index dd691b0..0ececbd 100644 --- a/lib/controller/functions/gemeni.dart +++ b/lib/controller/functions/gemeni.dart @@ -12,10 +12,14 @@ import '../../constant/colors.dart'; class ContentController extends GetxController { final picker = ImagePicker(); + Map responseMap = {}; + Map responseCarLicenseMap = {}; + Map responseBackCarLicenseMap = {}; + Map responseIdCardeMap = {}; bool isloading = false; var image; CroppedFile? croppedFile; - + DateTime now = DateTime.now(); Future pickImage() async { final pickedImage = await picker.pickImage(source: ImageSource.gallery); @@ -153,6 +157,294 @@ class ContentController extends GetxController { } } + Future generateDriverLicenseJordanContent() async { + await pickImage(); + isloading = true; + update(); + if (image != null) { + final imageBytes = await image.readAsBytes(); + final imageData = base64Encode(imageBytes); + + var requestBody = jsonEncode({ + 'contents': [ + { + 'parts': [ + { + 'inlineData': { + 'mimeType': 'image/jpeg', + 'data': imageData, + }, + }, + { + 'text': + 'write json for all data as first name ,last name,dob,id ,expiration date,issued date asdress class type,age in years ,output json type in arabic value and stay engish key and make date format like YYYY-MM-DD , for name please extract name in arabic in Name in json plus first_name ', + }, + ], + }, + ], + 'generationConfig': { + 'temperature': 0.4, + 'topK': 32, + 'topP': 1, + 'maxOutputTokens': 4096, + 'stopSequences': [], + }, + 'safetySettings': [ + { + 'category': 'HARM_CATEGORY_HARASSMENT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_HATE_SPEECH', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_DANGEROUS_CONTENT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + ], + }); + print(requestBody); + + final response = await http.post( + Uri.parse( + 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro-vision:generateContent?key=${AK.geminiApi}'), + headers: {'Content-Type': 'application/json'}, + body: requestBody, + ); + isloading = false; + update(); + if (response.statusCode == 200) { + var responseData = jsonDecode(response.body); + // Process the responseData as needed + // print(responseData); + + var result = + responseData['candidates'][0]['content']['parts'][0]['text']; + // print(jsonEncode(result)); + // print((result)); + // print(result['dob']); + RegExp regex = RegExp(r"```json([^`]*)```"); + String? jsonString = + regex.firstMatch(responseData.toString())?.group(1)?.trim(); + + if (jsonString != null) { + // Convert the JSON object to a String + jsonString = jsonEncode(json.decode(jsonString)); + responseMap = jsonDecode(jsonString); + print(jsonString); + print(responseMap); + print(responseMap['dob']); + } else { + print("JSON string not found"); + } + + // Rest of your code... + } else { + print('Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.body}'); + } + } else { + print('No image selected'); + } + } + + Future generateCarLicenseJordanContent() async { + await pickImage(); + isloading = true; + update(); + if (image != null) { + final imageBytes = await image.readAsBytes(); + final imageData = base64Encode(imageBytes); + + var requestBody = jsonEncode({ + 'contents': [ + { + 'parts': [ + { + 'inlineData': { + 'mimeType': 'image/jpeg', + 'data': imageData, + }, + }, + { + 'text': + 'write json output of this car license in jordan json contain name , address , car kind ,car color , car year , car plate ,registration adjective , using ,expire date of license and make date format like YYYY-MM-DD .dont add data else this image', + }, + ], + }, + ], + 'generationConfig': { + 'temperature': 0.4, + 'topK': 32, + 'topP': 1, + 'maxOutputTokens': 4096, + 'stopSequences': [], + }, + 'safetySettings': [ + { + 'category': 'HARM_CATEGORY_HARASSMENT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_HATE_SPEECH', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + { + 'category': 'HARM_CATEGORY_DANGEROUS_CONTENT', + 'threshold': 'BLOCK_MEDIUM_AND_ABOVE', + }, + ], + }); + print(requestBody); + + final response = await http.post( + Uri.parse( + 'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro-vision:generateContent?key=${AK.geminiApi}'), + headers: {'Content-Type': 'application/json'}, + body: requestBody, + ); + isloading = false; + update(); + if (response.statusCode == 200) { + var responseData = jsonDecode(response.body); + // Process the responseData as needed + // print(responseData); + + var result = + responseData['candidates'][0]['content']['parts'][0]['text']; + // print(jsonEncode(result)); + // print((result)); + // print(result['dob']); + RegExp regex = RegExp(r"```json([^`]*)```"); + String? jsonString = + regex.firstMatch(responseData.toString())?.group(1)?.trim(); + + if (jsonString != null) { + // Convert the JSON object to a String + jsonString = jsonEncode(json.decode(jsonString)); + responseCarLicenseMap = jsonDecode(jsonString); + print(jsonString); + print(responseCarLicenseMap); + print(responseCarLicenseMap['plate_number']); + } else { + print("JSON string not found"); + } + + // Rest of your code... + } else { + print('Request failed with status: ${response.statusCode}'); + print('Request failed with status: ${response.body}'); + } + } else { + print('No image selected'); + } + } + + Future 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 getFromCarRegistration() async { await pickImage(); if (image != null) { diff --git a/lib/controller/functions/location_controller.dart b/lib/controller/functions/location_controller.dart index b15a7f5..8bb1f38 100644 --- a/lib/controller/functions/location_controller.dart +++ b/lib/controller/functions/location_controller.dart @@ -24,6 +24,7 @@ class LocationController extends GetxController { void onInit() async { super.onInit(); location = Location(); + totalPoints = Get.find().totalPoints; getLocation(); } diff --git a/lib/controller/home/captin/home_captain_controller.dart b/lib/controller/home/captin/home_captain_controller.dart index 7044f3a..320d749 100644 --- a/lib/controller/home/captin/home_captain_controller.dart +++ b/lib/controller/home/captin/home_captain_controller.dart @@ -185,6 +185,7 @@ class HomeCaptainController extends GetxController { getPaymentToday(); getAllPayment(); startPeriodicExecution(); + onMapCreated(mapHomeCaptaiController!); getRefusedOrderByCaptain(); totalPoints = Get.find().totalPoints; super.onInit(); diff --git a/lib/controller/home/captin/map_driver_controller.dart b/lib/controller/home/captin/map_driver_controller.dart index af1fafd..c33103d 100644 --- a/lib/controller/home/captin/map_driver_controller.dart +++ b/lib/controller/home/captin/map_driver_controller.dart @@ -31,11 +31,17 @@ class MapDriverController extends GetxController { Set markers = {}; late String passengerLocation; late String passengerDestination; + late String step0; + late String step1; + late String step2; + late String step3; + late String step4; late String duration; late String distance; late String name; late String phone; late String rideId; + late String isHaveSteps; late String paymentAmount; late String paymentMethod; late String passengerId; @@ -311,20 +317,15 @@ class MapDriverController extends GetxController { ), ); - // Update the `markers` set and call the `update()` method on the controller to notify the view that the marker position has changed. - update(); - - // No recursive call here. The marker update will be triggered externally. - - // Optionally, you can animate the camera to the new location after updating the marker. mapController!.animateCamera( CameraUpdate.newLatLng(locationController.myLocation), ); + update(); } void addCustomCarIcon() { - ImageConfiguration config = ImageConfiguration( - size: Size(Get.width * .6, Get.height * .6), + ImageConfiguration config = const ImageConfiguration( + size: Size(20, 20), // scale: 1.0, ); BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png') @@ -441,13 +442,25 @@ class MapDriverController extends GetxController { rideId = Get.arguments['rideId']; durationOfRideValue = Get.arguments['durationOfRideValue']; paymentAmount = Get.arguments['paymentAmount']; - paymentMethod = Get.arguments['paymentMethod']; + isHaveSteps = Get.arguments['isHaveSteps']; + step0 = Get.arguments['step0']; + step1 = Get.arguments['step1']; + step2 = Get.arguments['step2']; + step3 = Get.arguments['step3']; + step4 = Get.arguments['step4']; String lat = Get.find().myLocation.latitude.toString(); String lng = Get.find().myLocation.longitude.toString(); String origin = '$lat,$lng'; // Set the origin and destination coordinates for the Google Maps directions request. getMap(origin, passengerLocation); - await getMapDestination(passengerLocation, passengerDestination); + isHaveSteps == 'haveSteps' + ? ( + await getMapDestination(step0, step1), + await getMapDestination(step1, step2), + await getMapDestination(step2, step3), + await getMapDestination(step3, step4), + ) + : await getMapDestination(passengerLocation, passengerDestination); addCustomCarIcon(); // updateMarker(); startTimerToShowPassengerInfoWindowFromDriver(); diff --git a/lib/controller/home/map_passenger_controller.dart b/lib/controller/home/map_passenger_controller.dart index 8b97044..ccf6a44 100644 --- a/lib/controller/home/map_passenger_controller.dart +++ b/lib/controller/home/map_passenger_controller.dart @@ -67,12 +67,12 @@ class MapPassengerController extends GetxController { late LatLng newPointLocation3 = const LatLng(32.115295, 36.064773); late LatLng newPointLocation4 = const LatLng(32.115295, 36.064773); LatLng myDestination = const LatLng(32.115295, 36.064773); - final List polylineCoordinates = []; - final List polylineCoordinates0 = []; - final List polylineCoordinates1 = []; - final List polylineCoordinates2 = []; - final List polylineCoordinates3 = []; - final List polylineCoordinates4 = []; + List polylineCoordinates = []; + List polylineCoordinates0 = []; + List polylineCoordinates1 = []; + List polylineCoordinates2 = []; + List polylineCoordinates3 = []; + List polylineCoordinates4 = []; List> polylineCoordinatesPointsAll = []; List carsLocationByPassenger = []; List driverCarsLocationToPassengerAfterApplied = []; @@ -187,7 +187,8 @@ class MapPassengerController extends GetxController { late Duration durationToAdd; late DateTime newTime = DateTime.now(); - + int hours = 0; + int minutes = 0; void onChangedPassengerCount(int newValue) { selectedPassengerCount = newValue; update(); @@ -573,7 +574,15 @@ class MapPassengerController extends GetxController { rideTimerBegin.toString(), dataCarsLocationByPassenger['message'][carsOrder]['driver_id'] .toString(), - durationToRide.toString() + durationToRide.toString(), + Get.find().wayPoints.length > 1 + ? 'haveSteps' + : 'startEnd', + placesCoordinate[0], + placesCoordinate[1], + placesCoordinate[2], + placesCoordinate[3], + placesCoordinate[4], ]; FirebaseMessagesController().sendNotificationToDriverMAP( 'Order', @@ -636,6 +645,14 @@ class MapPassengerController extends GetxController { cancelRideAfterRejectFromAll(); } + } else if (decod['data'].toString() == 'Cancel') { + remainingTime = 0; + shouldFetch = false; + rideConfirm = false; + FirebaseMessagesController().sendNotificationToDriverMAP( + 'Trip Canceled'.tr, '', driverToken, []); + + update(); } else { delayAndFetchRideStatus( rideId); // Repeat the delay and fetch operation @@ -807,6 +824,7 @@ class MapPassengerController extends GetxController { "status": 'Cancel' }); rideConfirm = false; + totalStepDurations = 0; shouldFetch = false; isPassengerChosen = false; isCashConfirmPageShown = false; @@ -825,6 +843,7 @@ class MapPassengerController extends GetxController { if (rideConfirm == false) { clearPlacesDestination(); clearPolyline(); + // clearPolylineAll(); data = []; changeCancelRidePageShow(); rideConfirm = false; @@ -834,6 +853,7 @@ class MapPassengerController extends GetxController { isCashSelectedBeforeConfirmRide = false; isPickerShown = false; totalStepDurations = 0; + totalStepDurations = 0; timeToPassengerFromDriverAfterApplied = 0; update(); } else { @@ -852,7 +872,9 @@ class MapPassengerController extends GetxController { isCashSelectedBeforeConfirmRide = false; timeToPassengerFromDriverAfterApplied = 0; totalStepDurations = 0; + totalStepDurations = 0; changeCancelRidePageShow(); + // clearPolylineAll(); remainingTime = 0; update(); @@ -1073,9 +1095,27 @@ class MapPassengerController extends GetxController { void clearPolyline() { polyLines = []; polylineCoordinates.clear(); + // polylineCoordinates = []; + polylineCoordinatesPointsAll[0].clear(); + polylineCoordinatesPointsAll[1].clear(); + polylineCoordinatesPointsAll[2].clear(); + polylineCoordinatesPointsAll[3].clear(); + polylineCoordinatesPointsAll[4].clear(); update(); } + // void clearPolylineAll() { + // polylineCoordinatesPointsAll[0].clear(); + // polylineCoordinatesPointsAll[1].clear(); + // polylineCoordinatesPointsAll[2].clear(); + // polylineCoordinatesPointsAll[3].clear(); + // polylineCoordinatesPointsAll[4].clear(); + + // polyLines = []; + // polylineCoordinates.clear(); + // update(); + // } + void addCustomPicker() { ImageConfiguration config = const ImageConfiguration( size: Size(20, 20), @@ -1111,9 +1151,9 @@ class MapPassengerController extends GetxController { } void addCustomCarIcon() { - ImageConfiguration config = ImageConfiguration( - size: Size(Get.width * .6, Get.height * .6), - // size: Size(20, 20), + ImageConfiguration config = const ImageConfiguration( + // size: Size(Get.width * .6, Get.height * .6), + size: Size(20, 20), // scale: 1.0, ); BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png') @@ -1414,19 +1454,23 @@ class MapPassengerController extends GetxController { int totalStepDurations = 0; getMapPoints(String origin, String destination, int index) async { isWayPointStopsSheetUtilGetMap = false; + await getCarsLocationByPassenger(); isLoading = false; update(); var url = ('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}'); - print(url); + // print(url); var response = await CRUD().getGoogleApi(link: url, payload: {}); data = response['routes'][0]['legs']; // print(data); isLoading = false; + + int durationToRide0 = data[0]['duration']['value']; + durationToRide = durationToRide + durationToRide0; + print('durationToRide is ${data[0]['duration']['value']}'); + print('totalStepDurations is $durationToRide'); update(); - durationToRide = durationToRide + int.parse(data[0]['duration']['value']); - // totalStepDurations = totalStepDurations + durationToRide; final points = decodePolyline(response["routes"][0]["overview_polyline"]["points"]); for (int i = 0; i < points.length; i++) { @@ -1452,20 +1496,20 @@ class MapPassengerController extends GetxController { // Animate the camera to the adjusted bounds if (distanceOfDestnation <= 5) { - mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 14)); + mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 15)); } else if (distanceOfDestnation > 5 && distanceOfDestnation <= 8) { - mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 13)); + mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 14)); } else if (distanceOfDestnation > 8 && distanceOfDestnation < 16) { - mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 12)); + mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 13)); } else if (distanceOfDestnation >= 16 && distanceOfDestnation < 30) { mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 11)); } else if (distanceOfDestnation >= 30 && distanceOfDestnation < 100) { - mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 10)); + mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 9)); } else if (distanceOfDestnation >= 100) { mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 7)); } if (polyLines.isNotEmpty) { - clearPolyline(); + // clearPolyline(); } else { var polyline = Polyline( polylineId: PolylineId(response["routes"][0]["summary"]), @@ -1540,18 +1584,21 @@ class MapPassengerController extends GetxController { print('================================='); distance = getDistanceFromText(distanceText); duration = getDistanceFromText(durationText); - durationToAdd = Duration(minutes: duration.toInt()); + durationToAdd = Duration(seconds: durationToRide); + print('durationToRide----- $durationToRide'); + hours = durationToAdd.inHours; + minutes = (durationToAdd.inMinutes % 60).round(); DateTime currentTime = DateTime.now(); newTime = currentTime.add(durationToAdd); - averageDuration = duration / distance; - costDuration = duration * averageDuration * 0.016; + averageDuration = (durationToRide / 60) / distance; + costDuration = (durationToRide / 60) * averageDuration * 0.016; var totalDriver1 = cost + costDuration; totalPassenger = totalDriver1 + (totalDriver1 * .16); totalDriver = totalDriver1 + (totalDriver1 * .16); - tax = totalPassenger * .04; - totalME = totalPassenger - totalDriver - tax; + tax = totalPassenger * .16; + totalME = totalPassenger - tax; update(); - if (currentTime.hour >= 21) { + if (currentTime.hour >= 22) { if (distanceText.contains('km')) { cost = distance * 0.23; update(); @@ -1570,7 +1617,7 @@ class MapPassengerController extends GetxController { } else if (currentTime.hour >= 13 && currentTime.hour <= 16) { if (averageDuration > 2.5) { if (distanceText.contains('km')) { - cost = distance * 0.23; + cost = distance * 0.25; update(); } else { cost = distance * 0.25 / 1000; @@ -1599,8 +1646,8 @@ class MapPassengerController extends GetxController { totalPassenger = 1; update(); if (totalDriver < .5) { - totalDriver = .80; - totalME = .16; + totalDriver = .75; + totalME = .21; update(); } else { totalDriver = .90; diff --git a/lib/controller/home/splash_screen_controlle.dart b/lib/controller/home/splash_screen_controlle.dart index e37e53b..7d81077 100644 --- a/lib/controller/home/splash_screen_controlle.dart +++ b/lib/controller/home/splash_screen_controlle.dart @@ -20,6 +20,7 @@ class SplashScreenController extends GetxController @override void onInit() { super.onInit(); + animationController = AnimationController( vsync: this, duration: const Duration(seconds: 7), diff --git a/lib/controller/local/local_controller.dart b/lib/controller/local/local_controller.dart index 55a4a43..6306355 100644 --- a/lib/controller/local/local_controller.dart +++ b/lib/controller/local/local_controller.dart @@ -7,6 +7,7 @@ import '../themes/themes.dart'; class LocaleController extends GetxController { Locale? language; + String countryCode = ''; void restartApp() { runApp(const MyApp()); } @@ -30,11 +31,13 @@ class LocaleController extends GetxController { break; default: locale = Locale(Get.deviceLocale!.languageCode); + appTheme = themeEnglish; break; } box.write(BoxName.lang, langcode); + // box.write(BoxName.lang, langcode); Get.changeTheme(appTheme); Get.updateLocale(locale); restartApp(); diff --git a/lib/main.dart b/lib/main.dart index 3d01591..511ee92 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -35,7 +35,8 @@ void main() async { await GetStorage.init(); await AC().gAK(); print( - 'local is ${WidgetsBinding.instance.platformDispatcher.locale.countryCode}'); + 'local is t ${WidgetsBinding.instance.platformDispatcher.locale.countryCode}'); + print(Get.deviceLocale!.countryCode); Stripe.publishableKey = AK.publishableKey; //StripeKey.publishableKey; diff --git a/lib/views/auth/captin/ai_page.dart b/lib/views/auth/captin/ai_page.dart index 2134450..c900be0 100644 --- a/lib/views/auth/captin/ai_page.dart +++ b/lib/views/auth/captin/ai_page.dart @@ -1,90 +1,391 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:ride/constant/colors.dart'; -import 'package:ride/constant/links.dart'; import 'package:ride/constant/style.dart'; import 'package:ride/constant/table_names.dart'; import 'package:ride/controller/auth/captin/register_captin_controller.dart'; import 'package:ride/controller/functions/ocr_controller.dart'; import 'package:ride/main.dart'; -import 'package:ride/views/auth/captin/car_license_page.dart'; import 'package:ride/views/widgets/elevated_btn.dart'; import 'package:ride/views/widgets/my_scafold.dart'; import 'package:ride/views/widgets/mycircular.dart'; +import '../../../controller/functions/gemeni.dart'; + class AiPage extends StatelessWidget { ScanDocumentsByApi scanDocumentsByApi = Get.put(ScanDocumentsByApi()); RegisterCaptainController registerCaptainController = Get.put(RegisterCaptainController()); - + ContentController contentController = Get.put(ContentController()); @override Widget build(BuildContext context) { return MyScafolld( title: 'AI Page'.tr, body: [ - Positioned( - top: 3, - left: Get.width * .2, - right: Get.width * .2, - child: MyElevatedButton( - title: 'Take Picture Of ID Card'.tr, - onPressed: () { - scanDocumentsByApi.scanDocumentsByApi(); - }, - )), - GetBuilder( - builder: (scanDocumentsByApi) => scanDocumentsByApi - .responseMap.isNotEmpty - ? Positioned( - top: Get.height * .06, - left: Get.width * .051, - right: Get.width * .051, - child: scanDocumentsByApi.isLoading - ? Column( - children: [ - const MyCircularProgressIndicator(), - Text( - 'We are process picture please wait '.tr, - style: AppStyle.title, - ) - ], - ) - : Column( - children: [ - Container( - decoration: AppStyle.boxDecoration, - height: Get.height * .4, - child: Padding( - padding: const EdgeInsets.all(5), - child: scanDocumentsByApi.responseMap.isEmpty - ? Center( - child: Text( - 'There is no data yet.'.tr, - style: AppStyle.title, + Get.deviceLocale!.countryCode != 'US' + ? Positioned( + top: 3, + left: Get.width * .2, + right: Get.width * .2, + child: MyElevatedButton( + title: 'Take Picture Of ID Card'.tr, + onPressed: () { + scanDocumentsByApi.scanDocumentsByApi(); + }, + )) + : Positioned( + top: 3, + left: Get.width * .1, + right: Get.width * .1, + child: MyElevatedButton( + title: 'Take Picture Of Driver License Card'.tr, + onPressed: () { + contentController.generateDriverLicenseJordanContent(); + }, + )), + Get.deviceLocale!.countryCode != 'US' + ? GetBuilder( + builder: (scanDocumentsByApi) => scanDocumentsByApi + .responseMap.isNotEmpty + ? Positioned( + top: Get.height * .06, + left: Get.width * .051, + right: Get.width * .051, + child: scanDocumentsByApi.isLoading + ? Column( + children: [ + const MyCircularProgressIndicator(), + Text( + 'We are process picture please wait '.tr, + style: AppStyle.title, + ) + ], + ) + : Column( + children: [ + Container( + decoration: AppStyle.boxDecoration, + height: Get.height * .4, + child: Padding( + padding: const EdgeInsets.all(5), + child: scanDocumentsByApi + .responseMap.isEmpty + ? Center( + child: Text( + 'There is no data yet.'.tr, + style: AppStyle.title, + ), + ) + : Column( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Column( + mainAxisAlignment: + MainAxisAlignment + .start, + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text( + 'Name :${scanDocumentsByApi.name}', + style: AppStyle + .subtitle, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + 'Drivers License Class: ${scanDocumentsByApi.licenseClass}', + style: AppStyle + .title, + ), + Image.memory( + scanDocumentsByApi + .imageSignature, + width: 100, + height: 30, + ), + ], + ), + ], + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + 'Document Number: ${scanDocumentsByApi.documentNo}', + style: AppStyle.title, + ), + Image.memory( + scanDocumentsByApi + .imagePortrait, + width: 60, + ), + ]), + Text( + 'Address: ${scanDocumentsByApi.address}', + style: AppStyle.title, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + 'Height: ${scanDocumentsByApi.height}', + style: + AppStyle.subtitle, + ), + Text( + 'Postal Code: ${scanDocumentsByApi.postalCode}', + style: + AppStyle.subtitle, + ), + Text( + 'Sex: ${scanDocumentsByApi.sex}', + style: + AppStyle.subtitle, + ), + ], + ), + Text( + 'Territorial Code: ${scanDocumentsByApi.stateCode}', + style: AppStyle.subtitle, + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + 'Expiry Date: ${scanDocumentsByApi.expireDate}', + style: DateTime.parse(scanDocumentsByApi + .responseMap['data'] + ['ocr'][ + 'dateOfExpiry'] + .toString()) + .isBefore( + scanDocumentsByApi + .now) + ? AppStyle.title + .copyWith( + color: AppColor + .redColor) + : AppStyle.title.copyWith( + color: AppColor + .greenColor), + ), + Text( + 'Date of Birth: ${scanDocumentsByApi.dob}', + style: AppStyle.title, + ), + ], + ), + ], + ), + ), + ), + DateTime.parse(scanDocumentsByApi + .responseMap['data']['ocr'] + ['dateOfExpiry'] + .toString()) + .isBefore(scanDocumentsByApi.now) + ? Text( + 'You can\'t continue with us .\nYou should renew Driver license', + style: AppStyle.title.copyWith( + color: AppColor.redColor), + ) + : MyElevatedButton( + title: 'Detect Your Face '.tr, + onPressed: () => scanDocumentsByApi + .checkMatchFaceApi(), ), - ) - : Column( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Column( + scanDocumentsByApi.res.isEmpty + ? const SizedBox() + : scanDocumentsByApi.res['data'] + ['result'] + .toString() == + 'Same' + ? MyElevatedButton( + onPressed: () async { + await registerCaptainController + .register(); + await registerCaptainController + .addLisence(); + // await scanDocumentsByApi + // .uploadImagePortrate(); + }, + title: + 'Go to next step\nscan Car License.' + .tr, + kolor: AppColor.greenColor, + ) + : const SizedBox(), + MyElevatedButton( + title: 'get sql data', + kolor: AppColor.yellowColor, + onPressed: () { + sql.deleteAllData( + TableName.faceDetectTimes); + sql + .getAllData( + TableName.faceDetectTimes) + .then((value) => print( + value[0]['faceDetectTimes'])); + }, + ) + ], + ), + ) + : Positioned( + top: Get.height * .06, + left: Get.width * .051, + right: Get.width * .051, + child: scanDocumentsByApi.isLoading + ? Column( + children: [ + const MyCircularProgressIndicator(), + Text( + 'We are process picture please wait '.tr, + style: AppStyle.title, + ) + ], + ) + : Column( + children: [ + Container( + decoration: AppStyle.boxDecoration, + height: Get.height * .35, + child: Padding( + padding: const EdgeInsets.all(5), + child: Center( + child: Text( + 'There is no data yet.'.tr, + style: AppStyle.title, + ), + )), + ), + ], + ), + ), + ) + : GetBuilder( + builder: (contentController) => contentController + .responseMap.isNotEmpty + ? Positioned( + top: Get.height * .09, + left: Get.width * .051, + right: Get.width * .051, + child: contentController.isloading + ? Column( + children: [ + const MyCircularProgressIndicator(), + Text( + 'We are process picture please wait '.tr, + style: AppStyle.title, + ) + ], + ) + : SizedBox( + height: Get.height * .7, + child: ListView( + children: [ + Container( + decoration: AppStyle.boxDecoration, + // height: Get.height * .4, + child: Padding( + padding: const EdgeInsets.all(5), + child: contentController + .responseMap.isEmpty + ? Center( + child: Text( + 'There is no data yet.'.tr, + style: AppStyle.title, + ), + ) + : Column( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment + .spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Column( + mainAxisAlignment: + MainAxisAlignment + .start, + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Row( + children: [ + Text( + '${'Name'.tr} :${contentController.responseMap['first_name']}', + style: AppStyle + .subtitle, + ), + Text( + ' ${contentController.responseMap['last_name']}', + style: AppStyle + .subtitle, + ), + ], + ), + Text( + '${'Name in arabic'.tr}: ${contentController.responseMap['name_in_arabic']}', + style: AppStyle + .title, + ), + Text( + '${'Drivers License Class'.tr}: ${contentController.responseMap['class']}', + style: AppStyle + .title, + ), + ], + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + '${'National Number'.tr}: ${contentController.responseMap['id']}', + style: + AppStyle.title, + ), + // Image.memory( + // scanDocumentsByApi + // .imagePortrait, + // width: 60, + // ), + ]), Text( - 'Name :${scanDocumentsByApi.name}', - style: AppStyle.subtitle, + '${'Address'.tr}: ${contentController.responseMap['address']}', + style: AppStyle.title, ), Row( mainAxisAlignment: @@ -92,177 +393,250 @@ class AiPage extends StatelessWidget { .spaceBetween, children: [ Text( - 'Drivers License Class: ${scanDocumentsByApi.licenseClass}', + '${'Date of Birth'.tr}: ${contentController.responseMap['dob']}', style: AppStyle.title, ), - Image.memory( - scanDocumentsByApi - .imageSignature, - width: 100, - height: 30, + Text( + '${'Age'.tr} : ${contentController.responseMap['age_in_years']}', + style: AppStyle.title, + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text( + '${'Expiry Date'.tr}: ${contentController.responseMap['expiration_date']}', + style: DateTime.parse(contentController + .responseMap[ + 'expiration_date'] + .toString()) + .isBefore( + contentController + .now) + ? AppStyle.title.copyWith( + color: AppColor + .redColor) + : AppStyle.title.copyWith( + color: AppColor + .greenColor), ), ], ), ], ), - ], - ), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, + ), + ), + const SizedBox( + height: 10, + ), + DateTime.parse(contentController + .responseMap[ + 'expiration_date'] + .toString()) + .isBefore(contentController.now) + ? Text( + 'You can\'t continue with us .\nYou should renew Driver license' + .tr, + style: AppStyle.title.copyWith( + color: AppColor.redColor), + ) + : MyElevatedButton( + kolor: AppColor.greenColor, + title: + 'Lets check Car license '.tr, + onPressed: () => contentController + .generateCarLicenseJordanContent()), + const SizedBox( + height: 10, + ), + contentController + .responseCarLicenseMap.isNotEmpty + ? Container( + decoration: + AppStyle.boxDecoration, + // height: Get.height * .3, + width: Get.width * .9, + child: Column( children: [ Text( - 'Document Number: ${scanDocumentsByApi.documentNo}', + '${'Name'.tr} ${contentController.responseCarLicenseMap['name']}', style: AppStyle.title, ), - Image.memory( - scanDocumentsByApi - .imagePortrait, - width: 60, + Text( + '${'Address'.tr} ${contentController.responseCarLicenseMap['address']}', + style: AppStyle.title, ), - ]), - Text( - 'Address: ${scanDocumentsByApi.address}', - style: AppStyle.title, - ), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ + Text( + '${'Car Kind'.tr} ${contentController.responseCarLicenseMap['car_kind']}', + style: AppStyle.title, + ), + Text( + '${'Color'.tr} ${contentController.responseCarLicenseMap['car_color']}', + style: AppStyle.title, + ), + Text( + '${'Year'.tr} ${contentController.responseCarLicenseMap['car_year']}', + style: AppStyle.title, + ), + Text( + '${'Car Plate'.tr} ${contentController.responseCarLicenseMap['car_plate']}', + style: AppStyle.title, + ), + Text( + '${'Car Expire'.tr} ${contentController.responseCarLicenseMap['expire_date_of_license']}', + style: contentController + .responseCarLicenseMap + .isNotEmpty + ? DateTime.parse(contentController + .responseCarLicenseMap[ + 'expire_date_of_license'] + .toString()) + .isBefore(contentController + .now) + ? AppStyle.title.copyWith( + color: AppColor + .redColor) + : AppStyle.title.copyWith( + color: AppColor + .greenColor) + : null, + ), + ], + ), + ) + : const SizedBox(), + const SizedBox( + height: 10, + ), + // DateTime.parse(contentController + // .responseCarLicenseMap[ + // 'expire_date_of_license'] + // .toString()) + // .isBefore(contentController.now) + // ? Text( + // 'You can\'t continue with us .\nYou should renew Car license' + // .tr, + // style: AppStyle.title.copyWith( + // color: AppColor.redColor), + // ) + // : + MyElevatedButton( + kolor: AppColor.greenColor, + title: + 'Lets check License Back Face'.tr, + onPressed: () => contentController + .generateBackCarLicenseJordanContent()), + const SizedBox( + height: 10, + ), + contentController + .responseBackCarLicenseMap + .isNotEmpty + ? Container( + decoration: + AppStyle.boxDecoration, + // height: 300, + child: Column(children: [ Text( - 'Height: ${scanDocumentsByApi.height}', - style: AppStyle.subtitle, - ), - Text( - 'Postal Code: ${scanDocumentsByApi.postalCode}', - style: AppStyle.subtitle, - ), - Text( - 'Sex: ${scanDocumentsByApi.sex}', - style: AppStyle.subtitle, - ), - ], - ), - Text( - 'Territorial Code: ${scanDocumentsByApi.stateCode}', - style: AppStyle.subtitle, - ), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Text( - 'Expiry Date: ${scanDocumentsByApi.expireDate}', - style: DateTime.parse( - scanDocumentsByApi - .responseMap['data'] - ['ocr'][ - 'dateOfExpiry'] - .toString()) - .isBefore( - scanDocumentsByApi - .now) - ? AppStyle.title.copyWith( - color: - AppColor.redColor) - : AppStyle.title.copyWith( - color: AppColor - .greenColor), - ), - Text( - 'Date of Birth: ${scanDocumentsByApi.dob}', + 'VIN ${contentController.responseBackCarLicenseMap['vin']}', style: AppStyle.title, ), - ], - ), - ], - ), + Text( + 'Fuel Type ${contentController.responseBackCarLicenseMap['fuelType']}', + style: AppStyle.title, + ), + Text( + 'Insurance Company ${contentController.responseBackCarLicenseMap['insuranceCompany']}', + style: AppStyle.title, + ), + Text( + 'Policy Number ${contentController.responseBackCarLicenseMap['policyNumber']}', + style: AppStyle.title, + ), + Text( + 'Insurance Type ${contentController.responseBackCarLicenseMap['insuranceType']}', + style: AppStyle.title, + ) + ])) + : const SizedBox() + // MyElevatedButton( + // title: 'Detect Your Face '.tr, + // onPressed: () => scanDocumentsByApi + // .checkMatchFaceApi(), + // ), + // scanDocumentsByApi.res.isEmpty + // ? const SizedBox() + // : scanDocumentsByApi.res['data'] + // ['result'] + // .toString() == + // 'Same' + // ? MyElevatedButton( + // onPressed: () async { + // await registerCaptainController + // .register(); + // await registerCaptainController + // .addLisence(); + // // await scanDocumentsByApi + // // .uploadImagePortrate(); + // }, + // title: + // 'Go to next step\nscan Car License.' + // .tr, + // kolor: AppColor.greenColor, + // ) + // : const SizedBox(), + // MyElevatedButton( + // title: 'get sql data', + // kolor: AppColor.yellowColor, + // onPressed: () { + // sql.deleteAllData( + // TableName.faceDetectTimes); + // sql + // .getAllData( + // TableName.faceDetectTimes) + // .then((value) => print( + // value[0]['faceDetectTimes'])); + // }, + // ), + ], + ), ), - ), - DateTime.parse(scanDocumentsByApi - .responseMap['data']['ocr'] - ['dateOfExpiry'] - .toString()) - .isBefore(scanDocumentsByApi.now) - ? Text( - 'You can\'t continue with us .\nYou should renew Driver license', - style: AppStyle.title - .copyWith(color: AppColor.redColor), + ) + : Positioned( + top: Get.height * .06, + left: Get.width * .051, + right: Get.width * .051, + child: scanDocumentsByApi.isLoading + ? Column( + children: [ + const MyCircularProgressIndicator(), + Text( + 'We are process picture please wait '.tr, + style: AppStyle.title, ) - : MyElevatedButton( - title: 'Detect Your Face '.tr, - onPressed: () => scanDocumentsByApi - .checkMatchFaceApi(), + ], + ) + : Column( + children: [ + Container( + decoration: AppStyle.boxDecoration, + height: Get.height * .35, + child: Padding( + padding: const EdgeInsets.all(5), + child: Center( + child: Text( + 'There is no data yet.'.tr, + style: AppStyle.title, + ), + )), ), - scanDocumentsByApi.res.isEmpty - ? const SizedBox() - : scanDocumentsByApi.res['data']['result'] - .toString() == - 'Same' - ? MyElevatedButton( - onPressed: () async { - await registerCaptainController - .register(); - await registerCaptainController - .addLisence(); - // await scanDocumentsByApi - // .uploadImagePortrate(); - }, - title: - 'Go to next step\nscan Car License.' - .tr, - kolor: AppColor.greenColor, - ) - : const SizedBox(), - MyElevatedButton( - title: 'get sql data', - kolor: AppColor.yellowColor, - onPressed: () { - sql.deleteAllData(TableName.faceDetectTimes); - sql - .getAllData(TableName.faceDetectTimes) - .then((value) => - print(value[0]['faceDetectTimes'])); - }, - ) - ], - ), - ) - : Positioned( - top: Get.height * .06, - left: Get.width * .051, - right: Get.width * .051, - child: scanDocumentsByApi.isLoading - ? Column( - children: [ - const MyCircularProgressIndicator(), - Text( - 'We are process picture please wait '.tr, - style: AppStyle.title, - ) - ], - ) - : Column( - children: [ - Container( - decoration: AppStyle.boxDecoration, - height: Get.height * .35, - child: Padding( - padding: const EdgeInsets.all(5), - child: Center( - child: Text( - 'There is no data yet.'.tr, - style: AppStyle.title, - ), - )), - ), - ], - ), - ), - ), + ], + ), + ), + ) ], isleading: true); } diff --git a/lib/views/auth/captin/login_captin.dart b/lib/views/auth/captin/login_captin.dart index 83c841a..780286d 100644 --- a/lib/views/auth/captin/login_captin.dart +++ b/lib/views/auth/captin/login_captin.dart @@ -24,6 +24,7 @@ class LoginCaptin extends StatelessWidget { @override Widget build(BuildContext context) { Get.put(LoginCaptinController()); + return GetBuilder( builder: (controller) => MyScafolld( title: 'Login Captin'.tr, diff --git a/lib/views/auth/captin/register_captin.dart b/lib/views/auth/captin/register_captin.dart index 7349393..800370c 100644 --- a/lib/views/auth/captin/register_captin.dart +++ b/lib/views/auth/captin/register_captin.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:ride/controller/auth/captin/register_captin_controller.dart'; -import 'package:ride/views/auth/captin/car_license_page.dart'; import 'package:ride/views/widgets/elevated_btn.dart'; import 'package:ride/views/widgets/my_scafold.dart'; diff --git a/lib/views/home/Captin/home_captain/home_captin.dart b/lib/views/home/Captin/home_captain/home_captin.dart index 51ea351..03efbb4 100644 --- a/lib/views/home/Captin/home_captain/home_captin.dart +++ b/lib/views/home/Captin/home_captain/home_captin.dart @@ -13,6 +13,7 @@ import '../../../../controller/home/captin/home_captain_controller.dart'; import '../../../../controller/home/captin/order_request_controller.dart'; import '../../../../controller/home/captin/widget/connect.dart'; import '../../../../controller/home/captin/widget/left_menu_map_captain.dart'; +import '../../../../controller/local/local_controller.dart'; import '../../../../main.dart'; import '../../../widgets/circle_container.dart'; @@ -26,6 +27,7 @@ class HomeCaptain extends StatelessWidget { Get.put(OrderRequestController()); Get.put(HomeCaptainController()); // Get.put(HomeCaptainController()); + print('local is ${Get.find().language!.countryCode}'); return Scaffold( appBar: AppBar( backgroundColor: AppColor.greenColor, diff --git a/lib/views/home/Captin/orderCaptin/order_request_page.dart b/lib/views/home/Captin/orderCaptin/order_request_page.dart index ccd4dc8..f8e7350 100644 --- a/lib/views/home/Captin/orderCaptin/order_request_page.dart +++ b/lib/views/home/Captin/orderCaptin/order_request_page.dart @@ -45,7 +45,12 @@ class OrderRequestPage extends StatelessWidget { launchUrl1(mapUrl); }, icon: const Icon(Icons.map), - label: Text('Rouats of Trip'.tr)), + label: myList[20].toString() == 'haveSteps' + ? Text( + 'Trip has Steps'.tr, + style: AppStyle.title, + ) + : Text('Rouats of Trip'.tr, style: AppStyle.title)), myList[13].toString() == 'true' //Visa or Cash Method from notify to driver ? Text( @@ -206,7 +211,13 @@ class OrderRequestPage extends StatelessWidget { 'durationOfRideValue': myList[19].toString(), 'paymentAmount': myList[3].toString(), 'paymentMethod': - myList[13].toString() == 'true' ? 'visa' : 'cash' + myList[13].toString() == 'true' ? 'visa' : 'cash', + 'isHaveSteps': myList[20].toString(), + 'step0': myList[21].toString(), + 'step1': myList[22].toString(), + 'step2': myList[23].toString(), + 'step3': myList[24].toString(), + 'step4': myList[25].toString(), }); }, ), diff --git a/lib/views/home/map_widget.dart/buttom_sheet_map_show.dart b/lib/views/home/map_widget.dart/buttom_sheet_map_show.dart index 19af2eb..c2d75e9 100644 --- a/lib/views/home/map_widget.dart/buttom_sheet_map_show.dart +++ b/lib/views/home/map_widget.dart/buttom_sheet_map_show.dart @@ -71,7 +71,9 @@ GetBuilder buttomSheetMapPage() { MainAxisAlignment.spaceEvenly, children: [ Text( - '${'Your Ride Duration is '.tr}${controller.duration} minutes', + controller.hours > 1 + ? '${'Your Ride Duration is '.tr}${controller.hours} H and ${controller.minutes} m' + : '${'Your Ride Duration is '.tr} ${controller.minutes} m', style: AppStyle.subtitle, ), Text( diff --git a/lib/views/home/map_widget.dart/points_page_for_rider.dart b/lib/views/home/map_widget.dart/points_page_for_rider.dart index 5c24bd3..d1224ce 100644 --- a/lib/views/home/map_widget.dart/points_page_for_rider.dart +++ b/lib/views/home/map_widget.dart/points_page_for_rider.dart @@ -57,18 +57,28 @@ class PointsPageForRider extends StatelessWidget { controller.clearPolyline(); controller.isWayPointStopsSheetUtilGetMap = false; + mapPassengerController.durationToRide = 0; for (var i = 0; i < wayPointController.wayPoints.length; i++) { - mapPassengerController.getMapPoints( - mapPassengerController.placesCoordinate[i] - .toString(), - mapPassengerController - .placesCoordinate[i + 1] - .toString(), - i, - ); + if (mapPassengerController + .placesCoordinate[i + 1] + .toString() != + '') { + mapPassengerController.getMapPoints( + mapPassengerController + .placesCoordinate[i] + .toString(), + mapPassengerController + .placesCoordinate[i + 1] + .toString(), + i, + ); + } } + + controller.bottomSheet(); + controller.showBottomSheet1(); }, child: const Text('Get Map'), ) diff --git a/lib/views/home/map_widget.dart/ride_begin_passenger.dart b/lib/views/home/map_widget.dart/ride_begin_passenger.dart index 204f25f..ecc2e1b 100644 --- a/lib/views/home/map_widget.dart/ride_begin_passenger.dart +++ b/lib/views/home/map_widget.dart/ride_begin_passenger.dart @@ -74,8 +74,9 @@ class RideBeginPassenger extends StatelessWidget { .phone, // Set the keyboard type to phone validator: (value) { if (value!.isEmpty || - value.length < 10) { - return 'Please enter a phone number'; + value.length != 10) { + return 'Please enter a valid phone number' + .tr; } // Add additional validation if needed return null;