From 54e92f4aa30d32963ef9ae79f7e2bd67b43cc9e2 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Tue, 16 Jul 2024 13:39:47 +0300 Subject: [PATCH] 7/16/1 --- android/app/src/main/AndroidManifest.xml | 13 +++ lib/constant/box_name.dart | 1 + lib/controller/firebase/firbase_messge.dart | 16 +-- lib/controller/functions/package_info.dart | 4 + .../home/map_passenger_controller.dart | 2 +- .../home/splash_screen_controlle.dart | 44 ++++++++ .../home/trip_monitor_controller.dart | 15 ++- lib/controller/local/translations.dart | 11 +- lib/main.dart | 25 +++-- lib/splash_screen_page.dart | 15 ++- .../trip_monitor/trip_link_monitor.dart | 105 ++++++++++++++++++ .../HomePage/trip_monitor/trip_monitor.dart | 10 +- lib/views/home/map_page_passenger.dart | 1 + .../map_widget.dart/ride_begin_passenger.dart | 2 +- pubspec.lock | 24 ++++ pubspec.yaml | 1 + 16 files changed, 256 insertions(+), 33 deletions(-) create mode 100644 lib/views/home/HomePage/trip_monitor/trip_link_monitor.dart diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 6932ec6..fedcf91 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,5 @@ + @@ -32,7 +33,19 @@ + + + + + + + + + + + + diff --git a/lib/constant/box_name.dart b/lib/constant/box_name.dart index bf87d51..0927bd1 100644 --- a/lib/constant/box_name.dart +++ b/lib/constant/box_name.dart @@ -8,6 +8,7 @@ class BoxName { static const String gender = "gender"; static const String carType = "carType"; static const String carPlate = "carPlate"; + static const String packagInfo = "packagInfo"; static const String isVerified = '0'; static const String statusDriverLocation = "statusDriverLocation"; static const String password = "password"; diff --git a/lib/controller/firebase/firbase_messge.dart b/lib/controller/firebase/firbase_messge.dart index 9c939bc..f59e990 100644 --- a/lib/controller/firebase/firbase_messge.dart +++ b/lib/controller/firebase/firbase_messge.dart @@ -134,12 +134,12 @@ class FirebaseMessagesController extends GetxController { NotificationController() .showNotification('Promo', 'Show latest promo'.tr, 'promo'); Get.to(const PromosPassengerPage()); - } else if (message.notification!.title! == 'Trip Monitoring') { - NotificationController().showNotification( - 'Trip Monitoring'.tr, 'Show latest promo'.tr, 'iphone_ringtone'); + } else if (message.notification!.title! == 'Trip Monitoring'.tr) { + NotificationController() + .showNotification('Trip Monitoring'.tr, '', 'iphone_ringtone'); var myListString = message.data['passengerList']; var myList = jsonDecode(myListString) as List; - Get.to(const TripMonitor(), arguments: { + Get.toNamed('/tripmonitor', arguments: { 'rideId': myList[0].toString(), 'driverId': myList[1].toString(), }); @@ -214,9 +214,11 @@ class FirebaseMessagesController extends GetxController { onPressed: () { Get.offAll(() => const MapPagePassenger()); })); - } else if (message.notification!.title! == "Trip Monitoring".tr) { - Get.to(() => const TripMonitor()); - } else if (message.notification!.title! == 'Call Income') { + } + // else if (message.notification!.title! == "Trip Monitoring".tr) { + // Get.to(() => const TripMonitor()); + // } + else if (message.notification!.title! == 'Call Income') { try { var myListString = message.data['passengerList']; var driverList = jsonDecode(myListString) as List; diff --git a/lib/controller/functions/package_info.dart b/lib/controller/functions/package_info.dart index 3ea48d7..b8a0c7f 100644 --- a/lib/controller/functions/package_info.dart +++ b/lib/controller/functions/package_info.dart @@ -7,14 +7,18 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../../constant/box_name.dart'; import '../../constant/info.dart'; +import '../../main.dart'; Future checkForUpdate(BuildContext context) async { final packageInfo = await PackageInfo.fromPlatform(); final currentVersion = packageInfo.buildNumber; + final version = packageInfo.version; print('currentVersion is : $currentVersion'); // Fetch the latest version from your server String latestVersion = await getPackageInfo(); + box.write(BoxName.packagInfo, version); if (latestVersion.isNotEmpty && latestVersion != currentVersion) { showUpdateDialog(context); diff --git a/lib/controller/home/map_passenger_controller.dart b/lib/controller/home/map_passenger_controller.dart index 6312202..415b8c1 100644 --- a/lib/controller/home/map_passenger_controller.dart +++ b/lib/controller/home/map_passenger_controller.dart @@ -1431,7 +1431,7 @@ class MapPassengerController extends GetxController { var res = await CRUD().getTokenParent( link: AppLink.getTokenParent, - payload: {'phone': '+2' + box.read(BoxName.sosPhonePassenger)}); + payload: {'phone': '+2${box.read(BoxName.sosPhonePassenger)}'}); // Check if `res` is already a map if (res is Map) { diff --git a/lib/controller/home/splash_screen_controlle.dart b/lib/controller/home/splash_screen_controlle.dart index 56f260e..4814a08 100644 --- a/lib/controller/home/splash_screen_controlle.dart +++ b/lib/controller/home/splash_screen_controlle.dart @@ -1,9 +1,11 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:get/get.dart'; import 'package:SEFER/views/auth/login_page.dart'; import 'package:package_info_plus/package_info_plus.dart'; +import 'package:uni_links/uni_links.dart'; import '../../constant/box_name.dart'; import '../../main.dart'; @@ -29,10 +31,52 @@ class SplashScreenController extends GetxController update(); } + StreamSubscription? _sub; + Future initUniLinks() async { + // Handle initial URI if the app was launched from a link + try { + final initialUri = await getInitialUri(); + if (initialUri != null) { + handleLink(initialUri); + } + } on PlatformException { + // Handle exception by warning the user their action did not succeed + print("Failed to get initial uri"); + } + + // Listen to new links while the app is running + _sub = uriLinkStream.listen((Uri? uri) { + if (uri != null) { + handleLink(uri); + } + }, onError: (Object err) { + print('Error occurred: $err'); + }); + } + + void handleLink(Uri uri) { + if (uri.host == 'sefer.live' && uri.path == '/tripmonitor') { + final rideId = uri.queryParameters['rideId']; + final driverId = uri.queryParameters['driverId']; + + if (rideId != null && driverId != null) { + Get.toNamed('/tripmonitor', parameters: { + 'rideId': rideId, + 'driverId': driverId, + }); + } else { + // Handle the case where rideId or driverId is null + print('Invalid parameters in the deep link'); + // You might want to show an error message to the user or handle this case differently + } + } + } + @override void onInit() async { super.onInit(); checkForUpdate(); + initUniLinks(); animationController = AnimationController( vsync: this, duration: const Duration(seconds: 4), diff --git a/lib/controller/home/trip_monitor_controller.dart b/lib/controller/home/trip_monitor_controller.dart index d593157..40be11e 100644 --- a/lib/controller/home/trip_monitor_controller.dart +++ b/lib/controller/home/trip_monitor_controller.dart @@ -51,11 +51,18 @@ class TripMonitorController extends GetxController { }); } - init() async { - final arguments = Get.arguments; - driverId = arguments['driverId']; - rideId = arguments['rideId']; + // init() async { + // final arguments = Get.arguments; + // driverId = arguments['driverId']; + // rideId = arguments['rideId']; + // await getLocationParent(); + // } + + Future init({String? rideId, String? driverId}) async { + this.driverId = driverId!; + this.rideId = rideId!; await getLocationParent(); + update(); } void addCustomCarIcon() { diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index b31a005..7064754 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -58,8 +58,7 @@ class MyTranslation extends Translations { "You can only use one device at a time. This device will now be set as your active device.": "يمكنك استخدام جهاز واحد في المرة الواحدة. سيتم الآن تعيين هذا الجهاز كجهازك النشط.", "Click here point": "انقر هنا", // Click here (literal translation) - "Pick or Tap to confirm": - "اختر أو اضغط للتأكيد", // Choose or Tap to confirm + "Are you want to change": "هل تريد التغيير؟", 'by': 'ب', "Enter your complaint here": "أدخل شكواك هنا", @@ -259,7 +258,7 @@ iOS [https://getapp.cc/app/6458734951] "Enter your phone number": "أدخل رقم هاتفك", "Please enter your phone number.": "يرجى إدخال رقم هاتفك.", "Please enter Your Password.": "يرجى إدخال كلمة المرور.", - "Submit": "إرسال", + "if you dont have account": "إذا لم يكن لديك حساب", "Register": "تسجيل", "Accept Ride's Terms & Review Privacy Notice": @@ -321,7 +320,7 @@ iOS [https://getapp.cc/app/6458734951] "Favorite Places": "الأَمَاكِن المُفَضَّلَة", "From : Current Location": "مِنْ: المَوْقِع الحَالِي", "Where to": "إِلَى أَيْن", - "Notifications": "الإشْعَارَات", + // "Notifications": "الإشْعَارَات", "Profile": "الملف الشَّخْصِي", "Home": "الصَّفْحَة الرَّئِيسِيَّة", "My Cared": "المُهْتَمَّ بِهِ", @@ -401,12 +400,12 @@ iOS [https://getapp.cc/app/6458734951] "Delete My Account": "حَذْف حِسَابِي", "Edit Profile": "تَعْدِيل الْمِلَف الشَّخْصِي", "Name": "الاسْم", - "Gender": "الْجِنْس", + // "Gender": "الْجِنْس", "Update Gender": "تَحْدِيث الْجِنْس", "Education": "التَّعْلِيم", "Update Education": "تَحْدِيث التَّعْلِيم", "Employment Type": "نَوْع التَّوْظِيف", - "Marital Status": "الْحَالَة الاجْتِمَاعِيَّة", + // "Marital Status": "الْحَالَة الاجْتِمَاعِيَّة", "SOS Phone": "هَاتِف الطَّوَارِئ", "High School Diploma": "شَهَادَة الثَّانَوِيَّة الْعَامَّة", "Associate Degree": "دَرَجَة الزَّمَالَة", diff --git a/lib/main.dart b/lib/main.dart index 1633d9b..1b474b7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -21,6 +21,7 @@ import 'controller/payment/paymob/paymob_wallet.dart'; import 'firebase_options.dart'; import 'models/db_sql.dart'; import 'splash_screen_page.dart'; +import 'views/home/HomePage/trip_monitor/trip_monitor.dart'; final box = GetStorage(); const storage = FlutterSecureStorage(); @@ -104,14 +105,20 @@ class MyApp extends StatelessWidget { LocaleController localController = Get.put(LocaleController()); return GetMaterialApp( - title: AppInformation.appName, - translations: MyTranslation(), - debugShowCheckedModeBanner: false, - locale: localController.language, - theme: localController.appTheme, - key: UniqueKey(), - // routes: {'/':const HomePage()}, - // home: LoginCaptin()); - home: SplashScreen()); + title: AppInformation.appName, + translations: MyTranslation(), + debugShowCheckedModeBanner: false, + locale: localController.language, + theme: localController.appTheme, + key: UniqueKey(), + // routes: {'/':const HomePage()}, + // home: LoginCaptin()); + initialRoute: '/', + getPages: [ + GetPage(name: '/', page: () => SplashScreen()), + GetPage(name: '/tripmonitor', page: () => const TripMonitor()), + ], + // home: SplashScreen() + ); } } diff --git a/lib/splash_screen_page.dart b/lib/splash_screen_page.dart index 11d760f..9ebc97d 100644 --- a/lib/splash_screen_page.dart +++ b/lib/splash_screen_page.dart @@ -5,7 +5,9 @@ import 'package:SEFER/constant/colors.dart'; import 'package:SEFER/constant/info.dart'; import 'package:SEFER/constant/style.dart'; +import 'constant/box_name.dart'; import 'controller/home/splash_screen_controlle.dart'; +import 'main.dart'; class SplashScreen extends StatelessWidget { final SplashScreenController splashScreenController = @@ -63,13 +65,18 @@ class SplashScreen extends StatelessWidget { const SizedBox( height: 100, ), - Text( - splashScreenController.version.toString(), - style: AppStyle.title, - ), ], ), ), + bottomNavigationBar: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + box.read(BoxName.packagInfo) ?? '1.4.54', + style: AppStyle.subtitle, + ), + ], + ), ); } } diff --git a/lib/views/home/HomePage/trip_monitor/trip_link_monitor.dart b/lib/views/home/HomePage/trip_monitor/trip_link_monitor.dart new file mode 100644 index 0000000..d458f6d --- /dev/null +++ b/lib/views/home/HomePage/trip_monitor/trip_link_monitor.dart @@ -0,0 +1,105 @@ +import 'dart:io'; + +import 'package:SEFER/controller/home/trip_monitor_controller.dart'; +import 'package:SEFER/views/widgets/my_scafold.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:get/get.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:vibration/vibration.dart'; + +import '../../../../constant/colors.dart'; +import '../../../../constant/style.dart'; +import '../../../widgets/elevated_btn.dart'; + +class TripMonitor extends StatelessWidget { + const TripMonitor({super.key}); + + @override + Widget build(BuildContext context) { + final params = Get.parameters; + // Use params to initialize your controller or pass data + Get.put(TripMonitorController()).init(); + return GetBuilder(builder: (tripMonitorController) { + return MyScafolld( + title: 'Trip Monitor'.tr, + body: [ + GoogleMap( + onMapCreated: tripMonitorController.onMapCreated, + initialCameraPosition: CameraPosition( + // bearing: 45, + target: tripMonitorController.parentLocation, + zoom: 16, + tilt: 40, + ), + // onCameraMove: (position) {}, + markers: { + Marker( + markerId: MarkerId('start'.tr), + position: tripMonitorController.parentLocation, + draggable: true, + icon: tripMonitorController.tripData['message'][0]['model'] + .contains('دراجة') + ? tripMonitorController.motoIcon + : tripMonitorController.tripData['message'][0]['model'] + ['gender'] == + 'Male' + ? tripMonitorController.carIcon + : tripMonitorController.ladyIcon, + rotation: tripMonitorController.rotation, + ), + }, + ), + speedCircle() + ], + isleading: true, + ); + }); + } +} + +GetBuilder speedCircle() { + if (Get.find().speed > 100) { + if (Platform.isIOS) { + HapticFeedback.selectionClick(); + } else { + Vibration.vibrate(duration: 1000); + } + Get.defaultDialog( + barrierDismissible: false, + titleStyle: AppStyle.title, + title: 'Speed Over'.tr, + middleText: 'Please slow down'.tr, + middleTextStyle: AppStyle.title, + confirm: MyElevatedButton( + title: 'I will slow down'.tr, + onPressed: () => Get.back(), + ), + ); + } + return GetBuilder( + builder: (tripMonitorController) { + return Positioned( + bottom: 25, + right: 100, + child: Container( + decoration: BoxDecoration( + shape: BoxShape.circle, + color: tripMonitorController.speed > 100 + ? Colors.red + : AppColor.secondaryColor, + border: Border.all(width: 3, color: AppColor.redColor), + ), + height: 60, + width: 60, + child: Center( + child: Text( + tripMonitorController.speed.toStringAsFixed(0), + style: AppStyle.number, + ), + ), + ), + ); + }, + ); +} diff --git a/lib/views/home/HomePage/trip_monitor/trip_monitor.dart b/lib/views/home/HomePage/trip_monitor/trip_monitor.dart index a2afcf6..861fae2 100644 --- a/lib/views/home/HomePage/trip_monitor/trip_monitor.dart +++ b/lib/views/home/HomePage/trip_monitor/trip_monitor.dart @@ -17,7 +17,15 @@ class TripMonitor extends StatelessWidget { @override Widget build(BuildContext context) { - Get.put(TripMonitorController()).init(); + final params = Get.parameters; + final arguments = Get.arguments as Map?; + + // Use params or arguments to initialize your controller + final controller = Get.put(TripMonitorController()); + controller.init( + rideId: params['rideId'] ?? arguments?['rideId'], + driverId: params['driverId'] ?? arguments?['driverId'], + ); return GetBuilder(builder: (tripMonitorController) { return MyScafolld( title: 'Trip Monitor'.tr, diff --git a/lib/views/home/map_page_passenger.dart b/lib/views/home/map_page_passenger.dart index e36d2ab..29d8a81 100644 --- a/lib/views/home/map_page_passenger.dart +++ b/lib/views/home/map_page_passenger.dart @@ -34,6 +34,7 @@ class MapPagePassenger extends StatelessWidget { WidgetsBinding.instance.addPostFrameCallback((_) { checkForUpdate(context); }); + return Scaffold( body: SafeArea( child: Stack( 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 4759cfb..984c2a7 100644 --- a/lib/views/home/map_widget.dart/ride_begin_passenger.dart +++ b/lib/views/home/map_widget.dart/ride_begin_passenger.dart @@ -297,7 +297,7 @@ class RideBeginPassenger extends StatelessWidget { await controller.getTokenForParent(); }, icon: const Icon( - Foundation.record, + Foundation.video, color: AppColor.blueColor, ), ), diff --git a/pubspec.lock b/pubspec.lock index b645100..9452209 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1717,6 +1717,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + uni_links: + dependency: "direct main" + description: + name: uni_links + sha256: "051098acfc9e26a9fde03b487bef5d3d228ca8f67693480c6f33fd4fbb8e2b6e" + url: "https://pub.dev" + source: hosted + version: "0.5.1" + uni_links_platform_interface: + dependency: transitive + description: + name: uni_links_platform_interface + sha256: "929cf1a71b59e3b7c2d8a2605a9cf7e0b125b13bc858e55083d88c62722d4507" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + uni_links_web: + dependency: transitive + description: + name: uni_links_web + sha256: "7539db908e25f67de2438e33cc1020b30ab94e66720b5677ba6763b25f6394df" + url: "https://pub.dev" + source: hosted + version: "0.1.0" url_launcher: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index a413f35..49e78dc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -57,6 +57,7 @@ dependencies: sign_in_with_apple: ^6.1.0 firebase_auth: ^4.19.6 package_info_plus: ^8.0.0 + uni_links: ^0.5.1 dev_dependencies: flutter_test: