From 775186642865b5719aad094b69d0374762010982 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Tue, 24 Dec 2024 17:55:20 +0300 Subject: [PATCH] hom --- lib/controller/firebase/firbase_messge.dart | 20 ++- lib/controller/functions/upload_image.dart | 2 +- .../home/splash_screen_controlle.dart | 155 +++++++++++++----- lib/controller/local/translations.dart | 3 +- lib/controller/rate/rate_conroller.dart | 9 +- lib/splash_screen_page.dart | 152 ++++++++++------- .../auth/captin/cards/egypt_card_a_i.dart | 21 ++- .../Captin/home_captain/drawer_captain.dart | 2 +- .../home/Captin/home_captain/home_captin.dart | 87 +++++----- 9 files changed, 280 insertions(+), 171 deletions(-) diff --git a/lib/controller/firebase/firbase_messge.dart b/lib/controller/firebase/firbase_messge.dart index c77cd83..c752a1e 100644 --- a/lib/controller/firebase/firbase_messge.dart +++ b/lib/controller/firebase/firbase_messge.dart @@ -195,15 +195,17 @@ class FirebaseMessagesController extends GetxController { // Handle the result here, e.g., show a dialog or update the UI var result = jsonDecode(result0); MyDialogContent().getDialog( - 'Face Detection Result'.tr, - Text( - result['similar'].toString() == 'true' - ? 'similar'.tr - : 'not similar'.tr, - style: AppStyle.title, - ), () { - Get.back(); - }); + 'Face Detection Result'.tr, + Text( + result['similar'].toString() == 'true' + ? 'similar'.tr + : 'not similar'.tr, + style: AppStyle.title, + ), + () { + Get.back(); + }, + ); update(); } else if (message.notification!.title! == 'Hi ,I will go now') { diff --git a/lib/controller/functions/upload_image.dart b/lib/controller/functions/upload_image.dart index 538d3c4..19b3cd1 100644 --- a/lib/controller/functions/upload_image.dart +++ b/lib/controller/functions/upload_image.dart @@ -306,7 +306,7 @@ class ImageController extends GetxController { 'POST', Uri.parse(link), ); - + Log.print('request: ${request}'); var length = await file.length(); var stream = http.ByteStream(file.openRead()); var multipartFile = http.MultipartFile( diff --git a/lib/controller/home/splash_screen_controlle.dart b/lib/controller/home/splash_screen_controlle.dart index 8bf8ebe..11e5866 100644 --- a/lib/controller/home/splash_screen_controlle.dart +++ b/lib/controller/home/splash_screen_controlle.dart @@ -10,73 +10,140 @@ import '../../constant/box_name.dart'; import '../../main.dart'; import '../../views/auth/captin/login_captin.dart'; +// class SplashScreenController extends GetxController +// with GetTickerProviderStateMixin { +// late AnimationController _animationController; +// late Animation animation; + +// String packageInfo = ''; + +// Future _getPackageInfo() async { +// final info = await PackageInfo.fromPlatform(); +// packageInfo = info.version; +// box.write(BoxName.packagInfo, packageInfo); +// update(); +// } + +// @override +// void onInit() { +// super.onInit(); +// _getPackageInfo(); +// _animationController = AnimationController( +// vsync: this, +// duration: const Duration(milliseconds: 1500), // Reduced duration +// )..forward(); + +// animation = +// CurvedAnimation(parent: _animationController, curve: Curves.easeOut); + +// startTimer(); +// } + +// void startTimer() async { +// debugPrint('onBoarding: ${box.read(BoxName.onBoarding)}'); +// debugPrint('emailDriver: ${box.read(BoxName.emailDriver)}'); +// debugPrint('phoneDriver: ${box.read(BoxName.phoneDriver)}'); +// debugPrint('phoneVerified: ${box.read(BoxName.phoneVerified)}'); +// Timer(const Duration(seconds: 5), () async { +// // Reduced timer duration +// box.read(BoxName.onBoarding) == null +// ? Get.off(() => OnBoardingPage()) +// : box.read(BoxName.emailDriver) != null && +// box.read(BoxName.phoneDriver) != null && +// box.read(BoxName.phoneVerified) == '1' +// ? await Get.put(LoginDriverController()) +// .loginWithGoogleCredential( +// box.read(BoxName.driverID).toString(), +// box.read(BoxName.emailDriver)) +// : Get.off(() => LoginCaptin()); +// }); +// } + +// @override +// void onClose() { +// _animationController.dispose(); +// super.onClose(); +// } +// } class SplashScreenController extends GetxController - with SingleGetTickerProviderMixin { - late AnimationController animationController; - late Animation zoomInAnimation; - late Animation zoomOutAnimation; + with GetTickerProviderStateMixin { + late AnimationController _animationController; + late Animation animation; + final progress = 0.0.obs; + Timer? _progressTimer; String packageInfo = ''; - Future checkForUpdate() async { - final packageInfo = await PackageInfo.fromPlatform(); - final currentVersion = packageInfo.buildNumber; - final version1 = packageInfo.version; - print('currentVersion is : $currentVersion'); - // Fetch the latest version from your server - + Future _getPackageInfo() async { + final info = await PackageInfo.fromPlatform(); + packageInfo = info.version; + box.write(BoxName.packagInfo, packageInfo); update(); } @override void onInit() { super.onInit(); - checkForUpdate(); - animationController = AnimationController( + _getPackageInfo(); + _animationController = AnimationController( vsync: this, - duration: const Duration(seconds: 4), - ); + duration: const Duration(milliseconds: 1500), // Reduced duration + )..forward(); - zoomInAnimation = Tween(begin: 1.0, end: 1.5).animate( - CurvedAnimation( - parent: animationController, - curve: Curves.easeInOut, - ), - ); + animation = + CurvedAnimation(parent: _animationController, curve: Curves.easeOut); - zoomOutAnimation = Tween(begin: 1.5, end: 1.0).animate( - CurvedAnimation( - parent: animationController, - curve: Curves.easeInOut, - ), - ); - - animationController.repeat(reverse: true); startTimer(); + _startProgressTimer(); + } + + void _startProgressTimer() { + const totalTime = 3000; // 5 seconds in milliseconds + const interval = 50; // Update every 50ms + int elapsed = 0; + + _progressTimer = + Timer.periodic(const Duration(milliseconds: interval), (timer) async { + elapsed += interval; + progress.value = (elapsed / totalTime).clamp(0.0, 1.0); + + if (elapsed >= totalTime) { + timer.cancel(); + + box.read(BoxName.onBoarding) == null + ? Get.off(() => OnBoardingPage()) + : box.read(BoxName.emailDriver) != null && + box.read(BoxName.phoneDriver) != null && + box.read(BoxName.phoneVerified) == '1' + ? await Get.put(LoginDriverController()) + .loginWithGoogleCredential( + box.read(BoxName.driverID).toString(), + box.read(BoxName.emailDriver)) + : Get.off(() => LoginCaptin()); + } + }); } void startTimer() async { - debugPrint('onBoarding: ${box.read(BoxName.onBoarding)}'); - debugPrint('emailDriver: ${box.read(BoxName.emailDriver)}'); - debugPrint('phoneDriver: ${box.read(BoxName.phoneDriver)}'); - debugPrint('phoneVerified: ${box.read(BoxName.phoneVerified)}'); Timer(const Duration(seconds: 5), () async { - box.read(BoxName.onBoarding) == null - ? Get.off(() => OnBoardingPage()) - : box.read(BoxName.emailDriver) != null && - box.read(BoxName.phoneDriver) != null && - box.read(BoxName.phoneVerified) == '1' - ? await Get.put(LoginDriverController()) - .loginWithGoogleCredential( - box.read(BoxName.driverID).toString(), - box.read(BoxName.emailDriver)) - : Get.off(() => LoginCaptin()); + // box.read(BoxName.onBoarding) == null + // ? Get.off(() => OnBoardingPage()) + // : box.read(BoxName.email) != null && + // box.read(BoxName.phone) != null && + // box.read(BoxName.isVerified) == '1' + // // ? Get.off(() => const MapPagePassenger()) + // ? await Get.put(LoginController()).loginUsingCredentials( + // box.read(BoxName.passengerID).toString(), + // box.read(BoxName.email).toString(), + // ) + // : Get.off(() => LoginPage()); }); } @override void onClose() { - animationController.dispose(); + _progressTimer?.cancel(); + _animationController.dispose(); super.onClose(); } } diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index 9dd87bb..5513bfd 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -942,7 +942,8 @@ Store your money with us and receive it in your bank as a monthly salary.''': "You can change the Country to get all features": "يمكنك تغيير الدولة للحصول على جميع الميزات", "Slide to End Trip": "‏اسحب لإنهاء الرحلة", - "App Preferences": "تفضيلات التطبيق", + "App Preferences": "تفضيلات التطبيق", "For Egypt": "للمصريين", + "Non Egypt": "لغير المصريين", "Google Map App": "تطبيق خرائط جوجل", "If you want to make Google Map App run directly when you apply order": "إذا كنت تريد تشغيل تطبيق خرائط جوجل مباشرة عند تطبيق الطلب", diff --git a/lib/controller/rate/rate_conroller.dart b/lib/controller/rate/rate_conroller.dart index 9e18eb8..0c32825 100644 --- a/lib/controller/rate/rate_conroller.dart +++ b/lib/controller/rate/rate_conroller.dart @@ -1,7 +1,5 @@ -import 'package:sefer_driver/constant/colors.dart'; import 'package:sefer_driver/controller/firebase/firbase_messge.dart'; import 'package:sefer_driver/controller/home/captin/map_driver_controller.dart'; -import 'package:sefer_driver/controller/payment/payment_controller.dart'; import 'package:sefer_driver/views/widgets/error_snakbar.dart'; import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; @@ -13,8 +11,6 @@ import 'package:sefer_driver/main.dart'; import 'package:sefer_driver/views/home/Captin/home_captain/home_captin.dart'; import 'package:sefer_driver/views/widgets/elevated_btn.dart'; -import '../home/payment/captain_wallet_controller.dart'; - // import '../home/captin/home_captain_controller.dart'; class RateController extends GetxController { @@ -43,9 +39,8 @@ class RateController extends GetxController { Future addPassengerWallet() async { if (formKey.currentState!.validate()) { - var priceOfTrip = - double.parse(price.toString()); - // double.parse(Get.find().paymentAmount); + var priceOfTrip = double.parse(price.toString()); + // double.parse(Get.find().paymentAmount); double remainingFee = double.parse(passengerPayAmount.text) - priceOfTrip; if (remainingFee > 0) { var paymentToken2 = await Get.find() diff --git a/lib/splash_screen_page.dart b/lib/splash_screen_page.dart index 67953b3..46b1b32 100644 --- a/lib/splash_screen_page.dart +++ b/lib/splash_screen_page.dart @@ -17,69 +17,109 @@ class SplashScreen extends StatelessWidget { @override Widget build(BuildContext context) { - // Get.put(LocationBackgroundController()); return Scaffold( - backgroundColor: - AppColor.secondaryColor, // Set your desired background color - body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GetBuilder( - builder: (_) { - return AnimatedBuilder( - animation: splashScreenController.animationController, - builder: (BuildContext context, Widget? child) { - return Transform.scale( - scale: - splashScreenController.animationController.value < 0.5 - ? splashScreenController.zoomInAnimation.value - : splashScreenController.zoomOutAnimation.value, - child: Image.asset( - 'assets/images/logo.gif', - width: Get.width * .5, + body: Container( + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + AppColor.primaryColor, + // AppColor.primaryColor, + AppColor.secondaryColor, + AppColor.secondaryColor, + ], + ), + ), + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GetBuilder( + builder: (_) { + return ScaleTransition( + scale: splashScreenController.animation, + child: FadeTransition( + opacity: splashScreenController.animation, + child: Column( + children: [ + DefaultTextStyle( + style: AppStyle.headTitle.copyWith( + color: AppColor.primaryColor, + fontSize: 48, + fontWeight: FontWeight.bold, + ), + child: AnimatedTextKit( + animatedTexts: [ + WavyAnimatedText( + AppInformation.appName, + speed: const Duration(milliseconds: 200), + ), + ], + isRepeatingAnimation: false, + onFinished: () { + // Trigger any additional animations here + }, + ), + ), + const SizedBox(height: 20), + DefaultTextStyle( + style: AppStyle.title.copyWith( + color: AppColor.writeColor.withOpacity(0.8), + fontSize: 18, + ), + child: AnimatedTextKit( + animatedTexts: [ + TyperAnimatedText( + 'Your Journey Begins Here'.tr, + speed: const Duration(milliseconds: 100), + ), + ], + isRepeatingAnimation: false, + ), + ), + ], ), - ); - }, - ); - }, - ), - const SizedBox( - height: 30, - ), - AnimatedTextKit(animatedTexts: [ - TypewriterAnimatedText( - 'Welcome to ${AppInformation.appName}', - textStyle: - AppStyle.headTitle2.copyWith(color: AppColor.writeColor), - speed: const Duration(milliseconds: 200), + ), + ); + }, ), - ], isRepeatingAnimation: true), - const SizedBox( - height: 20, - ), - AnimatedTextKit(animatedTexts: [ - TypewriterAnimatedText( - 'Powered By ${AppInformation.appName}', - textStyle: - AppStyle.title.copyWith(color: AppColor.primaryColor), - speed: const Duration(milliseconds: 200), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 40, vertical: 20), + child: Column( + children: [ + Obx(() => LinearProgressIndicator( + value: splashScreenController.progress.value, + backgroundColor: AppColor.writeColor.withOpacity(0.2), + valueColor: AlwaysStoppedAnimation( + AppColor.primaryColor), + minHeight: 3, + )), + const SizedBox(height: 16), + Text( + 'Version: ${box.read(BoxName.packagInfo) ?? '1.0.0'}', + style: AppStyle.subtitle.copyWith( + color: AppColor.writeColor.withOpacity(0.6), + ), + ), + const SizedBox(height: 20), + ], + ), ), - ], isRepeatingAnimation: true), - const SizedBox( - height: 100, - ), - ], + ], + ), ), ), - bottomNavigationBar: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - box.read(BoxName.packagInfo) ?? '1.4.54', - style: AppStyle.subtitle, + bottomNavigationBar: Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: Text( + 'Version: ${box.read(BoxName.packagInfo) ?? '1.0.0'}', + style: AppStyle.subtitle.copyWith( + color: AppColor.writeColor.withOpacity(0.6), ), - ], + textAlign: TextAlign.center, + ), ), ); } diff --git a/lib/views/auth/captin/cards/egypt_card_a_i.dart b/lib/views/auth/captin/cards/egypt_card_a_i.dart index 00ef592..9e3fff2 100644 --- a/lib/views/auth/captin/cards/egypt_card_a_i.dart +++ b/lib/views/auth/captin/cards/egypt_card_a_i.dart @@ -81,17 +81,16 @@ class EgyptCardAI extends StatelessWidget { : const SizedBox(), Row( children: [ - controller.isEgypt - ? MyElevatedButton( - title: 'For Egypt'.tr, - onPressed: () { - controller.changeNationality(); - }) - : MyElevatedButton( - title: 'Non Egypt'.tr, - onPressed: () { - controller.changeNationality(); - }), + MyElevatedButton( + kolor: controller.isEgypt + ? AppColor.greenColor + : AppColor.redColor, + title: controller.isEgypt + ? 'For Egypt'.tr + : 'Non Egypt'.tr, + onPressed: () { + controller.changeNationality(); + }) ], ) ], diff --git a/lib/views/home/Captin/home_captain/drawer_captain.dart b/lib/views/home/Captin/home_captain/drawer_captain.dart index cffc450..458328d 100644 --- a/lib/views/home/Captin/home_captain/drawer_captain.dart +++ b/lib/views/home/Captin/home_captain/drawer_captain.dart @@ -497,7 +497,7 @@ class UserAccountHeader extends StatelessWidget { padding: EdgeInsets.zero, onPressed: () { imageController.choosImagePicture( - AppLink.uploadImage1, 'portrait'); + AppLink.uploadImagePortrate, 'portrait'); }, child: Container( padding: const EdgeInsets.all(6), diff --git a/lib/views/home/Captin/home_captain/home_captin.dart b/lib/views/home/Captin/home_captain/home_captin.dart index 53e766d..cd44ff6 100644 --- a/lib/views/home/Captin/home_captain/home_captin.dart +++ b/lib/views/home/Captin/home_captain/home_captin.dart @@ -477,51 +477,56 @@ class HomeCaptain extends StatelessWidget { const SizedBox( height: 5, ), - box.read(BoxName.rideStatus) == 'Applied' || - box.read(BoxName.rideStatus) == 'Begin' - ? Positioned( - bottom: Get.height * .2, - right: 6, - child: AnimatedContainer( - duration: const Duration(microseconds: 200), - width: homeCaptainController.widthMapTypeAndTraffic, - decoration: BoxDecoration( - border: Border.all(color: AppColor.blueColor), - color: AppColor.secondaryColor, - borderRadius: BorderRadius.circular(15)), - child: GestureDetector( - onLongPress: () { - box.write(BoxName.rideStatus, 'delete'); - homeCaptainController.update(); - }, - child: IconButton( - onPressed: () { - box.read(BoxName.rideStatus) == 'Applied' - ? { - Get.to(() => PassengerLocationMapPage(), - arguments: box - .read(BoxName.rideArguments)), - Get.put(MapDriverController()) - .changeRideToBeginToPassenger() - } - : { - Get.to(() => PassengerLocationMapPage(), - arguments: box - .read(BoxName.rideArguments)), - Get.put(MapDriverController()) - .startRideFromStartApp() - }; + GetBuilder( + builder: (homeCaptainController) { + return box.read(BoxName.rideStatus) == 'Applied' || + box.read(BoxName.rideStatus) == 'Begin' + ? Positioned( + bottom: Get.height * .2, + right: 6, + child: AnimatedContainer( + duration: const Duration(microseconds: 200), + width: homeCaptainController.widthMapTypeAndTraffic, + decoration: BoxDecoration( + border: Border.all(color: AppColor.blueColor), + color: AppColor.secondaryColor, + borderRadius: BorderRadius.circular(15)), + child: GestureDetector( + onLongPress: () { + box.write(BoxName.rideStatus, 'delete'); + homeCaptainController.update(); }, - icon: const Icon( - Icons.rice_bowl, - size: 29, - color: AppColor.blueColor, + child: IconButton( + onPressed: () { + box.read(BoxName.rideStatus) == 'Applied' + ? { + Get.to( + () => PassengerLocationMapPage(), + arguments: box + .read(BoxName.rideArguments)), + Get.put(MapDriverController()) + .changeRideToBeginToPassenger() + } + : { + Get.to( + () => PassengerLocationMapPage(), + arguments: box + .read(BoxName.rideArguments)), + Get.put(MapDriverController()) + .startRideFromStartApp() + }; + }, + icon: const Icon( + Icons.rice_bowl, + size: 29, + color: AppColor.blueColor, + ), ), ), ), - ), - ) - : const SizedBox() + ) + : const SizedBox(); + }) ], ), ),