From 9854f80971cfa5d8c1876b71ffa9ae88ab0e8ba0 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Fri, 11 Oct 2024 08:43:49 +0300 Subject: [PATCH] 10/11/1 --- android/app/build.gradle | 4 +- ios/Runner/Info.plist | 6 +- lib/constant/box_name.dart | 3 +- lib/constant/info.dart | 2 +- lib/constant/links.dart | 2 + .../auth/captin/login_captin_controller.dart | 37 +- lib/controller/local/translations.dart | 5 + .../auth/captin/invite_driver_screen.dart | 14 +- lib/views/auth/captin/login_captin.dart | 320 +++++++++++++----- 9 files changed, 295 insertions(+), 98 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index ef50745..ec342a6 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -54,8 +54,8 @@ android { // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdk = 23 targetSdk = flutter.targetSdkVersion - versionCode = 107 - versionName = '1.5.07' + versionCode = 108 + versionName = '1.5.08' multiDexEnabled =true } diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 597f364..ea458d1 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -2,6 +2,8 @@ + LSMinimumSystemVersion + 12.0 UIBackgroundModes fetch @@ -33,7 +35,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 66 + 67 CFBundleSignature ???? CFBundleURLTypes @@ -48,7 +50,7 @@ CFBundleVersion - 4.0.66 + 4.0.67 FirebaseAppDelegateProxyEnabled NO GMSApiKey diff --git a/lib/constant/box_name.dart b/lib/constant/box_name.dart index 3b70247..83a2bed 100644 --- a/lib/constant/box_name.dart +++ b/lib/constant/box_name.dart @@ -10,7 +10,8 @@ class BoxName { static const String bodyOrder = "bodyOrder"; static const String gender = "gender"; static const String phoneWallet = "phoneWallet"; - static const String IsSavedPhones = "IsSavedPhones"; + static const String isSavedPhones = "IsSavedPhones"; + static const String isTest = "isTest"; static const String carType = "carType"; static const String carTypeOfDriver = "carTypeOfDriver"; static const String isFirstTime = "isFirstTime"; diff --git a/lib/constant/info.dart b/lib/constant/info.dart index 0f4b47e..d99f0e7 100644 --- a/lib/constant/info.dart +++ b/lib/constant/info.dart @@ -1,6 +1,6 @@ class AppInformation { static const String companyName = 'SEFER LLC'; - static const String appName = 'SEFER'; + static const String appName = 'SEFER DRIVER'; static const String appVersion = 'SEFER Captain'; static const String phoneNumber = '962798583052'; static const String linkedInProfile = diff --git a/lib/constant/links.dart b/lib/constant/links.dart index b20b1e4..8cc7fb8 100644 --- a/lib/constant/links.dart +++ b/lib/constant/links.dart @@ -148,6 +148,8 @@ class AppLink { static String deleteApiKey = "$ride/apiKey/delete.php"; static String checkPhoneNumberISVerfiedDriver = "$auth/checkPhoneNumberISVerfiedDriver.php"; + static String getTesterApp = "$auth/Tester/getTesterApp.php"; + static String updateTesterApp = "$auth/Tester/updateTesterApp.php"; //-----------------healthInsuranceProvider------------------ static String addHealthInsuranceProvider = "$server/driver_assurance/add.php"; diff --git a/lib/controller/auth/captin/login_captin_controller.dart b/lib/controller/auth/captin/login_captin_controller.dart index 1a08bc4..468b323 100644 --- a/lib/controller/auth/captin/login_captin_controller.dart +++ b/lib/controller/auth/captin/login_captin_controller.dart @@ -16,6 +16,7 @@ import 'package:SEFER/main.dart'; import 'package:SEFER/views/home/Captin/home_captain/home_captin.dart'; import 'package:location/location.dart'; +import '../../../constant/info.dart'; import '../../../views/auth/captin/cards/egypt_card_a_i.dart'; import '../../firebase/firbase_messge.dart'; @@ -26,6 +27,7 @@ class LoginDriverController extends GetxController { TextEditingController passwordController = TextEditingController(); bool isAgreeTerms = false; bool isloading = false; + late int isTest = 1; final FlutterSecureStorage _storage = const FlutterSecureStorage(); final location = Location(); void changeAgreeTerm() { @@ -33,6 +35,35 @@ class LoginDriverController extends GetxController { update(); } + @override + void onInit() async { + box.read(BoxName.isTest) == null || + box.read(BoxName.isTest).toString() == '0' + ? await getAppTester() + : null; + + super.onInit(); + } + + getAppTester() async { + var res = await CRUD().get( + link: AppLink.getTesterApp, + payload: {'appPlatform': AppInformation.appName}); + if (res != 'failure') { + var d = jsonDecode(res); + + isTest = d['message'][0]['isTest']; + update(); + } else { + return false; + } + } + + updateAppTester(String appPlatform) async { + await CRUD().post( + link: AppLink.updateTesterApp, payload: {'appPlatform': appPlatform}); + } + void saveAgreementTerms() { box.write(BoxName.agreeTerms, 'agreed'); update(); @@ -75,6 +106,8 @@ class LoginDriverController extends GetxController { if (jsonDecoeded['status'] == 'success' && jsonDecoeded['data'][0]['is_verified'].toString() == '1') { box.write(BoxName.emailDriver, jsonDecoeded['data'][0]['email']); + box.write(BoxName.driverID, jsonDecoeded['data'][0]['id']); + box.write(BoxName.isTest, '1'); box.write(BoxName.gender, jsonDecoeded['data'][0]['gender']); box.write(BoxName.phoneVerified, jsonDecoeded['data'][0]['is_verified'].toString()); @@ -110,9 +143,7 @@ class LoginDriverController extends GetxController { 2002) { box.write(BoxName.carTypeOfDriver, 'Awfar Car'); } - - Log.print( - ' box.write(BoxName.carTypeOfDriver: ${box.read(BoxName.carTypeOfDriver)}'); + updateAppTester(AppInformation.appName); var token = await CRUD().get( link: AppLink.getDriverToken, diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index 5df57a0..9d6812a 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -178,6 +178,11 @@ class MyTranslation extends Translations { "Enter phone": "أدخل رقم الهاتف", "Send Invite": "إرسال دعوة", "Show Invitations": "عرض الدعوات", + 'We need access to your location to match you with nearby passengers and ensure accurate navigation.': + 'نحتاج إلى الوصول إلى موقعك لمطابقتك مع الركاب القريبين وضمان التنقل الدقيق.', + + 'Please allow location access at all times to receive ride requests and ensure smooth service.': + 'يرجى السماح بالوصول إلى الموقع في جميع الأوقات لتلقي طلبات الرحلات وضمان خدمة سلسة.', "No invitation found yet!": "لم يتم العثور على دعوات حتى الآن!", "Trip": "رحلة", "Your Passenger Referral Code": "رمز الإحالة الخاص بالراكب", diff --git a/lib/views/auth/captin/invite_driver_screen.dart b/lib/views/auth/captin/invite_driver_screen.dart index e108713..5ebbe63 100644 --- a/lib/views/auth/captin/invite_driver_screen.dart +++ b/lib/views/auth/captin/invite_driver_screen.dart @@ -42,15 +42,13 @@ class InviteScreen extends StatelessWidget { ), child: SegmentedButton( style: ButtonStyle( - backgroundColor: - MaterialStateProperty.resolveWith( - (states) => states.contains(MaterialState.selected) + backgroundColor: WidgetStateProperty.resolveWith( + (states) => states.contains(WidgetState.selected) ? CupertinoColors.white : Colors.transparent, ), - foregroundColor: - MaterialStateProperty.resolveWith( - (states) => states.contains(MaterialState.selected) + foregroundColor: WidgetStateProperty.resolveWith( + (states) => states.contains(WidgetState.selected) ? AppColor.blueColor : CupertinoColors.label, ), @@ -175,9 +173,9 @@ class InviteScreen extends StatelessWidget { onPressed: () async { await controller.pickContacts(); if (controller.contacts.isNotEmpty) { - if (box.read(BoxName.IsSavedPhones) == null) { + if (box.read(BoxName.isSavedPhones) == null) { controller.savePhoneToServer(); - box.write(BoxName.IsSavedPhones, true); + box.write(BoxName.isSavedPhones, true); } _showContactsDialog(Get.context!); } diff --git a/lib/views/auth/captin/login_captin.dart b/lib/views/auth/captin/login_captin.dart index f0be904..17bb897 100644 --- a/lib/views/auth/captin/login_captin.dart +++ b/lib/views/auth/captin/login_captin.dart @@ -5,6 +5,7 @@ import 'package:SEFER/views/auth/captin/contact_us_page.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_font_icons/flutter_font_icons.dart'; import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:get/get.dart'; import 'package:permission_handler/permission_handler.dart'; @@ -21,6 +22,7 @@ import '../../../controller/functions/overlay_permisssion.dart'; import '../../../main.dart'; import '../../widgets/elevated_btn.dart'; import '../../widgets/my_scafold.dart'; +import '../../widgets/mycircular.dart'; import '../country_widget.dart'; class LoginCaptin extends StatelessWidget { @@ -196,40 +198,202 @@ class LoginCaptin extends StatelessWidget { width: Get.width * .3, fit: BoxFit.fill, ), - Container( - decoration: AppStyle.boxDecoration1, - height: Get.height * .3, - width: Get.width * .8, - child: Center( - child: Text( - 'Sign in with Google for easier email and name entry' - .tr, - textAlign: TextAlign.center, - style: AppStyle.title, + Platform.isIOS && controller.isTest == 0 + ? Container( + decoration: AppStyle.boxDecoration, + child: Column( + children: [ + Form( + key: controller.formKey, + child: Padding( + padding: const EdgeInsets.all(16.0), + child: SingleChildScrollView( + child: Column( + children: [ + TextFormField( + keyboardType: TextInputType + .emailAddress, + controller: controller + .emailController, + decoration: InputDecoration( + focusedBorder: + OutlineInputBorder( + borderSide: + const BorderSide( + color: AppColor + .primaryColor, + width: 2.0, + ), + borderRadius: + BorderRadius + .circular(10), + ), + fillColor: + AppColor.accentColor, + hoverColor: + AppColor.accentColor, + focusColor: + AppColor.accentColor, + border: const OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius + .circular( + 12))), + labelText: 'Email'.tr, + hintText: + 'Enter your email address' + .tr, + ), + validator: (value) { + if (value!.isEmpty || + (!value.contains( + '@') || + !value.contains( + '.'))) { + return 'Please enter Your Email.' + .tr; + } + return null; + }, + ), + const SizedBox( + height: 15, + ), + TextFormField( + obscureText: true, + keyboardType: TextInputType + .emailAddress, + controller: controller + .passwordController, + decoration: InputDecoration( + focusedBorder: + OutlineInputBorder( + borderSide: + const BorderSide( + color: AppColor + .primaryColor, + width: 2.0, + ), + borderRadius: + BorderRadius + .circular(10), + ), + fillColor: + AppColor.accentColor, + hoverColor: + AppColor.accentColor, + focusColor: + AppColor.accentColor, + border: const OutlineInputBorder( + borderRadius: + BorderRadius.all( + Radius + .circular( + 12))), + labelText: 'Password'.tr, + hintText: + 'Please enter your phone number.' + .tr, + ), + validator: (value) { + if (value!.isEmpty) { + return 'Please enter Your Password.' + .tr; + } + if (value.length < 6) { + return 'Password must br at least 6 character.' + .tr; + } + return null; + }, + ), + GetBuilder< + LoginDriverController>( + builder: (controller) => + controller.isloading + ? const MyCircularProgressIndicator() + : MyElevatedButton( + onPressed: + () async { + if (controller + .formKey + .currentState! + .validate()) { + await Get.find< + LoginDriverController>() + .loginUsingCredentials( + controller + .passwordController + .text, + controller + .emailController + .text, + ); + } + }, + title: + 'Submit'.tr, + ), + ) + ], + ), + ), + ), + ), + const SizedBox( + height: 10, + ), + ], + ), + ) + : Container( + decoration: AppStyle.boxDecoration1, + height: Get.height * .3, + width: Get.width * .8, + child: Center( + child: Text( + 'Sign in with Google for easier email and name entry' + .tr, + textAlign: TextAlign.center, + style: AppStyle.title, + ), + ), + ), + GestureDetector( + onTap: () async { + await GoogleSignInHelper().signInFromLogin(); + }, + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 16, vertical: 10), + decoration: BoxDecoration( + color: AppColor.redColor, + borderRadius: BorderRadius.circular(8), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon( + FontAwesome.google, + color: AppColor.blueColor, + ), + const SizedBox(width: 8), + Text( + 'Sign In by Google'.tr, + style: const TextStyle( + color: Colors.white, + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + ], ), ), ), - MyElevatedButton( - title: 'Sign In by Google'.tr, - onPressed: () async { - await GoogleSignInHelper().signInFromLogin(); - }, - kolor: AppColor.redColor, - ), - // Platform.isAndroid - // ? MyElevatedButton( - // title: 'Sign In by Facebook'.tr, - // onPressed: () async { - // await FacebookSignIn() - // .signInWithFacebook(); - // }, - // kolor: AppColor.blueColor, - // ) - // : const SizedBox(), !Platform.isAndroid - ? MyElevatedButton( - title: 'Sign In by Apple'.tr, - onPressed: () async { + ? GestureDetector( + onTap: () async { User? user = await authController .signInWithApple(); if (user != null) { @@ -246,19 +410,38 @@ class LoginCaptin extends StatelessWidget { // Navigate to another screen or perform other actions } else {} }, - kolor: AppColor.primaryColor, + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 16, vertical: 10), + decoration: BoxDecoration( + color: Colors.black, + borderRadius: BorderRadius.circular(8), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon( + Icons.apple, + color: Colors.white, + size: 24, + ), + const SizedBox(width: 8), + Text( + 'Sign in with Apple'.tr, + style: const TextStyle( + color: Colors.white, + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), ) : const SizedBox(), - // MyElevatedButton( - // title: 'Sign In by Google'.tr, - // onPressed: () async { - // }, - // kolor: AppColor.redColor, - // ), ], ), ))), - GestureDetector( onTap: () => Get.to(() => ContactUsPage()), child: Text( @@ -267,40 +450,6 @@ class LoginCaptin extends StatelessWidget { style: AppStyle.subtitle, ), ), - // AnimatedTextKit( - // onTap: () => Get.to(() => const RegisterCaptin()), - // animatedTexts: [ - // TypewriterAnimatedText( - // 'Register as Driver'.tr, - // textStyle: AppStyle.headTitle2, - // speed: const Duration(milliseconds: 200), - // ), - // ], - // totalRepeatCount: 4, - // pause: const Duration(milliseconds: 200), - // displayFullTextOnTap: true, - // stopPauseOnTap: true, - // ), - // // IconButton( - // onPressed: () async { - // AC credentials = AC(); - // String apiKey = AK.payMobApikey; - // String convertedStringN = credentials.c( - // credentials.c(credentials.c(apiKey, cs), cC), cn); - // - // String retrievedStringS = credentials.r( - // credentials.r( - // credentials.r(convertedStringN, cn), cC), - // cs); - // // - // if (retrievedStringS == apiKey) { - // } - // }, - // icon: const Icon( - // Icons.close, - // color: AppColor.blueColor, - // ), - // ), ], ), ) @@ -414,13 +563,13 @@ class LoginCaptin extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Text( - 'We use location to get accurate and nearest passengers for you' + 'We need access to your location to match you with nearby passengers and ensure accurate navigation.' .tr, textAlign: TextAlign.center, style: AppStyle.title, ), Text( - 'You will choose allow all the time to be ready receive orders' + 'Please allow location access at all times to receive ride requests and ensure smooth service.' .tr, textAlign: TextAlign.center, style: AppStyle.title.copyWith(color: AppColor.greenColor), @@ -428,22 +577,31 @@ class LoginCaptin extends StatelessWidget { MyElevatedButton( title: "Allow Location Access".tr, onPressed: () async { - // await Get.put(LocationBackgroundController()); ////// + // Request location permissions PermissionStatus status = await Permission.location.status; + if (!status.isGranted) { - // WidgetsBinding.instance.addPostFrameCallback((_) { - // getPermissionLocation(); - // getPermissionLocation(); - getLocationPermission(); - // }); + getLocationPermission(); // Function to request permission return; } + + // Save permission status to local storage box.write(BoxName.locationPermission, 'true'); controller.update(); }, kolor: AppColor.greenColor, - ) + ), + TextButton( + onPressed: () { + // Optionally, navigate to app settings for manual permission control + openAppSettings(); + }, + child: Text( + "Open Settings".tr, + style: const TextStyle(color: AppColor.blueColor), + ), + ), ], ), ),