This commit is contained in:
Hamza-Ayed
2024-05-31 19:19:32 +03:00
parent 794bc8fb24
commit cc76aa394f
8 changed files with 166 additions and 50 deletions

BIN
assets/images/roundtrip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@@ -211,6 +211,26 @@ class FirebaseMessagesController extends GetxController {
} catch (e) { } catch (e) {
print('Error navigating to PassengerCallPage: $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<dynamic>;
// 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') { } else if (message.notification!.title! == 'Call End') {
try { try {
var myListString = message.data['passengerList']; var myListString = message.data['passengerList'];

View File

@@ -48,9 +48,9 @@ class CRUD {
required String uid, required String uid,
}) async { }) async {
var uid = box.read(BoxName.phone) ?? box.read(BoxName.phoneDriver); var uid = box.read(BoxName.phone) ?? box.read(BoxName.phoneDriver);
var res = await http.get( var res = await http.get(Uri.parse(
Uri.parse( // 'https://repulsive-pig-rugby-shirt.cyclic.app/token?channelName=$channelName'),
'https://repulsive-pig-rugby-shirt.cyclic.app/token?channelName=$channelName'), 'https://orca-app-b2i85.ondigitalocean.app/token?channelName=$channelName'),
headers: {'Authorization': 'Bearer ${AK.agoraAppCertificate}'}); headers: {'Authorization': 'Bearer ${AK.agoraAppCertificate}'});
if (res.statusCode == 200) { if (res.statusCode == 200) {

View File

@@ -2413,8 +2413,8 @@ class MapPassengerController extends GetxController {
costDelivery = (distance * deliveryPrice) + costDuration * latePrice; costDelivery = (distance * deliveryPrice) + costDuration * latePrice;
costLady = (distance * comfortPrice + 2) + costDuration * latePrice; costLady = (distance * comfortPrice + 2) + costDuration * latePrice;
costRayehGai = (distance * 2 * speedPrice) - costRayehGai = (distance * 2 * speedPrice) -
((distance * 2 * speedPrice) * .3) + ((distance * 1 * speedPrice) * .4) +
costDuration * latePrice; costDuration * 2 * latePrice;
update(); update();
} else if (currentTime.hour >= 13 && currentTime.hour <= 16) { } else if (currentTime.hour >= 13 && currentTime.hour <= 16) {
@@ -2425,8 +2425,8 @@ class MapPassengerController extends GetxController {
costDelivery = (distance * deliveryPrice) + costDuration * heavyPrice; costDelivery = (distance * deliveryPrice) + costDuration * heavyPrice;
costLady = (distance * comfortPrice + 2) + costDuration * heavyPrice; costLady = (distance * comfortPrice + 2) + costDuration * heavyPrice;
costRayehGai = (distance * 2 * speedPrice) - costRayehGai = (distance * 2 * speedPrice) -
((distance * 2 * speedPrice) * .3) + ((distance * 1 * speedPrice) * .4) +
costDuration * heavyPrice; costDuration * 2 * heavyPrice;
update(); update();
// } / // } /
@@ -2437,8 +2437,8 @@ class MapPassengerController extends GetxController {
costDelivery = (distance * deliveryPrice) + costDuration; costDelivery = (distance * deliveryPrice) + costDuration;
costLady = (distance * comfortPrice + 2) + costDuration; costLady = (distance * comfortPrice + 2) + costDuration;
costRayehGai = (distance * 2 * speedPrice) - costRayehGai = (distance * 2 * speedPrice) -
((distance * 2 * speedPrice) * .3) + ((distance * 1 * speedPrice) * .4) +
costDuration; costDuration * 2;
update(); update();
} }
//print('cost $cost'); //print('cost $cost');

View File

@@ -4,6 +4,16 @@ class MyTranslation extends Translations {
@override @override
Map<String, Map<String, String>> get keys => { Map<String, Map<String, String>> get keys => {
"ar": { "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": "أفضل اختيار للمدن", "Best choice for cities": "أفضل اختيار للمدن",
"Rayeh Gai: Round trip service for convenient travel between cities, easy and reliable.": "Rayeh Gai: Round trip service for convenient travel between cities, easy and reliable.":
" رايح جاي: خدمة ذهاب وعودة للسفر المريح بين المدن، سهلة وموثوقة.", " رايح جاي: خدمة ذهاب وعودة للسفر المريح بين المدن، سهلة وموثوقة.",

View File

@@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:SEFER/constant/box_name.dart'; import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/controller/home/map_passenger_controller.dart';
import 'package:SEFER/main.dart'; import 'package:SEFER/main.dart';
import 'package:SEFER/views/widgets/my_scafold.dart'; import 'package:SEFER/views/widgets/my_scafold.dart';
import 'package:flutter/material.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 'package:agora_rtc_engine/agora_rtc_engine.dart';
import '../../../../constant/api_key.dart'; import '../../../../constant/api_key.dart';
import '../../../constant/colors.dart';
import '../../../constant/style.dart';
import '../../../controller/firebase/firbase_messge.dart';
String appId = AK.agoraAppId; String appId = AK.agoraAppId;
@@ -29,7 +33,7 @@ class _PassengerCallPageState extends State<PassengerCallPage> {
int? _remoteUid = 0; // uid of the remote user int? _remoteUid = 0; // uid of the remote user
bool _isJoined = false; // Indicates if the local user has joined the channel bool _isJoined = false; // Indicates if the local user has joined the channel
late RtcEngine agoraEngine; // Agora engine instance late RtcEngine agoraEngine; // Agora engine instance
String status = '';
final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey = final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey =
GlobalKey<ScaffoldMessengerState>(); // Global key to access the scaffold GlobalKey<ScaffoldMessengerState>(); // Global key to access the scaffold
@@ -72,18 +76,21 @@ class _PassengerCallPageState extends State<PassengerCallPage> {
"Local user uid:${connection.localUid} joined the channel"); "Local user uid:${connection.localUid} joined the channel");
setState(() { setState(() {
_isJoined = true; _isJoined = true;
status = 'joined'.tr;
}); });
}, },
onUserJoined: (RtcConnection connection, int remoteUid, int elapsed) { onUserJoined: (RtcConnection connection, int remoteUid, int elapsed) {
showMessage("Remote user uid:$remoteUid joined the channel"); showMessage("Driver joined the channel".tr);
setState(() { setState(() {
status = "Driver joined the channel".tr;
_remoteUid = remoteUid; _remoteUid = remoteUid;
}); });
}, },
onUserOffline: (RtcConnection connection, int? remoteUid, onUserOffline: (RtcConnection connection, int? remoteUid,
UserOfflineReasonType reason) { UserOfflineReasonType reason) {
showMessage("Remote user uid:$remoteUid left the channel"); showMessage("Driver left the channel".tr);
setState(() { setState(() {
status = "Driver left the channel".tr;
_remoteUid = null; _remoteUid = null;
}); });
}, },
@@ -131,50 +138,127 @@ class _PassengerCallPageState extends State<PassengerCallPage> {
// appBar: AppBar( // appBar: AppBar(
// title: const Text('Get started with Voice Calling'), // title: const Text('Get started with Voice Calling'),
// ), // ),
title: 'Voice Calling'.tr, title: 'Call Page'.tr,
isleading: true, isleading: true,
body: [ body: [
ListView( Positioned(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), top: Get.height * .2,
children: [ child: Container(
// Status text height: 100, width: Get.width,
Container(height: 40, child: Center(child: _status())), decoration: AppStyle.boxDecoration,
// Button Row child: Row(
Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: [
Expanded( GestureDetector(
child: ElevatedButton( onTap: () async {
child: Text("Join".tr), // await callController.initAgoraFull();
onPressed: () => {join()}, // callController.join();
), // FirebaseMessagesController().sendNotificationToPassengerToken(
// 'Call Income',
// '${'You have call from driver'.tr} ${box.read(BoxName.nameDriver)}',
// Get.find<MapDriverController>().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), Column(
Expanded( children: [
child: ElevatedButton( Text(
child: Text("Leave".tr), status,
onPressed: () => {leave()}, style: AppStyle.title,
), ),
Text(Get.find<MapPassengerController>()
.driverName
.toString()),
],
), ),
GestureDetector(
onTap: () async {
FirebaseMessagesController()
.sendNotificationToPassengerToken(
'Call End'.tr,
'Call End',
Get.find<MapPassengerController>().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: <Widget>[
// Expanded(
// child: ElevatedButton(
// child: Text("Join".tr),
// onPressed: () => {join()},
// ),
// ),
// const SizedBox(width: 10),
// Expanded(
// child: ElevatedButton(
// child: Text("Leave".tr),
// onPressed: () => {leave()},
// ),
// ),
// ],
// ),
// ],
// ),
]), ]),
); );
} }
Widget _status() { // Widget _status() {
String statusText; // String statusText;
//
if (!_isJoined) { // if (!_isJoined) {
statusText = 'Join a channel'; // statusText = 'Join a channel'.tr;
} else if (_remoteUid == null) // } else if (_remoteUid == null)
statusText = 'Waiting for a remote user to join...'; // statusText = 'Waiting for a remote user to join...';
else // else
statusText = 'Connected to remote user, uid:$_remoteUid'; // statusText = 'Connected to remote user, uid:$_remoteUid';
//
return Text( // return Text(
statusText, // statusText,
); // );
} // }
} }

View File

@@ -60,7 +60,7 @@ class CarDetailsTypeToChoose extends StatelessWidget {
CarType( CarType(
carType: 'Rayeh Gai', carType: 'Rayeh Gai',
carDetail: "Best choice for cities".tr, 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 } // Create a Set to remove duplicates based on the `carType` field
@@ -464,7 +464,7 @@ class CarDetailsTypeToChoose extends StatelessWidget {
content: CarDialogue( content: CarDialogue(
textToSpeechController: textToSpeechController:
textToSpeechController, textToSpeechController,
image: 'assets/images/lady.png', image: 'assets/images/roundtrip.png',
text: text:
"Rayeh Gai: Round trip service for convenient travel between cities, easy and reliable." "Rayeh Gai: Round trip service for convenient travel between cities, easy and reliable."
.tr), .tr),

View File

@@ -36,7 +36,7 @@ class SearchingCaptainWindow extends StatelessWidget {
), ),
), ),
Text( Text(
'We search nearst Driver to you'.tr, "We are searching for the nearest driver to you".tr,
style: AppStyle.headTitle2, style: AppStyle.headTitle2,
), ),
Text( Text(
@@ -167,9 +167,11 @@ Widget _buildTimer(MapPassengerController mapPassengerController) {
title: "No, thanks", title: "No, thanks",
onPressed: () { onPressed: () {
Get.back(); Get.back();
mapPassengerController.cancelRide();
}), }),
MyElevatedButton( MyElevatedButton(
title: "Increase Fee".tr, title: "Increase Fee".tr,
kolor: AppColor.greenColor,
onPressed: () { onPressed: () {
mapPassengerController.increaseFeeByPassengerAndReOrder(); mapPassengerController.increaseFeeByPassengerAndReOrder();
}) })