4/22/2
This commit is contained in:
@@ -22,17 +22,19 @@ class RateDriverFromPassenger extends StatelessWidget {
|
||||
title: 'Rate Driver'.tr,
|
||||
body: [
|
||||
Positioned(
|
||||
top: 40,
|
||||
top: 10,
|
||||
left: Get.width * .1,
|
||||
right: Get.width * .1,
|
||||
child: Container(
|
||||
// height: Get.height * 6,
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Container(
|
||||
height: Get.height * .25,
|
||||
height: Get.height * .5,
|
||||
decoration: AppStyle.boxDecoration1,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@@ -43,47 +45,54 @@ class RateDriverFromPassenger extends StatelessWidget {
|
||||
'${'Total price to '.tr}${Get.find<MapPassengerController>().firstName}',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 2,
|
||||
color: AppColor.redColor,
|
||||
)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Text(
|
||||
(double.parse(controller.price
|
||||
.toString()) *
|
||||
.12 +
|
||||
double.parse(
|
||||
controller.price.toString()))
|
||||
.toStringAsFixed(2),
|
||||
style: AppStyle.number.copyWith(
|
||||
color: AppColor.redColor,
|
||||
textBaseline:
|
||||
TextBaseline.ideographic,
|
||||
decoration:
|
||||
TextDecoration.lineThrough,
|
||||
decorationColor: AppColor.redColor),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 2,
|
||||
color: AppColor.redColor,
|
||||
)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Text(
|
||||
(double.parse(controller.price
|
||||
.toString()) *
|
||||
.12 +
|
||||
double.parse(controller.price
|
||||
.toString()))
|
||||
.toStringAsFixed(2),
|
||||
style: AppStyle.number.copyWith(
|
||||
color: AppColor.redColor,
|
||||
textBaseline:
|
||||
TextBaseline.ideographic,
|
||||
decoration:
|
||||
TextDecoration.lineThrough,
|
||||
decorationColor:
|
||||
AppColor.redColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 2,
|
||||
color: AppColor.greenColor,
|
||||
)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Text(
|
||||
controller.price.toString(),
|
||||
style: AppStyle.number,
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 2,
|
||||
color: AppColor.greenColor,
|
||||
)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Text(
|
||||
controller.price.toString(),
|
||||
style: AppStyle.number,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
import 'package:SEFER/constant/api_key.dart';
|
||||
import 'package:SEFER/controller/functions/crud.dart';
|
||||
import 'package:SEFER/controller/home/map_passenger_controller.dart';
|
||||
import 'package:agora_rtc_engine/agora_rtc_engine.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
import '../../../../constant/box_name.dart';
|
||||
import '../../../../controller/firebase/firbase_messge.dart';
|
||||
import '../../../../controller/home/captin/map_driver_controller.dart';
|
||||
import '../../../../main.dart';
|
||||
|
||||
class CallController extends GetxController {
|
||||
String channelName = ''; // Get.find<MapDriverController>().rideId;
|
||||
String token = '';
|
||||
// int uid = int.parse(box.read(BoxName.phoneDriver)); // uid of the local user
|
||||
int uid = 0;
|
||||
int? remoteUid; // uid of the remote user
|
||||
bool _isJoined = false; // Indicates if the local user has joined the channel
|
||||
String status = '';
|
||||
late RtcEngine agoraEngine; // Agora engine instance
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
channelName = box.read(BoxName.driverID) != null
|
||||
? Get.find<MapDriverController>().rideId
|
||||
: Get.find<MapPassengerController>().rideId; // 'sefer300'; //
|
||||
remoteUid = box.read(BoxName.driverID) != null
|
||||
? int.parse(box.read(BoxName.phoneDriver))
|
||||
: int.parse(box.read(BoxName.phone));
|
||||
uid = box.read(BoxName.driverID) == null
|
||||
? int.parse(box.read(BoxName.phoneDriver))
|
||||
: int.parse(box.read(BoxName.phone));
|
||||
|
||||
initAgoraFull();
|
||||
}
|
||||
|
||||
initAgoraFull() async {
|
||||
print('remoteid is $remoteUid');
|
||||
print('uid is $uid');
|
||||
await fetchToken();
|
||||
// Set up an instance of Agora engine
|
||||
setupVoiceSDKEngine();
|
||||
// join();
|
||||
FirebaseMessagesController().sendNotificationToPassengerToken(
|
||||
'Call Income',
|
||||
'${'You have call from driver'.tr} ${box.read(BoxName.nameDriver)}',
|
||||
Get.find<MapDriverController>().tokenPassenger,
|
||||
[
|
||||
token,
|
||||
channelName,
|
||||
uid.toString(),
|
||||
remoteUid.toString(),
|
||||
],
|
||||
);
|
||||
join();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
agoraEngine.leaveChannel();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
Future<void> setupVoiceSDKEngine() async {
|
||||
// retrieve or request microphone permission
|
||||
await [Permission.microphone].request();
|
||||
|
||||
//create an instance of the Agora engine
|
||||
agoraEngine = createAgoraRtcEngine();
|
||||
await agoraEngine.initialize(RtcEngineContext(appId: AK.agoraAppId));
|
||||
print('eeeeeeeeeeeeeeeeeeee');
|
||||
print(agoraEngine);
|
||||
// Register the event handler
|
||||
agoraEngine.registerEventHandler(
|
||||
RtcEngineEventHandler(
|
||||
onJoinChannelSuccess: (RtcConnection connection, int elapsed) {
|
||||
// Get.snackbar(
|
||||
// "Local user uid:${connection.localUid} joined the channel", '');
|
||||
status = 'joined'.tr;
|
||||
_isJoined = true;
|
||||
update();
|
||||
},
|
||||
onUserJoined: (RtcConnection connection, int remoteUid, int elapsed) {
|
||||
// Get.snackbar("Remote user uid:$remoteUid joined the channel", '');
|
||||
status = '${Get.find<MapDriverController>().passengerName}'
|
||||
' joined'
|
||||
.tr
|
||||
.tr;
|
||||
remoteUid = remoteUid;
|
||||
update();
|
||||
},
|
||||
onUserOffline: (RtcConnection connection, int? remoteUid,
|
||||
UserOfflineReasonType reason) {
|
||||
// Get.snackbar("Remote user uid:$remoteUid left the channel", '');
|
||||
status = 'Call left'.tr;
|
||||
remoteUid = null;
|
||||
update();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void join() async {
|
||||
// Set channel options including the client role and channel profile
|
||||
ChannelMediaOptions options = const ChannelMediaOptions(
|
||||
clientRoleType: ClientRoleType.clientRoleBroadcaster,
|
||||
channelProfile: ChannelProfileType.channelProfileCommunication,
|
||||
);
|
||||
|
||||
await agoraEngine.joinChannel(
|
||||
token: token,
|
||||
channelId: channelName,
|
||||
options: options,
|
||||
uid: uid,
|
||||
);
|
||||
}
|
||||
|
||||
void leave() {
|
||||
_isJoined = false;
|
||||
remoteUid = null;
|
||||
update();
|
||||
agoraEngine.leaveChannel();
|
||||
}
|
||||
|
||||
// Clean up the resources when you leave
|
||||
@override
|
||||
void dispose() async {
|
||||
await agoraEngine.leaveChannel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
fetchToken() async {
|
||||
var res = await CRUD()
|
||||
.getAgoraToken(channelName: channelName, uid: uid.toString());
|
||||
token = res;
|
||||
print('token is $token');
|
||||
update();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import 'package:SEFER/constant/colors.dart';
|
||||
import 'package:SEFER/constant/style.dart';
|
||||
import 'package:SEFER/controller/firebase/firbase_messge.dart';
|
||||
import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
|
||||
import 'package:SEFER/views/home/Captin/home_captain/call_controller.dart';
|
||||
import 'package:SEFER/controller/functions/call_controller.dart';
|
||||
import 'package:SEFER/views/widgets/my_scafold.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import 'package:SEFER/constant/colors.dart';
|
||||
import 'package:SEFER/constant/style.dart';
|
||||
import 'package:SEFER/controller/firebase/firbase_messge.dart';
|
||||
import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
|
||||
import 'package:SEFER/controller/home/map_passenger_controller.dart';
|
||||
import 'package:SEFER/views/home/Captin/home_captain/call_controller.dart';
|
||||
import 'package:SEFER/controller/functions/call_controller.dart';
|
||||
import 'package:SEFER/views/widgets/my_scafold.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
|
||||
|
||||
import '../../../../../constant/box_name.dart';
|
||||
import '../../../../../main.dart';
|
||||
|
||||
class CallPageFromPassenger extends StatelessWidget {
|
||||
const CallPageFromPassenger({super.key});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user