LiveCare Video Call fixes

haroon_dev
haroon amjad 1 day ago
parent bb565c58f4
commit 4f60227429

@ -78,5 +78,6 @@ class CacheConst {
static const String isMonthlyReportEnabled = 'is-monthly-report-enabled';
static const String zoomRoomID = 'zoom-room-id';
static const String callTypeID = 'call-type-id';
static String isAppOpenedFromCall = "is_app_opened_from_call";
}

@ -46,11 +46,13 @@ _incomingCall(Map<String, dynamic> data) async {
// LandingPage.isOpenCallPage = true;
String roomID = data['session_id'] ?? '';
String callTypeID = data['AppointmentNo'] ?? '';
// GetIt.instance<CacheService>().saveString(key: CacheConst.zoomRoomID, value: roomID);
// GetIt.instance<CacheService>().saveBool(key: CacheConst.isAppOpenedFromCall, value: true);
Utils.saveStringFromPrefs(CacheConst.zoomRoomID, roomID);
Utils.saveStringFromPrefs(CacheConst.callTypeID, callTypeID);
Utils.saveBoolFromPrefs(CacheConst.isAppOpenedFromCall, true);
WidgetsFlutterBinding.ensureInitialized();

@ -84,6 +84,7 @@ class _CallScreenState extends State<CallScreen> {
Color chatTextColor = const Color(0xFFAAAAAA);
Widget changeNamePopup;
final args = ModalRoute.of(context)!.settings.arguments as CallArguments;
var isFrontCamera = useState(true);
useEffect(() {
Future<void>.microtask(() async {
@ -93,8 +94,11 @@ class _CallScreenState extends State<CallScreen> {
try {
Map<String, bool> SDKaudioOptions = {"connect": true, "mute": false, "autoAdjustSpeakerVolume": false};
// Map<String, bool> SDKvideoOptions = {
// "localVideoOn": true,
// };
Map<String, bool> SDKvideoOptions = {
"localVideoOn": true,
"localVideoOn": args.callType == 1 ? true : false,
};
JoinSessionConfig joinSession = JoinSessionConfig(
sessionName: args.sessionName,
@ -302,6 +306,19 @@ class _CallScreenState extends State<CallScreen> {
List<ZoomVideoSdkUser>? remoteUserList = await zoom.session.getRemoteUsers();
var leftUserListJson = jsonDecode(data['leftUsers']) as List;
List<ZoomVideoSdkUser> leftUserLis = leftUserListJson.map((userJson) => ZoomVideoSdkUser.fromJson(userJson)).toList();
// If no remote users remain, the other participant has left end the session
if (remoteUserList == null || remoteUserList.isEmpty) {
await zoom.leaveSession(true);
Navigator.pushAndRemoveUntil(
context,
CustomPageRoute(
page: LandingNavigation(),
),
(r) => false);
return;
}
if (fullScreenUser.value != null) {
for (var user in leftUserLis) {
{
@ -313,8 +330,8 @@ class _CallScreenState extends State<CallScreen> {
} else {
fullScreenUser.value = mySelf;
}
remoteUserList?.add(mySelf!);
users.value = remoteUserList!;
remoteUserList.add(mySelf!);
users.value = remoteUserList;
});
final userNameChangedListener = eventListener.addListener(EventType.onUserNameChanged, (data) async {
@ -817,63 +834,38 @@ class _CallScreenState extends State<CallScreen> {
}
void onPressCameraList() async {
List<ListTile> options = [];
List<ZoomVideoSdkCameraDevice> cameraList = await zoom.videoHelper.getCameraList();
for (var camera in cameraList) {
options.add(
ListTile(
title: Text(
camera.deviceName,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.normal,
color: Colors.black,
),
),
onTap: () async => {
await zoom.videoHelper.switchCamera(camera.deviceId),
Navigator.of(context).pop(),
},
),
);
}
options.add(
ListTile(
title: Text(
"Cancel",
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.normal,
color: Colors.black,
),
),
onTap: () async => {
Navigator.of(context).pop(),
},
),
if (cameraList.isEmpty) return;
// Find the target camera by toggling between front and back
ZoomVideoSdkCameraDevice? targetCamera;
try {
if (isFrontCamera.value) {
// Currently front, switch to back
targetCamera = cameraList.firstWhere(
(c) => c.deviceName.toLowerCase().contains('back') || c.deviceName.toLowerCase().contains('rear'),
);
showDialog(
context: context,
builder: (context) {
return Dialog(
elevation: 0.0,
insetPadding: const EdgeInsets.symmetric(horizontal: 40),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
child: SizedBox(
height: options.length * 60,
child: Scrollbar(
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.vertical,
children: ListTile.divideTiles(
context: context,
tiles: options,
).toList(),
),
),
),
} else {
// Currently back, switch to front
targetCamera = cameraList.firstWhere(
(c) => c.deviceName.toLowerCase().contains('front') || c.deviceName.toLowerCase().contains('facing'),
);
});
}
} catch (_) {
targetCamera = null;
}
// Fallback: if we can't identify by name, just pick the other camera
if (targetCamera == null && cameraList.length >= 2) {
final currentIndex = isFrontCamera.value ? 0 : 1;
final nextIndex = (currentIndex + 1) % cameraList.length;
targetCamera = cameraList[nextIndex];
}
if (targetCamera != null) {
await zoom.videoHelper.switchCamera(targetCamera.deviceId);
isFrontCamera.value = !isFrontCamera.value;
}
}
// Future<void> onPressMore() async {

@ -80,7 +80,9 @@ class _SplashScreenState extends State<SplashPage> {
navigateToTeleConsult() async {
String roomID = await Utils.getStringFromPrefs(CacheConst.zoomRoomID);
String callTypeID = await Utils.getStringFromPrefs(CacheConst.callTypeID);
print('RoomID: $roomID');
print('callTypeID: $callTypeID');
// GetIt.instance<CacheService>().remove(key: CacheConst.isAppOpenedFromCall);
Utils.removeFromPrefs(CacheConst.isAppOpenedFromCall);
@ -92,7 +94,7 @@ class _SplashScreenState extends State<SplashPage> {
GetIt.instance<NavigationService>().navigatorKey.currentContext!,
AppRoutes.zoomCallPage,
// arguments: CallArguments(appointmentID, "111", "Patient", "40", "1", true, 1),
arguments: CallArguments(roomID, "123", "Patient", "40", "0", true, 1),
arguments: CallArguments(roomID, "123", "Patient", "40", "0", true, int.parse(callTypeID)),
// arguments: CallArguments("SmallDailyStandup9875", "123", "Patient", "40", "0", false, int.parse(widget.incomingCallData!.appointmentNo!)),
);
}

Loading…
Cancel
Save