diff --git a/assets/images/roundtrip.png b/assets/images/roundtrip.png new file mode 100644 index 0000000..c6088ba Binary files /dev/null and b/assets/images/roundtrip.png differ diff --git a/lib/controller/firebase/firbase_messge.dart b/lib/controller/firebase/firbase_messge.dart index 3876172..c2b1238 100644 --- a/lib/controller/firebase/firbase_messge.dart +++ b/lib/controller/firebase/firbase_messge.dart @@ -211,6 +211,26 @@ class FirebaseMessagesController extends GetxController { } catch (e) { print('Error navigating to PassengerCallPage: $e'); } + } else if (message.notification!.title! == 'Call Income from Driver') { + try { + var myListString = message.data['passengerList']; + var driverList = jsonDecode(myListString) as List; + // if (Platform.isAndroid) { + NotificationController().showNotification( + 'Call Income'.tr, + message.notification!.body!, + 'iphone_ringtone', + ); + // } + // Assuming GetMaterialApp is initialized and context is valid for navigation + Get.to(() => PassengerCallPage( + channelName: driverList[1].toString(), + token: driverList[0].toString(), + remoteID: driverList[2].toString(), + )); + } catch (e) { + print('Error navigating to PassengerCallPage: $e'); + } } else if (message.notification!.title! == 'Call End') { try { var myListString = message.data['passengerList']; diff --git a/lib/controller/functions/crud.dart b/lib/controller/functions/crud.dart index a4400c7..c6ced38 100644 --- a/lib/controller/functions/crud.dart +++ b/lib/controller/functions/crud.dart @@ -48,9 +48,9 @@ class CRUD { required String uid, }) async { var uid = box.read(BoxName.phone) ?? box.read(BoxName.phoneDriver); - var res = await http.get( - Uri.parse( - 'https://repulsive-pig-rugby-shirt.cyclic.app/token?channelName=$channelName'), + var res = await http.get(Uri.parse( + // 'https://repulsive-pig-rugby-shirt.cyclic.app/token?channelName=$channelName'), + 'https://orca-app-b2i85.ondigitalocean.app/token?channelName=$channelName'), headers: {'Authorization': 'Bearer ${AK.agoraAppCertificate}'}); if (res.statusCode == 200) { diff --git a/lib/controller/home/map_passenger_controller.dart b/lib/controller/home/map_passenger_controller.dart index e015b78..9576cb7 100644 --- a/lib/controller/home/map_passenger_controller.dart +++ b/lib/controller/home/map_passenger_controller.dart @@ -2413,8 +2413,8 @@ class MapPassengerController extends GetxController { costDelivery = (distance * deliveryPrice) + costDuration * latePrice; costLady = (distance * comfortPrice + 2) + costDuration * latePrice; costRayehGai = (distance * 2 * speedPrice) - - ((distance * 2 * speedPrice) * .3) + - costDuration * latePrice; + ((distance * 1 * speedPrice) * .4) + + costDuration * 2 * latePrice; update(); } else if (currentTime.hour >= 13 && currentTime.hour <= 16) { @@ -2425,8 +2425,8 @@ class MapPassengerController extends GetxController { costDelivery = (distance * deliveryPrice) + costDuration * heavyPrice; costLady = (distance * comfortPrice + 2) + costDuration * heavyPrice; costRayehGai = (distance * 2 * speedPrice) - - ((distance * 2 * speedPrice) * .3) + - costDuration * heavyPrice; + ((distance * 1 * speedPrice) * .4) + + costDuration * 2 * heavyPrice; update(); // } / @@ -2437,8 +2437,8 @@ class MapPassengerController extends GetxController { costDelivery = (distance * deliveryPrice) + costDuration; costLady = (distance * comfortPrice + 2) + costDuration; costRayehGai = (distance * 2 * speedPrice) - - ((distance * 2 * speedPrice) * .3) + - costDuration; + ((distance * 1 * speedPrice) * .4) + + costDuration * 2; update(); } //print('cost $cost'); diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index 8192a1d..2684baa 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -4,6 +4,16 @@ class MyTranslation extends Translations { @override Map> get keys => { "ar": { + "joined": "انضم", + "Driver joined the channel": "السائق انضم للقناة", + "Driver left the channel": "السائق غادر القناة", + "Call Page": "صفحة المكالمة", + "Call End": "إنهاء المكالمة", + "Call Left": "مكالمات متبقية", + "\$ Next as Cash \$!": " نقداً !", + "To use Wallet charge it": "لاستخدام المحفظة، قم بشحنها", + "We are searching for the nearest driver to you": + "نبحث عن أقرب سائق إليك", "Best choice for cities": "أفضل اختيار للمدن", "Rayeh Gai: Round trip service for convenient travel between cities, easy and reliable.": " رايح جاي: خدمة ذهاب وعودة للسفر المريح بين المدن، سهلة وموثوقة.", diff --git a/lib/views/home/map_widget.dart/call_passenger_page.dart b/lib/views/home/map_widget.dart/call_passenger_page.dart index 82106b8..3cabd9e 100644 --- a/lib/views/home/map_widget.dart/call_passenger_page.dart +++ b/lib/views/home/map_widget.dart/call_passenger_page.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:SEFER/constant/box_name.dart'; +import 'package:SEFER/controller/home/map_passenger_controller.dart'; import 'package:SEFER/main.dart'; import 'package:SEFER/views/widgets/my_scafold.dart'; import 'package:flutter/material.dart'; @@ -9,6 +10,9 @@ import 'package:permission_handler/permission_handler.dart'; import 'package:agora_rtc_engine/agora_rtc_engine.dart'; import '../../../../constant/api_key.dart'; +import '../../../constant/colors.dart'; +import '../../../constant/style.dart'; +import '../../../controller/firebase/firbase_messge.dart'; String appId = AK.agoraAppId; @@ -29,7 +33,7 @@ class _PassengerCallPageState extends State { int? _remoteUid = 0; // uid of the remote user bool _isJoined = false; // Indicates if the local user has joined the channel late RtcEngine agoraEngine; // Agora engine instance - + String status = ''; final GlobalKey scaffoldMessengerKey = GlobalKey(); // Global key to access the scaffold @@ -72,18 +76,21 @@ class _PassengerCallPageState extends State { "Local user uid:${connection.localUid} joined the channel"); setState(() { _isJoined = true; + status = 'joined'.tr; }); }, onUserJoined: (RtcConnection connection, int remoteUid, int elapsed) { - showMessage("Remote user uid:$remoteUid joined the channel"); + showMessage("Driver joined the channel".tr); setState(() { + status = "Driver joined the channel".tr; _remoteUid = remoteUid; }); }, onUserOffline: (RtcConnection connection, int? remoteUid, UserOfflineReasonType reason) { - showMessage("Remote user uid:$remoteUid left the channel"); + showMessage("Driver left the channel".tr); setState(() { + status = "Driver left the channel".tr; _remoteUid = null; }); }, @@ -131,50 +138,127 @@ class _PassengerCallPageState extends State { // appBar: AppBar( // title: const Text('Get started with Voice Calling'), // ), - title: 'Voice Calling'.tr, + title: 'Call Page'.tr, isleading: true, body: [ - ListView( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), - children: [ - // Status text - Container(height: 40, child: Center(child: _status())), - // Button Row - Row( - children: [ - Expanded( - child: ElevatedButton( - child: Text("Join".tr), - onPressed: () => {join()}, - ), + Positioned( + top: Get.height * .2, + child: Container( + height: 100, width: Get.width, + decoration: AppStyle.boxDecoration, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + GestureDetector( + onTap: () async { + // await callController.initAgoraFull(); + // callController.join(); + // FirebaseMessagesController().sendNotificationToPassengerToken( + // 'Call Income', + // '${'You have call from driver'.tr} ${box.read(BoxName.nameDriver)}', + // Get.find().tokenPassenger, + // [ + // callController.token, + // callController.channelName, + // callController.uid.toString(), + // callController.remoteUid.toString(), + // ], + // ); + join(); + // callController.fetchToken(); + }, + child: Container( + width: 50, + height: 50, + decoration: const BoxDecoration( + shape: BoxShape.circle, + color: AppColor.greenColor), + child: const Icon( + Icons.phone, + size: 35, + color: AppColor.secondaryColor, + )), ), - const SizedBox(width: 10), - Expanded( - child: ElevatedButton( - child: Text("Leave".tr), - onPressed: () => {leave()}, - ), + Column( + children: [ + Text( + status, + style: AppStyle.title, + ), + Text(Get.find() + .driverName + .toString()), + ], ), + GestureDetector( + onTap: () async { + FirebaseMessagesController() + .sendNotificationToPassengerToken( + 'Call End'.tr, + 'Call End', + Get.find().driverToken, + [], + ); + leave(); + Get.back(); + }, + child: Container( + width: 50, + height: 50, + decoration: const BoxDecoration( + shape: BoxShape.circle, color: AppColor.redColor), + child: const Icon( + Icons.phone_disabled_sharp, + size: 35, + color: AppColor.secondaryColor, + )), + ) ], ), - ], + // ignore: prefer_const_constructors + ), ), + // ListView( + // padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), + // children: [ + // // Status text + // Container(height: 40, child: Center(child: _status())), + // // Button Row + // Row( + // children: [ + // Expanded( + // child: ElevatedButton( + // child: Text("Join".tr), + // onPressed: () => {join()}, + // ), + // ), + // const SizedBox(width: 10), + // Expanded( + // child: ElevatedButton( + // child: Text("Leave".tr), + // onPressed: () => {leave()}, + // ), + // ), + // ], + // ), + // ], + // ), ]), ); } - Widget _status() { - String statusText; - - if (!_isJoined) { - statusText = 'Join a channel'; - } else if (_remoteUid == null) - statusText = 'Waiting for a remote user to join...'; - else - statusText = 'Connected to remote user, uid:$_remoteUid'; - - return Text( - statusText, - ); - } + // Widget _status() { + // String statusText; + // + // if (!_isJoined) { + // statusText = 'Join a channel'.tr; + // } else if (_remoteUid == null) + // statusText = 'Waiting for a remote user to join...'; + // else + // statusText = 'Connected to remote user, uid:$_remoteUid'; + // + // return Text( + // statusText, + // ); + // } } diff --git a/lib/views/home/map_widget.dart/car_details_widget_to_go.dart b/lib/views/home/map_widget.dart/car_details_widget_to_go.dart index d3ea3f1..693e28b 100644 --- a/lib/views/home/map_widget.dart/car_details_widget_to_go.dart +++ b/lib/views/home/map_widget.dart/car_details_widget_to_go.dart @@ -60,7 +60,7 @@ class CarDetailsTypeToChoose extends StatelessWidget { CarType( carType: 'Rayeh Gai', carDetail: "Best choice for cities".tr, - image: 'assets/images/freeRide.png', + image: 'assets/images/roundtrip.png', ), ); } // Create a Set to remove duplicates based on the `carType` field @@ -464,7 +464,7 @@ class CarDetailsTypeToChoose extends StatelessWidget { content: CarDialogue( textToSpeechController: textToSpeechController, - image: 'assets/images/lady.png', + image: 'assets/images/roundtrip.png', text: "Rayeh Gai: Round trip service for convenient travel between cities, easy and reliable." .tr), diff --git a/lib/views/home/map_widget.dart/searching_captain_window.dart b/lib/views/home/map_widget.dart/searching_captain_window.dart index 24b32eb..7e96030 100644 --- a/lib/views/home/map_widget.dart/searching_captain_window.dart +++ b/lib/views/home/map_widget.dart/searching_captain_window.dart @@ -36,7 +36,7 @@ class SearchingCaptainWindow extends StatelessWidget { ), ), Text( - 'We search nearst Driver to you'.tr, + "We are searching for the nearest driver to you".tr, style: AppStyle.headTitle2, ), Text( @@ -167,9 +167,11 @@ Widget _buildTimer(MapPassengerController mapPassengerController) { title: "No, thanks", onPressed: () { Get.back(); + mapPassengerController.cancelRide(); }), MyElevatedButton( title: "Increase Fee".tr, + kolor: AppColor.greenColor, onPressed: () { mapPassengerController.increaseFeeByPassengerAndReOrder(); })