diff --git a/android/.gradle/8.12/checksums/checksums.lock b/android/.gradle/8.12/checksums/checksums.lock index 6fea520..3a781f3 100644 Binary files a/android/.gradle/8.12/checksums/checksums.lock and b/android/.gradle/8.12/checksums/checksums.lock differ diff --git a/android/.gradle/8.12/checksums/md5-checksums.bin b/android/.gradle/8.12/checksums/md5-checksums.bin index 0f2e0f2..ead8505 100644 Binary files a/android/.gradle/8.12/checksums/md5-checksums.bin and b/android/.gradle/8.12/checksums/md5-checksums.bin differ diff --git a/android/.gradle/8.12/checksums/sha1-checksums.bin b/android/.gradle/8.12/checksums/sha1-checksums.bin index f59c76b..05ef92f 100644 Binary files a/android/.gradle/8.12/checksums/sha1-checksums.bin and b/android/.gradle/8.12/checksums/sha1-checksums.bin differ diff --git a/android/.gradle/8.12/executionHistory/executionHistory.bin b/android/.gradle/8.12/executionHistory/executionHistory.bin index 2cd6e02..029f802 100644 Binary files a/android/.gradle/8.12/executionHistory/executionHistory.bin and b/android/.gradle/8.12/executionHistory/executionHistory.bin differ diff --git a/android/.gradle/8.12/executionHistory/executionHistory.lock b/android/.gradle/8.12/executionHistory/executionHistory.lock index 21f349b..2c96ea7 100644 Binary files a/android/.gradle/8.12/executionHistory/executionHistory.lock and b/android/.gradle/8.12/executionHistory/executionHistory.lock differ diff --git a/android/.gradle/8.12/fileHashes/fileHashes.bin b/android/.gradle/8.12/fileHashes/fileHashes.bin index 5f11cd9..bf720d9 100644 Binary files a/android/.gradle/8.12/fileHashes/fileHashes.bin and b/android/.gradle/8.12/fileHashes/fileHashes.bin differ diff --git a/android/.gradle/8.12/fileHashes/fileHashes.lock b/android/.gradle/8.12/fileHashes/fileHashes.lock index 4e54282..b76ee35 100644 Binary files a/android/.gradle/8.12/fileHashes/fileHashes.lock and b/android/.gradle/8.12/fileHashes/fileHashes.lock differ diff --git a/android/.gradle/8.12/fileHashes/resourceHashesCache.bin b/android/.gradle/8.12/fileHashes/resourceHashesCache.bin index ff89fb1..76dd4f6 100644 Binary files a/android/.gradle/8.12/fileHashes/resourceHashesCache.bin and b/android/.gradle/8.12/fileHashes/resourceHashesCache.bin differ diff --git a/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 9d7a8c7..e5a2e42 100644 Binary files a/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/android/.gradle/buildOutputCleanup/outputFiles.bin b/android/.gradle/buildOutputCleanup/outputFiles.bin index 9bdddf6..19c56cd 100644 Binary files a/android/.gradle/buildOutputCleanup/outputFiles.bin and b/android/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/android/.gradle/file-system.probe b/android/.gradle/file-system.probe index 296968a..9b0448e 100644 Binary files a/android/.gradle/file-system.probe and b/android/.gradle/file-system.probe differ diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 5d74c4d..e192e29 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -25,7 +25,7 @@ android { defaultConfig { applicationId = "com.ejada.hmg" // minSdk = 24 - minSdk = 26 + minSdk = 28 targetSdk = 36 compileSdk = 36 // targetSdk = flutter.targetSdkVersion @@ -91,7 +91,7 @@ android { "lib/arm64-v8a/libc++_shared.so", "**/*.so" ) - useLegacyPackaging = true + useLegacyPackaging = false } resources { excludes += listOf("META-INF/proguard/androidx-annotations.pro") diff --git a/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java b/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java index a4c7742..350a5b9 100644 --- a/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java +++ b/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java @@ -25,6 +25,11 @@ public final class GeneratedPluginRegistrant { } catch (Exception e) { Log.e(TAG, "Error registering plugin audio_session, com.ryanheise.audio_session.AudioSessionPlugin", e); } + try { + flutterEngine.getPlugins().add(new de.mintware.barcode_scan.BarcodeScanPlugin()); + } catch (Exception e) { + Log.e(TAG, "Error registering plugin barcode_scan2, de.mintware.barcode_scan.BarcodeScanPlugin", e); + } try { flutterEngine.getPlugins().add(new dev.fluttercommunity.plus.connectivity.ConnectivityPlugin()); } catch (Exception e) { @@ -90,6 +95,11 @@ public final class GeneratedPluginRegistrant { } catch (Exception e) { Log.e(TAG, "Error registering plugin flutter_plugin_android_lifecycle, io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin", e); } + try { + flutterEngine.getPlugins().add(new com.flutterzoom.videosdk.FlutterZoomVideoSdkPlugin()); + } catch (Exception e) { + Log.e(TAG, "Error registering plugin flutter_zoom_videosdk, com.flutterzoom.videosdk.FlutterZoomVideoSdkPlugin", e); + } try { flutterEngine.getPlugins().add(new io.github.ponnamkarthik.toast.fluttertoast.FlutterToastPlugin()); } catch (Exception e) { diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 737aeba..a3320b8 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -1522,7 +1522,7 @@ "bmi": "مؤشر كتلة الجسم", "yesPleaseINeedHelp": "نعم، من فضلك أريد المساعدة", "noThanksIKnowTheClinic": "لا شكراً، أعرف العيادة", - "unableToSendOTP": "تعذر إرسال رمز التحقق لمرة واحدة" + "unableToSendOTP": "تعذر إرسال رمز التحقق لمرة واحدة", "callForVitalSign": "استدعاء لأخذ العلامات الحيوية", "callForDoctor": "استدعاء الطبيب", "yourQueueNumber": "رقمك في الدور", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index e27be83..850cf8f 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -1516,7 +1516,7 @@ "bmi": "BMI", "yesPleaseINeedHelp": "Yes, Please I need help", "noThanksIKnowTheClinic": "No, Thanks. I Know the clinic", - "unableToSendOTP": "Unable to send Verification OTP" + "unableToSendOTP": "Unable to send Verification OTP", "callForVitalSign": "Call for vital signs", "callForDoctor": "Call for Doctor", "yourQueueNumber": "Your Queue Number", diff --git a/lib/core/dependencies.dart b/lib/core/dependencies.dart index fb2c64d..0560ff9 100644 --- a/lib/core/dependencies.dart +++ b/lib/core/dependencies.dart @@ -127,10 +127,10 @@ class AppDependencies { getIt.registerLazySingleton(() => CacheServiceImp(sharedPreferences: sharedPreferences, loggerService: getIt())); final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); - // getIt.registerLazySingleton(() => NotificationServiceImp( - // flutterLocalNotificationsPlugin: flutterLocalNotificationsPlugin, - // loggerService: getIt(), - // )); + getIt.registerLazySingleton(() => NotificationServiceImp( + flutterLocalNotificationsPlugin: flutterLocalNotificationsPlugin, + loggerService: getIt(), + )); getIt.registerLazySingleton(() => ApiClientImp(appState: getIt())); getIt.registerLazySingleton( diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 46bdb0f..e8b6e0f 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -985,7 +985,6 @@ abstract class LocaleKeys { static const thankYouForPatience = 'thankYouForPatience'; static const servingNow = 'servingNow'; static const callForVitalSigns = 'callForVitalSigns'; - static const callForDoctor = 'callForDoctor'; static const thingsToAskDoctor = 'thingsToAskDoctor'; static const improveOverallHealth = 'improveOverallHealth'; static const routineScreenings = 'routineScreenings'; diff --git a/lib/presentation/appointments/widgets/appointment_checkin_bottom_sheet.dart b/lib/presentation/appointments/widgets/appointment_checkin_bottom_sheet.dart index 2afd5e6..b87a0a3 100644 --- a/lib/presentation/appointments/widgets/appointment_checkin_bottom_sheet.dart +++ b/lib/presentation/appointments/widgets/appointment_checkin_bottom_sheet.dart @@ -16,7 +16,7 @@ import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/presentation/appointments/appointment_queue_page.dart'; import 'package:hmg_patient_app_new/presentation/home/navigation_screen.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; -// import 'package:barcode_scan2/barcode_scan2.dart'; +import 'package:barcode_scan2/barcode_scan2.dart'; import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart'; import 'package:hmg_patient_app_new/widgets/nfc/nfc_reader_sheet.dart'; @@ -91,10 +91,10 @@ class AppointmentCheckinBottomSheet extends StatelessWidget { LocaleKeys.qrCode.tr(context: context), LocaleKeys.scanQRCodeToCheckIn.tr(context: context), ).onPress(() async { - // String onlineCheckInQRCode = (await BarcodeScanner.scan().then((value) => value.rawContent)); - // if (onlineCheckInQRCode != "") { - // sendCheckInRequest(onlineCheckInQRCode, 2, context); - // } else {} + String onlineCheckInQRCode = (await BarcodeScanner.scan().then((value) => value.rawContent)); + if (onlineCheckInQRCode != "") { + sendCheckInRequest(onlineCheckInQRCode, 2, context); + } else {} }), ], ); diff --git a/lib/presentation/book_appointment/waiting_appointment/waiting_appointment_online_checkin_sheet.dart b/lib/presentation/book_appointment/waiting_appointment/waiting_appointment_online_checkin_sheet.dart index 3b16825..6f3a773 100644 --- a/lib/presentation/book_appointment/waiting_appointment/waiting_appointment_online_checkin_sheet.dart +++ b/lib/presentation/book_appointment/waiting_appointment/waiting_appointment_online_checkin_sheet.dart @@ -14,7 +14,7 @@ import 'package:hmg_patient_app_new/features/book_appointments/book_appointments import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/presentation/book_appointment/review_appointment_page.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; -// import 'package:barcode_scan2/barcode_scan2.dart'; +import 'package:barcode_scan2/barcode_scan2.dart'; import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart'; import 'package:hmg_patient_app_new/widgets/nfc/nfc_reader_sheet.dart'; @@ -82,10 +82,10 @@ class WaitingAppointmentOnlineCheckinSheet extends StatelessWidget { LocaleKeys.qrCode.tr(), LocaleKeys.scanQRCodeToCheckIn.tr() ).onPress(() async { - // String onlineCheckInQRCode = (await BarcodeScanner.scan().then((value) => value.rawContent)); - // if (onlineCheckInQRCode != "") { - // checkScannedNFCAndQRCode(onlineCheckInQRCode, context); - // } else {} + String onlineCheckInQRCode = (await BarcodeScanner.scan().then((value) => value.rawContent)); + if (onlineCheckInQRCode != "") { + checkScannedNFCAndQRCode(onlineCheckInQRCode, context); + } else {} }), ], ); diff --git a/lib/presentation/emergency_services/er_online_checkin/er_online_checkin_select_checkin_bottom_sheet.dart b/lib/presentation/emergency_services/er_online_checkin/er_online_checkin_select_checkin_bottom_sheet.dart index 28c7d2a..3b2dc8a 100644 --- a/lib/presentation/emergency_services/er_online_checkin/er_online_checkin_select_checkin_bottom_sheet.dart +++ b/lib/presentation/emergency_services/er_online_checkin/er_online_checkin_select_checkin_bottom_sheet.dart @@ -12,7 +12,7 @@ import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; -// import 'package:barcode_scan2/barcode_scan2.dart'; +import 'package:barcode_scan2/barcode_scan2.dart'; import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; import 'package:hmg_patient_app_new/widgets/nfc/nfc_reader_sheet.dart'; @@ -80,10 +80,10 @@ class ErOnlineCheckinSelectCheckinBottomSheet extends StatelessWidget { LocaleKeys.qrCode.tr(context: context), LocaleKeys.scanQRCodeToCheckIn.tr(context: context), ).onPress(() async { - // String onlineCheckInQRCode = (await BarcodeScanner.scan().then((value) => value.rawContent)); - // if (onlineCheckInQRCode != "") { - // sendCheckInRequest(onlineCheckInQRCode, context); - // } else {} + String onlineCheckInQRCode = (await BarcodeScanner.scan().then((value) => value.rawContent)); + if (onlineCheckInQRCode != "") { + sendCheckInRequest(onlineCheckInQRCode, context); + } else {} }), ], ); diff --git a/lib/presentation/tele_consultation/zoom/call_screen.dart b/lib/presentation/tele_consultation/zoom/call_screen.dart index 51edf9e..59b5ce4 100644 --- a/lib/presentation/tele_consultation/zoom/call_screen.dart +++ b/lib/presentation/tele_consultation/zoom/call_screen.dart @@ -1,1838 +1,1838 @@ -// import 'dart:async'; -// import 'dart:convert'; -// import 'dart:io'; -// -// import 'package:flutter/cupertino.dart'; -// import 'package:flutter/foundation.dart'; -// import 'package:flutter/material.dart'; -// import 'package:flutter/services.dart'; -// import 'package:flutter_hooks/flutter_hooks.dart'; -// import 'package:flutter_ios_voip_kit_karmm/flutter_ios_voip_kit.dart'; -// import 'package:flutter_zoom_videosdk/flutter_zoom_view.dart'; -// import 'package:flutter_zoom_videosdk/native/zoom_videosdk.dart'; -// import 'package:flutter_zoom_videosdk/native/zoom_videosdk_camera_device.dart'; -// import 'package:flutter_zoom_videosdk/native/zoom_videosdk_cmd_channel.dart'; -// import 'package:flutter_zoom_videosdk/native/zoom_videosdk_event_listener.dart'; -// import 'package:flutter_zoom_videosdk/native/zoom_videosdk_live_transcription_message_info.dart'; -// import 'package:flutter_zoom_videosdk/native/zoom_videosdk_share_action.dart'; -// import 'package:flutter_zoom_videosdk/native/zoom_videosdk_user.dart'; -// import 'package:hmg_patient_app_new/core/app_export.dart'; -// import 'package:hmg_patient_app_new/core/cache_consts.dart'; -// import 'package:hmg_patient_app_new/core/utils/jwt.dart'; -// import 'package:hmg_patient_app_new/core/utils/utils.dart'; -// import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; -// import 'package:hmg_patient_app_new/presentation/home/navigation_screen.dart'; -// import 'package:hmg_patient_app_new/presentation/tele_consultation/zoom/video_view.dart'; -// import 'package:hmg_patient_app_new/theme/colors.dart'; -// import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart'; -// import 'package:image_picker/image_picker.dart'; -// -// class CallScreen extends StatefulHookWidget { -// const CallScreen({Key? key}) : super(key: key); -// -// @override -// State createState() => _CallScreenState(); -// } -// -// class _CallScreenState extends State { -// static TextEditingController changeNameController = TextEditingController(); -// double opacityLevel = 1.0; -// -// final voIPKit = FlutterIOSVoIPKit.instance; -// -// bool isScreenBeingShared = false; -// -// void _changeOpacity() { -// setState(() => opacityLevel = opacityLevel == 0 ? 1.0 : 0.0); -// } -// -// @override -// Widget build(BuildContext context) { -// var zoom = ZoomVideoSdk(); -// var eventListener = ZoomVideoSdkEventListener(); -// var isInSession = useState(false); -// var sessionName = useState(''); -// var sessionPassword = useState(''); -// var users = useState([]); -// var fullScreenUser = useState(null); -// var sharingUser = useState(null); -// var videoInfo = useState(''); -// var isSharing = useState(false); -// var isMuted = useState(true); -// var isVideoOn = useState(false); -// var isSpeakerOn = useState(false); -// var isRenameModalVisible = useState(false); -// var isRecordingStarted = useState(false); -// var isMicOriginalOn = useState(false); -// var isMounted = useIsMounted(); -// var audioStatusFlag = useState(false); -// var videoStatusFlag = useState(false); -// var userNameFlag = useState(false); -// var userShareStatusFlag = useState(false); -// var isReceiveSpokenLanguageContentEnabled = useState(false); -// var isVideoMirrored = useState(false); -// var isOriginalAspectRatio = useState(false); -// var isPiPView = useState(false); -// var isSharedCamera = useState(false); -// CameraShareView cameraShareView = const CameraShareView(creationParams: {}); -// -// //hide status bar -// SystemChrome.setEnabledSystemUIMode(SystemUiMode.leanBack); -// var circleButtonSize = 65.0; -// Color backgroundColor = const Color(0xFF232323); -// Color buttonBackgroundColor = const Color.fromRGBO(0, 0, 0, 0.6); -// Color chatTextColor = const Color(0xFFAAAAAA); -// Widget changeNamePopup; -// final args = ModalRoute.of(context)!.settings.arguments as CallArguments; -// -// useEffect(() { -// Future.microtask(() async { -// var token = generateJwt(args.sessionName, args.role); -// -// Utils.removeFromPrefs(CacheConst.isAppOpenedFromCall); -// -// try { -// Map SDKaudioOptions = {"connect": true, "mute": false, "autoAdjustSpeakerVolume": false}; -// Map SDKvideoOptions = { -// "localVideoOn": true, -// }; -// JoinSessionConfig joinSession = JoinSessionConfig( -// sessionName: args.sessionName, -// sessionPassword: args.sessionPwd, -// token: token, -// userName: args.displayName, -// audioOptions: SDKaudioOptions, -// videoOptions: SDKvideoOptions, -// sessionIdleTimeoutMins: int.parse(args.sessionIdleTimeoutMins), -// ); -// await zoom.joinSession(joinSession); -// } catch (e) { -// const AlertDialog( -// title: Text("Error"), -// content: Text("Failed to join the session"), -// ); -// Future.delayed(const Duration(milliseconds: 1000)).asStream().listen((event) { -// Navigator.pushAndRemoveUntil( -// context, -// CustomPageRoute( -// page: LandingNavigation(), -// ), -// (r) => false); -// }); -// } -// }); -// return null; -// }, []); -// -// useEffect(() { -// final sessionJoinListener = eventListener.addListener(EventType.onSessionJoin, (data) async { -// data = data as Map; -// isInSession.value = true; -// zoom.session.getSessionName().then((value) => sessionName.value = value!); -// sessionPassword.value = await zoom.session.getSessionPassword(); -// debugPrint("sessionPhonePasscode: ${await zoom.session.getSessionPhonePasscode()}"); -// ZoomVideoSdkUser mySelf = ZoomVideoSdkUser.fromJson(jsonDecode(data['sessionUser'])); -// List? remoteUsers = await zoom.session.getRemoteUsers(); -// var muted = await mySelf.audioStatus?.isMuted(); -// var videoOn = await mySelf.videoStatus?.isOn(); -// var speakerOn = await zoom.audioHelper.getSpeakerStatus(); -// fullScreenUser.value = mySelf; -// remoteUsers?.insert(0, mySelf); -// isMuted.value = muted!; -// isSpeakerOn.value = speakerOn; -// isVideoOn.value = videoOn!; -// users.value = remoteUsers!; -// isReceiveSpokenLanguageContentEnabled.value = await zoom.liveTranscriptionHelper.isReceiveSpokenLanguageContentEnabled(); -// }); -// -// final sessionLeaveListener = eventListener.addListener(EventType.onSessionLeave, (data) async { -// data = data as Map; -// debugPrint("onSessionLeave: ${data['reason']}"); -// isInSession.value = false; -// users.value = []; -// fullScreenUser.value = null; -// // Navigator.popAndPushNamed( -// // context, -// // "Join", -// // arguments: JoinArguments(args.isJoin, sessionName.value, sessionPassword.value, args.displayName, args.sessionIdleTimeoutMins, args.role), -// // ); -// Navigator.pushAndRemoveUntil( -// context, -// CustomPageRoute( -// page: LandingNavigation(), -// ), -// (r) => false); -// }); -// -// final sessionNeedPasswordListener = eventListener.addListener(EventType.onSessionNeedPassword, (data) async { -// showDialog( -// context: context, -// builder: (BuildContext context) => AlertDialog( -// title: const Text('Session Need Password'), -// content: const Text('Password is required'), -// actions: [ -// TextButton( -// onPressed: () async => { -// Navigator.pushAndRemoveUntil( -// context, -// CustomPageRoute( -// page: LandingNavigation(), -// ), -// (r) => false), -// await zoom.leaveSession(false), -// }, -// child: const Text('OK'), -// ), -// ], -// ), -// ); -// }); -// -// final sessionPasswordWrongListener = eventListener.addListener(EventType.onSessionPasswordWrong, (data) async { -// showDialog( -// context: context, -// builder: (BuildContext context) => AlertDialog( -// title: const Text('Session Password Incorrect'), -// content: const Text('Password is wrong'), -// actions: [ -// TextButton( -// onPressed: () async => { -// Navigator.popAndPushNamed(context, 'Join', arguments: JoinArguments(args.isJoin, args.sessionName, "", args.displayName, args.sessionIdleTimeoutMins, args.role)), -// await zoom.leaveSession(false), -// }, -// child: const Text('OK'), -// ), -// ], -// ), -// ); -// }); -// -// final userVideoStatusChangedListener = eventListener.addListener(EventType.onUserVideoStatusChanged, (data) async { -// data = data as Map; -// ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); -// var userListJson = jsonDecode(data['changedUsers']) as List; -// List userList = userListJson.map((userJson) => ZoomVideoSdkUser.fromJson(userJson)).toList(); -// for (var user in userList) { -// { -// if (user.userId == mySelf?.userId) { -// mySelf?.videoStatus?.isOn().then((on) => isVideoOn.value = on); -// } -// } -// } -// videoStatusFlag.value = !videoStatusFlag.value; -// }); -// -// final userAudioStatusChangedListener = eventListener.addListener(EventType.onUserAudioStatusChanged, (data) async { -// data = data as Map; -// ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); -// var userListJson = jsonDecode(data['changedUsers']) as List; -// List userList = userListJson.map((userJson) => ZoomVideoSdkUser.fromJson(userJson)).toList(); -// for (var user in userList) { -// { -// if (user.userId == mySelf?.userId) { -// mySelf?.audioStatus?.isMuted().then((muted) => isMuted.value = muted); -// } -// } -// } -// audioStatusFlag.value = !audioStatusFlag.value; -// }); -// -// final userShareStatusChangeListener = eventListener.addListener(EventType.onUserShareStatusChanged, (data) async { -// data = data as Map; -// ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); -// ZoomVideoSdkUser shareUser = ZoomVideoSdkUser.fromJson(jsonDecode(data['user'].toString())); -// ZoomVideoSdkShareAction? shareAction = ZoomVideoSdkShareAction.fromJson(jsonDecode(data['shareAction'])); -// -// if (shareAction.shareStatus == ShareStatus.Start || shareAction.shareStatus == ShareStatus.Resume) { -// sharingUser.value = shareUser; -// fullScreenUser.value = shareUser; -// isSharing.value = (shareUser.userId == mySelf?.userId); -// -// setState(() { -// isScreenBeingShared = true; -// }); -// Future.delayed(const Duration(seconds: 2), () { -// setState(() { -// isScreenBeingShared = false; -// }); -// }); -// } else { -// sharingUser.value = null; -// isSharing.value = false; -// isSharedCamera.value = false; -// fullScreenUser.value = mySelf; -// isScreenBeingShared = false; -// setState(() { -// isScreenBeingShared = true; -// }); -// Future.delayed(const Duration(seconds: 2), () { -// setState(() { -// isScreenBeingShared = false; -// }); -// }); -// } -// userShareStatusFlag.value = !userShareStatusFlag.value; -// }); -// -// final shareContentChangedListener = eventListener.addListener(EventType.onShareContentChanged, (data) async { -// data = data as Map; -// ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); -// ZoomVideoSdkUser shareUser = ZoomVideoSdkUser.fromJson(jsonDecode(data['user'].toString())); -// ZoomVideoSdkShareAction? shareAction = ZoomVideoSdkShareAction.fromJson(jsonDecode(data['shareAction'])); -// if (shareAction.shareType == ShareType.Camera) { -// debugPrint("Camera share started"); -// isSharedCamera.value = (shareUser.userId == mySelf?.userId); -// } -// }); -// -// final userJoinListener = eventListener.addListener(EventType.onUserJoin, (data) async { -// if (!isMounted()) return; -// data = data as Map; -// ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); -// var userListJson = jsonDecode(data['remoteUsers']) as List; -// List remoteUserList = userListJson.map((userJson) => ZoomVideoSdkUser.fromJson(userJson)).toList(); -// remoteUserList.insert(0, mySelf!); -// users.value = remoteUserList; -// }); -// -// final userLeaveListener = eventListener.addListener(EventType.onUserLeave, (data) async { -// if (!isMounted()) return; -// ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); -// data = data as Map; -// List? remoteUserList = await zoom.session.getRemoteUsers(); -// var leftUserListJson = jsonDecode(data['leftUsers']) as List; -// List leftUserLis = leftUserListJson.map((userJson) => ZoomVideoSdkUser.fromJson(userJson)).toList(); -// if (fullScreenUser.value != null) { -// for (var user in leftUserLis) { -// { -// if (fullScreenUser.value?.userId == user.userId) { -// fullScreenUser.value = mySelf; -// } -// } -// } -// } else { -// fullScreenUser.value = mySelf; -// } -// remoteUserList?.add(mySelf!); -// users.value = remoteUserList!; -// }); -// -// final userNameChangedListener = eventListener.addListener(EventType.onUserNameChanged, (data) async { -// if (!isMounted()) return; -// data = data as Map; -// ZoomVideoSdkUser? changedUser = ZoomVideoSdkUser.fromJson(jsonDecode(data['changedUser'])); -// int index; -// for (var user in users.value) { -// if (user.userId == changedUser.userId) { -// index = users.value.indexOf(user); -// users.value[index] = changedUser; -// } -// } -// userNameFlag.value = !userNameFlag.value; -// }); -// -// final commandReceived = eventListener.addListener(EventType.onCommandReceived, (data) async { -// data = data as Map; -// debugPrint("sender: ${ZoomVideoSdkUser.fromJson(jsonDecode(data['sender']))}, command: ${data['command']}"); -// }); -// -// final liveStreamStatusChangeListener = eventListener.addListener(EventType.onLiveStreamStatusChanged, (data) async { -// data = data as Map; -// debugPrint("onLiveStreamStatusChanged: status: ${data['status']}"); -// }); -// -// final liveTranscriptionStatusChangeListener = eventListener.addListener(EventType.onLiveTranscriptionStatus, (data) async { -// data = data as Map; -// debugPrint("onLiveTranscriptionStatus: status: ${data['status']}"); -// }); -// -// final cloudRecordingStatusListener = eventListener.addListener(EventType.onCloudRecordingStatus, (data) async { -// data = data as Map; -// debugPrint("onCloudRecordingStatus: status: ${data['status']}"); -// ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); -// if (data['status'] == RecordingStatus.Start) { -// if (mySelf != null && !mySelf.isHost!) { -// showDialog( -// context: context, -// builder: (BuildContext context) => AlertDialog( -// content: const Text('The session is being recorded.'), -// actions: [ -// TextButton( -// onPressed: () async { -// await zoom.acceptRecordingConsent(); -// if (context.mounted) { -// Navigator.pop(context); -// } -// ; -// }, -// child: const Text('accept'), -// ), -// TextButton( -// onPressed: () async { -// String currentConsentType = await zoom.getRecordingConsentType(); -// if (currentConsentType == ConsentType.ConsentType_Individual) { -// await zoom.declineRecordingConsent(); -// Navigator.pop(context); -// } else { -// await zoom.declineRecordingConsent(); -// zoom.leaveSession(false); -// if (!context.mounted) return; -// Navigator.popAndPushNamed( -// context, -// "Join", -// arguments: JoinArguments(args.isJoin, sessionName.value, sessionPassword.value, args.displayName, args.sessionIdleTimeoutMins, args.role), -// ); -// } -// }, -// child: const Text('decline'), -// ), -// ], -// ), -// ); -// } -// isRecordingStarted.value = true; -// } else { -// isRecordingStarted.value = false; -// } -// }); -// -// final liveTranscriptionMsgInfoReceivedListener = eventListener.addListener(EventType.onLiveTranscriptionMsgInfoReceived, (data) async { -// data = data as Map; -// ZoomVideoSdkLiveTranscriptionMessageInfo? messageInfo = ZoomVideoSdkLiveTranscriptionMessageInfo.fromJson(jsonDecode(data['messageInfo'])); -// debugPrint("onLiveTranscriptionMsgInfoReceived: content: ${messageInfo.messageContent}"); -// }); -// -// final inviteByPhoneStatusListener = eventListener.addListener(EventType.onInviteByPhoneStatus, (data) async { -// data = data as Map; -// debugPrint("onInviteByPhoneStatus: status: ${data['status']}, reason: ${data['reason']}"); -// }); -// -// final multiCameraStreamStatusChangedListener = eventListener.addListener(EventType.onMultiCameraStreamStatusChanged, (data) async { -// data = data as Map; -// ZoomVideoSdkUser? changedUser = ZoomVideoSdkUser.fromJson(jsonDecode(data['changedUser'])); -// var status = data['status']; -// for (var user in users.value) { -// { -// if (changedUser.userId == user.userId) { -// if (status == MultiCameraStreamStatus.Joined) { -// user.hasMultiCamera = true; -// } else if (status == MultiCameraStreamStatus.Left) { -// user.hasMultiCamera = false; -// } -// } -// } -// } -// }); -// -// final requireSystemPermission = eventListener.addListener(EventType.onRequireSystemPermission, (data) async { -// data = data as Map; -// ZoomVideoSdkUser? changedUser = ZoomVideoSdkUser.fromJson(jsonDecode(data['changedUser'])); -// var permissionType = data['permissionType']; -// switch (permissionType) { -// case SystemPermissionType.Camera: -// showDialog( -// context: context, -// builder: (BuildContext context) => AlertDialog( -// title: const Text("Can't Access Camera"), -// content: const Text("please turn on the toggle in system settings to grant permission"), -// actions: [ -// TextButton( -// onPressed: () => Navigator.pop(context, 'OK'), -// child: const Text('OK'), -// ), -// ], -// ), -// ); -// break; -// case SystemPermissionType.Microphone: -// showDialog( -// context: context, -// builder: (BuildContext context) => AlertDialog( -// title: const Text("Can't Access Microphone"), -// content: const Text("please turn on the toggle in system settings to grant permission"), -// actions: [ -// TextButton( -// onPressed: () => Navigator.pop(context, 'OK'), -// child: const Text('OK'), -// ), -// ], -// ), -// ); -// break; -// } -// }); -// -// final networkStatusChangeListener = eventListener.addListener(EventType.onUserVideoNetworkStatusChanged, (data) async { -// data = data as Map; -// ZoomVideoSdkUser? networkUser = ZoomVideoSdkUser.fromJson(jsonDecode(data['user'])); -// -// if (data['status'] == NetworkStatus.Bad) { -// debugPrint("onUserVideoNetworkStatusChanged: status: ${data['status']}, user: ${networkUser.userName}"); -// } -// }); -// -// final eventErrorListener = eventListener.addListener(EventType.onError, (data) async { -// data = data as Map; -// String errorType = data['errorType']; -// showDialog( -// context: context, -// builder: (BuildContext context) => AlertDialog( -// title: const Text("Error"), -// content: Text(errorType), -// actions: [ -// TextButton( -// onPressed: () => Navigator.pop(context, 'OK'), -// child: const Text('OK'), -// ), -// ], -// ), -// ); -// if (errorType == Errors.SessionJoinFailed || errorType == Errors.SessionDisconnecting) { -// Timer( -// const Duration(milliseconds: 1000), -// () => { -// Navigator.popAndPushNamed( -// context, -// "Join", -// arguments: JoinArguments(args.isJoin, sessionName.value, sessionPassword.value, args.displayName, args.sessionIdleTimeoutMins, args.role), -// ), -// }); -// } -// }); -// -// final userRecordingConsentListener = eventListener.addListener(EventType.onUserRecordingConsent, (data) async { -// data = data as Map; -// ZoomVideoSdkUser? user = ZoomVideoSdkUser.fromJson(jsonDecode(data['user'])); -// debugPrint('userRecordingConsentListener: user= ${user.userName}'); -// }); -// -// final callCRCDeviceStatusListener = eventListener.addListener(EventType.onCallCRCDeviceStatusChanged, (data) async { -// data = data as Map; -// debugPrint('onCallCRCDeviceStatusChanged: status = ${data['status']}'); -// }); -// -// final originalLanguageMsgReceivedListener = eventListener.addListener(EventType.onOriginalLanguageMsgReceived, (data) async { -// data = data as Map; -// ZoomVideoSdkLiveTranscriptionMessageInfo? messageInfo = ZoomVideoSdkLiveTranscriptionMessageInfo.fromJson(jsonDecode(data['messageInfo'])); -// debugPrint("onOriginalLanguageMsgReceived: content: ${messageInfo.messageContent}"); -// }); -// -// final chatPrivilegeChangedListener = eventListener.addListener(EventType.onChatPrivilegeChanged, (data) async { -// data = data as Map; -// String type = data['privilege']; -// debugPrint('chatPrivilegeChangedListener: type= $type'); -// }); -// -// final testMicStatusListener = eventListener.addListener(EventType.onTestMicStatusChanged, (data) async { -// data = data as Map; -// String status = data['status']; -// debugPrint('testMicStatusListener: status= $status'); -// }); -// -// final micSpeakerVolumeChangedListener = eventListener.addListener(EventType.onMicSpeakerVolumeChanged, (data) async { -// data = data as Map; -// int type = data['micVolume']; -// debugPrint('onMicSpeakerVolumeChanged: micVolume= $type, speakerVolume'); -// }); -// -// final cameraControlRequestResultListener = eventListener.addListener(EventType.onCameraControlRequestResult, (data) async { -// data = data as Map; -// bool approved = data['approved']; -// debugPrint('onCameraControlRequestResult: approved= $approved'); -// }); -// -// final callOutUserJoinListener = eventListener.addListener(EventType.onCalloutJoinSuccess, (data) async { -// data = data as Map; -// String phoneNumber = data['phoneNumber']; -// ZoomVideoSdkUser? user = ZoomVideoSdkUser.fromJson(jsonDecode(data['user'])); -// debugPrint('onCalloutJoinSuccess: phoneNumber= $phoneNumber, user= ${user.userName}'); -// }); -// -// return () => { -// sessionJoinListener.cancel(), -// sessionLeaveListener.cancel(), -// sessionPasswordWrongListener.cancel(), -// sessionNeedPasswordListener.cancel(), -// userVideoStatusChangedListener.cancel(), -// userAudioStatusChangedListener.cancel(), -// userJoinListener.cancel(), -// userLeaveListener.cancel(), -// userNameChangedListener.cancel(), -// userShareStatusChangeListener.cancel(), -// liveStreamStatusChangeListener.cancel(), -// cloudRecordingStatusListener.cancel(), -// inviteByPhoneStatusListener.cancel(), -// eventErrorListener.cancel(), -// commandReceived.cancel(), -// liveTranscriptionStatusChangeListener.cancel(), -// liveTranscriptionMsgInfoReceivedListener.cancel(), -// multiCameraStreamStatusChangedListener.cancel(), -// requireSystemPermission.cancel(), -// userRecordingConsentListener.cancel(), -// networkStatusChangeListener.cancel(), -// callCRCDeviceStatusListener.cancel(), -// originalLanguageMsgReceivedListener.cancel(), -// chatPrivilegeChangedListener.cancel(), -// testMicStatusListener.cancel(), -// micSpeakerVolumeChangedListener.cancel(), -// cameraControlRequestResultListener.cancel(), -// callOutUserJoinListener.cancel(), -// shareContentChangedListener.cancel(), -// }; -// }, [zoom, users.value, isMounted]); -// -// void selectVirtualBackgroundItem() async { -// final ImagePicker picker = ImagePicker(); -// // Pick an image. -// final XFile? image = await picker.pickImage(source: ImageSource.gallery); -// await zoom.virtualBackgroundHelper.addVirtualBackgroundItem(image!.path); -// } -// -// void onPressAudio() async { -// ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); -// if (mySelf != null) { -// final audioStatus = mySelf.audioStatus; -// if (audioStatus != null) { -// var muted = await audioStatus.isMuted(); -// if (muted) { -// await zoom.audioHelper.unMuteAudio(mySelf.userId); -// } else { -// await zoom.audioHelper.muteAudio(mySelf.userId); -// } -// } -// } -// } -// -// void onPressVideo() async { -// ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); -// if (mySelf != null) { -// final videoStatus = mySelf.videoStatus; -// if (videoStatus != null) { -// var videoOn = await videoStatus.isOn(); -// if (videoOn) { -// await zoom.videoHelper.stopVideo(); -// } else { -// await zoom.videoHelper.startVideo(); -// } -// } -// } -// } -// -// void onPressShare() async { -// var isOtherSharing = await zoom.shareHelper.isOtherSharing(); -// var isShareLocked = await zoom.shareHelper.isShareLocked(); -// String? shareCameraViewResult = Errors.InternalError; -// -// if (isOtherSharing) { -// showDialog( -// context: context, -// builder: (BuildContext context) => AlertDialog( -// title: const Text("Error"), -// content: const Text('Other is sharing'), -// actions: [ -// TextButton( -// onPressed: () => Navigator.pop(context, 'OK'), -// child: const Text('OK'), -// ), -// ], -// ), -// ); -// } else if (isShareLocked) { -// showDialog( -// context: context, -// builder: (BuildContext context) => AlertDialog( -// title: const Text("Error"), -// content: const Text('Share is locked by host'), -// actions: [ -// TextButton( -// onPressed: () => Navigator.pop(context, 'OK'), -// child: const Text('OK'), -// ), -// ], -// ), -// ); -// } else if (isSharing.value) { -// zoom.shareHelper.stopShare(); -// } else { -// List options = [ -// ListTile( -// title: Text( -// 'Share Device Screen', -// style: TextStyle( -// fontSize: 14, -// fontWeight: FontWeight.normal, -// color: Colors.black, -// ), -// ), -// onTap: () async => { -// zoom.shareHelper.shareScreen(), -// Navigator.of(context).pop(), -// }, -// ), -// ListTile( -// title: Text( -// 'Share Camera', -// style: TextStyle( -// fontSize: 14, -// fontWeight: FontWeight.normal, -// color: Colors.black, -// ), -// ), -// onTap: () async => { -// shareCameraViewResult = await zoom.shareHelper.startShareCamera(cameraShareView), -// debugPrint('start camera: $shareCameraViewResult'), -// Navigator.of(context).pop(), -// }, -// ), -// ]; -// 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(), -// ), -// ), -// ), -// ); -// }); -// } -// } -// -// void onSelectedUserVolume(ZoomVideoSdkUser user) async { -// var isShareAudio = user.isSharing; -// bool canSetVolume = await user.canSetUserVolume(user.userId, isShareAudio); -// num userVolume; -// -// List options = [ -// ListTile( -// title: Text( -// 'Adjust Volume', -// style: const TextStyle( -// fontSize: 18, -// fontWeight: FontWeight.w600, -// color: Colors.black, -// ), -// ), -// ), -// ListTile( -// title: Text( -// 'Current volume', -// style: const TextStyle( -// fontSize: 14, -// fontWeight: FontWeight.normal, -// color: Colors.black, -// ), -// ), -// onTap: () async => { -// debugPrint('user volume'), -// userVolume = await user.getUserVolume(user.userId, isShareAudio), -// debugPrint('user ${user.userName}\'s volume is ${userVolume!}'), -// }, -// ), -// ]; -// if (canSetVolume) { -// options.add( -// ListTile( -// title: Text( -// 'Volume up', -// style: const TextStyle( -// fontSize: 14, -// fontWeight: FontWeight.normal, -// color: Colors.black, -// ), -// ), -// onTap: () async => { -// userVolume = await user.getUserVolume(user.userId, isShareAudio), -// if (userVolume < 10) -// { -// await user.setUserVolume(user.userId, userVolume + 1, isShareAudio), -// } -// else -// { -// debugPrint("Cannot volume up."), -// } -// }, -// ), -// ); -// options.add( -// ListTile( -// title: Text( -// 'Volume down', -// style: const TextStyle( -// fontSize: 14, -// fontWeight: FontWeight.normal, -// color: Colors.black, -// ), -// ), -// onTap: () async => { -// userVolume = await user.getUserVolume(user.userId, isShareAudio), -// if (userVolume > 0) -// { -// await user.setUserVolume(user.userId, userVolume - 1, isShareAudio), -// } -// else -// { -// debugPrint("Cannot volume down."), -// } -// }, -// ), -// ); -// } -// 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 * 58, -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.stretch, -// children: [ -// ListView( -// shrinkWrap: true, -// children: ListTile.divideTiles( -// context: context, -// tiles: options, -// ).toList(), -// ), -// ], -// ), -// )); -// }); -// } -// -// void onPressCameraList() async { -// List options = []; -// List 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(), -// }, -// ), -// ); -// 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(), -// ), -// ), -// ), -// ); -// }); -// } -// -// // Future onPressMore() async { -// // ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); -// // bool isShareLocked = await zoom.shareHelper.isShareLocked(); -// // bool canSwitchSpeaker = await zoom.audioHelper.canSwitchSpeaker(); -// // bool canStartRecording = (await zoom.recordingHelper.canStartRecording()) == Errors.Success; -// // debugPrint("canStartRecording ${await zoom.recordingHelper.canStartRecording()}"); -// // var startLiveTranscription = (await zoom.liveTranscriptionHelper.getLiveTranscriptionStatus()) == LiveTranscriptionStatus.Start; -// // bool canStartLiveTranscription = await zoom.liveTranscriptionHelper.canStartLiveTranscription(); -// // bool isHost = (mySelf != null) ? (await mySelf.getIsHost()) : false; -// // isOriginalAspectRatio.value = await zoom.videoHelper.isOriginalAspectRatioEnabled(); -// // bool canCallOutToCRC = await zoom.CRCHelper.isCRCEnabled(); -// // bool supportVB = await zoom.virtualBackgroundHelper.isSupportVirtualBackground(); -// // List? shareActionList = await mySelf?.getShareActionList(); -// // -// // List options = [ -// // ListTile( -// // title: Text( -// // 'More', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 18, -// // fontWeight: FontWeight.w600, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // ), -// // ListTile( -// // title: Text( -// // 'Get Chat Privilege', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // debugPrint("Chat Privilege = ${await zoom.chatHelper.getChatPrivilege()}"), -// // Navigator.of(context).pop(), -// // }, -// // ), -// // ListTile( -// // title: Text( -// // 'Get Session Dial-in Number infos', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // debugPrint("session number = ${await zoom.session.getSessionNumber()}"), -// // Navigator.of(context).pop(), -// // }, -// // ), -// // ListTile( -// // title: Text( -// // 'Get Camera List', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // debugPrint("camera list= ${await zoom.videoHelper.getCameraList()}"), -// // onPressCameraList(), -// // Navigator.of(context).pop(), -// // }, -// // ), -// // ListTile( -// // title: Text( -// // '${isMicOriginalOn.value ? 'Disable' : 'Enable'} Original Sound', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // debugPrint("${isMicOriginalOn.value}"), -// // await zoom.audioSettingHelper.enableMicOriginalInput(!isMicOriginalOn.value), -// // isMicOriginalOn.value = await zoom.audioSettingHelper.isMicOriginalInputEnable(), -// // debugPrint("Original sound ${isMicOriginalOn.value ? 'Enabled' : 'Disabled'}"), -// // Navigator.of(context).pop(), -// // }, -// // ) -// // ]; -// // -// // if (supportVB) { -// // options.add( -// // ListTile( -// // title: Text( -// // 'Add Virtual Background', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // selectVirtualBackgroundItem(), -// // Navigator.of(context).pop(), -// // }, -// // ), -// // ); -// // } -// // -// // if (canCallOutToCRC) { -// // options.add(ListTile( -// // title: Text( -// // 'Call-out to CRC devices', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // debugPrint('CRC result = ${await zoom.CRCHelper.callCRCDevice("bjn.vc", ZoomVideoSdkCRCProtocolType.SIP)}'), -// // Navigator.of(context).pop(), -// // }, -// // )); -// // options.add(ListTile( -// // title: Text( -// // 'Cancel call-out to CRC devices', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // debugPrint('cancel result= ${await zoom.CRCHelper.cancelCallCRCDevice()}'), -// // Navigator.of(context).pop(), -// // }, -// // )); -// // } -// // -// // if (canSwitchSpeaker) { -// // options.add(ListTile( -// // title: Text( -// // 'Turn ${isSpeakerOn.value ? 'off' : 'on'} Speaker', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // await zoom.audioHelper.setSpeaker(!isSpeakerOn.value), -// // isSpeakerOn.value = await zoom.audioHelper.getSpeakerStatus(), -// // debugPrint('Turned ${isSpeakerOn.value ? 'on' : 'off'} Speaker'), -// // Navigator.of(context).pop(), -// // }, -// // )); -// // } -// // -// // if (isHost) { -// // options.add(ListTile( -// // title: Text( -// // '${isShareLocked ? 'Unlock' : 'Lock'} Share', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // debugPrint("isShareLocked = ${await zoom.shareHelper.lockShare(!isShareLocked)}"), -// // Navigator.of(context).pop(), -// // })); -// // options.add(ListTile( -// // title: Text( -// // 'Change Name', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () => { -// // isRenameModalVisible.value = true, -// // Navigator.of(context).pop(), -// // }, -// // )); -// // } -// // -// // if (canStartLiveTranscription) { -// // options.add(ListTile( -// // title: Text( -// // "${startLiveTranscription ? 'Stop' : 'Start'} Live Transcription", -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // if (startLiveTranscription) -// // { -// // debugPrint('stopLiveTranscription= ${await zoom.liveTranscriptionHelper.stopLiveTranscription()}'), -// // } -// // else -// // { -// // debugPrint('startLiveTranscription= ${await zoom.liveTranscriptionHelper.startLiveTranscription()}'), -// // }, -// // Navigator.of(context).pop(), -// // }, -// // )); -// // options.add(ListTile( -// // title: Text( -// // '${isReceiveSpokenLanguageContentEnabled.value ? 'Disable' : 'Enable'} receiving original caption', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // await zoom.liveTranscriptionHelper.enableReceiveSpokenLanguageContent(!isReceiveSpokenLanguageContentEnabled.value), -// // isReceiveSpokenLanguageContentEnabled.value = await zoom.liveTranscriptionHelper.isReceiveSpokenLanguageContentEnabled(), -// // debugPrint("isReceiveSpokenLanguageContentEnabled = ${isReceiveSpokenLanguageContentEnabled.value}"), -// // Navigator.of(context).pop(), -// // })); -// // } -// // -// // if (canStartRecording) { -// // options.add(ListTile( -// // title: Text( -// // '${isRecordingStarted.value ? 'Stop' : 'Start'} Recording', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // if (!isRecordingStarted.value) -// // { -// // debugPrint('isRecordingStarted = ${await zoom.recordingHelper.startCloudRecording()}'), -// // } -// // else -// // { -// // debugPrint('isRecordingStarted = ${await zoom.recordingHelper.stopCloudRecording()}'), -// // }, -// // Navigator.of(context).pop(), -// // })); -// // } -// // -// // if (Platform.isAndroid) { -// // bool isFlashlightSupported = await zoom.videoHelper.isSupportFlashlight(); -// // bool isFlashlightOn = await zoom.videoHelper.isFlashlightOn(); -// // if (isFlashlightSupported) { -// // options.add(ListTile( -// // title: Text( -// // '${isFlashlightOn ? 'Turn Off' : 'Turn On'} Flashlight', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // if (!isFlashlightOn) -// // { -// // await zoom.videoHelper.turnOnOrOffFlashlight(true), -// // } -// // else -// // { -// // await zoom.videoHelper.turnOnOrOffFlashlight(false), -// // }, -// // Navigator.of(context).pop(), -// // })); -// // } -// // } -// // -// // if (Platform.isIOS) { -// // options.add(ListTile( -// // title: Text( -// // '${isPiPView.value ? 'Disable' : 'Enable'} picture in picture view', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // isPiPView.value = !isPiPView.value, -// // Navigator.of(context).pop(), -// // })); -// // } -// // -// // if (isVideoOn.value) { -// // options.add(ListTile( -// // title: Text( -// // 'Mirror the video', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // await zoom.videoHelper.mirrorMyVideo(!isVideoMirrored.value), -// // isVideoMirrored.value = await zoom.videoHelper.isMyVideoMirrored(), -// // Navigator.of(context).pop(), -// // })); -// // options.add(ListTile( -// // title: Text( -// // '${isOriginalAspectRatio.value ? 'Enable' : 'Disable'} original aspect ratio', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.normal, -// // color: Colors.black, -// // ), -// // ), -// // ), -// // onTap: () async => { -// // await zoom.videoHelper.enableOriginalAspectRatio(!isOriginalAspectRatio.value), -// // isOriginalAspectRatio.value = await zoom.videoHelper.isOriginalAspectRatioEnabled(), -// // debugPrint("isOriginalAspectRatio= ${isOriginalAspectRatio.value}"), -// // Navigator.of(context).pop(), -// // })); -// // } -// // -// // 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: 500, -// // child: Scrollbar( -// // child: ListView( -// // shrinkWrap: true, -// // scrollDirection: Axis.vertical, -// // children: ListTile.divideTiles( -// // context: context, -// // tiles: options, -// // ).toList(), -// // ), -// // ), -// // ), -// // ); -// // }); -// // } -// -// void onLeaveSession(bool isEndSession) async { -// await zoom.leaveSession(isEndSession); -// Navigator.pushAndRemoveUntil( -// context, -// CustomPageRoute( -// page: LandingNavigation(), -// ), -// (r) => false); -// } -// -// void showLeaveOptions() async { -// ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); -// bool isHost = await mySelf!.getIsHost(); -// -// Widget endSession; -// Widget leaveSession; -// Widget cancel = TextButton( -// child: const Text('Cancel'), -// onPressed: () { -// Navigator.pop(context); //close Dialog -// }, -// ); -// -// switch (defaultTargetPlatform) { -// case TargetPlatform.android: -// endSession = TextButton( -// child: const Text('End Session'), -// onPressed: () => onLeaveSession(true), -// ); -// leaveSession = TextButton( -// child: const Text('Leave Session'), -// onPressed: () => onLeaveSession(false), -// ); -// break; -// default: -// endSession = CupertinoActionSheetAction( -// isDestructiveAction: true, -// child: const Text('End Session'), -// onPressed: () => onLeaveSession(true), -// ); -// leaveSession = CupertinoActionSheetAction( -// child: const Text('Leave Session'), -// onPressed: () => onLeaveSession(false), -// ); -// break; -// } -// -// List options = [ -// leaveSession, -// cancel, -// ]; -// -// if (Platform.isAndroid) { -// if (isHost) { -// options.removeAt(1); -// options.insert(0, endSession); -// } -// showDialog( -// context: context, -// builder: (context) { -// return AlertDialog( -// content: const Text("Do you want to leave this session?"), -// shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(2.0))), -// actions: options, -// ); -// }); -// } else { -// options.removeAt(1); -// if (isHost) { -// options.insert(1, endSession); -// } -// showCupertinoModalPopup( -// context: context, -// builder: (context) => CupertinoActionSheet( -// message: const Text('Are you sure that you want to leave the session?'), -// actions: options, -// cancelButton: cancel, -// ), -// ); -// } -// } -// -// final chatMessageController = TextEditingController(); -// -// void sendChatMessage(String message) async { -// await zoom.chatHelper.sendChatToAll(message); -// ZoomVideoSdkUser? self = await zoom.session.getMySelf(); -// ZoomVideoSdkCmdChannel cmdChannel = zoom.cmdChannel; -// for (var user in users.value) { -// if (user.userId != self?.userId) { -// await zoom.cmdChannel.sendCommand(user.userId, message); -// } -// } -// chatMessageController.clear(); -// // send the chat as a command -// } -// -// void onSelectedUser(ZoomVideoSdkUser user) async { -// setState(() { -// fullScreenUser.value = user; -// }); -// } -// -// changeNamePopup = Center( -// child: Stack( -// children: [ -// Visibility( -// visible: isRenameModalVisible.value, -// child: Row( -// mainAxisSize: MainAxisSize.min, -// children: [ -// Container( -// alignment: Alignment.bottomLeft, -// decoration: const BoxDecoration( -// borderRadius: BorderRadius.all(Radius.circular(10)), -// color: Colors.white, -// ), -// width: MediaQuery.of(context).size.width - 130, -// height: MediaQuery.of(context).size.height * 0.2, -// child: Center( -// child: (Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// Padding( -// padding: const EdgeInsets.only(top: 20, left: 20), -// child: Text( -// 'Change Name', -// style: const TextStyle( -// fontSize: 18, -// fontWeight: FontWeight.w500, -// ), -// ), -// ), -// Padding( -// padding: const EdgeInsets.only(top: 10, left: 20), -// child: SizedBox( -// width: MediaQuery.of(context).size.width - 230, -// child: TextField( -// onEditingComplete: () {}, -// autofocus: true, -// cursorColor: Colors.black, -// controller: changeNameController, -// decoration: InputDecoration( -// isDense: true, -// hintText: 'New name', -// hintStyle: TextStyle( -// fontSize: 14.0, -// color: chatTextColor, -// ), -// ), -// ), -// ), -// ), -// Padding( -// padding: const EdgeInsets.only(top: 15), -// child: Row( -// children: [ -// Padding( -// padding: const EdgeInsets.only(left: 40), -// child: InkWell( -// child: Text( -// 'Apply', -// style: const TextStyle( -// fontSize: 16, -// ), -// ), -// onTap: () async { -// if (fullScreenUser.value != null) { -// ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); -// await zoom.userHelper.changeName((mySelf?.userId)!, changeNameController.text); -// changeNameController.clear(); -// } -// isRenameModalVisible.value = false; -// }, -// ), -// ), -// Padding( -// padding: const EdgeInsets.only(left: 40), -// child: InkWell( -// child: Text( -// 'Cancel', -// style: const TextStyle( -// fontSize: 16, -// ), -// ), -// onTap: () async { -// isRenameModalVisible.value = false; -// }, -// ), -// ) -// ], -// ), -// ) -// ], -// )), -// ), -// ), -// ], -// )), -// ], -// ), -// ); -// -// Widget fullScreenView; -// Widget smallView; -// Widget cameraView; -// -// if (isInSession.value && fullScreenUser.value != null && users.value.isNotEmpty) { -// fullScreenView = AnimatedOpacity( -// opacity: opacityLevel, -// duration: const Duration(seconds: 3), -// child: VideoView( -// user: users.value.length > 1 ? users.value[1] : users.value[0], -// hasMultiCamera: false, -// isPiPView: isPiPView.value, -// sharing: sharingUser.value == null ? false : (sharingUser.value?.userId == fullScreenUser.value?.userId), -// preview: false, -// focused: false, -// multiCameraIndex: "0", -// videoAspect: VideoAspect.Original, -// fullScreen: true, -// resolution: VideoResolution.Resolution360, -// ), -// ); -// -// smallView = Container( -// height: 110, -// margin: const EdgeInsets.only(left: 20, right: 20), -// alignment: Alignment.center, -// child: ListView.separated( -// scrollDirection: Axis.horizontal, -// itemCount: users.value.length, -// itemBuilder: (BuildContext context, int index) { -// return InkWell( -// onTap: () async { -// onSelectedUser(users.value[index]); -// }, -// onDoubleTap: () async { -// onSelectedUserVolume(users.value[index]); -// }, -// child: Center( -// child: VideoView( -// user: users.value[index], -// hasMultiCamera: false, -// isPiPView: false, -// sharing: false, -// preview: false, -// focused: false, -// multiCameraIndex: "0", -// videoAspect: VideoAspect.Original, -// fullScreen: false, -// resolution: VideoResolution.Resolution180, -// ), -// ), -// ); -// }, -// separatorBuilder: (BuildContext context, int index) => const Divider(), -// ), -// ); -// } else { -// fullScreenView = Container( -// color: Colors.black, -// child: const Center( -// child: Text( -// "Connecting...", -// style: TextStyle( -// fontSize: 20, -// color: Colors.white, -// ), -// ), -// )); -// smallView = Container( -// height: 110, -// color: Colors.transparent, -// ); -// } -// -// cameraView = Offstage( -// offstage: !isSharedCamera.value, -// child: AnimatedOpacity( -// opacity: isSharedCamera.value ? 1.0 : 0.0, -// duration: const Duration(milliseconds: 300), -// child: cameraShareView, -// ), -// ); -// -// _changeOpacity; -// return Scaffold( -// resizeToAvoidBottomInset: false, -// backgroundColor: backgroundColor, -// body: Stack( -// children: [ -// // isScreenBeingShared ? fullScreenView : SizedBox.shrink(), -// isScreenBeingShared ? SizedBox.shrink() : fullScreenView, -// cameraView, -// Container( -// padding: const EdgeInsets.only(top: 35), -// child: Stack( -// children: [ -// Row( -// crossAxisAlignment: CrossAxisAlignment.start, -// mainAxisAlignment: MainAxisAlignment.spaceBetween, -// children: [ -// Container( -// height: 80, -// width: 180, -// margin: const EdgeInsets.only(top: 16, left: 8), -// padding: const EdgeInsets.all(8), -// alignment: Alignment.topLeft, -// decoration: BoxDecoration( -// borderRadius: const BorderRadius.all(Radius.circular(8.0)), -// // color: buttonBackgroundColor, -// ), -// // child: InkWell( -// // onTap: () async { -// // showDialog( -// // context: context, -// // builder: (context) { -// // return Dialog( -// // elevation: 0.0, -// // insetPadding: const EdgeInsets.symmetric(horizontal: 40), -// // shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), -// // child: FractionallySizedBox( -// // heightFactor: 0.2, -// // widthFactor: 0.3, -// // child: Column( -// // crossAxisAlignment: CrossAxisAlignment.stretch, -// // children: [ -// // ListView( -// // shrinkWrap: true, -// // children: ListTile.divideTiles( -// // context: context, -// // tiles: [ -// // ListTile( -// // title: Text( -// // 'Session Information', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 18, -// // fontWeight: FontWeight.w600, -// // ), -// // ), -// // ), -// // ), -// // ListTile( -// // title: Text( -// // 'Session Name', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // ), -// // ), -// // ), -// // subtitle: Text( -// // sessionName.value, -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 12, -// // ), -// // ), -// // ), -// // ), -// // ListTile( -// // title: Text( -// // 'Session Password', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // ), -// // ), -// // ), -// // subtitle: Text( -// // sessionPassword.value, -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 12, -// // ), -// // ), -// // ), -// // ), -// // ListTile( -// // title: Text( -// // 'Participants', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // ), -// // ), -// // ), -// // subtitle: Text( -// // '${users.value.length}', -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 12, -// // ), -// // ), -// // ), -// // ), -// // ], -// // ).toList(), -// // ), -// // ], -// // ), -// // )); -// // }); -// // }, -// // child: Stack( -// // children: [ -// // Column( -// // children: [ -// // const Padding(padding: EdgeInsets.symmetric(vertical: 4)), -// // Align( -// // alignment: Alignment.centerLeft, -// // child: Text( -// // sessionName.value, -// // overflow: TextOverflow.ellipsis, -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.w600, -// // color: Colors.white, -// // ), -// // ), -// // ), -// // ), -// // const Padding(padding: EdgeInsets.symmetric(vertical: 5)), -// // Align( -// // alignment: Alignment.centerLeft, -// // child: Text( -// // "Participants: ${users.value.length}", -// // style: GoogleFonts.lato( -// // textStyle: const TextStyle( -// // fontSize: 14, -// // fontWeight: FontWeight.w600, -// // color: Colors.white, -// // ), -// // ), -// // ), -// // ) -// // ], -// // ), -// // Container( -// // alignment: Alignment.centerRight, -// // child: Image.asset( -// // "assets/icons/unlocked@2x.png", -// // height: 22, -// // )), -// // ], -// // ), -// // ), -// ), -// TextButton( -// onPressed: (showLeaveOptions), -// child: Container( -// alignment: Alignment.topRight, -// margin: const EdgeInsets.only(top: 16, right: 8), -// padding: const EdgeInsets.only(top: 5, bottom: 5, left: 16, right: 16), -// height: 28, -// decoration: BoxDecoration( -// borderRadius: const BorderRadius.all(Radius.circular(20.0)), -// color: buttonBackgroundColor, -// ), -// child: const Text( -// "LEAVE", -// style: TextStyle( -// fontSize: 14, -// fontWeight: FontWeight.bold, -// color: Color(0xFFE02828), -// ), -// ), -// )), -// ], -// ), -// Align( -// alignment: Alignment.centerRight, -// child: FractionallySizedBox( -// widthFactor: 0.2, -// heightFactor: 0.6, -// child: Column( -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// IconButton( -// onPressed: onPressAudio, -// icon: isMuted.value ? Image.asset("assets/images/png/zoom/unmute@2x.png") : Image.asset("assets/images/png/zoom/mute@2x.png"), -// iconSize: circleButtonSize, -// tooltip: isMuted.value == true ? "Unmute" : "Mute", -// ), -// IconButton( -// onPressed: onPressShare, -// icon: isSharing.value ? Image.asset("assets/images/png/zoom/share-off@2x.png") : Image.asset("assets/images/png/zoom/share-on@2x.png"), -// iconSize: circleButtonSize, -// ), -// IconButton( -// onPressed: onPressVideo, -// iconSize: circleButtonSize, -// icon: isVideoOn.value ? Image.asset("assets/images/png/zoom/video-off@2x.png") : Image.asset("assets/images/png/zoom/video-on@2x.png"), -// ), -// Column( -// children: [ -// IconButton( -// onPressed: () async { -// onPressCameraList(); -// }, -// icon: Icon(Icons.cameraswitch, color: Colors.white), -// color: Colors.white, -// iconSize: 40.h, -// ), -// "Switch Camera".toText12(color: AppColors.whiteColor, isCenter: true, isBold: true) -// ], -// ), -// ], -// ), -// )), -// Container( -// margin: const EdgeInsets.only(left: 16, right: 16, bottom: 40, top: 10), -// alignment: Alignment.bottomCenter, -// child: SizedBox( -// height: MediaQuery.of(context).viewInsets.bottom == 0 ? 65 : MediaQuery.of(context).viewInsets.bottom + 18, -// child: TextField( -// maxLines: 1, -// textAlign: TextAlign.left, -// style: TextStyle(color: chatTextColor), -// cursorColor: chatTextColor, -// textAlignVertical: TextAlignVertical.center, -// controller: chatMessageController, -// decoration: InputDecoration( -// contentPadding: const EdgeInsets.only(left: 16, top: 10, bottom: 10, right: 16), -// enabledBorder: OutlineInputBorder( -// borderSide: BorderSide(width: 1, color: chatTextColor), //<-- SEE HERE -// ), -// hintText: 'Type your message here...', -// hintStyle: TextStyle( -// fontSize: 14.0, -// color: chatTextColor, -// ), -// ), -// onSubmitted: (String str) { -// sendChatMessage(str); -// }, -// ), -// ), -// ), -// Container( -// alignment: Alignment.bottomLeft, -// margin: const EdgeInsets.only(bottom: 120), -// child: smallView, -// ), -// // CommentList(zoom: zoom, eventListener: eventListener), -// changeNamePopup, -// ], -// )), -// ], -// )); -// } -// } -// -// class CallArguments { -// final bool isJoin; -// final String sessionName; -// final String sessionPwd; -// final String displayName; -// final String sessionIdleTimeoutMins; -// final String role; -// final int callType; -// -// CallArguments(this.sessionName, this.sessionPwd, this.displayName, this.sessionIdleTimeoutMins, this.role, this.isJoin, this.callType); -// } -// -// class JoinArguments { -// final bool isJoin; -// final String sessionName; -// final String sessionPwd; -// final String displayName; -// final String sessionTimeout; -// final String roleType; -// -// JoinArguments(this.isJoin, this.sessionName, this.sessionPwd, this.displayName, this.sessionTimeout, this.roleType); -// } +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:flutter_ios_voip_kit_karmm/flutter_ios_voip_kit.dart'; +import 'package:flutter_zoom_videosdk/flutter_zoom_view.dart'; +import 'package:flutter_zoom_videosdk/native/zoom_videosdk.dart'; +import 'package:flutter_zoom_videosdk/native/zoom_videosdk_camera_device.dart'; +import 'package:flutter_zoom_videosdk/native/zoom_videosdk_cmd_channel.dart'; +import 'package:flutter_zoom_videosdk/native/zoom_videosdk_event_listener.dart'; +import 'package:flutter_zoom_videosdk/native/zoom_videosdk_live_transcription_message_info.dart'; +import 'package:flutter_zoom_videosdk/native/zoom_videosdk_share_action.dart'; +import 'package:flutter_zoom_videosdk/native/zoom_videosdk_user.dart'; +import 'package:hmg_patient_app_new/core/app_export.dart'; +import 'package:hmg_patient_app_new/core/cache_consts.dart'; +import 'package:hmg_patient_app_new/core/utils/jwt.dart'; +import 'package:hmg_patient_app_new/core/utils/utils.dart'; +import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; +import 'package:hmg_patient_app_new/presentation/home/navigation_screen.dart'; +import 'package:hmg_patient_app_new/presentation/tele_consultation/zoom/video_view.dart'; +import 'package:hmg_patient_app_new/theme/colors.dart'; +import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart'; +import 'package:image_picker/image_picker.dart'; + +class CallScreen extends StatefulHookWidget { + const CallScreen({Key? key}) : super(key: key); + + @override + State createState() => _CallScreenState(); +} + +class _CallScreenState extends State { + static TextEditingController changeNameController = TextEditingController(); + double opacityLevel = 1.0; + + final voIPKit = FlutterIOSVoIPKit.instance; + + bool isScreenBeingShared = false; + + void _changeOpacity() { + setState(() => opacityLevel = opacityLevel == 0 ? 1.0 : 0.0); + } + + @override + Widget build(BuildContext context) { + var zoom = ZoomVideoSdk(); + var eventListener = ZoomVideoSdkEventListener(); + var isInSession = useState(false); + var sessionName = useState(''); + var sessionPassword = useState(''); + var users = useState([]); + var fullScreenUser = useState(null); + var sharingUser = useState(null); + var videoInfo = useState(''); + var isSharing = useState(false); + var isMuted = useState(true); + var isVideoOn = useState(false); + var isSpeakerOn = useState(false); + var isRenameModalVisible = useState(false); + var isRecordingStarted = useState(false); + var isMicOriginalOn = useState(false); + var isMounted = useIsMounted(); + var audioStatusFlag = useState(false); + var videoStatusFlag = useState(false); + var userNameFlag = useState(false); + var userShareStatusFlag = useState(false); + var isReceiveSpokenLanguageContentEnabled = useState(false); + var isVideoMirrored = useState(false); + var isOriginalAspectRatio = useState(false); + var isPiPView = useState(false); + var isSharedCamera = useState(false); + CameraShareView cameraShareView = const CameraShareView(creationParams: {}); + + //hide status bar + SystemChrome.setEnabledSystemUIMode(SystemUiMode.leanBack); + var circleButtonSize = 65.0; + Color backgroundColor = const Color(0xFF232323); + Color buttonBackgroundColor = const Color.fromRGBO(0, 0, 0, 0.6); + Color chatTextColor = const Color(0xFFAAAAAA); + Widget changeNamePopup; + final args = ModalRoute.of(context)!.settings.arguments as CallArguments; + + useEffect(() { + Future.microtask(() async { + var token = generateJwt(args.sessionName, args.role); + + Utils.removeFromPrefs(CacheConst.isAppOpenedFromCall); + + try { + Map SDKaudioOptions = {"connect": true, "mute": false, "autoAdjustSpeakerVolume": false}; + Map SDKvideoOptions = { + "localVideoOn": true, + }; + JoinSessionConfig joinSession = JoinSessionConfig( + sessionName: args.sessionName, + sessionPassword: args.sessionPwd, + token: token, + userName: args.displayName, + audioOptions: SDKaudioOptions, + videoOptions: SDKvideoOptions, + sessionIdleTimeoutMins: int.parse(args.sessionIdleTimeoutMins), + ); + await zoom.joinSession(joinSession); + } catch (e) { + const AlertDialog( + title: Text("Error"), + content: Text("Failed to join the session"), + ); + Future.delayed(const Duration(milliseconds: 1000)).asStream().listen((event) { + Navigator.pushAndRemoveUntil( + context, + CustomPageRoute( + page: LandingNavigation(), + ), + (r) => false); + }); + } + }); + return null; + }, []); + + useEffect(() { + final sessionJoinListener = eventListener.addListener(EventType.onSessionJoin, (data) async { + data = data as Map; + isInSession.value = true; + zoom.session.getSessionName().then((value) => sessionName.value = value!); + sessionPassword.value = await zoom.session.getSessionPassword(); + debugPrint("sessionPhonePasscode: ${await zoom.session.getSessionPhonePasscode()}"); + ZoomVideoSdkUser mySelf = ZoomVideoSdkUser.fromJson(jsonDecode(data['sessionUser'])); + List? remoteUsers = await zoom.session.getRemoteUsers(); + var muted = await mySelf.audioStatus?.isMuted(); + var videoOn = await mySelf.videoStatus?.isOn(); + var speakerOn = await zoom.audioHelper.getSpeakerStatus(); + fullScreenUser.value = mySelf; + remoteUsers?.insert(0, mySelf); + isMuted.value = muted!; + isSpeakerOn.value = speakerOn; + isVideoOn.value = videoOn!; + users.value = remoteUsers!; + isReceiveSpokenLanguageContentEnabled.value = await zoom.liveTranscriptionHelper.isReceiveSpokenLanguageContentEnabled(); + }); + + final sessionLeaveListener = eventListener.addListener(EventType.onSessionLeave, (data) async { + data = data as Map; + debugPrint("onSessionLeave: ${data['reason']}"); + isInSession.value = false; + users.value = []; + fullScreenUser.value = null; + // Navigator.popAndPushNamed( + // context, + // "Join", + // arguments: JoinArguments(args.isJoin, sessionName.value, sessionPassword.value, args.displayName, args.sessionIdleTimeoutMins, args.role), + // ); + Navigator.pushAndRemoveUntil( + context, + CustomPageRoute( + page: LandingNavigation(), + ), + (r) => false); + }); + + final sessionNeedPasswordListener = eventListener.addListener(EventType.onSessionNeedPassword, (data) async { + showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text('Session Need Password'), + content: const Text('Password is required'), + actions: [ + TextButton( + onPressed: () async => { + Navigator.pushAndRemoveUntil( + context, + CustomPageRoute( + page: LandingNavigation(), + ), + (r) => false), + await zoom.leaveSession(false), + }, + child: const Text('OK'), + ), + ], + ), + ); + }); + + final sessionPasswordWrongListener = eventListener.addListener(EventType.onSessionPasswordWrong, (data) async { + showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text('Session Password Incorrect'), + content: const Text('Password is wrong'), + actions: [ + TextButton( + onPressed: () async => { + Navigator.popAndPushNamed(context, 'Join', arguments: JoinArguments(args.isJoin, args.sessionName, "", args.displayName, args.sessionIdleTimeoutMins, args.role)), + await zoom.leaveSession(false), + }, + child: const Text('OK'), + ), + ], + ), + ); + }); + + final userVideoStatusChangedListener = eventListener.addListener(EventType.onUserVideoStatusChanged, (data) async { + data = data as Map; + ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); + var userListJson = jsonDecode(data['changedUsers']) as List; + List userList = userListJson.map((userJson) => ZoomVideoSdkUser.fromJson(userJson)).toList(); + for (var user in userList) { + { + if (user.userId == mySelf?.userId) { + mySelf?.videoStatus?.isOn().then((on) => isVideoOn.value = on); + } + } + } + videoStatusFlag.value = !videoStatusFlag.value; + }); + + final userAudioStatusChangedListener = eventListener.addListener(EventType.onUserAudioStatusChanged, (data) async { + data = data as Map; + ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); + var userListJson = jsonDecode(data['changedUsers']) as List; + List userList = userListJson.map((userJson) => ZoomVideoSdkUser.fromJson(userJson)).toList(); + for (var user in userList) { + { + if (user.userId == mySelf?.userId) { + mySelf?.audioStatus?.isMuted().then((muted) => isMuted.value = muted); + } + } + } + audioStatusFlag.value = !audioStatusFlag.value; + }); + + final userShareStatusChangeListener = eventListener.addListener(EventType.onUserShareStatusChanged, (data) async { + data = data as Map; + ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); + ZoomVideoSdkUser shareUser = ZoomVideoSdkUser.fromJson(jsonDecode(data['user'].toString())); + ZoomVideoSdkShareAction? shareAction = ZoomVideoSdkShareAction.fromJson(jsonDecode(data['shareAction'])); + + if (shareAction.shareStatus == ShareStatus.Start || shareAction.shareStatus == ShareStatus.Resume) { + sharingUser.value = shareUser; + fullScreenUser.value = shareUser; + isSharing.value = (shareUser.userId == mySelf?.userId); + + setState(() { + isScreenBeingShared = true; + }); + Future.delayed(const Duration(seconds: 2), () { + setState(() { + isScreenBeingShared = false; + }); + }); + } else { + sharingUser.value = null; + isSharing.value = false; + isSharedCamera.value = false; + fullScreenUser.value = mySelf; + isScreenBeingShared = false; + setState(() { + isScreenBeingShared = true; + }); + Future.delayed(const Duration(seconds: 2), () { + setState(() { + isScreenBeingShared = false; + }); + }); + } + userShareStatusFlag.value = !userShareStatusFlag.value; + }); + + final shareContentChangedListener = eventListener.addListener(EventType.onShareContentChanged, (data) async { + data = data as Map; + ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); + ZoomVideoSdkUser shareUser = ZoomVideoSdkUser.fromJson(jsonDecode(data['user'].toString())); + ZoomVideoSdkShareAction? shareAction = ZoomVideoSdkShareAction.fromJson(jsonDecode(data['shareAction'])); + if (shareAction.shareType == ShareType.Camera) { + debugPrint("Camera share started"); + isSharedCamera.value = (shareUser.userId == mySelf?.userId); + } + }); + + final userJoinListener = eventListener.addListener(EventType.onUserJoin, (data) async { + if (!isMounted()) return; + data = data as Map; + ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); + var userListJson = jsonDecode(data['remoteUsers']) as List; + List remoteUserList = userListJson.map((userJson) => ZoomVideoSdkUser.fromJson(userJson)).toList(); + remoteUserList.insert(0, mySelf!); + users.value = remoteUserList; + }); + + final userLeaveListener = eventListener.addListener(EventType.onUserLeave, (data) async { + if (!isMounted()) return; + ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); + data = data as Map; + List? remoteUserList = await zoom.session.getRemoteUsers(); + var leftUserListJson = jsonDecode(data['leftUsers']) as List; + List leftUserLis = leftUserListJson.map((userJson) => ZoomVideoSdkUser.fromJson(userJson)).toList(); + if (fullScreenUser.value != null) { + for (var user in leftUserLis) { + { + if (fullScreenUser.value?.userId == user.userId) { + fullScreenUser.value = mySelf; + } + } + } + } else { + fullScreenUser.value = mySelf; + } + remoteUserList?.add(mySelf!); + users.value = remoteUserList!; + }); + + final userNameChangedListener = eventListener.addListener(EventType.onUserNameChanged, (data) async { + if (!isMounted()) return; + data = data as Map; + ZoomVideoSdkUser? changedUser = ZoomVideoSdkUser.fromJson(jsonDecode(data['changedUser'])); + int index; + for (var user in users.value) { + if (user.userId == changedUser.userId) { + index = users.value.indexOf(user); + users.value[index] = changedUser; + } + } + userNameFlag.value = !userNameFlag.value; + }); + + final commandReceived = eventListener.addListener(EventType.onCommandReceived, (data) async { + data = data as Map; + debugPrint("sender: ${ZoomVideoSdkUser.fromJson(jsonDecode(data['sender']))}, command: ${data['command']}"); + }); + + final liveStreamStatusChangeListener = eventListener.addListener(EventType.onLiveStreamStatusChanged, (data) async { + data = data as Map; + debugPrint("onLiveStreamStatusChanged: status: ${data['status']}"); + }); + + final liveTranscriptionStatusChangeListener = eventListener.addListener(EventType.onLiveTranscriptionStatus, (data) async { + data = data as Map; + debugPrint("onLiveTranscriptionStatus: status: ${data['status']}"); + }); + + final cloudRecordingStatusListener = eventListener.addListener(EventType.onCloudRecordingStatus, (data) async { + data = data as Map; + debugPrint("onCloudRecordingStatus: status: ${data['status']}"); + ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); + if (data['status'] == RecordingStatus.Start) { + if (mySelf != null && !mySelf.isHost!) { + showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + content: const Text('The session is being recorded.'), + actions: [ + TextButton( + onPressed: () async { + await zoom.acceptRecordingConsent(); + if (context.mounted) { + Navigator.pop(context); + } + ; + }, + child: const Text('accept'), + ), + TextButton( + onPressed: () async { + String currentConsentType = await zoom.getRecordingConsentType(); + if (currentConsentType == ConsentType.ConsentType_Individual) { + await zoom.declineRecordingConsent(); + Navigator.pop(context); + } else { + await zoom.declineRecordingConsent(); + zoom.leaveSession(false); + if (!context.mounted) return; + Navigator.popAndPushNamed( + context, + "Join", + arguments: JoinArguments(args.isJoin, sessionName.value, sessionPassword.value, args.displayName, args.sessionIdleTimeoutMins, args.role), + ); + } + }, + child: const Text('decline'), + ), + ], + ), + ); + } + isRecordingStarted.value = true; + } else { + isRecordingStarted.value = false; + } + }); + + final liveTranscriptionMsgInfoReceivedListener = eventListener.addListener(EventType.onLiveTranscriptionMsgInfoReceived, (data) async { + data = data as Map; + ZoomVideoSdkLiveTranscriptionMessageInfo? messageInfo = ZoomVideoSdkLiveTranscriptionMessageInfo.fromJson(jsonDecode(data['messageInfo'])); + debugPrint("onLiveTranscriptionMsgInfoReceived: content: ${messageInfo.messageContent}"); + }); + + final inviteByPhoneStatusListener = eventListener.addListener(EventType.onInviteByPhoneStatus, (data) async { + data = data as Map; + debugPrint("onInviteByPhoneStatus: status: ${data['status']}, reason: ${data['reason']}"); + }); + + final multiCameraStreamStatusChangedListener = eventListener.addListener(EventType.onMultiCameraStreamStatusChanged, (data) async { + data = data as Map; + ZoomVideoSdkUser? changedUser = ZoomVideoSdkUser.fromJson(jsonDecode(data['changedUser'])); + var status = data['status']; + for (var user in users.value) { + { + if (changedUser.userId == user.userId) { + if (status == MultiCameraStreamStatus.Joined) { + user.hasMultiCamera = true; + } else if (status == MultiCameraStreamStatus.Left) { + user.hasMultiCamera = false; + } + } + } + } + }); + + final requireSystemPermission = eventListener.addListener(EventType.onRequireSystemPermission, (data) async { + data = data as Map; + ZoomVideoSdkUser? changedUser = ZoomVideoSdkUser.fromJson(jsonDecode(data['changedUser'])); + var permissionType = data['permissionType']; + switch (permissionType) { + case SystemPermissionType.Camera: + showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text("Can't Access Camera"), + content: const Text("please turn on the toggle in system settings to grant permission"), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, 'OK'), + child: const Text('OK'), + ), + ], + ), + ); + break; + case SystemPermissionType.Microphone: + showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text("Can't Access Microphone"), + content: const Text("please turn on the toggle in system settings to grant permission"), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, 'OK'), + child: const Text('OK'), + ), + ], + ), + ); + break; + } + }); + + final networkStatusChangeListener = eventListener.addListener(EventType.onUserVideoNetworkStatusChanged, (data) async { + data = data as Map; + ZoomVideoSdkUser? networkUser = ZoomVideoSdkUser.fromJson(jsonDecode(data['user'])); + + if (data['status'] == NetworkStatus.Bad) { + debugPrint("onUserVideoNetworkStatusChanged: status: ${data['status']}, user: ${networkUser.userName}"); + } + }); + + final eventErrorListener = eventListener.addListener(EventType.onError, (data) async { + data = data as Map; + String errorType = data['errorType']; + showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text("Error"), + content: Text(errorType), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, 'OK'), + child: const Text('OK'), + ), + ], + ), + ); + if (errorType == Errors.SessionJoinFailed || errorType == Errors.SessionDisconnecting) { + Timer( + const Duration(milliseconds: 1000), + () => { + Navigator.popAndPushNamed( + context, + "Join", + arguments: JoinArguments(args.isJoin, sessionName.value, sessionPassword.value, args.displayName, args.sessionIdleTimeoutMins, args.role), + ), + }); + } + }); + + final userRecordingConsentListener = eventListener.addListener(EventType.onUserRecordingConsent, (data) async { + data = data as Map; + ZoomVideoSdkUser? user = ZoomVideoSdkUser.fromJson(jsonDecode(data['user'])); + debugPrint('userRecordingConsentListener: user= ${user.userName}'); + }); + + final callCRCDeviceStatusListener = eventListener.addListener(EventType.onCallCRCDeviceStatusChanged, (data) async { + data = data as Map; + debugPrint('onCallCRCDeviceStatusChanged: status = ${data['status']}'); + }); + + final originalLanguageMsgReceivedListener = eventListener.addListener(EventType.onOriginalLanguageMsgReceived, (data) async { + data = data as Map; + ZoomVideoSdkLiveTranscriptionMessageInfo? messageInfo = ZoomVideoSdkLiveTranscriptionMessageInfo.fromJson(jsonDecode(data['messageInfo'])); + debugPrint("onOriginalLanguageMsgReceived: content: ${messageInfo.messageContent}"); + }); + + final chatPrivilegeChangedListener = eventListener.addListener(EventType.onChatPrivilegeChanged, (data) async { + data = data as Map; + String type = data['privilege']; + debugPrint('chatPrivilegeChangedListener: type= $type'); + }); + + final testMicStatusListener = eventListener.addListener(EventType.onTestMicStatusChanged, (data) async { + data = data as Map; + String status = data['status']; + debugPrint('testMicStatusListener: status= $status'); + }); + + final micSpeakerVolumeChangedListener = eventListener.addListener(EventType.onMicSpeakerVolumeChanged, (data) async { + data = data as Map; + int type = data['micVolume']; + debugPrint('onMicSpeakerVolumeChanged: micVolume= $type, speakerVolume'); + }); + + final cameraControlRequestResultListener = eventListener.addListener(EventType.onCameraControlRequestResult, (data) async { + data = data as Map; + bool approved = data['approved']; + debugPrint('onCameraControlRequestResult: approved= $approved'); + }); + + final callOutUserJoinListener = eventListener.addListener(EventType.onCalloutJoinSuccess, (data) async { + data = data as Map; + String phoneNumber = data['phoneNumber']; + ZoomVideoSdkUser? user = ZoomVideoSdkUser.fromJson(jsonDecode(data['user'])); + debugPrint('onCalloutJoinSuccess: phoneNumber= $phoneNumber, user= ${user.userName}'); + }); + + return () => { + sessionJoinListener.cancel(), + sessionLeaveListener.cancel(), + sessionPasswordWrongListener.cancel(), + sessionNeedPasswordListener.cancel(), + userVideoStatusChangedListener.cancel(), + userAudioStatusChangedListener.cancel(), + userJoinListener.cancel(), + userLeaveListener.cancel(), + userNameChangedListener.cancel(), + userShareStatusChangeListener.cancel(), + liveStreamStatusChangeListener.cancel(), + cloudRecordingStatusListener.cancel(), + inviteByPhoneStatusListener.cancel(), + eventErrorListener.cancel(), + commandReceived.cancel(), + liveTranscriptionStatusChangeListener.cancel(), + liveTranscriptionMsgInfoReceivedListener.cancel(), + multiCameraStreamStatusChangedListener.cancel(), + requireSystemPermission.cancel(), + userRecordingConsentListener.cancel(), + networkStatusChangeListener.cancel(), + callCRCDeviceStatusListener.cancel(), + originalLanguageMsgReceivedListener.cancel(), + chatPrivilegeChangedListener.cancel(), + testMicStatusListener.cancel(), + micSpeakerVolumeChangedListener.cancel(), + cameraControlRequestResultListener.cancel(), + callOutUserJoinListener.cancel(), + shareContentChangedListener.cancel(), + }; + }, [zoom, users.value, isMounted]); + + void selectVirtualBackgroundItem() async { + final ImagePicker picker = ImagePicker(); + // Pick an image. + final XFile? image = await picker.pickImage(source: ImageSource.gallery); + await zoom.virtualBackgroundHelper.addVirtualBackgroundItem(image!.path); + } + + void onPressAudio() async { + ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); + if (mySelf != null) { + final audioStatus = mySelf.audioStatus; + if (audioStatus != null) { + var muted = await audioStatus.isMuted(); + if (muted) { + await zoom.audioHelper.unMuteAudio(mySelf.userId); + } else { + await zoom.audioHelper.muteAudio(mySelf.userId); + } + } + } + } + + void onPressVideo() async { + ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); + if (mySelf != null) { + final videoStatus = mySelf.videoStatus; + if (videoStatus != null) { + var videoOn = await videoStatus.isOn(); + if (videoOn) { + await zoom.videoHelper.stopVideo(); + } else { + await zoom.videoHelper.startVideo(); + } + } + } + } + + void onPressShare() async { + var isOtherSharing = await zoom.shareHelper.isOtherSharing(); + var isShareLocked = await zoom.shareHelper.isShareLocked(); + String? shareCameraViewResult = Errors.InternalError; + + if (isOtherSharing) { + showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text("Error"), + content: const Text('Other is sharing'), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, 'OK'), + child: const Text('OK'), + ), + ], + ), + ); + } else if (isShareLocked) { + showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text("Error"), + content: const Text('Share is locked by host'), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, 'OK'), + child: const Text('OK'), + ), + ], + ), + ); + } else if (isSharing.value) { + zoom.shareHelper.stopShare(); + } else { + List options = [ + ListTile( + title: Text( + 'Share Device Screen', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.normal, + color: Colors.black, + ), + ), + onTap: () async => { + zoom.shareHelper.shareScreen(), + Navigator.of(context).pop(), + }, + ), + ListTile( + title: Text( + 'Share Camera', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.normal, + color: Colors.black, + ), + ), + onTap: () async => { + shareCameraViewResult = await zoom.shareHelper.startShareCamera(cameraShareView), + debugPrint('start camera: $shareCameraViewResult'), + Navigator.of(context).pop(), + }, + ), + ]; + 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(), + ), + ), + ), + ); + }); + } + } + + void onSelectedUserVolume(ZoomVideoSdkUser user) async { + var isShareAudio = user.isSharing; + bool canSetVolume = await user.canSetUserVolume(user.userId, isShareAudio); + num userVolume; + + List options = [ + ListTile( + title: Text( + 'Adjust Volume', + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + color: Colors.black, + ), + ), + ), + ListTile( + title: Text( + 'Current volume', + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.normal, + color: Colors.black, + ), + ), + onTap: () async => { + debugPrint('user volume'), + userVolume = await user.getUserVolume(user.userId, isShareAudio), + debugPrint('user ${user.userName}\'s volume is ${userVolume!}'), + }, + ), + ]; + if (canSetVolume) { + options.add( + ListTile( + title: Text( + 'Volume up', + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.normal, + color: Colors.black, + ), + ), + onTap: () async => { + userVolume = await user.getUserVolume(user.userId, isShareAudio), + if (userVolume < 10) + { + await user.setUserVolume(user.userId, userVolume + 1, isShareAudio), + } + else + { + debugPrint("Cannot volume up."), + } + }, + ), + ); + options.add( + ListTile( + title: Text( + 'Volume down', + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.normal, + color: Colors.black, + ), + ), + onTap: () async => { + userVolume = await user.getUserVolume(user.userId, isShareAudio), + if (userVolume > 0) + { + await user.setUserVolume(user.userId, userVolume - 1, isShareAudio), + } + else + { + debugPrint("Cannot volume down."), + } + }, + ), + ); + } + 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 * 58, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + ListView( + shrinkWrap: true, + children: ListTile.divideTiles( + context: context, + tiles: options, + ).toList(), + ), + ], + ), + )); + }); + } + + void onPressCameraList() async { + List options = []; + List 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(), + }, + ), + ); + 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(), + ), + ), + ), + ); + }); + } + + // Future onPressMore() async { + // ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); + // bool isShareLocked = await zoom.shareHelper.isShareLocked(); + // bool canSwitchSpeaker = await zoom.audioHelper.canSwitchSpeaker(); + // bool canStartRecording = (await zoom.recordingHelper.canStartRecording()) == Errors.Success; + // debugPrint("canStartRecording ${await zoom.recordingHelper.canStartRecording()}"); + // var startLiveTranscription = (await zoom.liveTranscriptionHelper.getLiveTranscriptionStatus()) == LiveTranscriptionStatus.Start; + // bool canStartLiveTranscription = await zoom.liveTranscriptionHelper.canStartLiveTranscription(); + // bool isHost = (mySelf != null) ? (await mySelf.getIsHost()) : false; + // isOriginalAspectRatio.value = await zoom.videoHelper.isOriginalAspectRatioEnabled(); + // bool canCallOutToCRC = await zoom.CRCHelper.isCRCEnabled(); + // bool supportVB = await zoom.virtualBackgroundHelper.isSupportVirtualBackground(); + // List? shareActionList = await mySelf?.getShareActionList(); + // + // List options = [ + // ListTile( + // title: Text( + // 'More', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 18, + // fontWeight: FontWeight.w600, + // color: Colors.black, + // ), + // ), + // ), + // ), + // ListTile( + // title: Text( + // 'Get Chat Privilege', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // debugPrint("Chat Privilege = ${await zoom.chatHelper.getChatPrivilege()}"), + // Navigator.of(context).pop(), + // }, + // ), + // ListTile( + // title: Text( + // 'Get Session Dial-in Number infos', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // debugPrint("session number = ${await zoom.session.getSessionNumber()}"), + // Navigator.of(context).pop(), + // }, + // ), + // ListTile( + // title: Text( + // 'Get Camera List', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // debugPrint("camera list= ${await zoom.videoHelper.getCameraList()}"), + // onPressCameraList(), + // Navigator.of(context).pop(), + // }, + // ), + // ListTile( + // title: Text( + // '${isMicOriginalOn.value ? 'Disable' : 'Enable'} Original Sound', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // debugPrint("${isMicOriginalOn.value}"), + // await zoom.audioSettingHelper.enableMicOriginalInput(!isMicOriginalOn.value), + // isMicOriginalOn.value = await zoom.audioSettingHelper.isMicOriginalInputEnable(), + // debugPrint("Original sound ${isMicOriginalOn.value ? 'Enabled' : 'Disabled'}"), + // Navigator.of(context).pop(), + // }, + // ) + // ]; + // + // if (supportVB) { + // options.add( + // ListTile( + // title: Text( + // 'Add Virtual Background', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // selectVirtualBackgroundItem(), + // Navigator.of(context).pop(), + // }, + // ), + // ); + // } + // + // if (canCallOutToCRC) { + // options.add(ListTile( + // title: Text( + // 'Call-out to CRC devices', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // debugPrint('CRC result = ${await zoom.CRCHelper.callCRCDevice("bjn.vc", ZoomVideoSdkCRCProtocolType.SIP)}'), + // Navigator.of(context).pop(), + // }, + // )); + // options.add(ListTile( + // title: Text( + // 'Cancel call-out to CRC devices', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // debugPrint('cancel result= ${await zoom.CRCHelper.cancelCallCRCDevice()}'), + // Navigator.of(context).pop(), + // }, + // )); + // } + // + // if (canSwitchSpeaker) { + // options.add(ListTile( + // title: Text( + // 'Turn ${isSpeakerOn.value ? 'off' : 'on'} Speaker', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // await zoom.audioHelper.setSpeaker(!isSpeakerOn.value), + // isSpeakerOn.value = await zoom.audioHelper.getSpeakerStatus(), + // debugPrint('Turned ${isSpeakerOn.value ? 'on' : 'off'} Speaker'), + // Navigator.of(context).pop(), + // }, + // )); + // } + // + // if (isHost) { + // options.add(ListTile( + // title: Text( + // '${isShareLocked ? 'Unlock' : 'Lock'} Share', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // debugPrint("isShareLocked = ${await zoom.shareHelper.lockShare(!isShareLocked)}"), + // Navigator.of(context).pop(), + // })); + // options.add(ListTile( + // title: Text( + // 'Change Name', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () => { + // isRenameModalVisible.value = true, + // Navigator.of(context).pop(), + // }, + // )); + // } + // + // if (canStartLiveTranscription) { + // options.add(ListTile( + // title: Text( + // "${startLiveTranscription ? 'Stop' : 'Start'} Live Transcription", + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // if (startLiveTranscription) + // { + // debugPrint('stopLiveTranscription= ${await zoom.liveTranscriptionHelper.stopLiveTranscription()}'), + // } + // else + // { + // debugPrint('startLiveTranscription= ${await zoom.liveTranscriptionHelper.startLiveTranscription()}'), + // }, + // Navigator.of(context).pop(), + // }, + // )); + // options.add(ListTile( + // title: Text( + // '${isReceiveSpokenLanguageContentEnabled.value ? 'Disable' : 'Enable'} receiving original caption', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // await zoom.liveTranscriptionHelper.enableReceiveSpokenLanguageContent(!isReceiveSpokenLanguageContentEnabled.value), + // isReceiveSpokenLanguageContentEnabled.value = await zoom.liveTranscriptionHelper.isReceiveSpokenLanguageContentEnabled(), + // debugPrint("isReceiveSpokenLanguageContentEnabled = ${isReceiveSpokenLanguageContentEnabled.value}"), + // Navigator.of(context).pop(), + // })); + // } + // + // if (canStartRecording) { + // options.add(ListTile( + // title: Text( + // '${isRecordingStarted.value ? 'Stop' : 'Start'} Recording', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // if (!isRecordingStarted.value) + // { + // debugPrint('isRecordingStarted = ${await zoom.recordingHelper.startCloudRecording()}'), + // } + // else + // { + // debugPrint('isRecordingStarted = ${await zoom.recordingHelper.stopCloudRecording()}'), + // }, + // Navigator.of(context).pop(), + // })); + // } + // + // if (Platform.isAndroid) { + // bool isFlashlightSupported = await zoom.videoHelper.isSupportFlashlight(); + // bool isFlashlightOn = await zoom.videoHelper.isFlashlightOn(); + // if (isFlashlightSupported) { + // options.add(ListTile( + // title: Text( + // '${isFlashlightOn ? 'Turn Off' : 'Turn On'} Flashlight', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // if (!isFlashlightOn) + // { + // await zoom.videoHelper.turnOnOrOffFlashlight(true), + // } + // else + // { + // await zoom.videoHelper.turnOnOrOffFlashlight(false), + // }, + // Navigator.of(context).pop(), + // })); + // } + // } + // + // if (Platform.isIOS) { + // options.add(ListTile( + // title: Text( + // '${isPiPView.value ? 'Disable' : 'Enable'} picture in picture view', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // isPiPView.value = !isPiPView.value, + // Navigator.of(context).pop(), + // })); + // } + // + // if (isVideoOn.value) { + // options.add(ListTile( + // title: Text( + // 'Mirror the video', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // await zoom.videoHelper.mirrorMyVideo(!isVideoMirrored.value), + // isVideoMirrored.value = await zoom.videoHelper.isMyVideoMirrored(), + // Navigator.of(context).pop(), + // })); + // options.add(ListTile( + // title: Text( + // '${isOriginalAspectRatio.value ? 'Enable' : 'Disable'} original aspect ratio', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.normal, + // color: Colors.black, + // ), + // ), + // ), + // onTap: () async => { + // await zoom.videoHelper.enableOriginalAspectRatio(!isOriginalAspectRatio.value), + // isOriginalAspectRatio.value = await zoom.videoHelper.isOriginalAspectRatioEnabled(), + // debugPrint("isOriginalAspectRatio= ${isOriginalAspectRatio.value}"), + // Navigator.of(context).pop(), + // })); + // } + // + // 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: 500, + // child: Scrollbar( + // child: ListView( + // shrinkWrap: true, + // scrollDirection: Axis.vertical, + // children: ListTile.divideTiles( + // context: context, + // tiles: options, + // ).toList(), + // ), + // ), + // ), + // ); + // }); + // } + + void onLeaveSession(bool isEndSession) async { + await zoom.leaveSession(isEndSession); + Navigator.pushAndRemoveUntil( + context, + CustomPageRoute( + page: LandingNavigation(), + ), + (r) => false); + } + + void showLeaveOptions() async { + ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); + bool isHost = await mySelf!.getIsHost(); + + Widget endSession; + Widget leaveSession; + Widget cancel = TextButton( + child: const Text('Cancel'), + onPressed: () { + Navigator.pop(context); //close Dialog + }, + ); + + switch (defaultTargetPlatform) { + case TargetPlatform.android: + endSession = TextButton( + child: const Text('End Session'), + onPressed: () => onLeaveSession(true), + ); + leaveSession = TextButton( + child: const Text('Leave Session'), + onPressed: () => onLeaveSession(false), + ); + break; + default: + endSession = CupertinoActionSheetAction( + isDestructiveAction: true, + child: const Text('End Session'), + onPressed: () => onLeaveSession(true), + ); + leaveSession = CupertinoActionSheetAction( + child: const Text('Leave Session'), + onPressed: () => onLeaveSession(false), + ); + break; + } + + List options = [ + leaveSession, + cancel, + ]; + + if (Platform.isAndroid) { + if (isHost) { + options.removeAt(1); + options.insert(0, endSession); + } + showDialog( + context: context, + builder: (context) { + return AlertDialog( + content: const Text("Do you want to leave this session?"), + shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(2.0))), + actions: options, + ); + }); + } else { + options.removeAt(1); + if (isHost) { + options.insert(1, endSession); + } + showCupertinoModalPopup( + context: context, + builder: (context) => CupertinoActionSheet( + message: const Text('Are you sure that you want to leave the session?'), + actions: options, + cancelButton: cancel, + ), + ); + } + } + + final chatMessageController = TextEditingController(); + + void sendChatMessage(String message) async { + await zoom.chatHelper.sendChatToAll(message); + ZoomVideoSdkUser? self = await zoom.session.getMySelf(); + ZoomVideoSdkCmdChannel cmdChannel = zoom.cmdChannel; + for (var user in users.value) { + if (user.userId != self?.userId) { + await zoom.cmdChannel.sendCommand(user.userId, message); + } + } + chatMessageController.clear(); + // send the chat as a command + } + + void onSelectedUser(ZoomVideoSdkUser user) async { + setState(() { + fullScreenUser.value = user; + }); + } + + changeNamePopup = Center( + child: Stack( + children: [ + Visibility( + visible: isRenameModalVisible.value, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + alignment: Alignment.bottomLeft, + decoration: const BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(10)), + color: Colors.white, + ), + width: MediaQuery.of(context).size.width - 130, + height: MediaQuery.of(context).size.height * 0.2, + child: Center( + child: (Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(top: 20, left: 20), + child: Text( + 'Change Name', + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + ), + ), + Padding( + padding: const EdgeInsets.only(top: 10, left: 20), + child: SizedBox( + width: MediaQuery.of(context).size.width - 230, + child: TextField( + onEditingComplete: () {}, + autofocus: true, + cursorColor: Colors.black, + controller: changeNameController, + decoration: InputDecoration( + isDense: true, + hintText: 'New name', + hintStyle: TextStyle( + fontSize: 14.0, + color: chatTextColor, + ), + ), + ), + ), + ), + Padding( + padding: const EdgeInsets.only(top: 15), + child: Row( + children: [ + Padding( + padding: const EdgeInsets.only(left: 40), + child: InkWell( + child: Text( + 'Apply', + style: const TextStyle( + fontSize: 16, + ), + ), + onTap: () async { + if (fullScreenUser.value != null) { + ZoomVideoSdkUser? mySelf = await zoom.session.getMySelf(); + await zoom.userHelper.changeName((mySelf?.userId)!, changeNameController.text); + changeNameController.clear(); + } + isRenameModalVisible.value = false; + }, + ), + ), + Padding( + padding: const EdgeInsets.only(left: 40), + child: InkWell( + child: Text( + 'Cancel', + style: const TextStyle( + fontSize: 16, + ), + ), + onTap: () async { + isRenameModalVisible.value = false; + }, + ), + ) + ], + ), + ) + ], + )), + ), + ), + ], + )), + ], + ), + ); + + Widget fullScreenView; + Widget smallView; + Widget cameraView; + + if (isInSession.value && fullScreenUser.value != null && users.value.isNotEmpty) { + fullScreenView = AnimatedOpacity( + opacity: opacityLevel, + duration: const Duration(seconds: 3), + child: VideoView( + user: users.value.length > 1 ? users.value[1] : users.value[0], + hasMultiCamera: false, + isPiPView: isPiPView.value, + sharing: sharingUser.value == null ? false : (sharingUser.value?.userId == fullScreenUser.value?.userId), + preview: false, + focused: false, + multiCameraIndex: "0", + videoAspect: VideoAspect.Original, + fullScreen: true, + resolution: VideoResolution.Resolution360, + ), + ); + + smallView = Container( + height: 110, + margin: const EdgeInsets.only(left: 20, right: 20), + alignment: Alignment.center, + child: ListView.separated( + scrollDirection: Axis.horizontal, + itemCount: users.value.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + onTap: () async { + onSelectedUser(users.value[index]); + }, + onDoubleTap: () async { + onSelectedUserVolume(users.value[index]); + }, + child: Center( + child: VideoView( + user: users.value[index], + hasMultiCamera: false, + isPiPView: false, + sharing: false, + preview: false, + focused: false, + multiCameraIndex: "0", + videoAspect: VideoAspect.Original, + fullScreen: false, + resolution: VideoResolution.Resolution180, + ), + ), + ); + }, + separatorBuilder: (BuildContext context, int index) => const Divider(), + ), + ); + } else { + fullScreenView = Container( + color: Colors.black, + child: const Center( + child: Text( + "Connecting...", + style: TextStyle( + fontSize: 20, + color: Colors.white, + ), + ), + )); + smallView = Container( + height: 110, + color: Colors.transparent, + ); + } + + cameraView = Offstage( + offstage: !isSharedCamera.value, + child: AnimatedOpacity( + opacity: isSharedCamera.value ? 1.0 : 0.0, + duration: const Duration(milliseconds: 300), + child: cameraShareView, + ), + ); + + _changeOpacity; + return Scaffold( + resizeToAvoidBottomInset: false, + backgroundColor: backgroundColor, + body: Stack( + children: [ + // isScreenBeingShared ? fullScreenView : SizedBox.shrink(), + isScreenBeingShared ? SizedBox.shrink() : fullScreenView, + cameraView, + Container( + padding: const EdgeInsets.only(top: 35), + child: Stack( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + height: 80, + width: 180, + margin: const EdgeInsets.only(top: 16, left: 8), + padding: const EdgeInsets.all(8), + alignment: Alignment.topLeft, + decoration: BoxDecoration( + borderRadius: const BorderRadius.all(Radius.circular(8.0)), + // color: buttonBackgroundColor, + ), + // child: InkWell( + // onTap: () async { + // showDialog( + // context: context, + // builder: (context) { + // return Dialog( + // elevation: 0.0, + // insetPadding: const EdgeInsets.symmetric(horizontal: 40), + // shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), + // child: FractionallySizedBox( + // heightFactor: 0.2, + // widthFactor: 0.3, + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.stretch, + // children: [ + // ListView( + // shrinkWrap: true, + // children: ListTile.divideTiles( + // context: context, + // tiles: [ + // ListTile( + // title: Text( + // 'Session Information', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 18, + // fontWeight: FontWeight.w600, + // ), + // ), + // ), + // ), + // ListTile( + // title: Text( + // 'Session Name', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // ), + // ), + // ), + // subtitle: Text( + // sessionName.value, + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 12, + // ), + // ), + // ), + // ), + // ListTile( + // title: Text( + // 'Session Password', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // ), + // ), + // ), + // subtitle: Text( + // sessionPassword.value, + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 12, + // ), + // ), + // ), + // ), + // ListTile( + // title: Text( + // 'Participants', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // ), + // ), + // ), + // subtitle: Text( + // '${users.value.length}', + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 12, + // ), + // ), + // ), + // ), + // ], + // ).toList(), + // ), + // ], + // ), + // )); + // }); + // }, + // child: Stack( + // children: [ + // Column( + // children: [ + // const Padding(padding: EdgeInsets.symmetric(vertical: 4)), + // Align( + // alignment: Alignment.centerLeft, + // child: Text( + // sessionName.value, + // overflow: TextOverflow.ellipsis, + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.w600, + // color: Colors.white, + // ), + // ), + // ), + // ), + // const Padding(padding: EdgeInsets.symmetric(vertical: 5)), + // Align( + // alignment: Alignment.centerLeft, + // child: Text( + // "Participants: ${users.value.length}", + // style: GoogleFonts.lato( + // textStyle: const TextStyle( + // fontSize: 14, + // fontWeight: FontWeight.w600, + // color: Colors.white, + // ), + // ), + // ), + // ) + // ], + // ), + // Container( + // alignment: Alignment.centerRight, + // child: Image.asset( + // "assets/icons/unlocked@2x.png", + // height: 22, + // )), + // ], + // ), + // ), + ), + TextButton( + onPressed: (showLeaveOptions), + child: Container( + alignment: Alignment.topRight, + margin: const EdgeInsets.only(top: 16, right: 8), + padding: const EdgeInsets.only(top: 5, bottom: 5, left: 16, right: 16), + height: 28, + decoration: BoxDecoration( + borderRadius: const BorderRadius.all(Radius.circular(20.0)), + color: buttonBackgroundColor, + ), + child: const Text( + "LEAVE", + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xFFE02828), + ), + ), + )), + ], + ), + Align( + alignment: Alignment.centerRight, + child: FractionallySizedBox( + widthFactor: 0.2, + heightFactor: 0.6, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + onPressed: onPressAudio, + icon: isMuted.value ? Image.asset("assets/images/png/zoom/unmute@2x.png") : Image.asset("assets/images/png/zoom/mute@2x.png"), + iconSize: circleButtonSize, + tooltip: isMuted.value == true ? "Unmute" : "Mute", + ), + IconButton( + onPressed: onPressShare, + icon: isSharing.value ? Image.asset("assets/images/png/zoom/share-off@2x.png") : Image.asset("assets/images/png/zoom/share-on@2x.png"), + iconSize: circleButtonSize, + ), + IconButton( + onPressed: onPressVideo, + iconSize: circleButtonSize, + icon: isVideoOn.value ? Image.asset("assets/images/png/zoom/video-off@2x.png") : Image.asset("assets/images/png/zoom/video-on@2x.png"), + ), + Column( + children: [ + IconButton( + onPressed: () async { + onPressCameraList(); + }, + icon: Icon(Icons.cameraswitch, color: Colors.white), + color: Colors.white, + iconSize: 40.h, + ), + "Switch Camera".toText12(color: AppColors.whiteColor, isCenter: true, isBold: true) + ], + ), + ], + ), + )), + Container( + margin: const EdgeInsets.only(left: 16, right: 16, bottom: 40, top: 10), + alignment: Alignment.bottomCenter, + child: SizedBox( + height: MediaQuery.of(context).viewInsets.bottom == 0 ? 65 : MediaQuery.of(context).viewInsets.bottom + 18, + child: TextField( + maxLines: 1, + textAlign: TextAlign.left, + style: TextStyle(color: chatTextColor), + cursorColor: chatTextColor, + textAlignVertical: TextAlignVertical.center, + controller: chatMessageController, + decoration: InputDecoration( + contentPadding: const EdgeInsets.only(left: 16, top: 10, bottom: 10, right: 16), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(width: 1, color: chatTextColor), //<-- SEE HERE + ), + hintText: 'Type your message here...', + hintStyle: TextStyle( + fontSize: 14.0, + color: chatTextColor, + ), + ), + onSubmitted: (String str) { + sendChatMessage(str); + }, + ), + ), + ), + Container( + alignment: Alignment.bottomLeft, + margin: const EdgeInsets.only(bottom: 120), + child: smallView, + ), + // CommentList(zoom: zoom, eventListener: eventListener), + changeNamePopup, + ], + )), + ], + )); + } +} + +class CallArguments { + final bool isJoin; + final String sessionName; + final String sessionPwd; + final String displayName; + final String sessionIdleTimeoutMins; + final String role; + final int callType; + + CallArguments(this.sessionName, this.sessionPwd, this.displayName, this.sessionIdleTimeoutMins, this.role, this.isJoin, this.callType); +} + +class JoinArguments { + final bool isJoin; + final String sessionName; + final String sessionPwd; + final String displayName; + final String sessionTimeout; + final String roleType; + + JoinArguments(this.isJoin, this.sessionName, this.sessionPwd, this.displayName, this.sessionTimeout, this.roleType); +} diff --git a/lib/presentation/tele_consultation/zoom/video_view.dart b/lib/presentation/tele_consultation/zoom/video_view.dart index a6b2428..4c1e049 100644 --- a/lib/presentation/tele_consultation/zoom/video_view.dart +++ b/lib/presentation/tele_consultation/zoom/video_view.dart @@ -1,258 +1,258 @@ -// import 'dart:async'; -// -// import 'package:flutter/material.dart'; -// import 'package:flutter_hooks/flutter_hooks.dart'; -// import 'package:flutter_zoom_videosdk/flutter_zoom_view.dart' as FlutterZoomView; -// import 'package:flutter_zoom_videosdk/native/zoom_videosdk.dart'; -// -// const SHOW_TALKING_ICON_DURATION = 2000; -// -// class VideoView extends FlutterZoomView.ZoomView { -// const VideoView({ -// super.key, -// required super.user, -// required super.sharing, -// required super.preview, -// required super.focused, -// required super.hasMultiCamera, -// required super.multiCameraIndex, -// required super.videoAspect, -// required super.fullScreen, -// required super.resolution, -// required super.isPiPView, -// }); -// -// @override -// Widget build(BuildContext context) { -// var isVideoOn = useState(false); -// var isTalking = useState(false); -// var isMuted = useState(false); -// var isMounted = useIsMounted(); -// var zoom = ZoomVideoSdk(); -// var isSharing = useState(false); -// user?.audioStatus?.isMuted().then((muted) => isMuted.value = muted); -// -// useEffect(() { -// updateVideoStatus() { -// if (user == null) return; -// Future.microtask(() async { -// if (isMounted()) { -// isVideoOn.value = (await user!.videoStatus!.isOn()); -// isSharing.value = sharing; -// } -// }); -// } -// -// resetAudioStatus() { -// isTalking.value = false; -// isMuted.value = false; -// } -// -// updateAudioStatus() async { -// if (!isMounted()) return; -// var talking = await user?.audioStatus?.isTalking(); -// var muted = await user?.audioStatus?.isMuted(); -// isMuted.value = muted!; -// isTalking.value = talking!; -// if (talking) { -// Timer( -// const Duration(milliseconds: SHOW_TALKING_ICON_DURATION), -// () => { -// if (isMounted()) -// { -// isTalking.value = false, -// } -// }); -// } -// } -// -// updateVideoStatus(); -// return null; -// }, [zoom, user]); -// -// ImageIcon audioStatusIcon; -// if (isTalking.value) { -// audioStatusIcon = const ImageIcon( -// AssetImage("assets/images/png/zoom/talking@2x.png"), -// ); -// } else if (isMuted.value) { -// audioStatusIcon = const ImageIcon( -// AssetImage("assets/images/png/zoom/muted@2x.png"), -// ); -// } -// // Pass parameters to the platform side. -// final Map creationParams = {}; -// creationParams.putIfAbsent("userId", () => user?.userId); -// creationParams.putIfAbsent("sharing", () => sharing); -// creationParams.putIfAbsent("preview", () => preview); -// creationParams.putIfAbsent("focused", () => focused); -// creationParams.putIfAbsent("hasMultiCamera", () => hasMultiCamera); -// if (videoAspect.isEmpty) { -// creationParams.putIfAbsent("videoAspect", () => VideoAspect.PanAndScan); -// } else { -// creationParams.putIfAbsent("videoAspect", () => videoAspect); -// } -// creationParams.putIfAbsent("fullScreen", () => fullScreen); -// if (resolution.isNotEmpty) { -// creationParams.putIfAbsent("videoAspect", () => videoAspect); -// } -// -// if (fullScreen) { -// if (sharing) { -// return Container( -// height: MediaQuery.of(context).size.height, -// width: MediaQuery.of(context).size.width, -// alignment: Alignment.center, -// child: FlutterZoomView.View(creationParams: creationParams), -// ); -// } else if (isVideoOn.value) { -// return Container( -// height: MediaQuery.of(context).size.height, -// width: MediaQuery.of(context).size.width, -// alignment: Alignment.center, -// child: FlutterZoomView.View(creationParams: creationParams), -// ); -// } else { -// return Container( -// margin: const EdgeInsets.symmetric(vertical: 0), -// child: Container( -// alignment: Alignment.center, -// child: const Image( -// image: AssetImage("assets/images/png/zoom/default-avatar.png"), -// )), -// ); -// } -// } else { -// if (isVideoOn.value || sharing) { -// return Container( -// padding: const EdgeInsets.symmetric(horizontal: 8), -// height: 110, -// width: 110, -// child: Stack( -// children: [ -// Container( -// height: 110, -// width: 110, -// decoration: BoxDecoration( -// color: const Color(0xff232323), -// border: Border.all( -// color: const Color(0xff666666), -// width: 1, -// ), -// borderRadius: const BorderRadius.all(Radius.circular(8)), -// ), -// alignment: Alignment.center, -// child: FlutterZoomView.View(creationParams: creationParams), -// ), -// Container( -// height: 110, -// width: 110, -// decoration: const BoxDecoration( -// borderRadius: BorderRadius.all(Radius.circular(8)), -// ), -// ), -// Container( -// alignment: Alignment.bottomCenter, -// child: Container( -// height: 20, -// width: 110, -// decoration: const BoxDecoration( -// color: Colors.black26, -// borderRadius: BorderRadius.all(Radius.circular(8)), -// ), -// ), -// ), -// Container( -// alignment: Alignment.bottomLeft, -// margin: const EdgeInsets.only(left: 5), -// child: Text( -// user!.userName, -// textAlign: TextAlign.left, -// style: const TextStyle( -// color: Colors.white, -// fontSize: 12, -// ), -// ), -// ), -// Container( -// alignment: Alignment.bottomRight, -// margin: const EdgeInsets.only(right: 5, bottom: 5), -// // height: 110, -// // width: 110, -// child: Image( -// height: 12, -// width: 12, -// image: isMuted.value ? const AssetImage("assets/images/png/zoom/muted@2x.png") : const AssetImage("assets/images/png/zoom/talking@2x.png"), -// fit: BoxFit.cover, -// ), -// ) -// ], -// ), -// ); -// } else { -// return Container( -// padding: const EdgeInsets.symmetric(horizontal: 8), -// height: 110, -// width: 110, -// child: Stack( -// children: [ -// Container( -// height: 110, -// width: 110, -// decoration: BoxDecoration( -// color: const Color(0xff232323), -// border: Border.all( -// color: const Color(0xff666666), -// width: 1, -// ), -// borderRadius: const BorderRadius.all(Radius.circular(8)), -// ), -// alignment: Alignment.center, -// child: Container( -// alignment: Alignment.center, -// child: const Image( -// height: 60, -// width: 60, -// image: AssetImage("assets/images/png/zoom/default-avatar.png"), -// )), -// ), -// Align( -// alignment: Alignment.bottomCenter, -// child: Container( -// height: 20, -// width: 110, -// decoration: const BoxDecoration( -// color: Colors.black26, -// borderRadius: BorderRadius.all(Radius.circular(8)), -// ), -// ), -// ), -// Container( -// alignment: Alignment.bottomLeft, -// margin: const EdgeInsets.only(left: 5), -// child: Text( -// user!.userName, -// textAlign: TextAlign.left, -// style: const TextStyle( -// color: Colors.white, -// fontSize: 12, -// ), -// ), -// ), -// Container( -// alignment: Alignment.bottomRight, -// margin: const EdgeInsets.only(right: 5, bottom: 5), -// child: Image( -// height: 12, -// width: 12, -// image: isMuted.value ? const AssetImage("assets/images/png/zoom/muted@2x.png") : const AssetImage("assets/images/png/zoom/talking@2x.png"), -// fit: BoxFit.cover, -// ), -// ), -// ], -// ), -// ); -// } -// } -// } -// } +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:flutter_zoom_videosdk/flutter_zoom_view.dart' as FlutterZoomView; +import 'package:flutter_zoom_videosdk/native/zoom_videosdk.dart'; + +const SHOW_TALKING_ICON_DURATION = 2000; + +class VideoView extends FlutterZoomView.ZoomView { + const VideoView({ + super.key, + required super.user, + required super.sharing, + required super.preview, + required super.focused, + required super.hasMultiCamera, + required super.multiCameraIndex, + required super.videoAspect, + required super.fullScreen, + required super.resolution, + required super.isPiPView, + }); + + @override + Widget build(BuildContext context) { + var isVideoOn = useState(false); + var isTalking = useState(false); + var isMuted = useState(false); + var isMounted = useIsMounted(); + var zoom = ZoomVideoSdk(); + var isSharing = useState(false); + user?.audioStatus?.isMuted().then((muted) => isMuted.value = muted); + + useEffect(() { + updateVideoStatus() { + if (user == null) return; + Future.microtask(() async { + if (isMounted()) { + isVideoOn.value = (await user!.videoStatus!.isOn()); + isSharing.value = sharing; + } + }); + } + + resetAudioStatus() { + isTalking.value = false; + isMuted.value = false; + } + + updateAudioStatus() async { + if (!isMounted()) return; + var talking = await user?.audioStatus?.isTalking(); + var muted = await user?.audioStatus?.isMuted(); + isMuted.value = muted!; + isTalking.value = talking!; + if (talking) { + Timer( + const Duration(milliseconds: SHOW_TALKING_ICON_DURATION), + () => { + if (isMounted()) + { + isTalking.value = false, + } + }); + } + } + + updateVideoStatus(); + return null; + }, [zoom, user]); + + ImageIcon audioStatusIcon; + if (isTalking.value) { + audioStatusIcon = const ImageIcon( + AssetImage("assets/images/png/zoom/talking@2x.png"), + ); + } else if (isMuted.value) { + audioStatusIcon = const ImageIcon( + AssetImage("assets/images/png/zoom/muted@2x.png"), + ); + } + // Pass parameters to the platform side. + final Map creationParams = {}; + creationParams.putIfAbsent("userId", () => user?.userId); + creationParams.putIfAbsent("sharing", () => sharing); + creationParams.putIfAbsent("preview", () => preview); + creationParams.putIfAbsent("focused", () => focused); + creationParams.putIfAbsent("hasMultiCamera", () => hasMultiCamera); + if (videoAspect.isEmpty) { + creationParams.putIfAbsent("videoAspect", () => VideoAspect.PanAndScan); + } else { + creationParams.putIfAbsent("videoAspect", () => videoAspect); + } + creationParams.putIfAbsent("fullScreen", () => fullScreen); + if (resolution.isNotEmpty) { + creationParams.putIfAbsent("videoAspect", () => videoAspect); + } + + if (fullScreen) { + if (sharing) { + return Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + alignment: Alignment.center, + child: FlutterZoomView.View(creationParams: creationParams), + ); + } else if (isVideoOn.value) { + return Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + alignment: Alignment.center, + child: FlutterZoomView.View(creationParams: creationParams), + ); + } else { + return Container( + margin: const EdgeInsets.symmetric(vertical: 0), + child: Container( + alignment: Alignment.center, + child: const Image( + image: AssetImage("assets/images/png/zoom/default-avatar.png"), + )), + ); + } + } else { + if (isVideoOn.value || sharing) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 8), + height: 110, + width: 110, + child: Stack( + children: [ + Container( + height: 110, + width: 110, + decoration: BoxDecoration( + color: const Color(0xff232323), + border: Border.all( + color: const Color(0xff666666), + width: 1, + ), + borderRadius: const BorderRadius.all(Radius.circular(8)), + ), + alignment: Alignment.center, + child: FlutterZoomView.View(creationParams: creationParams), + ), + Container( + height: 110, + width: 110, + decoration: const BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(8)), + ), + ), + Container( + alignment: Alignment.bottomCenter, + child: Container( + height: 20, + width: 110, + decoration: const BoxDecoration( + color: Colors.black26, + borderRadius: BorderRadius.all(Radius.circular(8)), + ), + ), + ), + Container( + alignment: Alignment.bottomLeft, + margin: const EdgeInsets.only(left: 5), + child: Text( + user!.userName, + textAlign: TextAlign.left, + style: const TextStyle( + color: Colors.white, + fontSize: 12, + ), + ), + ), + Container( + alignment: Alignment.bottomRight, + margin: const EdgeInsets.only(right: 5, bottom: 5), + // height: 110, + // width: 110, + child: Image( + height: 12, + width: 12, + image: isMuted.value ? const AssetImage("assets/images/png/zoom/muted@2x.png") : const AssetImage("assets/images/png/zoom/talking@2x.png"), + fit: BoxFit.cover, + ), + ) + ], + ), + ); + } else { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 8), + height: 110, + width: 110, + child: Stack( + children: [ + Container( + height: 110, + width: 110, + decoration: BoxDecoration( + color: const Color(0xff232323), + border: Border.all( + color: const Color(0xff666666), + width: 1, + ), + borderRadius: const BorderRadius.all(Radius.circular(8)), + ), + alignment: Alignment.center, + child: Container( + alignment: Alignment.center, + child: const Image( + height: 60, + width: 60, + image: AssetImage("assets/images/png/zoom/default-avatar.png"), + )), + ), + Align( + alignment: Alignment.bottomCenter, + child: Container( + height: 20, + width: 110, + decoration: const BoxDecoration( + color: Colors.black26, + borderRadius: BorderRadius.all(Radius.circular(8)), + ), + ), + ), + Container( + alignment: Alignment.bottomLeft, + margin: const EdgeInsets.only(left: 5), + child: Text( + user!.userName, + textAlign: TextAlign.left, + style: const TextStyle( + color: Colors.white, + fontSize: 12, + ), + ), + ), + Container( + alignment: Alignment.bottomRight, + margin: const EdgeInsets.only(right: 5, bottom: 5), + child: Image( + height: 12, + width: 12, + image: isMuted.value ? const AssetImage("assets/images/png/zoom/muted@2x.png") : const AssetImage("assets/images/png/zoom/talking@2x.png"), + fit: BoxFit.cover, + ), + ), + ], + ), + ); + } + } + } +} diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart index bb74479..9cf0ed9 100644 --- a/lib/routes/app_routes.dart +++ b/lib/routes/app_routes.dart @@ -95,7 +95,7 @@ class AppRoutes { register: (context) => RegisterNew(), registerStepTwo: (context) => RegisterNewStep2(), medicalFilePage: (context) => MedicalFilePage(), - zoomCallPage: (context) => MedicalFilePage(), + zoomCallPage: (context) => CallScreen(), eReferralPage: (context) => NewReferralPage(), comprehensiveCheckupPage: (context) => ComprehensiveCheckupPage(), homeHealthCarePage: (context) => HhcProceduresPage(), diff --git a/pubspec.yaml b/pubspec.yaml index d472bd5..5cbd882 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -61,7 +61,7 @@ dependencies: geolocator: ^14.0.2 dropdown_search: ^6.0.2 google_maps_flutter: ^2.13.1 - flutter_zoom_videosdk: 2.1.10 + flutter_zoom_videosdk: 2.4.0 dart_jsonwebtoken: ^3.2.0 dartz: ^0.10.1 equatable: ^2.0.7