@@ -134,15 +134,11 @@ class CometChatCallDetails: UIViewController {
134134 progressIndicator. LoadingLabel. text = " Unable to fetch History. "
135135 self . tableView. reloadRows ( at: [ indexPath] , with: . automatic)
136136 }
137- if let errorCode = error? . errorCode, let errorDescription = error? . errorDescription {
138- if errorCode. isLocalized {
139- CometChatSnackBoard . display ( message: errorCode. localized ( ) , mode: . error, duration: . short)
140- } else {
141- CometChatSnackBoard . display ( message: errorDescription , mode: . error, duration: . short)
142- }
137+ if let error = error {
138+ CometChatSnackBoard . showErrorMessage ( for: error)
143139 }
144140 }
145-
141+
146142 } )
147143 }
148144
@@ -292,8 +288,8 @@ extension CometChatCallDetails: UITableViewDelegate , UITableViewDataSource {
292288 /// - tableView: The table-view object requesting this information.
293289 /// - section: An index number identifying a section of tableView .
294290 public func tableView( _ tableView: UITableView , viewForHeaderInSection section: Int ) -> UIView ? {
295- let returnedView = UIView ( frame: CGRect ( x: 0 , y: 0 , width: view. frame. size. width, height: 25 ) )
296- let sectionTitle = UILabel ( frame: CGRect ( x: 10 , y: 2 , width: view . frame. size. width, height: 20 ) )
291+ let returnedView = UIView ( frame: CGRect ( x: 0 , y: 0 , width: view. frame. size. width - 20 , height: 25 ) )
292+ let sectionTitle = UILabel ( frame: CGRect ( x: 10 , y: 2 , width: returnedView . frame. size. width, height: 20 ) )
297293 if section == 0 {
298294 sectionTitle. text = " "
299295 } else if section == 1 {
@@ -351,14 +347,12 @@ extension CometChatCallDetails: UITableViewDelegate , UITableViewDataSource {
351347 let userDetail = tableView. dequeueReusableCell ( withIdentifier: " detailView " , for: indexPath) as! CometChatDetailItem
352348 userDetail. detailViewDelegate = self
353349 userDetail. user = currentUser
354- userDetail. call. isHidden = false
355350 userDetail. separatorInset = UIEdgeInsets ( top: 0 , left: 20 , bottom: 0 , right: 20 )
356351 return userDetail
357352 } else if currentGroup != nil {
358353 let groupDetail = tableView. dequeueReusableCell ( withIdentifier: " detailView " , for: indexPath) as! CometChatDetailItem
359354 groupDetail. group = currentGroup
360355 groupDetail. detailViewDelegate = self
361- groupDetail. call. isHidden = false
362356 groupDetail. separatorInset = UIEdgeInsets ( top: 0 , left: 20 , bottom: 0 , right: 20 )
363357 groupDetail. separatorInset = UIEdgeInsets ( top: 0 , left: 20 , bottom: 0 , right: 20 )
364358 return groupDetail
@@ -456,18 +450,11 @@ extension CometChatCallDetails: UITableViewDelegate , UITableViewDataSource {
456450 NotificationCenter . default. post ( name: NSNotification . Name ( rawValue: " didUserUnblocked " ) , object: nil , userInfo: nil )
457451 if let user = self . currentUser, let name = user. name {
458452 self . set ( user: user)
459- DispatchQueue . main. async {
460- CometChatSnackBoard . display ( message: name + " " + " UNBLOCKED_SUCCESSFULLY " . localized ( ) , mode: . success, duration: . short)
461- }
462453 }
463454 } ) { ( error) in
464455 DispatchQueue . main. async {
465- if let errorCode = error? . errorCode, let errorDescription = error? . errorDescription {
466- if errorCode. isLocalized {
467- CometChatSnackBoard . display ( message: errorCode. localized ( ) , mode: . error, duration: . short)
468- } else {
469- CometChatSnackBoard . display ( message: errorDescription , mode: . error, duration: . short)
470- }
456+ if let error = error {
457+ CometChatSnackBoard . showErrorMessage ( for: error)
471458 }
472459 }
473460 }
@@ -478,17 +465,12 @@ extension CometChatCallDetails: UITableViewDelegate , UITableViewDataSource {
478465 self . set ( user: user)
479466 let data : [ String : String ] = [ " name " : name]
480467 NotificationCenter . default. post ( name: NSNotification . Name ( rawValue: " didUserBlocked " ) , object: nil , userInfo: data)
481- CometChatSnackBoard . display ( message: name + " " + " BLOCKED_SUCCESSFULLY " . localized ( ) , mode: . success, duration: . short)
482468 }
483469 }
484470 } ) { ( error) in
485471 DispatchQueue . main. async {
486- if let errorCode = error? . errorCode, let errorDescription = error? . errorDescription {
487- if errorCode. isLocalized {
488- CometChatSnackBoard . display ( message: errorCode. localized ( ) , mode: . error, duration: . short)
489- } else {
490- CometChatSnackBoard . display ( message: errorDescription , mode: . error, duration: . short)
491- }
472+ if let error = error {
473+ CometChatSnackBoard . showErrorMessage ( for: error)
492474 }
493475 }
494476
@@ -501,19 +483,12 @@ extension CometChatCallDetails: UITableViewDelegate , UITableViewDataSource {
501483 DispatchQueue . main. async {
502484 self . dismiss ( animated: true ) {
503485 NotificationCenter . default. post ( name: NSNotification . Name ( rawValue: " didGroupDeleted " ) , object: nil , userInfo: nil )
504- let message = " YOU_LEFT_FROM " . localized ( ) + " " + ( self . currentGroup? . name ?? " " ) + " . "
505- CometChatSnackBoard . display ( message: message, mode: . success, duration: . short)
506486 }
507-
508487 }
509488 } ) { ( error) in
510489 DispatchQueue . main. async {
511- if let errorCode = error? . errorCode, let errorDescription = error? . errorDescription {
512- if errorCode. isLocalized {
513- CometChatSnackBoard . display ( message: errorCode. localized ( ) , mode: . error, duration: . short)
514- } else {
515- CometChatSnackBoard . display ( message: errorDescription , mode: . error, duration: . short)
516- }
490+ if let error = error {
491+ CometChatSnackBoard . showErrorMessage ( for: error)
517492 }
518493 }
519494
@@ -566,45 +541,22 @@ extension CometChatCallDetails: UITableViewDelegate , UITableViewDataSource {
566541extension CometChatCallDetails : DetailViewDelegate {
567542
568543
569- /// This method triggers when user pressed on Call Button in CometChatDetailItem
570- /// - Parameter for: This specifies `AppEntity` Object
571- func didCallButtonPressed( for: AppEntity ) {
572- let actionSheetController : UIAlertController = UIAlertController ( title: nil , message: nil , preferredStyle: . actionSheet)
573- let audioCall : UIAlertAction = UIAlertAction ( title: " AUDIO_CALL " . localized ( ) , style: . default) { action -> Void in
574- if let user = self . currentUser {
575- CometChatCallManager ( ) . makeCall ( call: . audio, to: user)
576- }
577- if let group = self . currentGroup {
578- CometChatCallManager ( ) . makeCall ( call: . audio, to: group)
579- }
544+ func didAudioCallButtonPressed( for: AppEntity ) {
545+ if let user = self . currentUser {
546+ CometChatCallManager ( ) . makeCall ( call: . audio, to: user)
580547 }
581-
582- let videoCall : UIAlertAction = UIAlertAction ( title: " VIDEO_CALL " . localized ( ) , style: . default) { action -> Void in
583- if let user = self . currentUser {
584- CometChatCallManager ( ) . makeCall ( call: . video, to: user)
585- }
586-
587- if let group = self . currentGroup {
588- CometChatCallManager ( ) . makeCall ( call: . video, to: group)
589- }
548+ if let group = self . currentGroup {
549+ CometChatCallManager ( ) . makeCall ( call: . audio, to: group)
590550 }
591-
592- let cancelAction : UIAlertAction = UIAlertAction ( title: " CANCEL " . localized ( ) , style: . cancel) { action -> Void in
551+ }
552+
553+ func didVideoCallButtonPressed( for: AppEntity ) {
554+ if let user = self . currentUser {
555+ CometChatCallManager ( ) . makeCall ( call: . video, to: user)
593556 }
594- cancelAction. setValue ( UIColor . red, forKey: " titleTextColor " )
595- actionSheetController. addAction ( audioCall)
596- actionSheetController. addAction ( videoCall)
597- actionSheetController. addAction ( cancelAction)
598- actionSheetController. view. tintColor = UIKitSettings . primaryColor
599- // Added ActionSheet support for iPad
600- if ( UI_USER_INTERFACE_IDIOM ( ) == UIUserInterfaceIdiom . pad ) {
601- if let currentPopoverpresentioncontroller =
602- actionSheetController. popoverPresentationController{
603- currentPopoverpresentioncontroller. sourceView = self . view
604- self . present ( actionSheetController, animated: true , completion: nil )
605- }
606- } else {
607- self . present ( actionSheetController, animated: true , completion: nil )
557+
558+ if let group = self . currentGroup {
559+ CometChatCallManager ( ) . makeCall ( call: . video, to: group)
608560 }
609561 }
610562}
0 commit comments