diff --git a/assets/images/on1.png b/assets/images/on1.png new file mode 100644 index 0000000..c9881c6 Binary files /dev/null and b/assets/images/on1.png differ diff --git a/assets/images/on2.png b/assets/images/on2.png new file mode 100644 index 0000000..3b6d28c Binary files /dev/null and b/assets/images/on2.png differ diff --git a/assets/images/on3.png b/assets/images/on3.png new file mode 100644 index 0000000..88af4ae Binary files /dev/null and b/assets/images/on3.png differ diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 6571411..013aead 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -34,11 +34,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 2 + 4 CFBundleSignature ???? CFBundleVersion - 1.01 + 1.04 LSRequiresIPhoneOS UILaunchStoryboardName diff --git a/lib/constant/box_name.dart b/lib/constant/box_name.dart index c7d2479..93ab4f2 100644 --- a/lib/constant/box_name.dart +++ b/lib/constant/box_name.dart @@ -29,4 +29,5 @@ class BoxName { static const String passengerWalletTotal = "passengerWalletTotal"; static const String passengerWalletFound = "passengerWalletFound"; static const String periods = 'periods'; + static const String onBoarding = 'onBoarding'; } diff --git a/lib/controller/auth/onboarding_controller.dart b/lib/controller/auth/onboarding_controller.dart new file mode 100644 index 0000000..c7ebd93 --- /dev/null +++ b/lib/controller/auth/onboarding_controller.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:ride/constant/box_name.dart'; +import 'package:ride/main.dart'; +import 'package:ride/views/auth/login_page.dart'; +import 'package:ride/views/home/home_page.dart'; + +import '../../models/model/onboarding_model.dart'; + +class OnboardingController extends GetxController {} + +abstract class OnBoardingController extends GetxController { + next(); + onPageChanged(int index); +} + +class OnBoardingControllerImp extends OnBoardingController { + late PageController pageController; + + int currentPage = 0; + + @override + next() { + currentPage++; + + if (currentPage > onBoardingList.length - 1) { + box.write(BoxName.onBoarding, 'yes'); + Get.offAll(LoginPage()); + } else { + pageController.animateToPage(currentPage, + duration: const Duration(milliseconds: 900), curve: Curves.easeInOut); + } + } + + @override + onPageChanged(int index) { + currentPage = index; + update(); + } + + @override + void onInit() { + pageController = PageController(); + super.onInit(); + } +} diff --git a/lib/controller/functions/camer_controller.dart b/lib/controller/functions/camer_controller.dart index b8490a8..5c8c0c6 100644 --- a/lib/controller/functions/camer_controller.dart +++ b/lib/controller/functions/camer_controller.dart @@ -6,10 +6,12 @@ import 'package:flutter_tesseract_ocr/flutter_tesseract_ocr.dart'; import 'package:get/get.dart'; import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart'; import 'package:ride/constant/box_name.dart'; +import 'package:ride/constant/credential.dart'; +import 'package:ride/constant/links.dart'; import 'package:ride/views/widgets/elevated_btn.dart'; import 'package:path_provider/path_provider.dart' as path_provider; import 'package:path/path.dart' as path; - +import 'package:http/http.dart' as http; import '../../main.dart'; class CameraClassController extends GetxController { @@ -32,7 +34,7 @@ class CameraClassController extends GetxController { update(); cameraController = CameraController( cameras[0], - ResolutionPreset.max, + ResolutionPreset.medium, enableAudio: false, ); await cameraController.initialize(); @@ -57,6 +59,76 @@ class CameraClassController extends GetxController { } } + var imgUrl = ''; + Future extractCardId() async { + // Construct the path for the image file + final directory = await path_provider.getTemporaryDirectory(); + final imagePath = + path.join(directory.path, '${box.read(BoxName.driverID)}.png'); + + // Capture the image and save it to the specified path + final XFile capturedImage = await cameraController.takePicture(); + + // Move the captured image to the desired path + await capturedImage.saveTo(imagePath); + await uploadImage(File(capturedImage.path)); + + extractByAPI(AppLink.server + '/card_image/' + box.read(BoxName.driverID)); + } + + Future extractByAPI(String imgUrl) async { + var headers = {'apikey': 'K89368168788957'}; + var request = http.MultipartRequest( + 'POST', Uri.parse('https://api.ocr.space/parse/image')); + request.fields.addAll({ + 'language': 'ara', + 'isOverlayRequired': 'false', + 'url': imgUrl, + 'iscreatesearchablepdf': 'false', + 'issearchablepdfhidetextlayer': 'false' + }); + + request.headers.addAll(headers); + + http.StreamedResponse response = await request.send(); + + if (response.statusCode == 200) { + print(await response.stream.bytesToString()); + } else { + print(response.reasonPhrase); + } + } + + Future uploadImage(File imageFile) async { + var request = http.MultipartRequest( + 'POST', + Uri.parse(AppLink.uploadImage), + ); + + // Attach the image file to the request + request.files.add( + await http.MultipartFile.fromPath('image', imageFile.path), + ); // Add the headers to the request + request.headers.addAll({ + // "Content-Type": "application/x-www-form-urlencoded", + 'Authorization': + 'Basic ${base64Encode(utf8.encode(AppCredintials.basicAuthCredentials))}', + }); + + // Add the driverID to the request + request.fields['driverID'] = box.read(BoxName.driverID); + // Send the request + var response = await request.send(); + + // Read the response + var responseData = await response.stream.toBytes(); + var responseString = String.fromCharCodes(responseData); + scannedText = responseString; + update(); + // Return the link received from the server + return responseString; + } + Future takePictureAndMLGoogleScan() async { try { // Construct the path for the image file diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index baf5c4d..070aa62 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -179,7 +179,15 @@ class MyTranslation extends Translations { "Type something...": "اكتب شيئا ما...", "Submit rating": "إرسال التقييم", "Rate Passenger": "تقييم الراكب", - "Ride Summary": "ملخص الرحلة" + "Ride Summary": "ملخص الرحلة", + "welcome_message": "مرحبا بك في سفر!", + "app_description": + "سفر هو تطبيق تطبيقات مشاركة الركوب الآمن والموثوق ويمكن الوصول إليه.", + "get_to_destination": "اذهب إلى وجهتك بسرعة وسهولة.", + "get_a_ride": "مع سفر، يمكنك الحصول على رحلة إلى وجهتك في دقائق.", + "safe_and_comfortable": "استمتع برحلة آمنة ومريحة.", + "committed_to_safety": + "تلتزم سفر بالسلامة، ويتم فحص جميع قباطننا بعناية وفحص خلفيتهم." /// // 'Saved Sucssefully': @@ -363,7 +371,18 @@ class MyTranslation extends Translations { "Type something...": "Bir şeyler yazın...", "Submit rating": "Değerlendirmeyi gönder", "Rate Passenger": "Yolcularınızı değerlendirin", - "Ride Summary": "Seyahat özeti" + "Ride Summary": "Seyahat özeti", + "welcome_message": "Sefer'e hoş geldiniz!", + "app_description": + "Sefer, güvenli, güvenilir ve erişilebilir bir araç paylaşım uygulamasıdır.", + "get_to_destination": + "Hedef noktanıza hızlı ve kolay bir şekilde ulaşın.", + "get_a_ride": + "Sefer ile dakikalar içinde varış noktanıza bir yolculuk alabilirsiniz.", + "safe_and_comfortable": + "Güvenli ve konforlu bir yolculuğun tadını çıkarın.", + "committed_to_safety": + "Sefer, güvenliğe bağlıdır ve tüm kaptanlarımız dikkatle seçilir ve sicil sorgusu yapılır." }, "en": { "Choose Language": "Choose Language", diff --git a/lib/main.dart b/lib/main.dart index 83a11d8..f96a794 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -19,6 +19,7 @@ import 'controller/local/local_controller.dart'; import 'controller/local/translations.dart'; import 'firebase_options.dart'; import 'models/db_sql.dart'; +import 'onbording_page.dart'; import 'views/home/map_page.dart'; final box = GetStorage(); @@ -42,7 +43,6 @@ void main() async { ); await FirebaseMessagesController().requestFirebaseMessagingPermission(); - await FirebaseMessagesController().getToken(); FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler); List initializationTasks = [ @@ -69,19 +69,22 @@ class MyApp extends StatelessWidget { LocaleController controller = Get.put(LocaleController()); return GetMaterialApp( - title: AppInformation.appName, - translations: MyTranslation(), - debugShowCheckedModeBanner: false, - locale: controller.language, - theme: controller.appTheme, - key: UniqueKey(), - // routes: {'/':const HomePage()}, - home: box.read(BoxName.email) != null - ? const MapPage() - : box.read(BoxName.emailDriver) == null - ? LoginPage() - : box.read(BoxName.emailDriver) != null - ? const HomeCaptain() - : LoginCaptin()); + title: AppInformation.appName, + translations: MyTranslation(), + debugShowCheckedModeBanner: false, + locale: controller.language, + theme: controller.appTheme, + key: UniqueKey(), + // routes: {'/':const HomePage()}, + home: box.read(BoxName.onBoarding) == null + ? OnBoardingPage() + : box.read(BoxName.email) != null + ? const MapPage() + : box.read(BoxName.emailDriver) == null + ? LoginPage() + : box.read(BoxName.emailDriver) != null + ? const HomeCaptain() + : LoginCaptin(), + ); } } diff --git a/lib/models/model/onboarding_model.dart b/lib/models/model/onboarding_model.dart new file mode 100644 index 0000000..199909f --- /dev/null +++ b/lib/models/model/onboarding_model.dart @@ -0,0 +1,30 @@ +import 'package:get/get.dart'; + +List onBoardingList = [ + OnBoardingModel( + title: 'Welcome to Sefer!'.tr, + image: 'assets/images/on1.png', + body: + 'Sefer is the ride-hailing app that is safe, reliable, and accessible.' + .tr, + ), + OnBoardingModel( + title: 'Get to your destination quickly and easily.'.tr, + image: 'assets/images/on2.png', + body: 'With Sefer, you can get a ride to your destination in minutes.'.tr, + ), + OnBoardingModel( + title: 'Enjoy a safe and comfortable ride.'.tr, + image: 'assets/images/on3.png', + body: + 'Sefer is committed to safety, and all of our captains are carefully screened and background checked.' + .tr, + ), +]; + +class OnBoardingModel { + final String? title; + final String? image; + final String? body; + OnBoardingModel({this.body, this.title, this.image}); +} diff --git a/lib/onbording_page.dart b/lib/onbording_page.dart new file mode 100644 index 0000000..17cadd0 --- /dev/null +++ b/lib/onbording_page.dart @@ -0,0 +1,104 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:ride/views/widgets/elevated_btn.dart'; + +import 'constant/colors.dart'; +import 'controller/auth/onboarding_controller.dart'; +import 'models/model/onboarding_model.dart'; + +class OnBoardingPage extends StatelessWidget { + OnBoardingControllerImp onBoardingControllerImp = + Get.put(OnBoardingControllerImp()); + + OnBoardingPage({super.key}); + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColor.secondaryColor, + body: SafeArea( + child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ + SizedBox( + child: const CustomSliderOnBoarding(), + height: Get.height * .7, + ), + const CustomDotControllerOnBoarding(), + // const Spacer(flex: 2), + const SizedBox(height: 20), + MyElevatedButton( + onPressed: () => onBoardingControllerImp.next(), + title: 'Next'.tr, + ) + ]), + )); + } +} + +class CustomSliderOnBoarding extends GetView { + const CustomSliderOnBoarding({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return PageView.builder( + controller: controller.pageController, + onPageChanged: (val) { + controller.onPageChanged(val); + }, + itemCount: onBoardingList.length, + itemBuilder: (context, i) => Column( + children: [ + Image.asset( + onBoardingList[i].image!, + // width: , + height: Get.width / 1.3, + fit: BoxFit.fill, + ), + const SizedBox(height: 60), + Text(onBoardingList[i].title!, + textAlign: TextAlign.center, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 22, + color: AppColor.primaryColor)), + const SizedBox(height: 20), + Container( + width: Get.width * .8, + alignment: Alignment.center, + child: Text( + onBoardingList[i].body!, + textAlign: TextAlign.center, + style: const TextStyle( + height: 2, + color: AppColor.accentColor, + fontWeight: FontWeight.bold, + fontSize: 14), + )), + // const SizedBox(height: 20), + ], + )); + } +} + +class CustomDotControllerOnBoarding extends StatelessWidget { + const CustomDotControllerOnBoarding({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return GetBuilder( + builder: (controller) => Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ...List.generate( + onBoardingList.length, + (index) => AnimatedContainer( + margin: const EdgeInsets.only(right: 5), + duration: const Duration(milliseconds: 900), + width: controller.currentPage == index ? 20 : 5, + height: 6, + decoration: BoxDecoration( + color: AppColor.primaryColor, + borderRadius: BorderRadius.circular(10)), + )) + ], + )); + } +} diff --git a/lib/views/home/Captin/camer_widget.dart b/lib/views/home/Captin/camer_widget.dart index cbb76a5..06b7ffc 100644 --- a/lib/views/home/Captin/camer_widget.dart +++ b/lib/views/home/Captin/camer_widget.dart @@ -24,146 +24,151 @@ class CameraWidgetCardId extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12), child: GetBuilder( - builder: (cameraClassController) => - cameraClassController.isCameraInitialized - ? Stack( - children: [ - Container( - decoration: AppStyle.boxDecoration, - height: Get.height * .3, - width: Get.width, - child: - // Image.asset( - // 'assets/images/cardid.jpg', - // fit: BoxFit.cover, - // ) - CameraPreview( - cameraClassController.cameraController, - // child: IconButton( - // onPressed: () { - // cameraClassController.takePicture(); - // }, - // icon: const Icon(Icons.camera), - // ), - ), - ), - Positioned( - top: 50, - child: Container( - width: 230, - height: 25, - decoration: BoxDecoration( - // color: AppColor.blueColor, - border: Border.all( - color: AppColor.yellowColor, - width: 2), - ), - ), - ), - Positioned( - top: 38, - right: 5, - child: Container( - width: 230, - height: 25, - decoration: BoxDecoration( - // color: AppColor.blueColor, - border: Border.all( - color: AppColor.blueColor, width: 2), - ), - ), - ), - Positioned( - top: 130, - right: 5, - child: Container( - width: 140, - height: 20, - decoration: BoxDecoration( - // color: AppColor.blueColor, - border: Border.all( - color: AppColor.blueColor, width: 2), - ), - ), - ), - Positioned( - top: 148, - right: 5, - child: Container( - width: 140, - height: 15, - decoration: BoxDecoration( - // color: AppColor.blueColor, - border: Border.all( - color: AppColor.blueColor, width: 2), - ), - ), - ), - Positioned( - top: 165, - right: 5, - child: Container( - width: 140, - height: 15, - decoration: BoxDecoration( - // color: AppColor.blueColor, - border: Border.all( - color: AppColor.blueColor, width: 2), - ), - ), - ), - Positioned( - top: 182, - right: 5, - child: Container( - width: 140, - height: 15, - decoration: BoxDecoration( - // color: AppColor.blueColor, - border: Border.all( - color: AppColor.blueColor, width: 2), - ), - ), - ), - Positioned( - top: 198, - right: 5, - child: Container( - width: 140, - height: 15, - decoration: BoxDecoration( - // color: AppColor.blueColor, - border: Border.all( - color: AppColor.blueColor, width: 2), - ), - ), - ), - Positioned( - top: 80, - left: 35, - child: Container( - width: 120, - height: 110, - decoration: BoxDecoration( - // color: AppColor.blueColor, - border: Border.all( - color: AppColor.blueColor, width: 2), - ), - ), - ), - ], - ) - : Container( + builder: (cameraClassController) => cameraClassController + .isCameraInitialized + ? Stack( + children: [ + Container( decoration: AppStyle.boxDecoration, - height: Get.height * .3, + height: Get.width * 3 / 4, width: Get.width, - child: Center( - child: Text( - 'Camera not initilaized yet', - style: AppStyle.title, + child: OverflowBox( + alignment: Alignment.center, + child: FittedBox( + fit: BoxFit.fitWidth, + child: SizedBox( + width: Get.width, + height: Get.width * + 3 / + 4, // Set the desired aspect ratio here + child: + // Image.asset( + // 'assets/images/cardid.jpg', + // fit: BoxFit.fill, + // ) + CameraPreview( + cameraClassController.cameraController, + ), + ), ), ), ), + Positioned( + top: 72, + child: Container( + width: 230, + height: 25, + decoration: BoxDecoration( + // color: AppColor.blueColor, + border: Border.all( + color: AppColor.yellowColor, width: 2), + ), + ), + ), + Positioned( + top: 60, + right: 5, + child: Container( + width: 230, + height: 25, + decoration: BoxDecoration( + // color: AppColor.blueColor, + border: Border.all( + color: AppColor.blueColor, width: 2), + ), + ), + ), + Positioned( + top: 156, + right: 5, + child: Container( + width: 140, + height: 20, + decoration: BoxDecoration( + // color: AppColor.blueColor, + border: Border.all( + color: AppColor.blueColor, width: 2), + ), + ), + ), + Positioned( + top: 175, + right: 5, + child: Container( + width: 140, + height: 15, + decoration: BoxDecoration( + // color: AppColor.blueColor, + border: Border.all( + color: AppColor.blueColor, width: 2), + ), + ), + ), + Positioned( + top: 191, + right: 5, + child: Container( + width: 140, + height: 15, + decoration: BoxDecoration( + // color: AppColor.blueColor, + border: Border.all( + color: AppColor.blueColor, width: 2), + ), + ), + ), + Positioned( + top: 207, + right: 5, + child: Container( + width: 140, + height: 15, + decoration: BoxDecoration( + // color: AppColor.blueColor, + border: Border.all( + color: AppColor.blueColor, width: 2), + ), + ), + ), + Positioned( + top: 225, + right: 5, + child: Container( + width: 140, + height: 15, + decoration: BoxDecoration( + // color: AppColor.blueColor, + border: Border.all( + color: AppColor.blueColor, width: 2), + ), + ), + ), + Positioned( + top: 115, + left: 25, + child: Container( + width: 120, + height: 110, + decoration: BoxDecoration( + // color: AppColor.blueColor, + border: Border.all( + color: AppColor.blueColor, width: 2), + ), + ), + ), + ], + ) + : Container( + decoration: AppStyle.boxDecoration, + height: Get.width * 3 / 4, + width: Get.width, + child: Center( + child: Text( + 'Camera not initilaized yet', + style: AppStyle.title, + ), + ), + ), ), ), Row( @@ -179,6 +184,9 @@ class CameraWidgetCardId extends StatelessWidget { cameraClassController.takePictureAndTesseractScan()), ], ), + MyElevatedButton( + title: 'Scan ID Api'.tr, + onPressed: () => cameraClassController.extractCardId()), GetBuilder( builder: (cameraClassController) => Expanded( child: diff --git a/lib/views/home/Captin/home_captin.dart b/lib/views/home/Captin/home_captin.dart index c67e20f..5bf721f 100644 --- a/lib/views/home/Captin/home_captin.dart +++ b/lib/views/home/Captin/home_captin.dart @@ -4,6 +4,7 @@ import 'package:get/get.dart'; import 'package:ride/constant/colors.dart'; import 'package:ride/constant/style.dart'; import 'package:ride/constant/table_names.dart'; +import 'package:ride/controller/functions/camer_controller.dart'; import 'package:ride/controller/home/captin/home_captain_controller.dart'; import 'package:ride/controller/home/captin/order_request_controller.dart'; import 'package:ride/controller/payment/payment_controller.dart'; @@ -205,6 +206,15 @@ class HomeCaptain extends StatelessWidget { "Text IdCamera", ), ), + TextButton( + onPressed: () { + CameraClassController().extractByAPI( + 'https://img.alwakeelnews.com/Content/Upload/large/b8109dd0d33af5195938104af6835fef.jpg'); + }, + child: const Text( + "Text By API", + ), + ), TextButton( onPressed: () { PaymentController().makePayment(