getCometChatCallingView method

Future<Map> getCometChatCallingView(
  1. String callToken,
  2. CallSettings? callSettings,
  3. PresentationSettings? presentationSettings
)

Implementation

Future<Map<dynamic, dynamic>> getCometChatCallingView(
    String callToken,
    CallSettings? callSettings,
    PresentationSettings? presentationSettings) async {
  if (presentationSettings != null) {
    final result = await methodChannel
        .invokeMethod<Map<dynamic, dynamic>>('joinPresentation', {
      "callToken": callToken,
      "defaultLayout": presentationSettings.defaultLayout,
      "isAudioOnly": presentationSettings.isAudioOnly,
      "isSingleMode": presentationSettings.isSingleMode,
      "endCallButtonDisable": presentationSettings.endCallButtonDisable,
      "showRecordingButton": presentationSettings.showRecordingButton,
      "switchCameraButtonDisable":
          presentationSettings.switchCameraButtonDisable,
      "muteAudioButtonDisable": presentationSettings.muteAudioButtonDisable,
      "pauseVideoButtonDisable": presentationSettings.pauseVideoButtonDisable,
      "audioModeButtonDisable": presentationSettings.audioModeButtonDisable,
      "startAudioMuted": presentationSettings.startAudioMuted,
      "startVideoMuted": presentationSettings.startVideoMuted,
      "isPresenter": presentationSettings.isPresenter,
      "defaultAudioMode": presentationSettings.defaultAudioMode?.value,
    });
    return result!;
  } else {
    String? videoFit;

    String? fullScreenButtonPosition;
    bool? fullScreenButtonVisibility;

    String? userListButtonPosition;
    bool? userListButtonVisibility;

    String? zoomButtonPosition;
    bool? zoomButtonVisibility;

    String? nameLabelPosition;
    bool? nameLabelVisibility;
    String? nameLabelColor;

    if (callSettings!.videoSettings != null) {
      videoFit = callSettings.videoSettings!.videoFit?.value;
      if (callSettings.videoSettings!.fullScreenButton != null) {
        fullScreenButtonPosition =
            callSettings.videoSettings!.fullScreenButton!.position.value;
        fullScreenButtonVisibility =
            callSettings.videoSettings!.fullScreenButton!.visibility;
      }
      if (callSettings.videoSettings!.userListButton != null) {
        userListButtonPosition =
            callSettings.videoSettings!.userListButton!.position.value;
        userListButtonVisibility =
            callSettings.videoSettings!.userListButton!.visibility;
      }
      if (callSettings.videoSettings!.zoomButton != null) {
        zoomButtonPosition =
            callSettings.videoSettings!.zoomButton!.position.value;
        zoomButtonVisibility =
            callSettings.videoSettings!.zoomButton!.visibility;
      }
      if (callSettings.videoSettings!.nameLabel != null) {
        nameLabelPosition =
            callSettings.videoSettings!.nameLabel!.position.value;
        nameLabelVisibility =
            callSettings.videoSettings!.nameLabel!.visibility;
        nameLabelColor = callSettings.videoSettings!.nameLabel!.color;
      }
    }

    final result = await methodChannel
        .invokeMethod<Map<dynamic, dynamic>>('startSession', {
      "callToken": callToken,
      "defaultLayout": callSettings.defaultLayout,
      "isAudioOnly": callSettings.isAudioOnly,
      "isSingleMode": callSettings.isSingleMode,
      "showSwitchToVideoCall": callSettings.showSwitchToVideoCall,
      "enableVideoTileClick": callSettings.enableVideoTileClick,
      "enableDraggableVideoTile": callSettings.enableDraggableVideoTile,
      "endCallButtonDisable": callSettings.endCallButtonDisable,
      "showRecordingButton": callSettings.showRecordingButton,
      "startRecordingOnCallStart": callSettings.startRecordingOnCallStart,
      "switchCameraButtonDisable": callSettings.switchCameraButtonDisable,
      "muteAudioButtonDisable": callSettings.muteAudioButtonDisable,
      "pauseVideoButtonDisable": callSettings.pauseVideoButtonDisable,
      "audioModeButtonDisable": callSettings.audioModeButtonDisable,
      "startAudioMuted": callSettings.startAudioMuted,
      "startVideoMuted": callSettings.startVideoMuted,
      "avatarMode": callSettings.avatarMode?.value,
      "mode": callSettings.mode?.value,
      "defaultAudioMode": callSettings.defaultAudioMode?.value,
      "videoFit": videoFit,
      "fullScreenButtonPosition": fullScreenButtonPosition,
      "fullScreenButtonVisibility": fullScreenButtonVisibility,
      "userListButtonPosition": userListButtonPosition,
      "userListButtonVisibility": userListButtonVisibility,
      "zoomButtonPosition": zoomButtonPosition,
      "zoomButtonVisibility": zoomButtonVisibility,
      "nameLabelPosition": nameLabelPosition,
      "nameLabelVisibility": nameLabelVisibility,
      "nameLabelColor": nameLabelColor,
    });
    return result!;
  }
}